aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/export
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/export')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabel.scala22
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidence.scala28
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidenceDocument.scala34
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala22
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrial.scala26
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialArm.scala20
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialLabelCriterion.scala39
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialList.scala15
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala38
9 files changed, 244 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabel.scala
new file mode 100644
index 0000000..78a73a6
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabel.scala
@@ -0,0 +1,22 @@
+package xyz.driver.pdsuidomain.formats.json.export
+
+import play.api.libs.functional.syntax._
+import play.api.libs.json.{Format, JsPath}
+import xyz.driver.pdsuidomain.entities.export.patient.ExportPatientLabel
+
+final case class ApiExportPatientLabel(id: String, labelName: String, evidences: List[ApiExportPatientLabelEvidence])
+
+object ApiExportPatientLabel {
+
+ implicit val format: Format[ApiExportPatientLabel] = (
+ (JsPath \ "labelId").format[String] and
+ (JsPath \ "labelName").format[String] and
+ (JsPath \ "evidence").format[List[ApiExportPatientLabelEvidence]]
+ ) (ApiExportPatientLabel.apply, unlift(ApiExportPatientLabel.unapply))
+
+ def fromDomain(label: ExportPatientLabel) = ApiExportPatientLabel(
+ id = label.id.toString,
+ labelName = label.name,
+ evidences = label.evidences.map(ApiExportPatientLabelEvidence.fromDomain)
+ )
+}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidence.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidence.scala
new file mode 100644
index 0000000..b38c2a0
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidence.scala
@@ -0,0 +1,28 @@
+package xyz.driver.pdsuidomain.formats.json.export
+
+import play.api.libs.functional.syntax._
+import play.api.libs.json._
+import xyz.driver.pdsuicommon.domain.FuzzyValue
+import xyz.driver.pdsuidomain.entities.export.patient.ExportPatientLabelEvidence
+
+final case class ApiExportPatientLabelEvidence(evidenceId: String,
+ labelValue: String,
+ evidenceText: String,
+ document: ApiExportPatientLabelEvidenceDocument)
+
+object ApiExportPatientLabelEvidence {
+
+ implicit val format: Format[ApiExportPatientLabelEvidence] = (
+ (JsPath \ "evidenceId").format[String] and
+ (JsPath \ "labelValue").format[String](Writes[String](x => JsString(x.toUpperCase))) and
+ (JsPath \ "evidenceText").format[String] and
+ (JsPath \ "document").format[ApiExportPatientLabelEvidenceDocument]
+ ) (ApiExportPatientLabelEvidence.apply, unlift(ApiExportPatientLabelEvidence.unapply))
+
+ def fromDomain(evidence: ExportPatientLabelEvidence) = ApiExportPatientLabelEvidence(
+ evidenceId = evidence.id.toString,
+ labelValue = FuzzyValue.valueToString(evidence.value),
+ evidenceText = evidence.evidenceText,
+ document = ApiExportPatientLabelEvidenceDocument.fromDomain(evidence.document)
+ )
+}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidenceDocument.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidenceDocument.scala
new file mode 100644
index 0000000..d094014
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidenceDocument.scala
@@ -0,0 +1,34 @@
+package xyz.driver.pdsuidomain.formats.json.export
+
+import java.time.LocalDate
+
+import play.api.libs.functional.syntax._
+import play.api.libs.json.{Format, JsPath}
+import xyz.driver.pdsuidomain.entities.export.patient.ExportPatientLabelEvidenceDocument
+
+final case class ApiExportPatientLabelEvidenceDocument(documentId: String,
+ requestId: String,
+ documentType: String,
+ providerType: String,
+ date: LocalDate)
+
+
+object ApiExportPatientLabelEvidenceDocument {
+
+ implicit val format: Format[ApiExportPatientLabelEvidenceDocument] = (
+ (JsPath \ "documentId").format[String] and
+ (JsPath \ "requestId").format[String] and
+ (JsPath \ "documentType").format[String] and
+ (JsPath \ "providerType").format[String] and
+ (JsPath \ "date").format[LocalDate]
+ ) (ApiExportPatientLabelEvidenceDocument.apply, unlift(ApiExportPatientLabelEvidenceDocument.unapply))
+
+ def fromDomain(document: ExportPatientLabelEvidenceDocument) =
+ ApiExportPatientLabelEvidenceDocument(
+ documentId = document.documentId.toString,
+ requestId = document.requestId.toString,
+ documentType = document.documentType,
+ providerType = document.providerType,
+ date = document.date
+ )
+}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala
new file mode 100644
index 0000000..d5b9eb3
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala
@@ -0,0 +1,22 @@
+package xyz.driver.pdsuidomain.formats.json.export
+
+import play.api.libs.functional.syntax._
+import play.api.libs.json.{Format, JsPath}
+import xyz.driver.pdsuidomain.entities.export.patient.ExportPatientWithLabels
+
+final case class ApiExportPatientWithLabels(patientId: String, labelVersion: Long, labels: List[ApiExportPatientLabel])
+
+object ApiExportPatientWithLabels {
+
+ implicit val format: Format[ApiExportPatientWithLabels] = (
+ (JsPath \ "patientId").format[String] and
+ (JsPath \ "labelVersion").format[Long] and
+ (JsPath \ "labels").format[List[ApiExportPatientLabel]]
+ ) (ApiExportPatientWithLabels.apply, unlift(ApiExportPatientWithLabels.unapply))
+
+ def fromDomain(patient: ExportPatientWithLabels) = ApiExportPatientWithLabels(
+ patientId = patient.patientId.toString,
+ labelVersion = patient.labelVersion,
+ labels = patient.labels.map(ApiExportPatientLabel.fromDomain)
+ )
+}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrial.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrial.scala
new file mode 100644
index 0000000..b12cb93
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrial.scala
@@ -0,0 +1,26 @@
+package xyz.driver.pdsuidomain.formats.json.export
+
+import java.time.ZoneId
+
+import play.api.libs.functional.syntax._
+import play.api.libs.json.{Format, JsPath}
+import xyz.driver.pdsuidomain.entities.export.trial.ExportTrial
+
+final case class ApiExportTrial(nctId: String, trialId: String, disease: String, lastReviewed: Long)
+
+object ApiExportTrial {
+
+ implicit val format: Format[ApiExportTrial] = (
+ (JsPath \ "nctId").format[String] and
+ (JsPath \ "trialId").format[String] and
+ (JsPath \ "disease").format[String] and
+ (JsPath \ "lastReviewed").format[Long]
+ ) (ApiExportTrial.apply, unlift(ApiExportTrial.unapply))
+
+ def fromDomain(trial: ExportTrial): ApiExportTrial = ApiExportTrial(
+ nctId = trial.nctId.id,
+ trialId = trial.trialId.toString,
+ disease = trial.condition.toString.toUpperCase,
+ lastReviewed = trial.lastReviewed.atZone(ZoneId.of("Z")).toEpochSecond
+ )
+}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialArm.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialArm.scala
new file mode 100644
index 0000000..0b77832
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialArm.scala
@@ -0,0 +1,20 @@
+package xyz.driver.pdsuidomain.formats.json.export
+
+import play.api.libs.functional.syntax._
+import play.api.libs.json._
+import xyz.driver.pdsuidomain.entities.export.trial.ExportTrialArm
+
+final case class ApiExportTrialArm(armId: String, armName: String)
+
+object ApiExportTrialArm {
+
+ implicit val format: Format[ApiExportTrialArm] = (
+ (JsPath \ "armId").format[String] and
+ (JsPath \ "armName").format[String]
+ ) (ApiExportTrialArm.apply, unlift(ApiExportTrialArm.unapply))
+
+ def fromDomain(arm: ExportTrialArm) = ApiExportTrialArm(
+ armId = arm.armId.toString,
+ armName = arm.armName
+ )
+}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialLabelCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialLabelCriterion.scala
new file mode 100644
index 0000000..09935c0
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialLabelCriterion.scala
@@ -0,0 +1,39 @@
+package xyz.driver.pdsuidomain.formats.json.export
+
+import xyz.driver.pdsuicommon.domain.FuzzyValue
+import play.api.libs.functional.syntax._
+import play.api.libs.json._
+import xyz.driver.pdsuidomain.entities.export.trial.ExportTrialLabelCriterion
+
+final case class ApiExportTrialLabelCriterion(value: String,
+ labelId: String,
+ criterionId: String,
+ criterionText: String,
+ armIds: List[String],
+ isCompound: Boolean,
+ isDefining: Boolean)
+
+object ApiExportTrialLabelCriterion {
+
+ implicit val format: Format[ApiExportTrialLabelCriterion] = (
+ (JsPath \ "value").format[String](Writes[String](x => JsString(x.toUpperCase))) and
+ (JsPath \ "labelId").format[String] and
+ (JsPath \ "criterionId").format[String] and
+ (JsPath \ "criterionText").format[String] and
+ (JsPath \ "armIds").format[List[String]] and
+ (JsPath \ "isCompound").format[Boolean] and
+ (JsPath \ "isDefining").format[Boolean]
+ ) (ApiExportTrialLabelCriterion.apply, unlift(ApiExportTrialLabelCriterion.unapply))
+
+ def fromDomain(x: ExportTrialLabelCriterion) = ApiExportTrialLabelCriterion(
+ value = x.value.map { x =>
+ FuzzyValue.valueToString(FuzzyValue.fromBoolean(x))
+ }.getOrElse("Unknown"),
+ labelId = x.labelId.toString,
+ criterionId = x.criterionId.toString,
+ criterionText = x.criteria,
+ armIds = x.armIds.map(_.toString).toList,
+ isCompound = x.isCompound,
+ isDefining = x.isDefining
+ )
+}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialList.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialList.scala
new file mode 100644
index 0000000..93ee42e
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialList.scala
@@ -0,0 +1,15 @@
+package xyz.driver.pdsuidomain.formats.json.export
+
+import play.api.libs.json.{Format, Json}
+import xyz.driver.pdsuidomain.entities.export.trial.ExportTrial
+
+final case class ApiExportTrialList(trials: Seq[ApiExportTrial])
+
+object ApiExportTrialList {
+
+ implicit val format: Format[ApiExportTrialList] = Json.format
+
+ def fromDomain(trialList: Seq[ExportTrial]) = ApiExportTrialList(
+ trials = trialList.map(ApiExportTrial.fromDomain)
+ )
+}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala
new file mode 100644
index 0000000..dd855f7
--- /dev/null
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala
@@ -0,0 +1,38 @@
+package xyz.driver.pdsuidomain.formats.json.export
+
+import java.time.ZoneId
+
+import play.api.libs.functional.syntax._
+import play.api.libs.json.{Format, JsPath}
+import xyz.driver.pdsuidomain.entities.export.trial.ExportTrialWithLabels
+
+final case class ApiExportTrialWithLabels(nctId: String,
+ trialId: String,
+ condition: String,
+ lastReviewed: Long,
+ labelVersion: Long,
+ arms: List[ApiExportTrialArm],
+ criteria: List[ApiExportTrialLabelCriterion])
+
+object ApiExportTrialWithLabels {
+
+ implicit val format: Format[ApiExportTrialWithLabels] = (
+ (JsPath \ "nctId").format[String] and
+ (JsPath \ "trialId").format[String] and
+ (JsPath \ "disease").format[String] and
+ (JsPath \ "lastReviewed").format[Long] and
+ (JsPath \ "labelVersion").format[Long] and
+ (JsPath \ "arms").format[List[ApiExportTrialArm]] and
+ (JsPath \ "criteria").format[List[ApiExportTrialLabelCriterion]]
+ ) (ApiExportTrialWithLabels.apply, unlift(ApiExportTrialWithLabels.unapply))
+
+ def fromDomain(x: ExportTrialWithLabels) = ApiExportTrialWithLabels(
+ nctId = x.nctId.id,
+ trialId = x.trialId.toString,
+ condition = x.condition,
+ lastReviewed = x.lastReviewed.atZone(ZoneId.of("Z")).toEpochSecond,
+ labelVersion = x.labelVersion,
+ arms = x.arms.map(ApiExportTrialArm.fromDomain),
+ criteria = x.criteria.map(ApiExportTrialLabelCriterion.fromDomain)
+ )
+}