From 7f1cbe3d1d34a6fc65e5e506a40a3b882c3fdb74 Mon Sep 17 00:00:00 2001 From: vlad Date: Wed, 4 Oct 2017 20:51:27 -0700 Subject: Fixing Label JSON format bug --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'build.sbt') diff --git a/build.sbt b/build.sbt index 66c0f7b..f820bcc 100644 --- a/build.sbt +++ b/build.sbt @@ -19,7 +19,7 @@ lazy val core = (project in file(".")) "org.davidbild" %% "tristate-core" % "0.2.0", "org.davidbild" %% "tristate-play" % "0.2.0" exclude ("com.typesafe.play", "play-json"), "xyz.driver" %% "core" % "1.2.1", - "xyz.driver" %% "domain-model" % "0.17.1", + "xyz.driver" %% "domain-model" % "0.17.5", "ch.qos.logback" % "logback-classic" % "1.1.7", "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.8.4", "com.github.spullara.mustache.java" % "scala-extensions-2.11" % "0.9.4", -- cgit v1.2.3 From 6751966577c0f005858f372458ccdb72be7d879f Mon Sep 17 00:00:00 2001 From: vlad Date: Thu, 5 Oct 2017 01:37:32 -0700 Subject: Fixing binary incompat --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'build.sbt') diff --git a/build.sbt b/build.sbt index f820bcc..bebf2aa 100644 --- a/build.sbt +++ b/build.sbt @@ -11,7 +11,7 @@ lazy val core = (project in file(".")) "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.8.3", "com.github.pureconfig" %% "pureconfig" % "0.7.2", "com.lihaoyi" %% "fastparse" % "0.3.7", - "com.typesafe.akka" %% "akka-http" % "10.0.9", + "com.typesafe.akka" %% "akka-http" % "10.0.10", "com.typesafe.play" %% "play" % "2.5.15", "com.typesafe.scala-logging" %% "scala-logging" % "3.5.0", "io.getquill" %% "quill-jdbc" % "1.2.1", -- cgit v1.2.3 From 7d8712a62d30b412717e1b730c0ad267cd207aa4 Mon Sep 17 00:00:00 2001 From: vlad Date: Mon, 9 Oct 2017 12:24:59 -0700 Subject: Getting rid of the FuzzyValues, Name as a string, and condition --- build.sbt | 2 +- .../xyz/driver/pdsuicommon/domain/FuzzyValue.scala | 40 ---------------------- .../driver/pdsuidomain/entities/DirectReport.scala | 27 +++------------ .../pdsuidomain/entities/ExtractedData.scala | 8 ++--- .../xyz/driver/pdsuidomain/entities/Patient.scala | 6 ++-- .../pdsuidomain/entities/PatientCriterion.scala | 19 +++++----- .../entities/PatientEligibleTrial.scala | 23 +++++++------ .../driver/pdsuidomain/entities/PatientLabel.scala | 10 +++--- .../entities/PatientLabelEvidenceView.scala | 6 ++-- .../pdsuidomain/entities/RawPatientLabel.scala | 31 ----------------- .../export/patient/ExportPatientLabel.scala | 5 --- .../patient/ExportPatientLabelEvidence.scala | 19 +++------- .../ExportPatientLabelEvidenceDocument.scala | 8 ----- .../export/patient/ExportPatientWithLabels.scala | 12 +------ .../driver/pdsuidomain/fakes/entities/common.scala | 5 +-- .../fakes/entities/rep/ExportPatientGen.scala | 6 ++-- .../fakes/entities/rep/ExtractedDataGen.scala | 5 +-- .../json/evidence/ApiPatientLabelEvidence.scala | 3 +- .../formats/json/label/ApiCriterionLabel.scala | 6 ++-- .../formats/json/label/ApiExtractedDataLabel.scala | 12 +++---- .../formats/json/patient/ApiPatient.scala | 21 +++++++++--- .../patient/eligible/ApiPatientEligibleTrial.scala | 8 ++--- .../patient/label/ApiPartialPatientLabel.scala | 15 ++++---- .../json/patient/label/ApiPatientLabel.scala | 32 ++++++++++------- .../label/ApiPatientLabelDefiningCriteria.scala | 8 ++--- .../patient/trial/ApiPartialPatientCriterion.scala | 14 ++++---- .../trial/ApiPartialPatientCriterionList.scala | 9 ++--- .../json/patient/trial/ApiPatientCriterion.scala | 18 +++++----- .../formats/json/sprayformats/common.scala | 10 +----- .../formats/json/sprayformats/export.scala | 1 + .../formats/json/sprayformats/extracteddata.scala | 7 ++-- .../formats/json/sprayformats/patient.scala | 4 ++- .../json/sprayformats/patientcriterion.scala | 7 ++-- .../sprayformats/patientdefiningcriteria.scala | 1 + .../json/sprayformats/patienteligibletrial.scala | 1 + .../formats/json/sprayformats/patientlabel.scala | 7 ++-- .../services/PatientCriterionService.scala | 4 +-- .../json/sprayformats/ExportFormatSuite.scala | 11 +++--- .../sprayformats/ExtractedDataFormatSuite.scala | 11 +++--- .../sprayformats/PatientCriterionFormatSuite.scala | 9 ++--- .../PatientEligibleTrialFormatSuite.scala | 7 ++-- .../json/sprayformats/PatientFormatSuite.scala | 11 +++--- .../sprayformats/PatientLabelFormatSuite.scala | 13 +++---- 43 files changed, 195 insertions(+), 287 deletions(-) delete mode 100644 src/main/scala/xyz/driver/pdsuicommon/domain/FuzzyValue.scala delete mode 100644 src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientLabel.scala (limited to 'build.sbt') diff --git a/build.sbt b/build.sbt index bebf2aa..bd7468f 100644 --- a/build.sbt +++ b/build.sbt @@ -19,7 +19,7 @@ lazy val core = (project in file(".")) "org.davidbild" %% "tristate-core" % "0.2.0", "org.davidbild" %% "tristate-play" % "0.2.0" exclude ("com.typesafe.play", "play-json"), "xyz.driver" %% "core" % "1.2.1", - "xyz.driver" %% "domain-model" % "0.17.5", + "xyz.driver" %% "domain-model" % "0.17.8", "ch.qos.logback" % "logback-classic" % "1.1.7", "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.8.4", "com.github.spullara.mustache.java" % "scala-extensions-2.11" % "0.9.4", diff --git a/src/main/scala/xyz/driver/pdsuicommon/domain/FuzzyValue.scala b/src/main/scala/xyz/driver/pdsuicommon/domain/FuzzyValue.scala deleted file mode 100644 index 36c3de7..0000000 --- a/src/main/scala/xyz/driver/pdsuicommon/domain/FuzzyValue.scala +++ /dev/null @@ -1,40 +0,0 @@ -package xyz.driver.pdsuicommon.domain - -import xyz.driver.pdsuicommon.logging._ -import xyz.driver.pdsuicommon.utils.Utils - -sealed trait FuzzyValue - -object FuzzyValue { - case object Yes extends FuzzyValue - case object No extends FuzzyValue - case object Maybe extends FuzzyValue - - private val yes = "Yes" - private val no = "No" - private val maybe = "Maybe" - - val All: Set[FuzzyValue] = - Set(Yes, No, Maybe) - - def fromBoolean(x: Boolean): FuzzyValue = - if (x) Yes else No - - implicit def toPhiString(x: FuzzyValue): PhiString = - Unsafe(Utils.getClassSimpleName(x.getClass)) - - val fromString: PartialFunction[String, FuzzyValue] = { - case fuzzy => - fuzzy.toLowerCase.capitalize match { - case `yes` => Yes - case `no` => No - case `maybe` => Maybe - } - } - - def valueToString(x: FuzzyValue): String = x match { - case Yes => `yes` - case No => `no` - case Maybe => `maybe` - } -} 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) - ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala index 7318ff6..a38d52c 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala @@ -3,7 +3,7 @@ package xyz.driver.pdsuidomain.fakes.entities import java.time.{LocalDate, LocalDateTime, LocalTime} import xyz.driver.core.generators.{nextDouble, nextOption} -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, StringId, UuidId} +import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} import xyz.driver.pdsuidomain.entities.{Trial, TrialHistory} import scala.util.Random @@ -52,9 +52,6 @@ object common { ranges.map(_._1) -> ranges.flatMap(_._2) } - def nextFuzzyValue(): FuzzyValue = - generators.oneOf[FuzzyValue](FuzzyValue.All) - def nextStartAndEndPages: (Option[Double], Option[Double]) = genBoundedRangeOption[Double](nextDouble(), nextDouble()) diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala index 3fcc4cb..85bab8c 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExportPatientGen.scala @@ -1,9 +1,9 @@ package xyz.driver.pdsuidomain.fakes.entities.rep +import xyz.driver.core.generators import xyz.driver.core.generators._ -import xyz.driver.entities.labels.Label +import xyz.driver.entities.labels.{Label, LabelValue} import xyz.driver.pdsuicommon.domain.{LongId, UuidId} -import xyz.driver.pdsuidomain.fakes.entities.common._ import xyz.driver.pdsuidomain.entities._ import xyz.driver.pdsuidomain.entities.export.patient._ import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDate, nextLongId} @@ -26,7 +26,7 @@ object ExportPatientGen { def nextExportPatientLabelEvidence(documentId: LongId[Document]): ExportPatientLabelEvidence = { ExportPatientLabelEvidence( id = nextLongId[ExtractedData], - value = nextFuzzyValue(), + value = generators.oneOf[LabelValue](LabelValue.Yes, LabelValue.No, LabelValue.Maybe), evidenceText = nextString(), document = nextExportPatientLabelEvidenceDocument(documentId) ) diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala index 8e77445..70ddd10 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/ExtractedDataGen.scala @@ -1,7 +1,8 @@ package xyz.driver.pdsuidomain.fakes.entities.rep +import xyz.driver.core.generators import xyz.driver.core.generators._ -import xyz.driver.entities.labels.{Label, LabelCategory} +import xyz.driver.entities.labels.{Label, LabelCategory, LabelValue} import xyz.driver.pdsuicommon.domain.{LongId, TextJson} import xyz.driver.pdsuidomain.entities._ import xyz.driver.pdsuidomain.entities.ExtractedData.Meta @@ -85,7 +86,7 @@ object ExtractedDataGen { dataId = nextLongId[ExtractedData], labelId = nextOption(nextLongId[Label]), categoryId = nextOption(nextLongId[LabelCategory]), - value = nextOption(nextFuzzyValue()) + value = nextOption(generators.oneOf[LabelValue](LabelValue.Yes, LabelValue.No, LabelValue.Maybe)) ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/evidence/ApiPatientLabelEvidence.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/evidence/ApiPatientLabelEvidence.scala index e0f23e3..7409e90 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/evidence/ApiPatientLabelEvidence.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/evidence/ApiPatientLabelEvidence.scala @@ -3,7 +3,6 @@ package xyz.driver.pdsuidomain.formats.json.evidence import java.time.LocalDate import play.api.libs.json._ -import xyz.driver.pdsuicommon.domain.FuzzyValue import xyz.driver.pdsuidomain.entities.PatientLabelEvidenceView final case class ApiPatientLabelEvidence(id: Long, @@ -22,7 +21,7 @@ object ApiPatientLabelEvidence { def fromDomain(x: PatientLabelEvidenceView) = ApiPatientLabelEvidence( id = x.id.id, - value = FuzzyValue.valueToString(x.value), + value = x.value.toString, evidenceText = x.evidenceText, documentId = x.documentId.map(_.id), evidenceId = x.evidenceId.map(_.id), diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/label/ApiCriterionLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/label/ApiCriterionLabel.scala index d486749..edb0603 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/label/ApiCriterionLabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/label/ApiCriterionLabel.scala @@ -1,11 +1,11 @@ package xyz.driver.pdsuidomain.formats.json.label -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId} +import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuidomain.entities.{Criterion, CriterionLabel} import play.api.data.validation.ValidationError import play.api.libs.functional.syntax._ import play.api.libs.json._ -import xyz.driver.entities.labels.{Label, LabelCategory} +import xyz.driver.entities.labels.{Label, LabelCategory, LabelValue} /** * @param value Yes|No @@ -34,7 +34,7 @@ object ApiCriterionLabel { labelId = x.labelId.map(_.id), categoryId = x.categoryId.map(_.id), value = x.value.map { x => - FuzzyValue.valueToString(FuzzyValue.fromBoolean(x)) + LabelValue.fromBoolean(x).toString }, isDefining = x.isDefining ) diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/label/ApiExtractedDataLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/label/ApiExtractedDataLabel.scala index f8161af..1497679 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/label/ApiExtractedDataLabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/label/ApiExtractedDataLabel.scala @@ -1,11 +1,11 @@ package xyz.driver.pdsuidomain.formats.json.label -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId} +import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuidomain.entities.{ExtractedData, ExtractedDataLabel} import play.api.data.validation.ValidationError import play.api.libs.functional.syntax._ import play.api.libs.json._ -import xyz.driver.entities.labels.{Label, LabelCategory} +import xyz.driver.entities.labels.{Label, LabelCategory, LabelValue} final case class ApiExtractedDataLabel(id: Option[Long], categoryId: Option[Long], value: Option[String]) { @@ -14,7 +14,7 @@ final case class ApiExtractedDataLabel(id: Option[Long], categoryId: Option[Long dataId = dataId, labelId = id.map(LongId[Label]), categoryId = categoryId.map(LongId[LabelCategory]), - value = value.map(FuzzyValue.fromString) + value = value.flatMap(LabelValue.fromString) ) } @@ -27,8 +27,8 @@ object ApiExtractedDataLabel { Format(Reads .of[String] .filter(ValidationError("unknown value"))({ - case x if FuzzyValue.fromString.isDefinedAt(x) => true - case _ => false + case x if LabelValue.fromString(x).isDefined => true + case _ => false }), Writes.of[String])) )(ApiExtractedDataLabel.apply, unlift(ApiExtractedDataLabel.unapply)) @@ -36,6 +36,6 @@ object ApiExtractedDataLabel { def fromDomain(dataLabel: ExtractedDataLabel) = ApiExtractedDataLabel( id = dataLabel.labelId.map(_.id), categoryId = dataLabel.categoryId.map(_.id), - value = dataLabel.value.map(FuzzyValue.valueToString) + value = dataLabel.value.map(_.toString) ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/ApiPatient.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/ApiPatient.scala index db430ae..ad6bc80 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/ApiPatient.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/ApiPatient.scala @@ -7,6 +7,8 @@ import xyz.driver.pdsuicommon.domain.{StringId, UuidId} import xyz.driver.pdsuidomain.entities.{Patient, PatientOrderId} import play.api.libs.functional.syntax._ import play.api.libs.json.{Format, JsPath} +import xyz.driver.entities.common.FullName +import xyz.driver.entities.patient final case class ApiPatient(id: String, status: String, @@ -24,17 +26,28 @@ final case class ApiPatient(id: String, PatientStatus.statusFromString .applyOrElse(status, (s: String) => throw new NoSuchElementException(s"Unknown status $s")) + private def parseName(name: String): FullName[Patient] = + name.split(" ") match { + case Array() => throw new NoSuchElementException(s"Patient's name cannot be empty") + case Array(first) => FullName.fromStrings[Patient](first, "", "") + case Array(first, last) => FullName.fromStrings[Patient](first, "", last) + case Array(first, middle, last) => FullName.fromStrings[Patient](first, middle, last) + case _ => throw new NoSuchElementException(s"Patient's name is ambiguous") + } + def toDomain = Patient( id = UuidId(this.id), status = extractStatus(this.status), - name = this.name, + name = parseName(this.name), dob = this.dob, assignee = this.assignee.map(StringId(_)), previousStatus = this.previousStatus.map(extractStatus), previousAssignee = this.previousAssignee.map(StringId(_)), lastActiveUserId = this.lastActiveUser.map(StringId(_)), isUpdateRequired = false, - condition = this.condition, + cancerType = patient.CancerType + .fromString(this.condition) + .getOrElse(throw new IllegalArgumentException(s"Unknown cancer type ${this.condition}")), orderId = PatientOrderId(this.orderId), lastUpdate = this.lastUpdate.toLocalDateTime ) @@ -60,14 +73,14 @@ object ApiPatient { def fromDomain(patient: Patient) = ApiPatient( id = patient.id.toString, status = PatientStatus.statusToString(patient.status), - name = patient.name, + name = patient.name.toString(), dob = patient.dob, assignee = patient.assignee.map(_.id), previousStatus = patient.previousStatus.map(PatientStatus.statusToString), previousAssignee = patient.previousAssignee.map(_.id), lastActiveUser = patient.lastActiveUserId.map(_.id), lastUpdate = ZonedDateTime.of(patient.lastUpdate, ZoneId.of("Z")), - condition = patient.condition, + condition = patient.cancerType.toString, orderId = patient.orderId.id ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/eligible/ApiPatientEligibleTrial.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/eligible/ApiPatientEligibleTrial.scala index 4136715..55c8149 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/eligible/ApiPatientEligibleTrial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/eligible/ApiPatientEligibleTrial.scala @@ -5,7 +5,7 @@ import java.util.UUID import play.api.data.validation.ValidationError import play.api.libs.functional.syntax._ import play.api.libs.json._ -import xyz.driver.pdsuicommon.domain.FuzzyValue +import xyz.driver.entities.labels.LabelValue import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial final case class ApiPatientEligibleTrial(id: Long, @@ -30,8 +30,8 @@ object ApiPatientEligibleTrial { Reads .of[String] .filter(ValidationError("unknown eligibility status"))({ - case x if FuzzyValue.fromString.isDefinedAt(x) => true - case _ => false + case x if LabelValue.fromString(x).isDefined => true + case _ => false }), Writes.of[String] )) and @@ -45,7 +45,7 @@ object ApiPatientEligibleTrial { trialTitle = eligibleTrialWithTrial.trial.title, arms = eligibleTrialWithTrial.arms.map(_.armName), hypothesisId = eligibleTrialWithTrial.group.hypothesisId.id, - eligibleTrialWithTrial.group.verifiedEligibilityStatus.map(FuzzyValue.valueToString), + eligibleTrialWithTrial.group.verifiedEligibilityStatus.map(_.toString), eligibleTrialWithTrial.group.isVerified ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPartialPatientLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPartialPatientLabel.scala index 91d0a0e..d92872c 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPartialPatientLabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPartialPatientLabel.scala @@ -6,15 +6,14 @@ import org.davidbild.tristate.contrib.play.ToJsPathOpsFromJsPath import play.api.data.validation.ValidationError import play.api.libs.functional.syntax._ import play.api.libs.json._ -import xyz.driver.pdsuicommon.domain.FuzzyValue +import xyz.driver.entities.labels.LabelValue final case class ApiPartialPatientLabel(primaryValue: Option[String], verifiedPrimaryValue: Tristate[String]) { def applyTo(orig: PatientLabel): PatientLabel = { orig.copy( - primaryValue = primaryValue.map(FuzzyValue.fromString).orElse(orig.primaryValue), - verifiedPrimaryValue = - verifiedPrimaryValue.cata(x => Some(FuzzyValue.fromString(x)), None, orig.verifiedPrimaryValue) + primaryValue = primaryValue.flatMap(LabelValue.fromString).orElse(orig.primaryValue), + verifiedPrimaryValue = verifiedPrimaryValue.cata(x => LabelValue.fromString(x), None, orig.verifiedPrimaryValue) ) } } @@ -26,8 +25,8 @@ object ApiPartialPatientLabel { Format(Reads .of[String] .filter(ValidationError("unknown primary value"))({ - case x if FuzzyValue.fromString.isDefinedAt(x) => true - case _ => false + case x if LabelValue.fromString(x).isDefined => true + case _ => false }), Writes.of[String])) and (JsPath \ "verifiedPrimaryValue").formatTristate[String]( @@ -35,8 +34,8 @@ object ApiPartialPatientLabel { Reads .of[String] .filter(ValidationError("unknown verified primary value"))({ - case x if FuzzyValue.fromString.isDefinedAt(x) => true - case _ => false + case x if LabelValue.fromString(x).isDefined => true + case _ => false }), Writes.of[String] )) diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPatientLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPatientLabel.scala index fc8687b..cc8532d 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPatientLabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPatientLabel.scala @@ -4,7 +4,7 @@ import xyz.driver.pdsuidomain.entities.PatientLabel import play.api.data.validation.ValidationError import play.api.libs.functional.syntax._ import play.api.libs.json._ -import xyz.driver.pdsuicommon.domain.FuzzyValue +import xyz.driver.entities.labels.LabelValue final case class ApiPatientLabel(id: Long, labelId: Long, @@ -20,25 +20,33 @@ object ApiPatientLabel { implicit val apiPatientLabelJsonFormat: Format[ApiPatientLabel] = ( (JsPath \ "id").format[Long] and (JsPath \ "labelId").format[Long] and - (JsPath \ "primaryValue").formatNullable[String](Format(Reads.of[String].filter(ValidationError("unknown value"))({ - case x if FuzzyValue.fromString.isDefinedAt(x) => true - case _ => false - }), Writes.of[String])) and - (JsPath \ "verifiedPrimaryValue").formatNullable[String](Format(Reads.of[String].filter(ValidationError("unknown value"))({ - case x if FuzzyValue.fromString.isDefinedAt(x) => true - case _ => false - }), Writes.of[String])) and + (JsPath \ "primaryValue").formatNullable[String]( + Format(Reads + .of[String] + .filter(ValidationError("unknown value"))({ + case x if LabelValue.fromString(x).isDefined => true + case _ => false + }), + Writes.of[String])) and + (JsPath \ "verifiedPrimaryValue").formatNullable[String]( + Format(Reads + .of[String] + .filter(ValidationError("unknown value"))({ + case x if LabelValue.fromString(x).isDefined => true + case _ => false + }), + Writes.of[String])) and (JsPath \ "score").format[Int] and (JsPath \ "isImplicitMatch").format[Boolean] and (JsPath \ "isVisible").format[Boolean] and (JsPath \ "isVerified").format[Boolean] - ) (ApiPatientLabel.apply, unlift(ApiPatientLabel.unapply)) + )(ApiPatientLabel.apply, unlift(ApiPatientLabel.unapply)) def fromDomain(patientLabel: PatientLabel, isVerified: Boolean): ApiPatientLabel = ApiPatientLabel( id = patientLabel.id.id, labelId = patientLabel.labelId.id, - primaryValue = patientLabel.primaryValue.map(FuzzyValue.valueToString), - verifiedPrimaryValue = patientLabel.verifiedPrimaryValue.map(FuzzyValue.valueToString), + primaryValue = patientLabel.primaryValue.map(_.toString), + verifiedPrimaryValue = patientLabel.verifiedPrimaryValue.map(_.toString), score = patientLabel.score, isImplicitMatch = patientLabel.isImplicitMatch, isVisible = patientLabel.isVisible, diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPatientLabelDefiningCriteria.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPatientLabelDefiningCriteria.scala index ae64c33..16b9cc9 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPatientLabelDefiningCriteria.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPatientLabelDefiningCriteria.scala @@ -3,7 +3,7 @@ package xyz.driver.pdsuidomain.formats.json.patient.label import play.api.data.validation.ValidationError import play.api.libs.functional.syntax._ import play.api.libs.json._ -import xyz.driver.pdsuicommon.domain.FuzzyValue +import xyz.driver.entities.labels.LabelValue import xyz.driver.pdsuidomain.entities.PatientLabel final case class ApiPatientLabelDefiningCriteria(labelId: Long, value: Option[String]) @@ -16,14 +16,14 @@ object ApiPatientLabelDefiningCriteria { Format(Reads .of[String] .filter(ValidationError("unknown value"))({ - case x if FuzzyValue.fromString.isDefinedAt(x) => true - case _ => false + case x if LabelValue.fromString(x).isDefined => true + case _ => false }), Writes.of[String])) )(ApiPatientLabelDefiningCriteria.apply, unlift(ApiPatientLabelDefiningCriteria.unapply)) def fromDomain(x: PatientLabel) = ApiPatientLabelDefiningCriteria( labelId = x.labelId.id, - value = x.verifiedPrimaryValue.map(FuzzyValue.valueToString) + value = x.verifiedPrimaryValue.map(_.toString) ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPartialPatientCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPartialPatientCriterion.scala index 399bc7d..09538b8 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPartialPatientCriterion.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPartialPatientCriterion.scala @@ -6,16 +6,16 @@ import org.davidbild.tristate.contrib.play.ToJsPathOpsFromJsPath import play.api.data.validation.ValidationError import play.api.libs.functional.syntax._ import play.api.libs.json.{Format, JsPath, Reads, Writes} -import xyz.driver.pdsuicommon.domain.FuzzyValue +import xyz.driver.entities.labels.LabelValue final case class ApiPartialPatientCriterion(eligibilityStatus: Option[String], verifiedEligibilityStatus: Tristate[String]) { def applyTo(orig: PatientCriterion): PatientCriterion = { orig.copy( - eligibilityStatus = eligibilityStatus.map(FuzzyValue.fromString).orElse(orig.eligibilityStatus), + eligibilityStatus = eligibilityStatus.flatMap(LabelValue.fromString).orElse(orig.eligibilityStatus), verifiedEligibilityStatus = - verifiedEligibilityStatus.cata(x => Some(FuzzyValue.fromString(x)), None, orig.verifiedEligibilityStatus) + verifiedEligibilityStatus.cata(x => LabelValue.fromString(x), None, orig.verifiedEligibilityStatus) ) } } @@ -28,8 +28,8 @@ object ApiPartialPatientCriterion { Reads .of[String] .filter(ValidationError("unknown eligibility status"))({ - case x if FuzzyValue.fromString.isDefinedAt(x) => true - case _ => false + case x if LabelValue.fromString(x).isDefined => true + case _ => false }), Writes.of[String] )) and @@ -38,8 +38,8 @@ object ApiPartialPatientCriterion { Reads .of[String] .filter(ValidationError("unknown verified eligibility status"))({ - case x if FuzzyValue.fromString.isDefinedAt(x) => true - case _ => false + case x if LabelValue.fromString(x).isDefined => true + case _ => false }), Writes.of[String] )) diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPartialPatientCriterionList.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPartialPatientCriterionList.scala index 4b08970..b7616a1 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPartialPatientCriterionList.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPartialPatientCriterionList.scala @@ -1,10 +1,11 @@ package xyz.driver.pdsuidomain.formats.json.patient.trial -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId} +import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuidomain.entities.PatientCriterion import play.api.data.validation.ValidationError import play.api.libs.functional.syntax._ import play.api.libs.json.{Format, JsPath, Reads, Writes} +import xyz.driver.entities.labels.LabelValue import xyz.driver.pdsuidomain.services.PatientCriterionService.DraftPatientCriterion final case class ApiPartialPatientCriterionList(id: Long, @@ -13,7 +14,7 @@ final case class ApiPartialPatientCriterionList(id: Long, def toDomain: DraftPatientCriterion = DraftPatientCriterion( id = LongId[PatientCriterion](id), - eligibilityStatus = eligibilityStatus.map(FuzzyValue.fromString), + eligibilityStatus = eligibilityStatus.flatMap(LabelValue.fromString), isVerified = isVerified ) } @@ -26,8 +27,8 @@ object ApiPartialPatientCriterionList { Reads .of[String] .filter(ValidationError("unknown eligibility status"))({ - case x if FuzzyValue.fromString.isDefinedAt(x) => true - case _ => false + case x if LabelValue.fromString(x).isDefined => true + case _ => false }), Writes.of[String] )) and diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPatientCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPatientCriterion.scala index 6eeb40b..b9bf772 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPatientCriterion.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPatientCriterion.scala @@ -2,12 +2,12 @@ package xyz.driver.pdsuidomain.formats.json.patient.trial import java.time.{ZoneId, ZonedDateTime} -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId} +import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuidomain.entities.{PatientCriterion, PatientCriterionArm} import play.api.data.validation.ValidationError import play.api.libs.functional.syntax._ import play.api.libs.json.{Format, JsPath, Reads, Writes} -import xyz.driver.entities.labels.Label +import xyz.driver.entities.labels.{Label, LabelValue} final case class ApiPatientCriterion(id: Long, labelId: Long, @@ -39,13 +39,13 @@ object ApiPatientCriterion { (JsPath \ "criterionIsCompound").format[Boolean] and (JsPath \ "arms").format[List[String]] and (JsPath \ "eligibilityStatus").formatNullable[String](Format(Reads.of[String].filter(ValidationError("unknown status"))({ - case x if FuzzyValue.fromString.isDefinedAt(x) => true - case _ => false + case x if LabelValue.fromString(x).isDefined => true + case _ => false }), Writes.of[String])) and (JsPath \ "verifiedEligibilityStatus").formatNullable[String](Format( Reads.of[String].filter(ValidationError("unknown status"))({ - case x if FuzzyValue.fromString.isDefinedAt(x) => true - case _ => false + case x if LabelValue.fromString(x).isDefined => true + case _ => false }), Writes.of[String])) and (JsPath \ "isVerified").format[Boolean] and (JsPath \ "isVisible").format[Boolean] and @@ -61,13 +61,13 @@ object ApiPatientCriterion { criterionId = patientCriterion.criterionId.id, criterionText = patientCriterion.criterionText, criterionValue = patientCriterion.criterionValue.map { x => - FuzzyValue.valueToString(FuzzyValue.fromBoolean(x)) + LabelValue.fromBoolean(x).toString }, criterionIsDefining = patientCriterion.criterionIsDefining, criterionIsCompound = patientCriterion.criterionValue.isEmpty, arms = arms.map(_.armName), - eligibilityStatus = patientCriterion.eligibilityStatus.map(FuzzyValue.valueToString), - verifiedEligibilityStatus = patientCriterion.verifiedEligibilityStatus.map(FuzzyValue.valueToString), + eligibilityStatus = patientCriterion.eligibilityStatus.map(_.toString), + verifiedEligibilityStatus = patientCriterion.verifiedEligibilityStatus.map(_.toString), isVerified = patientCriterion.isVerified, isVisible = patientCriterion.isVisible, lastUpdate = ZonedDateTime.of(patientCriterion.lastUpdate, ZoneId.of("Z")) diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/common.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/common.scala index dbd0a43..61e0e7f 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/common.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/common.scala @@ -3,7 +3,7 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import java.time.{LocalDate, LocalDateTime, ZoneId, ZonedDateTime} import spray.json._ -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, StringId, UuidId} +import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} object common { @@ -55,14 +55,6 @@ object common { } } - implicit def fuzzyValueFormat: RootJsonFormat[FuzzyValue] = new RootJsonFormat[FuzzyValue] { - override def write(value: FuzzyValue): JsString = JsString(FuzzyValue.valueToString(value)) - override def read(json: JsValue): FuzzyValue = json match { - case JsString(value) => FuzzyValue.fromString(value) - case _ => deserializationError(s"Expected value as FuzzyValue, but got $json") - } - } - implicit val integerFormat: RootJsonFormat[Integer] = new RootJsonFormat[Integer] { override def write(obj: Integer): JsNumber = JsNumber(obj.intValue()) override def read(json: JsValue): Integer = json match { diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala index 39d5c59..85d614d 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala @@ -5,6 +5,7 @@ import xyz.driver.entities.labels.Label import xyz.driver.pdsuidomain.entities.{Arm, Criterion} import xyz.driver.pdsuidomain.entities.export.patient._ import xyz.driver.pdsuidomain.entities.export.trial.{ExportTrialArm, ExportTrialLabelCriterion, ExportTrialWithLabels} +import xyz.driver.formats.json.labels._ object export { import DefaultJsonProtocol._ diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/extracteddata.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/extracteddata.scala index d6eadbd..5d5585a 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/extracteddata.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/extracteddata.scala @@ -1,10 +1,11 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import spray.json._ -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.pdsuidomain.entities._ import xyz.driver.pdsuidomain.services.ExtractedDataService.RichExtractedData +import xyz.driver.formats.json.labels._ object extracteddata { import DefaultJsonProtocol._ @@ -44,7 +45,7 @@ object extracteddata { val value = fields .get("value") - .map(_.convertTo[FuzzyValue]) + .map(_.convertTo[LabelValue]) ExtractedDataLabel( id = LongId(0), diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patient.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patient.scala index 95c0674..3da76c1 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patient.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patient.scala @@ -3,6 +3,8 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import spray.json._ import xyz.driver.core.json.EnumJsonFormat import xyz.driver.pdsuidomain.entities._ +import xyz.driver.formats.json.common._ +import xyz.driver.formats.json.patient._ object patient { import DefaultJsonProtocol._ @@ -38,7 +40,7 @@ object patient { "previousAssignee" -> patient.previousAssignee.toJson, "lastActiveUser" -> patient.lastActiveUserId.toJson, "lastUpdate" -> patient.lastUpdate.toJson, - "condition" -> patient.condition.toJson, + "condition" -> patient.cancerType.toJson, "orderId" -> patient.orderId.toJson ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientcriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientcriterion.scala index affb346..7e8c220 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientcriterion.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientcriterion.scala @@ -1,9 +1,10 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import spray.json._ -import xyz.driver.pdsuicommon.domain.FuzzyValue +import xyz.driver.entities.labels.LabelValue import xyz.driver.pdsuidomain.entities._ import xyz.driver.pdsuidomain.services.PatientCriterionService.{DraftPatientCriterion, RichPatientCriterion} +import xyz.driver.formats.json.labels._ object patientcriterion { import DefaultJsonProtocol._ @@ -14,13 +15,13 @@ object patientcriterion { val eligibilityStatus = if (fields.contains("eligibilityStatus")) { fields .get("eligibilityStatus") - .map(_.convertTo[FuzzyValue]) + .map(_.convertTo[LabelValue]) } else orig.eligibilityStatus val verifiedEligibilityStatus = if (fields.contains("verifiedEligibilityStatus")) { fields .get("verifiedEligibilityStatus") - .map(_.convertTo[FuzzyValue]) + .map(_.convertTo[LabelValue]) } else orig.verifiedEligibilityStatus orig.copy( diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientdefiningcriteria.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientdefiningcriteria.scala index 0520ef2..746c7b4 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientdefiningcriteria.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientdefiningcriteria.scala @@ -2,6 +2,7 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import spray.json._ import xyz.driver.pdsuidomain.entities.PatientLabel +import xyz.driver.formats.json.labels._ object patientdefiningcriteria { import DefaultJsonProtocol._ diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patienteligibletrial.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patienteligibletrial.scala index 041d9da..342d3a8 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patienteligibletrial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patienteligibletrial.scala @@ -3,6 +3,7 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import spray.json._ import xyz.driver.pdsuidomain.entities._ import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial +import xyz.driver.formats.json.labels._ object patienteligibletrial { import DefaultJsonProtocol._ diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala index b36949e..ff6d24d 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala @@ -1,9 +1,10 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import spray.json._ -import xyz.driver.pdsuicommon.domain.FuzzyValue +import xyz.driver.entities.labels.LabelValue import xyz.driver.pdsuidomain.entities._ import xyz.driver.pdsuidomain.services.PatientLabelService.RichPatientLabel +import xyz.driver.formats.json.labels._ object patientlabel { import DefaultJsonProtocol._ @@ -13,12 +14,12 @@ object patientlabel { case JsObject(fields) => val primaryValue = fields .get("primaryValue") - .map(_.convertTo[Option[FuzzyValue]]) + .map(_.convertTo[Option[LabelValue]]) .getOrElse(orig.primaryValue) val verifiedPrimaryValue = fields .get("verifiedPrimaryValue") - .map(_.convertTo[Option[FuzzyValue]]) + .map(_.convertTo[Option[LabelValue]]) .getOrElse(orig.verifiedPrimaryValue) orig.copy( diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/PatientCriterionService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/PatientCriterionService.scala index a07eed8..4d0e188 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/PatientCriterionService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/PatientCriterionService.scala @@ -2,7 +2,7 @@ package xyz.driver.pdsuidomain.services import java.time.LocalDateTime -import xyz.driver.entities.labels.Label +import xyz.driver.entities.labels.{Label, LabelValue} import xyz.driver.pdsuicommon.auth.AuthenticatedRequestContext import xyz.driver.pdsuicommon.db._ import xyz.driver.pdsuicommon.domain._ @@ -15,7 +15,7 @@ import scala.concurrent.Future object PatientCriterionService { final case class DraftPatientCriterion(id: LongId[PatientCriterion], - eligibilityStatus: Option[FuzzyValue], + eligibilityStatus: Option[LabelValue], isVerified: Option[Boolean]) { def applyTo(orig: PatientCriterion) = { orig.copy( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala index a451905..05f5863 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala @@ -5,7 +5,8 @@ import java.util.UUID import spray.json._ import org.scalatest.{FlatSpec, Matchers} -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.pdsuidomain.entities.{DocumentType, ProviderType, RecordRequestId} class ExportFormatSuite extends FlatSpec with Matchers { @@ -27,13 +28,13 @@ class ExportFormatSuite extends FlatSpec with Matchers { evidences = List( ExportPatientLabelEvidence( id = LongId(11), - value = FuzzyValue.Yes, + value = LabelValue.Yes, evidenceText = "evidence text 11", document = document ), ExportPatientLabelEvidence( id = LongId(12), - value = FuzzyValue.No, + value = LabelValue.No, evidenceText = "evidence text 12", document = document ) @@ -44,13 +45,13 @@ class ExportFormatSuite extends FlatSpec with Matchers { evidences = List( ExportPatientLabelEvidence( id = LongId(12), - value = FuzzyValue.Yes, + value = LabelValue.Yes, evidenceText = "evidence text 12", document = document ), ExportPatientLabelEvidence( id = LongId(13), - value = FuzzyValue.Yes, + value = LabelValue.Yes, evidenceText = "evidence text 13", document = document ) diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala index a4b8bab..aa82b98 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala @@ -2,7 +2,8 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import spray.json._ import org.scalatest.{FlatSpec, Matchers} -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, TextJson} +import xyz.driver.entities.labels.LabelValue +import xyz.driver.pdsuicommon.domain.{LongId, TextJson} import xyz.driver.pdsuidomain.entities.ExtractedData.Meta import xyz.driver.pdsuidomain.entities.{ExtractedData, ExtractedDataLabel} import xyz.driver.pdsuidomain.services.ExtractedDataService.RichExtractedData @@ -24,14 +25,14 @@ class ExtractedDataFormatSuite extends FlatSpec with Matchers { dataId = extractedData.id, labelId = None, categoryId = None, - value = Some(FuzzyValue.Yes) + value = Some(LabelValue.Yes) ), ExtractedDataLabel( id = LongId(2), dataId = extractedData.id, labelId = Some(LongId(12)), categoryId = Some(LongId(1)), - value = Some(FuzzyValue.No) + value = Some(LabelValue.No) ) ) val origRichExtractedData = RichExtractedData( @@ -64,14 +65,14 @@ class ExtractedDataFormatSuite extends FlatSpec with Matchers { dataId = extractedData.id, labelId = Some(LongId(20)), categoryId = Some(LongId(1)), - value = Some(FuzzyValue.Yes) + value = Some(LabelValue.Yes) ), ExtractedDataLabel( id = LongId(0), dataId = extractedData.id, labelId = Some(LongId(12)), categoryId = Some(LongId(1)), - value = Some(FuzzyValue.No) + value = Some(LabelValue.No) ) ) val expectedUpdatedExtractedData = origRichExtractedData.copy( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala index 623b3a9..fc206c7 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala @@ -4,7 +4,8 @@ import java.time.LocalDateTime import spray.json._ import org.scalatest.{FlatSpec, Matchers} -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, StringId} +import xyz.driver.entities.labels.LabelValue +import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuidomain.entities.{PatientCriterion, PatientCriterionArm} import xyz.driver.pdsuidomain.services.PatientCriterionService.{DraftPatientCriterion, RichPatientCriterion} @@ -21,7 +22,7 @@ class PatientCriterionFormatSuite extends FlatSpec with Matchers { criterionText = "criterion text", criterionValue = Some(true), criterionIsDefining = false, - eligibilityStatus = Some(FuzzyValue.Yes), + eligibilityStatus = Some(LabelValue.Yes), verifiedEligibilityStatus = None, isVisible = true, isVerified = true, @@ -40,13 +41,13 @@ class PatientCriterionFormatSuite extends FlatSpec with Matchers { "isVisible":true,"isVerified":true,"lastUpdate":"2017-08-10T18:00Z","arms":["arm 31","arm 32"]}""".parseJson) val updatePatientCriterionJson = """{"verifiedEligibilityStatus":"No"}""".parseJson - val expectedUpdatedPatientCriterion = orig.copy(verifiedEligibilityStatus = Some(FuzzyValue.No)) + val expectedUpdatedPatientCriterion = orig.copy(verifiedEligibilityStatus = Some(LabelValue.No)) val parsedUpdatePatientCriterion = applyUpdateToPatientCriterion(updatePatientCriterionJson, orig) parsedUpdatePatientCriterion should be(expectedUpdatedPatientCriterion) val updateBulkPatientCriterionJson = """[{"id":1,"eligibilityStatus":"No"},{"id":2,"isVerified":false}]""".parseJson val expectedDraftPatientCriterionList = List( - DraftPatientCriterion(id = LongId(1), eligibilityStatus = Some(FuzzyValue.No), isVerified = None), + DraftPatientCriterion(id = LongId(1), eligibilityStatus = Some(LabelValue.No), isVerified = None), DraftPatientCriterion(id = LongId(2), eligibilityStatus = None, isVerified = Some(false)) ) val parsedDraftPatientCriterionList = draftPatientCriterionListReader.read(updateBulkPatientCriterionJson) diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala index ad54946..f48625c 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala @@ -4,7 +4,8 @@ import java.time.LocalDateTime import spray.json._ import org.scalatest.{FlatSpec, Matchers} -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.pdsuidomain.entities.{PatientCriterionArm, PatientTrialArmGroupView, Trial} import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial @@ -38,8 +39,8 @@ class PatientEligibleTrialFormatSuite extends FlatSpec with Matchers { patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), trialId = StringId("NCT000001"), hypothesisId = UuidId("e76e2fc4-a29c-44fb-a81b-8856d06bb1d4"), - eligibilityStatus = Some(FuzzyValue.Yes), - verifiedEligibilityStatus = Some(FuzzyValue.Yes), + eligibilityStatus = Some(LabelValue.Yes), + verifiedEligibilityStatus = Some(LabelValue.Yes), isVerified = false ) val arms = List( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala index 2761d6a..443c8e8 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala @@ -4,6 +4,8 @@ import java.time.{LocalDate, LocalDateTime} import spray.json._ import org.scalatest.{FlatSpec, Matchers} +import xyz.driver.entities.common.FullName +import xyz.driver.entities.patient.CancerType import xyz.driver.pdsuicommon.domain.UuidId import xyz.driver.pdsuidomain.entities.{Patient, PatientOrderId} @@ -14,23 +16,24 @@ class PatientFormatSuite extends FlatSpec with Matchers { val orig = Patient( id = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), status = Patient.Status.New, - name = "John Doe", + name = FullName.fromStrings("John", "", "Doe"), dob = LocalDate.parse("1980-06-30"), assignee = None, previousStatus = None, previousAssignee = None, lastActiveUserId = None, isUpdateRequired = false, - condition = "breast", + cancerType = CancerType.Breast, orderId = PatientOrderId("7b54a75d-4197-4b27-9045-b9b6cb131be9"), lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00") ) val writtenJson = patientWriter.write(orig) writtenJson should be ( - """{"id":"748b5884-3528-4cb9-904b-7a8151d6e343","dob":"1980-06-30","name":"John Doe","status":"New","assignee":null, + """{"id":"748b5884-3528-4cb9-904b-7a8151d6e343","dob":"1980-06-30", + "name":{"firstName":"John","middleName":"","lastName":"Doe"},"status":"New","assignee":null, "previousStatus":null,"previousAssignee":null,"lastActiveUser":null,"lastUpdate":"2017-08-10T18:00Z", - "orderId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","condition":"breast"}""".parseJson) + "orderId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","condition":"Breast"}""".parseJson) } } diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala index 3ef286d..47b251a 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala @@ -4,7 +4,8 @@ import java.time.LocalDate import spray.json._ import org.scalatest.{FlatSpec, Matchers} -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, UuidId} +import xyz.driver.entities.labels.LabelValue +import xyz.driver.pdsuicommon.domain.{LongId, UuidId} import xyz.driver.pdsuidomain.entities.{PatientLabel, PatientLabelEvidenceView} import xyz.driver.pdsuidomain.services.PatientLabelService.RichPatientLabel @@ -16,7 +17,7 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers { id = LongId(1), patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), labelId = LongId(20), - primaryValue = Some(FuzzyValue.Yes), + primaryValue = Some(LabelValue.Yes), verifiedPrimaryValue = None, isVisible = true, score = 1, @@ -29,7 +30,7 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers { "score":1,"isImplicitMatch":false}""".parseJson) val updatePatientLabelJson = """{"verifiedPrimaryValue":"No"}""".parseJson - val expectedUpdatedPatientLabel = orig.copy(verifiedPrimaryValue = Some(FuzzyValue.No)) + val expectedUpdatedPatientLabel = orig.copy(verifiedPrimaryValue = Some(LabelValue.No)) val parsedUpdatePatientLabel = applyUpdateToPatientLabel(updatePatientLabelJson, orig) parsedUpdatePatientLabel should be(expectedUpdatedPatientLabel) } @@ -38,7 +39,7 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers { import patientlabel._ val orig = PatientLabelEvidenceView( id = LongId(1), - value = FuzzyValue.Maybe, + value = LabelValue.Maybe, evidenceText = "evidence text", documentId = Some(LongId(21)), evidenceId = Some(LongId(10)), @@ -63,8 +64,8 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers { id = LongId(1), patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), labelId = LongId(20), - primaryValue = Some(FuzzyValue.Yes), - verifiedPrimaryValue = Some(FuzzyValue.Yes), + primaryValue = Some(LabelValue.Yes), + verifiedPrimaryValue = Some(LabelValue.Yes), isVisible = true, score = 1, isImplicitMatch = false -- cgit v1.2.3 From 9cfd099d063016c313d4fb8d69202a6184ecdffc Mon Sep 17 00:00:00 2001 From: vlad Date: Mon, 9 Oct 2017 13:21:56 -0700 Subject: Update core --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'build.sbt') diff --git a/build.sbt b/build.sbt index bd7468f..d68a8f5 100644 --- a/build.sbt +++ b/build.sbt @@ -18,7 +18,7 @@ lazy val core = (project in file(".")) "io.github.cloudify" %% "spdf" % "1.4.0", "org.davidbild" %% "tristate-core" % "0.2.0", "org.davidbild" %% "tristate-play" % "0.2.0" exclude ("com.typesafe.play", "play-json"), - "xyz.driver" %% "core" % "1.2.1", + "xyz.driver" %% "core" % "1.2.2", "xyz.driver" %% "domain-model" % "0.17.8", "ch.qos.logback" % "logback-classic" % "1.1.7", "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.8.4", -- cgit v1.2.3