diff options
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats')
4 files changed, 17 insertions, 23 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 index ad6bc80..585d4ed 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 @@ -19,7 +19,7 @@ final case class ApiPatient(id: String, previousAssignee: Option[String], lastActiveUser: Option[String], lastUpdate: ZonedDateTime, - condition: String, + disease: String, orderId: UUID) { private def extractStatus(status: String): Patient.Status = @@ -45,9 +45,9 @@ final case class ApiPatient(id: String, previousAssignee = this.previousAssignee.map(StringId(_)), lastActiveUserId = this.lastActiveUser.map(StringId(_)), isUpdateRequired = false, - cancerType = patient.CancerType - .fromString(this.condition) - .getOrElse(throw new IllegalArgumentException(s"Unknown cancer type ${this.condition}")), + disease = patient.CancerType + .fromString(this.disease) + .getOrElse(throw new IllegalArgumentException(s"Unknown cancer type ${this.disease}")), orderId = PatientOrderId(this.orderId), lastUpdate = this.lastUpdate.toLocalDateTime ) @@ -66,7 +66,7 @@ object ApiPatient { (JsPath \ "previousAssignee").formatNullable[String] and (JsPath \ "lastActiveUser").formatNullable[String] and (JsPath \ "lastUpdate").format[ZonedDateTime] and - (JsPath \ "condition").format[String] and + (JsPath \ "disease").format[String] and (JsPath \ "orderId").format[UUID] )(ApiPatient.apply, unlift(ApiPatient.unapply)) @@ -80,7 +80,7 @@ object ApiPatient { previousAssignee = patient.previousAssignee.map(_.id), lastActiveUser = patient.lastActiveUserId.map(_.id), lastUpdate = ZonedDateTime.of(patient.lastUpdate, ZoneId.of("Z")), - condition = patient.cancerType.toString, + disease = patient.disease.toString, orderId = patient.orderId.id ) } 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 3da76c1..2b0dfe5 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 @@ -40,7 +40,7 @@ object patient { "previousAssignee" -> patient.previousAssignee.toJson, "lastActiveUser" -> patient.lastActiveUserId.toJson, "lastUpdate" -> patient.lastUpdate.toJson, - "condition" -> patient.cancerType.toJson, + "disease" -> patient.disease.toJson, "orderId" -> patient.orderId.toJson ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/trial.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/trial.scala index 8000a27..d851c2c 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/trial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/trial.scala @@ -6,6 +6,7 @@ import spray.json._ import xyz.driver.core.json.EnumJsonFormat import xyz.driver.pdsuicommon.domain.{LongId, UuidId} import xyz.driver.pdsuidomain.entities._ +import xyz.driver.formats.json.patient._ object trial { import DefaultJsonProtocol._ @@ -24,12 +25,6 @@ object trial { "Archived" -> Status.Archived ) - implicit val conditionFormat = new EnumJsonFormat[Condition]( - "Breast" -> Condition.Breast, - "Lung" -> Condition.Lung, - "Prostate" -> Condition.Prostate - ) - implicit val trialWriter: RootJsonWriter[Trial] = new RootJsonWriter[Trial] { override def write(obj: Trial) = JsObject( @@ -41,7 +36,7 @@ object trial { "previousStatus" -> obj.previousStatus.toJson, "previousAssignee" -> obj.previousAssignee.toJson, "lastActiveUser" -> obj.lastActiveUserId.toJson, - "condition" -> obj.condition.toJson, + "disease" -> obj.disease.toJson, "phase" -> obj.phase.toJson, "hypothesisId" -> obj.hypothesisId.toJson, "studyDesignId" -> obj.studyDesignId.toJson, diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/trial/ApiTrial.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/trial/ApiTrial.scala index 1b4ac64..a2a1ca9 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/trial/ApiTrial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/trial/ApiTrial.scala @@ -2,11 +2,12 @@ package xyz.driver.pdsuidomain.formats.json.trial import java.time.{ZoneId, ZonedDateTime} import java.util.UUID -import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} +import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} import xyz.driver.pdsuidomain.entities.Trial import play.api.libs.functional.syntax._ import play.api.libs.json._ +import xyz.driver.entities.patient.CancerType final case class ApiTrial(id: String, externalId: UUID, @@ -16,7 +17,7 @@ final case class ApiTrial(id: String, previousStatus: Option[String], previousAssignee: Option[String], lastActiveUser: Option[String], - condition: String, + disease: String, phase: String, hypothesisId: Option[UUID], studyDesignId: Option[Long], @@ -37,11 +38,9 @@ final case class ApiTrial(id: String, previousAssignee = this.previousAssignee.map(id => StringId(id)), lastActiveUserId = this.lastActiveUser.map(id => StringId(id)), lastUpdate = this.lastUpdate.toLocalDateTime, - condition = Trial.Condition - .fromString(this.condition) - .getOrElse( - throw new NoSuchElementException(s"unknown condition ${this.condition}") - ), + disease = CancerType + .fromString(this.disease) + .getOrElse(throw new NoSuchElementException(s"Unknown disease ${this.disease}")), phase = this.phase, hypothesisId = this.hypothesisId.map(id => UuidId(id)), studyDesignId = this.studyDesignId.map(id => LongId(id)), @@ -67,7 +66,7 @@ object ApiTrial { (JsPath \ "previousStatus").formatNullable[String] and (JsPath \ "previousAssignee").formatNullable[String] and (JsPath \ "lastActiveUser").formatNullable[String] and - (JsPath \ "condition").format[String] and + (JsPath \ "disease").format[String] and (JsPath \ "phase").format[String] and (JsPath \ "hypothesisId").formatNullable[UUID] and (JsPath \ "studyDesignId").formatNullable[Long] and @@ -89,7 +88,7 @@ object ApiTrial { previousAssignee = trial.previousAssignee.map(_.id), lastActiveUser = trial.lastActiveUserId.map(_.id), lastUpdate = ZonedDateTime.of(trial.lastUpdate, ZoneId.of("Z")), - condition = trial.condition.toString, + disease = trial.disease.toString, phase = trial.phase, hypothesisId = trial.hypothesisId.map(_.id), studyDesignId = trial.studyDesignId.map(_.id), |