aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/patient/trial')
-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.scala77
3 files changed, 0 insertions, 161 deletions
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
index 5e44413..8b13789 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
@@ -1,78 +1 @@
-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,
- inclusion: Option[Boolean])
-
-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] and
- (JsPath \ "inclusion").formatNullable[Boolean]
- ) (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")),
- inclusion = patientCriterion.inclusion
- )
-}