aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/patient')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/ApiPatient.scala86
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/PatientStatus.scala24
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/eligible/ApiPartialPatientEligibleTrial.scala18
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/eligible/ApiPatientEligibleTrial.scala51
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/hypothesis/ApiPartialPatientHypothesis.scala27
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/hypothesis/ApiPatientHypothesis.scala35
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPartialPatientLabel.scala43
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPatientLabel.scala55
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPatientLabelDefiningCriteria.scala29
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPartialPatientCriterion.scala47
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPartialPatientCriterionList.scala37
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPatientCriterion.scala75
12 files changed, 0 insertions, 527 deletions
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
deleted file mode 100644
index 585d4ed..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/ApiPatient.scala
+++ /dev/null
@@ -1,86 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.patient
-
-import java.time.{LocalDate, ZoneId, ZonedDateTime}
-import java.util.UUID
-
-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,
- name: String,
- dob: LocalDate,
- assignee: Option[String],
- previousStatus: Option[String],
- previousAssignee: Option[String],
- lastActiveUser: Option[String],
- lastUpdate: ZonedDateTime,
- disease: String,
- orderId: UUID) {
-
- private def extractStatus(status: String): Patient.Status =
- 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 = 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,
- disease = patient.CancerType
- .fromString(this.disease)
- .getOrElse(throw new IllegalArgumentException(s"Unknown cancer type ${this.disease}")),
- orderId = PatientOrderId(this.orderId),
- lastUpdate = this.lastUpdate.toLocalDateTime
- )
-
-}
-
-object ApiPatient {
-
- implicit val format: Format[ApiPatient] = (
- (JsPath \ "id").format[String] and
- (JsPath \ "status").format[String] and
- (JsPath \ "name").format[String] and
- (JsPath \ "dob").format[LocalDate] and
- (JsPath \ "assignee").formatNullable[String] and
- (JsPath \ "previousStatus").formatNullable[String] and
- (JsPath \ "previousAssignee").formatNullable[String] and
- (JsPath \ "lastActiveUser").formatNullable[String] and
- (JsPath \ "lastUpdate").format[ZonedDateTime] and
- (JsPath \ "disease").format[String] and
- (JsPath \ "orderId").format[UUID]
- )(ApiPatient.apply, unlift(ApiPatient.unapply))
-
- def fromDomain(patient: Patient) = ApiPatient(
- id = patient.id.toString,
- status = PatientStatus.statusToString(patient.status),
- 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")),
- disease = patient.disease.toString,
- orderId = patient.orderId.id
- )
-}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/PatientStatus.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/PatientStatus.scala
deleted file mode 100644
index a23a1de..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/PatientStatus.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.patient
-
-import xyz.driver.pdsuidomain.entities.Patient.Status
-
-object PatientStatus {
-
- val statusFromString: PartialFunction[String, Status] = {
- case "New" => Status.New
- case "Verified" => Status.Verified
- case "Reviewed" => Status.Reviewed
- case "Curated" => Status.Curated
- case "Flagged" => Status.Flagged
- case "Done" => Status.Done
- }
-
- def statusToString(x: Status): String = x match {
- case Status.New => "New"
- case Status.Verified => "Verified"
- case Status.Reviewed => "Reviewed"
- case Status.Curated => "Curated"
- case Status.Flagged => "Flagged"
- case Status.Done => "Done"
- }
-}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/eligible/ApiPartialPatientEligibleTrial.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/eligible/ApiPartialPatientEligibleTrial.scala
deleted file mode 100644
index 03ff275..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/eligible/ApiPartialPatientEligibleTrial.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.patient.eligible
-
-import xyz.driver.pdsuidomain.entities.PatientTrialArmGroupView
-import play.api.libs.json.{Format, Json}
-
-final case class ApiPartialPatientEligibleTrial(isVerified: Option[Boolean]) {
-
- def applyTo(orig: PatientTrialArmGroupView): PatientTrialArmGroupView = {
- orig.copy(
- isVerified = isVerified.getOrElse(orig.isVerified)
- )
- }
-}
-
-object ApiPartialPatientEligibleTrial {
-
- implicit val format: Format[ApiPartialPatientEligibleTrial] = Json.format
-}
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
deleted file mode 100644
index 55c8149..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/eligible/ApiPatientEligibleTrial.scala
+++ /dev/null
@@ -1,51 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.patient.eligible
-
-import java.util.UUID
-
-import play.api.data.validation.ValidationError
-import play.api.libs.functional.syntax._
-import play.api.libs.json._
-import xyz.driver.entities.labels.LabelValue
-import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial
-
-final case class ApiPatientEligibleTrial(id: Long,
- patientId: String,
- trialId: String,
- trialTitle: String,
- arms: List[String],
- hypothesisId: UUID,
- verifiedEligibilityStatus: Option[String],
- isVerified: Boolean)
-
-object ApiPatientEligibleTrial {
-
- implicit val apiEligibleTrialJsonFormat: Format[ApiPatientEligibleTrial] = (
- (JsPath \ "id").format[Long] and
- (JsPath \ "patientId").format[String] and
- (JsPath \ "trialId").format[String] and
- (JsPath \ "trialTitle").format[String] and
- (JsPath \ "arms").format[List[String]] and
- (JsPath \ "hypothesisId").format[UUID] and
- (JsPath \ "verifiedEligibilityStatus").formatNullable[String](Format(
- Reads
- .of[String]
- .filter(ValidationError("unknown eligibility status"))({
- case x if LabelValue.fromString(x).isDefined => true
- case _ => false
- }),
- Writes.of[String]
- )) and
- (JsPath \ "isVerified").format[Boolean]
- )(ApiPatientEligibleTrial.apply, unlift(ApiPatientEligibleTrial.unapply))
-
- def fromDomain(eligibleTrialWithTrial: RichPatientEligibleTrial) = ApiPatientEligibleTrial(
- id = eligibleTrialWithTrial.group.id.id,
- patientId = eligibleTrialWithTrial.group.patientId.toString,
- trialId = eligibleTrialWithTrial.group.trialId.id,
- trialTitle = eligibleTrialWithTrial.trial.title,
- arms = eligibleTrialWithTrial.arms.map(_.armName),
- hypothesisId = eligibleTrialWithTrial.group.hypothesisId.id,
- eligibleTrialWithTrial.group.verifiedEligibilityStatus.map(_.toString),
- eligibleTrialWithTrial.group.isVerified
- )
-}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/hypothesis/ApiPartialPatientHypothesis.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/hypothesis/ApiPartialPatientHypothesis.scala
deleted file mode 100644
index 0858ce1..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/hypothesis/ApiPartialPatientHypothesis.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.patient.hypothesis
-
-import xyz.driver.pdsuidomain.entities.PatientHypothesis
-import org.davidbild.tristate.Tristate
-import org.davidbild.tristate.contrib.play.ToJsPathOpsFromJsPath
-import play.api.libs.functional.syntax._
-import play.api.libs.json._
-
-final case class ApiPartialPatientHypothesis(rationale: Tristate[String]) {
-
- def applyTo(orig: PatientHypothesis): PatientHypothesis = {
- orig.copy(
- rationale = rationale.cata(Some(_), None, orig.rationale)
- )
- }
-}
-
-object ApiPartialPatientHypothesis {
-
- implicit val reads: Reads[ApiPartialPatientHypothesis] =
- (__ \ "rationale").readTristate[String].map(x => ApiPartialPatientHypothesis(x))
-
- implicit val writes: Writes[ApiPartialPatientHypothesis] =
- (__ \ "rationale").writeTristate[String].contramap(_.rationale)
-
- implicit val format: Format[ApiPartialPatientHypothesis] = Format(reads, writes)
-}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/hypothesis/ApiPatientHypothesis.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/hypothesis/ApiPatientHypothesis.scala
deleted file mode 100644
index 584ff72..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/hypothesis/ApiPatientHypothesis.scala
+++ /dev/null
@@ -1,35 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.patient.hypothesis
-
-import java.util.UUID
-
-import xyz.driver.pdsuidomain.entities.PatientHypothesis
-import play.api.libs.functional.syntax._
-import play.api.libs.json._
-
-final case class ApiPatientHypothesis(id: UUID,
- patientId: String,
- hypothesisId: UUID,
- matchedTrials: Long,
- rationale: Option[String],
- isRationaleRequired: Boolean)
-
-object ApiPatientHypothesis {
-
- implicit val apiPatientHypothesisJsonFormat: Format[ApiPatientHypothesis] = (
- (JsPath \ "id").format[UUID] and
- (JsPath \ "patientId").format[String] and
- (JsPath \ "hypothesisId").format[UUID] and
- (JsPath \ "matchedTrials").format[Long] and
- (JsPath \ "rationale").formatNullable[String] and
- (JsPath \ "isRationaleRequired").format[Boolean]
- )(ApiPatientHypothesis.apply, unlift(ApiPatientHypothesis.unapply))
-
- def fromDomain(patientHypothesis: PatientHypothesis, isRationaleRequired: Boolean) = ApiPatientHypothesis(
- id = patientHypothesis.id.id,
- patientId = patientHypothesis.patientId.toString,
- hypothesisId = patientHypothesis.hypothesisId.id,
- matchedTrials = patientHypothesis.matchedTrials,
- rationale = patientHypothesis.rationale,
- isRationaleRequired = isRationaleRequired
- )
-}
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
deleted file mode 100644
index d92872c..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPartialPatientLabel.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.patient.label
-
-import xyz.driver.pdsuidomain.entities.PatientLabel
-import org.davidbild.tristate.Tristate
-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.entities.labels.LabelValue
-
-final case class ApiPartialPatientLabel(primaryValue: Option[String], verifiedPrimaryValue: Tristate[String]) {
-
- def applyTo(orig: PatientLabel): PatientLabel = {
- orig.copy(
- primaryValue = primaryValue.flatMap(LabelValue.fromString).orElse(orig.primaryValue),
- verifiedPrimaryValue = verifiedPrimaryValue.cata(x => LabelValue.fromString(x), None, orig.verifiedPrimaryValue)
- )
- }
-}
-
-object ApiPartialPatientLabel {
-
- implicit val format: Format[ApiPartialPatientLabel] = (
- (JsPath \ "primaryValue").formatNullable[String](
- Format(Reads
- .of[String]
- .filter(ValidationError("unknown primary value"))({
- case x if LabelValue.fromString(x).isDefined => true
- case _ => false
- }),
- Writes.of[String])) and
- (JsPath \ "verifiedPrimaryValue").formatTristate[String](
- Format(
- Reads
- .of[String]
- .filter(ValidationError("unknown verified primary value"))({
- case x if LabelValue.fromString(x).isDefined => true
- case _ => false
- }),
- Writes.of[String]
- ))
- )(ApiPartialPatientLabel.apply, unlift(ApiPartialPatientLabel.unapply))
-}
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
deleted file mode 100644
index cc8532d..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPatientLabel.scala
+++ /dev/null
@@ -1,55 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.patient.label
-
-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.entities.labels.LabelValue
-
-final case class ApiPatientLabel(id: Long,
- labelId: Long,
- primaryValue: Option[String],
- verifiedPrimaryValue: Option[String],
- score: Int,
- isImplicitMatch: Boolean,
- isVisible: Boolean,
- isVerified: Boolean)
-
-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 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))
-
- def fromDomain(patientLabel: PatientLabel, isVerified: Boolean): ApiPatientLabel = ApiPatientLabel(
- id = patientLabel.id.id,
- labelId = patientLabel.labelId.id,
- primaryValue = patientLabel.primaryValue.map(_.toString),
- verifiedPrimaryValue = patientLabel.verifiedPrimaryValue.map(_.toString),
- score = patientLabel.score,
- isImplicitMatch = patientLabel.isImplicitMatch,
- isVisible = patientLabel.isVisible,
- isVerified = isVerified
- )
-}
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
deleted file mode 100644
index 16b9cc9..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/label/ApiPatientLabelDefiningCriteria.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-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.entities.labels.LabelValue
-import xyz.driver.pdsuidomain.entities.PatientLabel
-
-final case class ApiPatientLabelDefiningCriteria(labelId: Long, value: Option[String])
-
-object ApiPatientLabelDefiningCriteria {
-
- implicit val format: Format[ApiPatientLabelDefiningCriteria] = (
- (JsPath \ "labelId").format[Long] and
- (JsPath \ "value").formatNullable[String](
- Format(Reads
- .of[String]
- .filter(ValidationError("unknown value"))({
- 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(_.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
deleted file mode 100644
index 09538b8..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPartialPatientCriterion.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.patient.trial
-
-import xyz.driver.pdsuidomain.entities.PatientCriterion
-import org.davidbild.tristate.Tristate
-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.entities.labels.LabelValue
-
-final case class ApiPartialPatientCriterion(eligibilityStatus: Option[String],
- verifiedEligibilityStatus: Tristate[String]) {
-
- def applyTo(orig: PatientCriterion): PatientCriterion = {
- orig.copy(
- eligibilityStatus = eligibilityStatus.flatMap(LabelValue.fromString).orElse(orig.eligibilityStatus),
- verifiedEligibilityStatus =
- verifiedEligibilityStatus.cata(x => LabelValue.fromString(x), None, orig.verifiedEligibilityStatus)
- )
- }
-}
-
-object ApiPartialPatientCriterion {
-
- implicit val format: Format[ApiPartialPatientCriterion] = (
- (JsPath \ "eligibilityStatus").formatNullable[String](
- Format(
- Reads
- .of[String]
- .filter(ValidationError("unknown eligibility status"))({
- case x if LabelValue.fromString(x).isDefined => true
- case _ => false
- }),
- Writes.of[String]
- )) and
- (JsPath \ "verifiedEligibilityStatus").formatTristate[String](
- Format(
- Reads
- .of[String]
- .filter(ValidationError("unknown verified eligibility status"))({
- case x if LabelValue.fromString(x).isDefined => true
- case _ => false
- }),
- Writes.of[String]
- ))
- )(ApiPartialPatientCriterion.apply, unlift(ApiPartialPatientCriterion.unapply))
-}
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
deleted file mode 100644
index b7616a1..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPartialPatientCriterionList.scala
+++ /dev/null
@@ -1,37 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.patient.trial
-
-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,
- eligibilityStatus: Option[String],
- isVerified: Option[Boolean]) {
-
- def toDomain: DraftPatientCriterion = DraftPatientCriterion(
- id = LongId[PatientCriterion](id),
- eligibilityStatus = eligibilityStatus.flatMap(LabelValue.fromString),
- isVerified = isVerified
- )
-}
-
-object ApiPartialPatientCriterionList {
-
- implicit val format: Format[ApiPartialPatientCriterionList] = (
- (JsPath \ "id").format[Long] and
- (JsPath \ "eligibilityStatus").formatNullable[String](Format(
- Reads
- .of[String]
- .filter(ValidationError("unknown eligibility status"))({
- case x if LabelValue.fromString(x).isDefined => true
- case _ => false
- }),
- Writes.of[String]
- )) and
- (JsPath \ "isVerified").formatNullable[Boolean]
- )(ApiPartialPatientCriterionList.apply, unlift(ApiPartialPatientCriterionList.unapply))
-}
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
deleted file mode 100644
index b9bf772..0000000
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial/ApiPatientCriterion.scala
+++ /dev/null
@@ -1,75 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.patient.trial
-
-import java.time.{ZoneId, ZonedDateTime}
-
-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, LabelValue}
-
-final case class ApiPatientCriterion(id: Long,
- labelId: Long,
- nctId: String,
- criterionId: Long,
- criterionText: String,
- criterionValue: Option[String],
- criterionIsDefining: Boolean,
- criterionIsCompound: Boolean,
- arms: List[String],
- eligibilityStatus: Option[String],
- verifiedEligibilityStatus: Option[String],
- isVerified: Boolean,
- isVisible: Boolean,
- lastUpdate: ZonedDateTime)
-
-object ApiPatientCriterion {
-
- implicit val format: Format[ApiPatientCriterion] = (
- (JsPath \ "id").format[Long] and
- (JsPath \ "labelId").format[Long] and
- (JsPath \ "nctId").format[String] and
- (JsPath \ "criterionId").format[Long] and
- (JsPath \ "criterionText").format[String] and
- (JsPath \ "criterionValue").formatNullable[String](Format(Reads.of[String].filter(ValidationError("unknown value"))({ x =>
- x == "Yes" || x == "No"
- }), Writes.of[String])) and
- (JsPath \ "criterionIsDefining").format[Boolean] and
- (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 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 LabelValue.fromString(x).isDefined => true
- case _ => false
- }), Writes.of[String])) and
- (JsPath \ "isVerified").format[Boolean] and
- (JsPath \ "isVisible").format[Boolean] and
- (JsPath \ "lastUpdate").format[ZonedDateTime]
- ) (ApiPatientCriterion.apply, unlift(ApiPatientCriterion.unapply))
-
- def fromDomain(patientCriterion: PatientCriterion,
- labelId: LongId[Label],
- arms: List[PatientCriterionArm]) = ApiPatientCriterion(
- id = patientCriterion.id.id,
- labelId = labelId.id,
- nctId = patientCriterion.nctId.id,
- criterionId = patientCriterion.criterionId.id,
- criterionText = patientCriterion.criterionText,
- criterionValue = patientCriterion.criterionValue.map { x =>
- LabelValue.fromBoolean(x).toString
- },
- criterionIsDefining = patientCriterion.criterionIsDefining,
- criterionIsCompound = patientCriterion.criterionValue.isEmpty,
- arms = arms.map(_.armName),
- eligibilityStatus = patientCriterion.eligibilityStatus.map(_.toString),
- verifiedEligibilityStatus = patientCriterion.verifiedEligibilityStatus.map(_.toString),
- isVerified = patientCriterion.isVerified,
- isVisible = patientCriterion.isVisible,
- lastUpdate = ZonedDateTime.of(patientCriterion.lastUpdate, ZoneId.of("Z"))
- )
-}