diff options
author | Marvin Bertin <marvin.bertin@gmail.com> | 2017-10-10 11:54:20 -0700 |
---|---|---|
committer | Marvin Bertin <marvin.bertin@gmail.com> | 2017-10-10 11:54:20 -0700 |
commit | 19a70318ecee81872fffe23c03d83e725610911d (patch) | |
tree | 984510310c95856fcdcb463d9a242f9773795266 /src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats | |
parent | 05aa114cfd22228f0457b6457ce441af5eabfc60 (diff) | |
parent | 4f83461cba1f78e607ca2a4edb6fa26f6e16e732 (diff) | |
download | rest-query-19a70318ecee81872fffe23c03d83e725610911d.tar.gz rest-query-19a70318ecee81872fffe23c03d83e725610911d.tar.bz2 rest-query-19a70318ecee81872fffe23c03d83e725610911d.zip |
fix merge conflicts with master
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats')
11 files changed, 27 insertions, 61 deletions
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/document.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/document.scala index 6c33fe5..69e8b75 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/document.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/document.scala @@ -26,7 +26,7 @@ object document { "PN" -> RequiredType.PN ) - implicit val documentMetaFormat: RootJsonFormat[Meta] = jsonFormat3(Meta.apply) + implicit val documentMetaFormat: RootJsonFormat[Meta] = jsonFormat2(Meta.apply) implicit val documentTypeFormat: RootJsonFormat[DocumentType] = new RootJsonFormat[DocumentType] { override def read(json: JsValue): DocumentType = 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..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 @@ -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, + "disease" -> patient.disease.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..57dca1e 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,12 @@ 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._ +import xyz.driver.pdsuidomain.formats.json.sprayformats.record._ +import xyz.driver.pdsuidomain.formats.json.sprayformats.document._ object patientlabel { import DefaultJsonProtocol._ @@ -13,12 +16,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/formats/json/sprayformats/record.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/record.scala index 8eef44a..65687c1 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/record.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/record.scala @@ -67,7 +67,6 @@ object record { override def write(obj: Duplicate) = JsObject( "type" -> "duplicate".toJson, - "predicted" -> obj.predicted.toJson, "startPage" -> obj.startPage.toJson, "endPage" -> obj.endPage.toJson, "startOriginalPage" -> obj.startOriginalPage.toJson, @@ -76,10 +75,6 @@ object record { override def read(json: JsValue): Duplicate = json match { case JsObject(fields) => - val predicted = fields - .get("predicted") - .map(_.convertTo[Boolean]) - val startPage = fields .get("startPage") .map(_.convertTo[Double]) @@ -101,7 +96,6 @@ object record { .map(_.convertTo[Double]) Duplicate( - predicted = predicted, startPage = startPage, endPage = endPage, startOriginalPage = startOriginalPage, @@ -114,27 +108,16 @@ object record { implicit val reorderMetaFormat: RootJsonFormat[Reorder] = new RootJsonFormat[Reorder] { override def write(obj: Reorder) = - JsObject( - "type" -> "reorder".toJson, - "predicted" -> obj.predicted.toJson, - "items" -> obj.items.toJson - ) + JsObject("type" -> "reorder".toJson, "items" -> obj.items.toJson) override def read(json: JsValue): Reorder = json match { case JsObject(fields) => - val predicted = fields - .get("predicted") - .map(_.convertTo[Boolean]) - val items = fields .get("items") .map(_.convertTo[Seq[Int]]) .getOrElse(deserializationError(s"Reorder meta json object does not contain `items` field: $json")) - Reorder( - predicted = predicted, - items = items - ) + Reorder(items) case _ => deserializationError(s"Expected JsObject as Reorder meta of medical record, but got $json") } @@ -142,27 +125,16 @@ object record { implicit val rotateMetaFormat: RootJsonFormat[Rotation] = new RootJsonFormat[Rotation] { override def write(obj: Rotation) = - JsObject( - "type" -> "rotation".toJson, - "predicted" -> obj.predicted.toJson, - "items" -> obj.items.toJson - ) + JsObject("type" -> "rotation".toJson, "items" -> obj.items.toJson) override def read(json: JsValue): Rotation = json match { case JsObject(fields) => - val predicted = fields - .get("predicted") - .map(_.convertTo[Boolean]) - val items = fields .get("items") .map(_.convertTo[Map[String, Int]]) .getOrElse(deserializationError(s"Rotation meta json object does not contain `items` field: $json")) - Rotation( - predicted = predicted, - items = items - ) + Rotation(items = items) case _ => deserializationError(s"Expected JsObject as Rotation meta of medical record, but got $json") } @@ -233,8 +205,6 @@ object record { caseId = None, physician = None, meta = None, - predictedMeta = None, - predictedDocuments = None, lastUpdate = LocalDateTime.now() ) 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 aeec90f..b25ed1d 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 @@ -9,8 +9,8 @@ import xyz.driver.pdsuidomain.entities._ object trial { import DefaultJsonProtocol._ - import common._ import Trial._ + import common._ implicit val trialStatusFormat = new EnumJsonFormat[Status]( "New" -> Status.New, @@ -24,12 +24,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( |