diff options
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain')
20 files changed, 196 insertions, 215 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Arm.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Arm.scala index 17a913d..70b84ff 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Arm.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Arm.scala @@ -15,7 +15,6 @@ object Arm { implicit def toPhiString(x: Arm): PhiString = { import x._ - phi"Arm(id=$id, name=${Unsafe(x.name)}, trialId=${Unsafe(x.trialId)})" + phi"Arm(id=$id, name=${Unsafe(x.name)}, trialId=${Unsafe(x.trialId)})" } } - diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/DirectReport.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/DirectReport.scala index c9d1d88..4f1f1b9 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/DirectReport.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/DirectReport.scala @@ -16,11 +16,11 @@ object DirectReport { } object ReportType { - case object IHC extends ReportType - case object DNA extends ReportType + case object IHC extends ReportType + case object DNA extends ReportType case object CFDNA extends ReportType - val All = Set(IHC, DNA, CFDNA) + val All = Set(IHC, DNA, CFDNA) implicit def toPhiString(x: ReportType): PhiString = Unsafe(Utils.getClassSimpleName(x.getClass)) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala index 8c2616a..b10f67a 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala @@ -14,7 +14,6 @@ import xyz.driver.pdsuicommon.validation.Validators.Validator import xyz.driver.pdsuidomain.entities.Document.Meta import xyz.driver.pdsuicommon.compat.Implicits._ - final case class ProviderType(id: LongId[ProviderType], name: String) object ProviderType { @@ -36,6 +35,7 @@ object DocumentType { object Document { case class Meta(predicted: Option[Boolean], startPage: Double, endPage: Double) { + /** * Return a regular meta: this meta is considered as not predicted */ @@ -51,9 +51,9 @@ object Document { class DocumentStatusDeserializer extends JsonDeserializer[Status] { def deserialize(parser: JsonParser, context: DeserializationContext): Status = { val value = parser.getValueAsString - Option(value).fold[Document.Status](Status.New /* Default document status */) { v => + Option(value).fold[Document.Status](Status.New /* Default document status */ ) { v => Status.All.find(_.toString.toUpperCase == v) match { - case None => throw new RuntimeJsonMappingException(s"$v is not valid Document.Status") + case None => throw new RuntimeJsonMappingException(s"$v is not valid Document.Status") case Some(status) => status } } @@ -72,14 +72,14 @@ object Document { } object Status { - case object New extends Status + case object New extends Status case object Organized extends Status case object Extracted extends Status - case object Done extends Status - case object Flagged extends Status - case object Archived extends Status + case object Done extends Status + case object Flagged extends Status + case object Archived extends Status - val All = Set[Status](New, Organized, Extracted, Done, Flagged, Archived) + val All = Set[Status](New, Organized, Extracted, Done, Flagged, Archived) val AllPrevious = Set[Status](Organized, Extracted) implicit def toPhiString(x: Status): PhiString = Unsafe(Utils.getClassSimpleName(x.getClass)) @@ -101,15 +101,15 @@ object Document { startDate <- Validators.nonEmpty("startDate")(input.startDate) isOrderRight <- input.endDate match { - case Some(endDate) if startDate.isAfter(endDate) => - Validators.fail("The start date should be less, than the end one") + case Some(endDate) if startDate.isAfter(endDate) => + Validators.fail("The start date should be less, than the end one") - case _ => Validators.success(true) - } + case _ => Validators.success(true) + } areDatesInThePast <- { - val dates = List(input.startDate, input.endDate).flatten - val now = LocalDateTime.now() + val dates = List(input.startDate, input.endDate).flatten + val now = LocalDateTime.now() val hasInvalid = dates.exists(_.isAfter(now)) if (hasInvalid) Validators.fail("Dates should be in the past") @@ -129,7 +129,7 @@ case class Document(id: LongId[Document] = LongId(0L), recordId: LongId[MedicalRecord], physician: Option[String], typeId: Option[LongId[DocumentType]], // not null - providerName: Option[String], // not null + providerName: Option[String], // not null providerTypeId: Option[LongId[ProviderType]], // not null meta: Option[TextJson[Meta]], // not null startDate: Option[LocalDateTime], // not null @@ -139,8 +139,7 @@ case class Document(id: LongId[Document] = LongId(0L), import Document.Status._ if (previousStatus.nonEmpty) { - assert(AllPrevious.contains(previousStatus.get), - s"Previous status has invalid value: ${previousStatus.get}") + assert(AllPrevious.contains(previousStatus.get), s"Previous status has invalid value: ${previousStatus.get}") } // TODO: with the current business logic code this constraint sometimes harmful diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Hypothesis.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Hypothesis.scala index eb2b95e..47b87ff 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Hypothesis.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Hypothesis.scala @@ -3,10 +3,7 @@ package xyz.driver.pdsuidomain.entities import xyz.driver.pdsuicommon.domain.UuidId import xyz.driver.pdsuicommon.logging._ -final case class Hypothesis(id: UuidId[Hypothesis], - name: String, - treatmentType: String, - description: String) +final case class Hypothesis(id: UuidId[Hypothesis], name: String, treatmentType: String, description: String) object Hypothesis { implicit def toPhiString(x: Hypothesis): PhiString = { diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala index 6ff1a67..dc82050 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Intervention.scala @@ -3,7 +3,6 @@ package xyz.driver.pdsuidomain.entities import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuicommon.logging._ - final case class InterventionType(id: LongId[InterventionType], name: String) object InterventionType { diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Label.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Label.scala index 7f9c2aa..eea39de 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Label.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Label.scala @@ -12,10 +12,7 @@ object Category { } } -final case class Label(id: LongId[Label], - categoryId: LongId[Category], - name: String, - description: String) +final case class Label(id: LongId[Label], categoryId: LongId[Category], name: String, description: String) object Label { implicit def toPhiString(x: Label): PhiString = { diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecord.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecord.scala index 977f4cc..17de7de 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecord.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/MedicalRecord.scala @@ -14,11 +14,12 @@ import xyz.driver.pdsuidomain.entities.MedicalRecord.Meta.{Duplicate, Reorder, R object MedicalRecord { @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") - @JsonSubTypes(Array( - new Type(value = classOf[Duplicate], name = "duplicate"), - new Type(value = classOf[Reorder], name = "reorder"), - new Type(value = classOf[Rotation], name = "rotation") - )) + @JsonSubTypes( + Array( + new Type(value = classOf[Duplicate], name = "duplicate"), + new Type(value = classOf[Reorder], name = "reorder"), + new Type(value = classOf[Rotation], name = "rotation") + )) trait Meta { @JsonProperty("type") def metaType: String def predicted: Option[Boolean] @@ -35,9 +36,9 @@ object MedicalRecord { startPage: Double, endPage: Double, startOriginalPage: Double, - endOriginalPage: Option[Double] - ) extends Meta { - override val metaType = "duplicate" + endOriginalPage: Option[Double]) + extends Meta { + override val metaType = "duplicate" override def confirmed: Duplicate = copy(predicted = predicted.map(_ => false)) } @@ -49,11 +50,8 @@ object MedicalRecord { } } - - case class Reorder(predicted: Option[Boolean], - items: Seq[Int] - ) extends Meta { - override val metaType = "reorder" + case class Reorder(predicted: Option[Boolean], items: Seq[Int]) extends Meta { + override val metaType = "reorder" override def confirmed: Reorder = copy(predicted = predicted.map(_ => false)) } @@ -64,11 +62,8 @@ object MedicalRecord { } } - - case class Rotation(predicted: Option[Boolean], - items: Map[String, Int] - ) extends Meta { - override val metaType = "rotation" + case class Rotation(predicted: Option[Boolean], items: Map[String, Int]) extends Meta { + override val metaType = "rotation" override def confirmed: Rotation = copy(predicted = predicted.map(_ => false)) } @@ -79,11 +74,10 @@ object MedicalRecord { } } - implicit def toPhiString(input: Meta): PhiString = input match { case x: Duplicate => Duplicate.toPhiString(x) - case x: Reorder => Reorder.toPhiString(x) - case x: Rotation => Rotation.toPhiString(x) + case x: Reorder => Reorder.toPhiString(x) + case x: Rotation => Rotation.toPhiString(x) } } @@ -98,20 +92,30 @@ object MedicalRecord { } object Status { - case object Unprocessed extends Status - case object PreCleaning extends Status - case object New extends Status - case object Cleaned extends Status - case object PreOrganized extends Status + case object Unprocessed extends Status + case object PreCleaning extends Status + case object New extends Status + case object Cleaned extends Status + case object PreOrganized extends Status case object PreOrganizing extends Status - case object Reviewed extends Status - case object Organized extends Status - case object Done extends Status - case object Flagged extends Status - case object Archived extends Status + case object Reviewed extends Status + case object Organized extends Status + case object Done extends Status + case object Flagged extends Status + case object Archived extends Status val All = Set[Status]( - Unprocessed, PreCleaning, New, Cleaned, PreOrganized, PreOrganizing, Reviewed, Organized, Done, Flagged, Archived + Unprocessed, + PreCleaning, + New, + Cleaned, + PreOrganized, + PreOrganizing, + Reviewed, + Organized, + Done, + Flagged, + Archived ) val AllPrevious = Set[Status](New, Cleaned, Reviewed, Organized) @@ -123,6 +127,7 @@ object MedicalRecord { object PdfSource { case object Empty extends PdfSource + /** @param createResource Constructor of the resource which is represents the file */ case class Channel(createResource: () => ReadableByteChannel) extends PdfSource } @@ -152,8 +157,7 @@ case class MedicalRecord(id: LongId[MedicalRecord], import MedicalRecord.Status._ if (previousStatus.nonEmpty) { - assert(AllPrevious.contains(previousStatus.get), - s"Previous status has invalid value: ${previousStatus.get}") + assert(AllPrevious.contains(previousStatus.get), s"Previous status has invalid value: ${previousStatus.get}") } // TODO: with the current business logic code this constraint sometimes harmful diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Patient.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Patient.scala index 7767db0..bc80ce3 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Patient.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Patient.scala @@ -17,19 +17,27 @@ object Patient { } object Status { - case object New extends Status + case object New extends Status case object Verified extends Status case object Reviewed extends Status - case object Curated extends Status - case object Flagged extends Status - case object Done extends Status + case object Curated extends Status + case object Flagged extends Status + case object Done extends Status val AllPrevious = Set[Status]( - New, Verified, Reviewed, Curated + New, + Verified, + Reviewed, + Curated ) val All = Set[Status]( - New, Verified, Reviewed, Curated, Flagged, Done + New, + Verified, + Reviewed, + Curated, + Flagged, + Done ) implicit def toPhiString(x: Status): PhiString = Unsafe(Utils.getClassSimpleName(x.getClass)) @@ -57,7 +65,6 @@ case class Patient(id: UuidId[Patient], import Patient.Status._ if (previousStatus.nonEmpty) { - assert(AllPrevious.contains(previousStatus.get), - s"Previous status has invalid value: ${previousStatus.get}") + assert(AllPrevious.contains(previousStatus.get), s"Previous status has invalid value: ${previousStatus.get}") } } diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala index 8d5af0d..5df5253 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala @@ -18,17 +18,17 @@ object PatientCriterion { /** * @see https://driverinc.atlassian.net/wiki/display/MTCH/EV+Business+Process */ - def getEligibilityStatus(criterionValue: Option[Boolean], - primaryValue: Option[FuzzyValue]): Option[FuzzyValue] = { + def getEligibilityStatus(criterionValue: Option[Boolean], primaryValue: Option[FuzzyValue]): Option[FuzzyValue] = { primaryValue match { - case None => None - case Some(FuzzyValue.Maybe) => Some(FuzzyValue.Maybe) + case None => None + case Some(FuzzyValue.Maybe) => Some(FuzzyValue.Maybe) case Some(_) if criterionValue.isEmpty => Some(FuzzyValue.Maybe) - case Some(status) => Some(FuzzyValue.fromBoolean( - FuzzyValue.fromBoolean(criterionValue.getOrElse( - throw new IllegalArgumentException("Criterion should not be empty")) - ) == status - )) + case Some(status) => + Some( + FuzzyValue.fromBoolean( + FuzzyValue.fromBoolean( + criterionValue.getOrElse(throw new IllegalArgumentException("Criterion should not be empty"))) == status + )) } } @@ -93,15 +93,18 @@ object PatientTrialArmGroup { // Eligible, if for all (verified for EV) label-criteria eligibilityStatus=NULL or YES and at least one has status=YES // If method executes from PatientService (when EV submit patient) need to check value PatientCriterion.isVerified val verifiedList = criterionList.filter { case (isVerifiedOpt, _) => isVerifiedOpt.isEmpty || isVerifiedOpt.get } - verifiedList.forall { case (_, eligibilityStatus) => - eligibilityStatus.isEmpty || eligibilityStatus.contains(FuzzyValue.Yes) + verifiedList.forall { + case (_, eligibilityStatus) => + eligibilityStatus.isEmpty || eligibilityStatus.contains(FuzzyValue.Yes) } && verifiedList.exists { case (_, eligibilityStatus) => eligibilityStatus.contains(FuzzyValue.Yes) } } - if (criterionList.exists { case (isVerified, eligibilityStatus) => - eligibilityStatus.contains(FuzzyValue.No) && (isVerified.isEmpty || isVerified.get) - }) { Some(FuzzyValue.No) - } else if (criterionList.forall { case (_, eligibilityStatus) => eligibilityStatus.isEmpty }) { + if (criterionList.exists { + case (isVerified, eligibilityStatus) => + eligibilityStatus.contains(FuzzyValue.No) && (isVerified.isEmpty || isVerified.get) + }) { Some(FuzzyValue.No) } else if (criterionList.forall { + case (_, eligibilityStatus) => eligibilityStatus.isEmpty + }) { None } else if (isEligible) { Some(FuzzyValue.Yes) @@ -114,9 +117,9 @@ object PatientTrialArmGroup { * @see https://driverinc.atlassian.net/wiki/display/DMPD/EV+Business+Process */ def getEligibilityStatusForRc(criterionList: TraversableOnce[PatientCriterion]): Option[FuzzyValue] = { - def isEligible: Boolean = criterionList.forall(_.verifiedEligibilityStatus.contains(FuzzyValue.Yes)) + def isEligible: Boolean = criterionList.forall(_.verifiedEligibilityStatus.contains(FuzzyValue.Yes)) def isIneligible: Boolean = criterionList.exists(_.verifiedEligibilityStatus.contains(FuzzyValue.No)) - def isUnknown: Boolean = criterionList.forall(_.verifiedEligibilityStatus.isEmpty) + def isUnknown: Boolean = criterionList.forall(_.verifiedEligibilityStatus.isEmpty) if (isEligible) Some(FuzzyValue.Yes) else if (isIneligible) Some(FuzzyValue.No) diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Trial.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Trial.scala index 2477c22..f5ab3cb 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Trial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Trial.scala @@ -8,7 +8,6 @@ import xyz.driver.pdsuicommon.logging._ import xyz.driver.pdsuicommon.utils.Utils import xyz.driver.pdsuidomain.entities.Trial.{Condition, Status} - final case class StudyDesign(id: LongId[StudyDesign], name: String) object StudyDesign { @@ -21,23 +20,31 @@ object StudyDesign { object Trial { sealed trait Status { - def oneOf(xs: Status*): Boolean = xs.contains(this) + def oneOf(xs: Status*): Boolean = xs.contains(this) def oneOf(xs: Set[Status]): Boolean = xs.contains(this) } object Status { - case object New extends Status - case object ReviewSummary extends Status - case object Summarized extends Status - case object PendingUpdate extends Status - case object Update extends Status + case object New extends Status + case object ReviewSummary extends Status + case object Summarized extends Status + case object PendingUpdate extends Status + case object Update extends Status case object ReviewCriteria extends Status - case object Done extends Status - case object Flagged extends Status - case object Archived extends Status + case object Done extends Status + case object Flagged extends Status + case object Archived extends Status val All = Set[Status]( - New, ReviewSummary, Summarized, PendingUpdate, Update, ReviewCriteria, Done, Flagged, Archived + New, + ReviewSummary, + Summarized, + PendingUpdate, + Update, + ReviewCriteria, + Done, + Flagged, + Archived ) val AllPrevious = Set[Status](New, ReviewSummary, Summarized, ReviewCriteria) @@ -60,8 +67,8 @@ object Trial { object Condition { - case object Breast extends Condition - case object Lung extends Condition + case object Breast extends Condition + case object Lung extends Condition case object Prostate extends Condition val All = Set(Breast, Lung, Prostate) @@ -96,7 +103,6 @@ final case class Trial(id: StringId[Trial], import Trial.Status._ if (previousStatus.nonEmpty) { - assert(AllPrevious.contains(previousStatus.get), - s"Previous status has invalid value: ${previousStatus.get}") + assert(AllPrevious.contains(previousStatus.get), s"Previous status has invalid value: ${previousStatus.get}") } } diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabel.scala index 7d5de79..3b7a6ad 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabel.scala @@ -4,9 +4,7 @@ import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuicommon.logging._ import xyz.driver.pdsuidomain.entities.{Label, RawPatientLabel} -case class ExportPatientLabel(id: LongId[Label], - name: String, - evidences: List[ExportPatientLabelEvidence]) +case class ExportPatientLabel(id: LongId[Label], name: String, evidences: List[ExportPatientLabelEvidence]) object ExportPatientLabel extends PhiLogging { diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientWithLabels.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientWithLabels.scala index 418f20b..718255b 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientWithLabels.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientWithLabels.scala @@ -15,8 +15,7 @@ object ExportPatientWithLabels { phi"ExportPatientWithLabels(patientId=$patientId, version=${Unsafe(labelVersion)}, labels=$labels)" } - def fromRaw(patientId: UuidId[Patient], - rawPatientRefs: List[RawPatientLabel]) = ExportPatientWithLabels( + def fromRaw(patientId: UuidId[Patient], rawPatientRefs: List[RawPatientLabel]) = ExportPatientWithLabels( patientId = patientId, labelVersion = 1L, // TODO It is needed to replace this mock label version. labels = rawPatientRefs diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialWithLabels.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialWithLabels.scala index 251f6fb..2580e54 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialWithLabels.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/trial/ExportTrialWithLabels.scala @@ -36,16 +36,21 @@ object ExportTrialWithLabels { condition = trial.condition, lastReviewed = trial.lastReviewed, labelVersion = 1, // TODO It is needed to replace this mock label version. - arms = rawData.groupBy(_.armId).map { case (armId, rawTrials) => - ExportTrialArm(armId, rawTrials.head.armName) - }(breakOut), - criteria = rawData.groupBy { x => - (x.criterionId, x.labelId) - }.map { - case (_, rawTrialLabels) => - val armIds = rawTrialLabels.map(_.criterionArmId).toSet - ExportTrialLabelCriterion.fromRaw(rawTrialLabels.head, armIds) - }(breakOut) + arms = rawData + .groupBy(_.armId) + .map { + case (armId, rawTrials) => + ExportTrialArm(armId, rawTrials.head.armName) + }(breakOut), + criteria = rawData + .groupBy { x => + (x.criterionId, x.labelId) + } + .map { + case (_, rawTrialLabels) => + val armIds = rawTrialLabels.map(_.criterionArmId).toSet + ExportTrialLabelCriterion.fromRaw(rawTrialLabels.head, armIds) + }(breakOut) ) } } diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/CategoryService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/CategoryService.scala index 31ccff7..a735ade 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/CategoryService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/CategoryService.scala @@ -13,8 +13,7 @@ object CategoryService { object GetListReply { case class EntityList(xs: Seq[CategoryWithLabels], totalFound: Int) extends GetListReply - case object AuthorizationError - extends GetListReply with DomainError.AuthorizationError { + case object AuthorizationError extends GetListReply with DomainError.AuthorizationError { def userMessage: String = "Access denied" } } @@ -24,5 +23,6 @@ trait CategoryService extends PhiLogging { import CategoryService._ - def getAll(sorting: Option[Sorting] = None)(implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] + def getAll(sorting: Option[Sorting] = None)( + implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] } diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/ExportService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/ExportService.scala index eaffb2a..5be037c 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/ExportService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/ExportService.scala @@ -29,7 +29,7 @@ object ExportService { sealed trait GetTrialListReply object GetTrialListReply { case class EntityList(xs: Seq[ExportTrial], totalFound: Int, lastUpdate: Option[LocalDateTime]) - extends GetTrialListReply + extends GetTrialListReply } sealed trait GetTrialReply @@ -48,13 +48,12 @@ trait ExportService extends PhiLogging { import ExportService._ - def getPatient(id: UuidId[Patient]) - (implicit requestContext: AnonymousRequestContext): Future[GetPatientReply] + def getPatient(id: UuidId[Patient])(implicit requestContext: AnonymousRequestContext): Future[GetPatientReply] - def getTrialList(filter: SearchFilterExpr = SearchFilterExpr.Empty) - (implicit requestContext: AnonymousRequestContext): Future[GetTrialListReply] + def getTrialList(filter: SearchFilterExpr = SearchFilterExpr.Empty)( + implicit requestContext: AnonymousRequestContext): Future[GetTrialListReply] - def getTrial(trialId: StringId[Trial], condition: String) - (implicit requestContext: AnonymousRequestContext): Future[GetTrialReply] + def getTrial(trialId: StringId[Trial], condition: String)( + implicit requestContext: AnonymousRequestContext): Future[GetTrialReply] } diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/LabelService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/LabelService.scala index 25291f1..0677584 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/LabelService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/LabelService.scala @@ -14,8 +14,7 @@ object LabelService { object GetListReply { case class EntityList(xs: Seq[Label], totalFound: Int) extends GetListReply - case object AuthorizationError - extends GetListReply with DomainError.AuthorizationError { + case object AuthorizationError extends GetListReply with DomainError.AuthorizationError { def userMessage: String = "Access denied" } } @@ -24,6 +23,6 @@ object LabelService { trait LabelService extends PhiLogging { import LabelService._ - def getAll(sorting: Option[Sorting] = None) - (implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] + def getAll(sorting: Option[Sorting] = None)( + implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] } diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/MessageService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/MessageService.scala index 56140ce..8ce06f2 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/MessageService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/MessageService.scala @@ -24,45 +24,37 @@ object MessageService { sealed trait CreateReply object CreateReply { type Error = CreateReply with DomainError - case class Created(x: Message) - extends CreateReply + case class Created(x: Message) extends CreateReply case object AuthorizationError - extends CreateReply with DomainError.AuthorizationError with DefaultAccessDeniedError - case class CommonError(userMessage: String) - extends CreateReply with DomainError + extends CreateReply with DomainError.AuthorizationError with DefaultAccessDeniedError + case class CommonError(userMessage: String) extends CreateReply with DomainError } sealed trait GetByIdReply object GetByIdReply { type Error = GetByIdReply with DomainError - case class Entity(x: Message) - extends GetByIdReply - case object NotFoundError - extends GetByIdReply with DomainError.NotFoundError with DefaultNotFoundError - case class CommonError(userMessage: String) - extends GetByIdReply with DomainError + case class Entity(x: Message) extends GetByIdReply + case object NotFoundError extends GetByIdReply with DomainError.NotFoundError with DefaultNotFoundError + case class CommonError(userMessage: String) extends GetByIdReply with DomainError case object AuthorizationError - extends GetByIdReply with DomainError.AuthorizationError with DefaultAccessDeniedError + extends GetByIdReply with DomainError.AuthorizationError with DefaultAccessDeniedError } sealed trait GetListReply object GetListReply { type Error = GetListReply with DomainError - case class EntityList(xs: Seq[Message], totalFound: Int, lastUpdate: Option[LocalDateTime]) - extends GetListReply + case class EntityList(xs: Seq[Message], totalFound: Int, lastUpdate: Option[LocalDateTime]) extends GetListReply case object AuthorizationError - extends GetListReply with DomainError.AuthorizationError with DefaultAccessDeniedError + extends GetListReply with DomainError.AuthorizationError with DefaultAccessDeniedError } sealed trait UpdateReply object UpdateReply { type Error = UpdateReply with DomainError - case class Updated(updated: Message) - extends UpdateReply + case class Updated(updated: Message) extends UpdateReply case object AuthorizationError - extends UpdateReply with DomainError.AuthorizationError with DefaultAccessDeniedError - case class CommonError(userMessage: String) - extends UpdateReply with DomainError + extends UpdateReply with DomainError.AuthorizationError with DefaultAccessDeniedError + case class CommonError(userMessage: String) extends UpdateReply with DomainError } sealed trait DeleteReply @@ -70,11 +62,9 @@ object MessageService { type Error = DeleteReply with DomainError case object Deleted extends DeleteReply case object AuthorizationError - extends DeleteReply with DomainError.AuthorizationError with DefaultAccessDeniedError - case object NotFoundError - extends DeleteReply with DomainError.NotFoundError with DefaultNotFoundError - case class CommonError(userMessage: String) - extends DeleteReply with DomainError + extends DeleteReply with DomainError.AuthorizationError with DefaultAccessDeniedError + case object NotFoundError extends DeleteReply with DomainError.NotFoundError with DefaultNotFoundError + case class CommonError(userMessage: String) extends DeleteReply with DomainError } } @@ -89,12 +79,11 @@ trait MessageService extends PhiLogging { def getAll(filter: SearchFilterExpr = SearchFilterExpr.Empty, sorting: Option[Sorting] = None, - pagination: Option[Pagination] = None) - (implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] + pagination: Option[Pagination] = None)( + implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] - def update(origMessage: Message, draftMessage: Message) - (implicit requestContext: AuthenticatedRequestContext): Future[UpdateReply] + def update(origMessage: Message, draftMessage: Message)( + implicit requestContext: AuthenticatedRequestContext): Future[UpdateReply] - def delete(messageId: LongId[Message]) - (implicit requestContext: AuthenticatedRequestContext): Future[DeleteReply] + def delete(messageId: LongId[Message])(implicit requestContext: AuthenticatedRequestContext): Future[DeleteReply] } diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/UserService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/UserService.scala index 350720e..79e9835 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/UserService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/UserService.scala @@ -26,8 +26,7 @@ object UserService { object ActivateExecutorReply { type Error = ActivateExecutorReply with DomainError case class Entity(x: User) extends ActivateExecutorReply - case object NotFoundError - extends ActivateExecutorReply with DomainError.NotFoundError { + case object NotFoundError extends ActivateExecutorReply with DomainError.NotFoundError { val userMessage = "Info about you is not found on the server" } } @@ -37,18 +36,15 @@ object UserService { type Error = GetByIdReply with DomainError case class Entity(x: User) extends GetByIdReply case object AuthorizationError - extends GetByIdReply with DomainError.AuthorizationError with DefaultAccessDeniedError - case object NotFoundError - extends GetByIdReply with DomainError.NotFoundError with DefaultNotFoundError - case class CommonError(userMessage: String) - extends GetByIdReply with DomainError + extends GetByIdReply with DomainError.AuthorizationError with DefaultAccessDeniedError + case object NotFoundError extends GetByIdReply with DomainError.NotFoundError with DefaultNotFoundError + case class CommonError(userMessage: String) extends GetByIdReply with DomainError } sealed trait GetByEmailReply object GetByEmailReply { case class Entity(x: User) extends GetByEmailReply - case object NotFoundError - extends GetByEmailReply with DefaultNotFoundError with DomainError.NotFoundError { + case object NotFoundError extends GetByEmailReply with DefaultNotFoundError with DomainError.NotFoundError { override def userMessage: String = "Incorrect email. Try again." } } @@ -57,30 +53,25 @@ object UserService { object GetByCredentialsReply { case class Entity(x: User) extends GetByCredentialsReply case object AuthenticationError - extends GetByCredentialsReply with DefaultCredentialsError with DomainError.AuthenticationError - case object NotFoundError - extends GetByCredentialsReply with DomainError.NotFoundError with DefaultNotFoundError + extends GetByCredentialsReply with DefaultCredentialsError with DomainError.AuthenticationError + case object NotFoundError extends GetByCredentialsReply with DomainError.NotFoundError with DefaultNotFoundError } sealed trait GetListReply object GetListReply { case class EntityList(xs: Seq[User], totalFound: Int) extends GetListReply - case object AuthorizationError - extends GetListReply with DomainError.AuthorizationError with DefaultNotFoundError + case object AuthorizationError extends GetListReply with DomainError.AuthorizationError with DefaultNotFoundError } sealed trait CreateReply object CreateReply { type Error = CreateReply with DomainError - case class Created(x: User) extends CreateReply - case object AuthorizationError - extends CreateReply with DefaultNotFoundError with DomainError.AuthorizationError - case class UserAlreadyExistsError(email: Email) - extends CreateReply with DomainError { + case class Created(x: User) extends CreateReply + case object AuthorizationError extends CreateReply with DefaultNotFoundError with DomainError.AuthorizationError + case class UserAlreadyExistsError(email: Email) extends CreateReply with DomainError { val userMessage = s"The user with this email already exists." } - case class CommonError(userMessage: String) - extends CreateReply with DomainError + case class CommonError(userMessage: String) extends CreateReply with DomainError } sealed trait UpdateReply @@ -88,9 +79,8 @@ object UserService { type Error = UpdateReply with DomainError case class Updated(updated: User) extends UpdateReply case object AuthorizationError - extends UpdateReply with DefaultAccessDeniedError with DomainError.AuthorizationError - case class CommonError(userMessage: String) - extends UpdateReply with DomainError + extends UpdateReply with DefaultAccessDeniedError with DomainError.AuthorizationError + case class CommonError(userMessage: String) extends UpdateReply with DomainError } sealed trait DeleteReply @@ -98,15 +88,12 @@ object UserService { type Error = DeleteReply with DomainError case object Deleted extends DeleteReply case class AuthorizationError(user: User) - extends DeleteReply with DefaultAccessDeniedError with DomainError.AuthorizationError - case object AssignedToRecordAndDocumentError - extends DeleteReply with DomainError { + extends DeleteReply with DefaultAccessDeniedError with DomainError.AuthorizationError + case object AssignedToRecordAndDocumentError extends DeleteReply with DomainError { val userMessage = "User is can not be deleted because he has record and document in work" } - case object NotFoundError - extends DeleteReply with DefaultNotFoundError with DomainError.NotFoundError - case class CommonError(userMessage: String) - extends DeleteReply with DomainError + case object NotFoundError extends DeleteReply with DefaultNotFoundError with DomainError.NotFoundError + case class CommonError(userMessage: String) extends DeleteReply with DomainError } } @@ -118,26 +105,25 @@ trait UserService extends PhiLogging { /** * Utility method for getting request executor. */ - def activateExecutor(executorId: LongId[User]) - (implicit requestContext: AnonymousRequestContext): Future[ActivateExecutorReply] + def activateExecutor(executorId: LongId[User])( + implicit requestContext: AnonymousRequestContext): Future[ActivateExecutorReply] def getById(userId: LongId[User])(implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] - def getByEmail(email: Email) - (implicit requestContext: AnonymousRequestContext): Future[GetByEmailReply] + def getByEmail(email: Email)(implicit requestContext: AnonymousRequestContext): Future[GetByEmailReply] - def getByCredentials(email: Email, password: String) - (implicit requestContext: AnonymousRequestContext): Future[GetByCredentialsReply] + def getByCredentials(email: Email, password: String)( + implicit requestContext: AnonymousRequestContext): Future[GetByCredentialsReply] def getAll(filter: SearchFilterExpr = SearchFilterExpr.Empty, sorting: Option[Sorting] = None, - pagination: Option[Pagination] = None) - (implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] + pagination: Option[Pagination] = None)( + implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] def create(draftUser: User)(implicit requestContext: AuthenticatedRequestContext): Future[CreateReply] - def update(origUser: User, draftUser: User) - (implicit requestContext: AuthenticatedRequestContext): Future[UpdateReply] + def update(origUser: User, draftUser: User)( + implicit requestContext: AuthenticatedRequestContext): Future[UpdateReply] def delete(userId: LongId[User])(implicit requestContext: AuthenticatedRequestContext): Future[DeleteReply] } diff --git a/src/main/scala/xyz/driver/pdsuidomain/storage/MedicalRecordDocumentStorage.scala b/src/main/scala/xyz/driver/pdsuidomain/storage/MedicalRecordDocumentStorage.scala index d50be2c..192512f 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/storage/MedicalRecordDocumentStorage.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/storage/MedicalRecordDocumentStorage.scala @@ -9,8 +9,7 @@ import scala.concurrent.{ExecutionContext, Future, blocking} object MedicalRecordDocumentStorage extends StrictLogging { private val storage = StorageOptions.getDefaultInstance.getService - def fetchPdf(bucket: String, path: String) - (implicit ec: ExecutionContext): Future[PdfSource] = { + def fetchPdf(bucket: String, path: String)(implicit ec: ExecutionContext): Future[PdfSource] = { logger.trace(s"fetchPdf(bucket=$bucket, path=$path)") Future { blocking { diff --git a/src/main/scala/xyz/driver/pdsuidomain/storage/RequestStorage.scala b/src/main/scala/xyz/driver/pdsuidomain/storage/RequestStorage.scala index d9651ca..9e3ad67 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/storage/RequestStorage.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/storage/RequestStorage.scala @@ -7,7 +7,7 @@ import xyz.driver.pdsuidomain.entities.{Arm, Patient} import scala.collection.concurrent.TrieMap object RequestStorage { - type Key = (UuidId[Patient], String) + type Key = (UuidId[Patient], String) type Value = Set[LongId[Arm]] } @@ -16,9 +16,7 @@ class RequestStorage extends PhiLogging { private val storage = new TrieMap[Key, Value]() - def put(patientId: UuidId[Patient], - disease: String, - ineligibleArms: Set[LongId[Arm]]): Unit = { + def put(patientId: UuidId[Patient], disease: String, ineligibleArms: Set[LongId[Arm]]): Unit = { logger.debug(phi"put($patientId, ${Unsafe(disease)}, $ineligibleArms") val key = (patientId, disease.toLowerCase) get(patientId, disease.toLowerCase) match { @@ -37,9 +35,7 @@ class RequestStorage extends PhiLogging { storage.get(key) } - def contains(patientId: UuidId[Patient], - disease: String, - value: Set[LongId[Arm]]): Boolean = { + def contains(patientId: UuidId[Patient], disease: String, value: Set[LongId[Arm]]): Boolean = { logger.debug(phi"contains(key=($patientId,${Unsafe(disease)}),value=$value") get(patientId, disease.toLowerCase).contains(value) } |