diff options
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/entities')
12 files changed, 48 insertions, 126 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/DirectReport.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/DirectReport.scala index 42ac55b..f35c3fd 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/DirectReport.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/DirectReport.scala @@ -2,31 +2,14 @@ package xyz.driver.pdsuidomain.entities import java.time.LocalDate +import xyz.driver.entities.assays.AssayType import xyz.driver.pdsuicommon.logging._ import xyz.driver.pdsuicommon.domain.UuidId -import xyz.driver.pdsuicommon.utils.Utils -import xyz.driver.pdsuidomain.entities.DirectReport.ReportType object DirectReport { - - sealed trait ReportType extends Product with Serializable { - def oneOf(xs: ReportType*): Boolean = xs.contains(this) - - def oneOf(xs: Set[ReportType]): Boolean = xs.contains(this) - } - - object ReportType { - case object IHC extends ReportType - case object DNA extends ReportType - case object CFDNA extends ReportType - - val All = Set(IHC, DNA, CFDNA) - implicit def toPhiString(x: ReportType): PhiString = Unsafe(Utils.getClassSimpleName(x.getClass)) - } - implicit def toPhiString(x: DirectReport): PhiString = { import x._ - phi"DirectReport(id=$id, patientId=$patientId, reportType=$reportType, date=${Unsafe(date)}, " + + phi"DirectReport(id=$id, patientId=$patientId, reportType=${Unsafe(reportType)}, date=${Unsafe(date)}, " + phi"documentType=${Unsafe(documentType)}, providerType=${Unsafe(providerType)}, " + phi"providerName=${Unsafe(providerName)})" } @@ -34,8 +17,8 @@ object DirectReport { final case class DirectReport(id: UuidId[DirectReport], patientId: UuidId[Patient], - reportType: ReportType, + reportType: AssayType, date: LocalDate, - documentType: String, - providerType: String, + documentType: DocumentType, + providerType: ProviderType, providerName: String) diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/ExtractedData.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/ExtractedData.scala index fbd468f..352cf55 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/ExtractedData.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/ExtractedData.scala @@ -1,7 +1,7 @@ package xyz.driver.pdsuidomain.entities -import xyz.driver.entities.labels.{Label, LabelCategory} -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, TextJson} +import xyz.driver.entities.labels.{Label, LabelCategory, LabelValue} +import xyz.driver.pdsuicommon.domain.{LongId, TextJson} import xyz.driver.pdsuicommon.logging._ import xyz.driver.pdsuidomain.entities.ExtractedData.Meta @@ -37,7 +37,7 @@ object ExtractedDataLabel { implicit def toPhiString(x: ExtractedDataLabel): PhiString = { import x._ - phi"ExtractedDataLabel(id=$id, dataId=$dataId, labelId=$labelId, categoryId=$categoryId, value=$value)" + phi"ExtractedDataLabel(id=$id, dataId=$dataId, labelId=$labelId, categoryId=$categoryId, value=${Unsafe(value)})" } } @@ -45,4 +45,4 @@ final case class ExtractedDataLabel(id: LongId[ExtractedDataLabel], dataId: LongId[ExtractedData], labelId: Option[LongId[Label]], categoryId: Option[LongId[LabelCategory]], - value: Option[FuzzyValue]) + value: Option[LabelValue]) diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Patient.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Patient.scala index 6be0b88..193ef11 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Patient.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Patient.scala @@ -2,6 +2,8 @@ package xyz.driver.pdsuidomain.entities import java.time.{LocalDate, LocalDateTime} +import xyz.driver.entities.common.FullName +import xyz.driver.entities.patient.CancerType import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuicommon.logging._ import xyz.driver.pdsuicommon.utils.Utils @@ -52,14 +54,14 @@ object Patient { final case class Patient(id: UuidId[Patient], status: Patient.Status, - name: String, + name: FullName[Patient], dob: LocalDate, assignee: Option[StringId[User]], previousStatus: Option[Patient.Status], previousAssignee: Option[StringId[User]], lastActiveUserId: Option[StringId[User]], isUpdateRequired: Boolean, - condition: String, + cancerType: CancerType, orderId: PatientOrderId, lastUpdate: LocalDateTime) { diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientCriterion.scala index 469b21c..79a19ed 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientCriterion.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientCriterion.scala @@ -2,7 +2,8 @@ package xyz.driver.pdsuidomain.entities import java.time.LocalDateTime -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, StringId} +import xyz.driver.entities.labels.LabelValue +import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuicommon.logging._ object PatientCriterion { @@ -18,15 +19,15 @@ 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[LabelValue]): Option[LabelValue] = { primaryValue match { case None => None - case Some(FuzzyValue.Maybe) => Some(FuzzyValue.Maybe) - case Some(_) if criterionValue.isEmpty => Some(FuzzyValue.Maybe) + case Some(LabelValue.Maybe) => Some(LabelValue.Maybe) + case Some(_) if criterionValue.isEmpty => Some(LabelValue.Maybe) case Some(status) => Some( - FuzzyValue.fromBoolean( - FuzzyValue.fromBoolean( + LabelValue.fromBoolean( + LabelValue.fromBoolean( criterionValue.getOrElse(throw new IllegalArgumentException("Criterion should not be empty"))) == status )) } @@ -47,12 +48,12 @@ final case class PatientCriterion(id: LongId[PatientCriterion], criterionText: String, criterionValue: Option[Boolean], criterionIsDefining: Boolean, - eligibilityStatus: Option[FuzzyValue], - verifiedEligibilityStatus: Option[FuzzyValue], + eligibilityStatus: Option[LabelValue], + verifiedEligibilityStatus: Option[LabelValue], isVerified: Boolean, isVisible: Boolean, lastUpdate: LocalDateTime) { - def isIneligibleForEv: Boolean = eligibilityStatus.contains(FuzzyValue.No) && isVerified + def isIneligibleForEv: Boolean = eligibilityStatus.contains(LabelValue.No) && isVerified } object PatientCriterionArm { diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala index 8ee5b3c..ff272a8 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala @@ -1,6 +1,7 @@ package xyz.driver.pdsuidomain.entities -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, StringId, UuidId} +import xyz.driver.entities.labels.LabelValue +import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} import xyz.driver.pdsuicommon.logging._ object PatientTrialArm { @@ -37,22 +38,22 @@ 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 isIneligible: Boolean = criterionList.exists(_.verifiedEligibilityStatus.contains(FuzzyValue.No)) + def getEligibilityStatusForRc(criterionList: TraversableOnce[PatientCriterion]): Option[LabelValue] = { + def isEligible: Boolean = criterionList.forall(_.verifiedEligibilityStatus.contains(LabelValue.Yes)) + def isIneligible: Boolean = criterionList.exists(_.verifiedEligibilityStatus.contains(LabelValue.No)) def isUnknown: Boolean = criterionList.forall(_.verifiedEligibilityStatus.isEmpty) - if (isEligible) Some(FuzzyValue.Yes) - else if (isIneligible) Some(FuzzyValue.No) + if (isEligible) Some(LabelValue.Yes) + else if (isIneligible) Some(LabelValue.No) else if (isUnknown) None - else Some(FuzzyValue.Maybe) + else Some(LabelValue.Maybe) } } final case class PatientTrialArmGroup(id: LongId[PatientTrialArmGroup], eligibleTrialId: UuidId[PatientEligibleTrial], - eligibilityStatus: Option[FuzzyValue], - verifiedEligibilityStatus: Option[FuzzyValue], + eligibilityStatus: Option[LabelValue], + verifiedEligibilityStatus: Option[LabelValue], isVerified: Boolean) object PatientTrialArmGroupView { @@ -69,8 +70,8 @@ final case class PatientTrialArmGroupView(id: LongId[PatientTrialArmGroup], patientId: UuidId[Patient], trialId: StringId[Trial], hypothesisId: UuidId[Hypothesis], - eligibilityStatus: Option[FuzzyValue], - verifiedEligibilityStatus: Option[FuzzyValue], + eligibilityStatus: Option[LabelValue], + verifiedEligibilityStatus: Option[LabelValue], isVerified: Boolean) { def applyTo(trialArmGroup: PatientTrialArmGroup) = { diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabel.scala index d10c7d2..4c0f4ef 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabel.scala @@ -1,7 +1,7 @@ package xyz.driver.pdsuidomain.entities -import xyz.driver.entities.labels.Label -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, UuidId} +import xyz.driver.entities.labels.{Label, LabelValue} +import xyz.driver.pdsuicommon.domain.{LongId, UuidId} import xyz.driver.pdsuicommon.logging._ object PatientLabel { @@ -17,8 +17,8 @@ final case class PatientLabel(id: LongId[PatientLabel], patientId: UuidId[Patient], labelId: LongId[Label], score: Int, - primaryValue: Option[FuzzyValue], - verifiedPrimaryValue: Option[FuzzyValue], + primaryValue: Option[LabelValue], + verifiedPrimaryValue: Option[LabelValue], isImplicitMatch: Boolean, isVisible: Boolean) @@ -32,7 +32,7 @@ object PatientLabelEvidence { final case class PatientLabelEvidence(id: LongId[PatientLabelEvidence], patientLabelId: LongId[PatientLabel], - value: FuzzyValue, + value: LabelValue, evidenceText: String, reportId: Option[UuidId[DirectReport]], documentId: Option[LongId[Document]], diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabelEvidenceView.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabelEvidenceView.scala index 3311d96..2dbe099 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabelEvidenceView.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabelEvidenceView.scala @@ -2,21 +2,21 @@ package xyz.driver.pdsuidomain.entities import java.time.LocalDate -import xyz.driver.entities.labels.Label +import xyz.driver.entities.labels.{Label, LabelValue} import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuicommon.logging._ object PatientLabelEvidenceView { implicit def toPhiString(x: PatientLabelEvidenceView): PhiString = { import x._ - phi"PatientLabelEvidenceView(id=$id, value=$value, documentId=$documentId, " + + phi"PatientLabelEvidenceView(id=$id, value=${Unsafe(value)}, documentId=$documentId, " + phi"evidenceId=$evidenceId, reportId=$reportId, patientId=$patientId, labelId=$labelId, " + phi"isImplicitMatch=$isImplicitMatch)" } } final case class PatientLabelEvidenceView(id: LongId[PatientLabelEvidence], - value: FuzzyValue, + value: LabelValue, evidenceText: String, documentId: Option[LongId[Document]], evidenceId: Option[LongId[ExtractedData]], diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientLabel.scala deleted file mode 100644 index 689eaa4..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientLabel.scala +++ /dev/null @@ -1,31 +0,0 @@ -package xyz.driver.pdsuidomain.entities - -import java.time.LocalDate - -import xyz.driver.entities.labels.Label -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, UuidId} -import xyz.driver.pdsuicommon.logging._ - -final case class RawPatientLabel(patientId: UuidId[Patient], - labelId: LongId[Label], - value: FuzzyValue, - evidenceId: LongId[ExtractedData], - evidenceText: String, - disease: String, - documentId: LongId[Document], - requestId: RecordRequestId, - documentType: DocumentType, - providerType: ProviderType, - startDate: LocalDate, - endDate: Option[LocalDate]) - -object RawPatientLabel { - - implicit def toPhiString(x: RawPatientLabel): PhiString = { - import x._ - phi"RawPatientLabel(patientId=$patientId, labelId=$labelId, value=$value, evidenceId=${Unsafe(evidenceId)}, " + - phi"evidenceText=${Unsafe(evidenceText)}, documentId=$documentId, requestId=${Unsafe(requestId)}, " + - phi"documentType=${Unsafe(documentType)}, providerType=${Unsafe(providerType)}, " + - phi"startDate=$startDate, endDate=$endDate)" - } -} 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 2edd707..957e607 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 @@ -3,7 +3,6 @@ package xyz.driver.pdsuidomain.entities.export.patient import xyz.driver.entities.labels.Label import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuicommon.logging._ -import xyz.driver.pdsuidomain.entities.RawPatientLabel final case class ExportPatientLabel(id: LongId[Label], evidences: List[ExportPatientLabelEvidence]) @@ -13,8 +12,4 @@ object ExportPatientLabel extends PhiLogging { import x._ phi"ExportPatientLabel(id=$id, evidences=$evidences)" } - - def fromRaw(labelId: LongId[Label], rawPatientLabels: List[RawPatientLabel]): ExportPatientLabel = { - ExportPatientLabel(id = labelId, evidences = rawPatientLabels.map(ExportPatientLabelEvidence.fromRaw)) - } } diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabelEvidence.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabelEvidence.scala index fb40339..6472a6b 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabelEvidence.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabelEvidence.scala @@ -1,11 +1,12 @@ package xyz.driver.pdsuidomain.entities.export.patient +import xyz.driver.entities.labels.LabelValue import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuicommon.logging._ -import xyz.driver.pdsuidomain.entities.{ExtractedData, RawPatientLabel} +import xyz.driver.pdsuidomain.entities.ExtractedData final case class ExportPatientLabelEvidence(id: LongId[ExtractedData], - value: FuzzyValue, + value: LabelValue, evidenceText: String, document: ExportPatientLabelEvidenceDocument) @@ -13,20 +14,8 @@ object ExportPatientLabelEvidence { implicit def toPhiString(x: ExportPatientLabelEvidence): PhiString = { import x._ - phi"ExportPatientLabelEvidence(id=${Unsafe(id)}, value=$value, " + + phi"ExportPatientLabelEvidence(id=${Unsafe(id)}, value=${Unsafe(value)}, " + phi"evidenceText=${Unsafe(evidenceText)}, document=$document)" } - def fromRaw(x: RawPatientLabel) = ExportPatientLabelEvidence( - id = x.evidenceId, - value = x.value, - evidenceText = x.evidenceText, - document = ExportPatientLabelEvidenceDocument( - x.documentId, - x.requestId, - x.documentType, - x.providerType, - x.startDate - ) - ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabelEvidenceDocument.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabelEvidenceDocument.scala index 7003615..467170b 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabelEvidenceDocument.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabelEvidenceDocument.scala @@ -19,12 +19,4 @@ object ExportPatientLabelEvidenceDocument extends PhiLogging { phi"ExportPatientLabelEvidenceDocument(documentId=$documentId, requestId=$requestId, " + phi"documentType=${Unsafe(documentType)}, providerType=${Unsafe(providerType)}, date=$date)" } - - def fromRaw(x: RawPatientLabel) = ExportPatientLabelEvidenceDocument( - documentId = x.documentId, - requestId = x.requestId, - documentType = x.documentType, - providerType = x.providerType, - date = x.startDate - ) } 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 bd6173b..8fb2660 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 @@ -2,9 +2,7 @@ package xyz.driver.pdsuidomain.entities.export.patient import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuicommon.logging._ -import xyz.driver.pdsuidomain.entities.{Patient, RawPatientLabel} - -import scala.collection.breakOut +import xyz.driver.pdsuidomain.entities.Patient final case class ExportPatientWithLabels(patientId: UuidId[Patient], labelVersion: Long, @@ -16,12 +14,4 @@ object ExportPatientWithLabels { import x._ phi"ExportPatientWithLabels(patientId=$patientId, version=${Unsafe(labelVersion)}, labels=$labels)" } - - 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 - .groupBy(_.labelId) - .map(Function.tupled(ExportPatientLabel.fromRaw))(breakOut) - ) } |