diff options
author | Marvin Bertin <marvin.bertin@gmail.com> | 2017-10-10 11:22:11 -0700 |
---|---|---|
committer | Marvin Bertin <marvin.bertin@gmail.com> | 2017-10-10 11:22:11 -0700 |
commit | 05aa114cfd22228f0457b6457ce441af5eabfc60 (patch) | |
tree | 62acecf547f01ca4d69fcd4c7c911e0899e9d96c /src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patienthypothesis.scala | |
parent | 0be360064e7b46eb0ebeac3bfde09d5e80c21d81 (diff) | |
parent | 6751966577c0f005858f372458ccdb72be7d879f (diff) | |
download | rest-query-05aa114cfd22228f0457b6457ce441af5eabfc60.tar.gz rest-query-05aa114cfd22228f0457b6457ce441af5eabfc60.tar.bz2 rest-query-05aa114cfd22228f0457b6457ce441af5eabfc60.zip |
Merge branch 'master' into trial-46-disease-entity
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patienthypothesis.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patienthypothesis.scala | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patienthypothesis.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patienthypothesis.scala index 4f2783c..b8c0058 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patienthypothesis.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patienthypothesis.scala @@ -2,6 +2,7 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import spray.json._ import xyz.driver.pdsuidomain.entities._ +import xyz.driver.pdsuidomain.services.PatientHypothesisService.RichPatientHypothesis object patienthypothesis { import DefaultJsonProtocol._ @@ -18,18 +19,29 @@ object patienthypothesis { case _ => deserializationError(s"Expected Json Object as partial PatientHypothesis, but got $json") } - implicit val patientHypothesisWriter: JsonWriter[(PatientHypothesis, Boolean)] = - new JsonWriter[(PatientHypothesis, Boolean)] { - override def write(obj: (PatientHypothesis, Boolean)): JsValue = { - val patientHypothesis = obj._1 - val isRationaleRequired = obj._2 + implicit val richPatientHypothesisWriter: RootJsonWriter[RichPatientHypothesis] = + new RootJsonWriter[RichPatientHypothesis] { + override def write(obj: RichPatientHypothesis): JsValue = { JsObject( - "id" -> patientHypothesis.id.toJson, - "patientId" -> patientHypothesis.patientId.toJson, - "hypothesisId" -> patientHypothesis.hypothesisId.toJson, - "matchedTrials" -> patientHypothesis.matchedTrials.toJson, - "rationale" -> patientHypothesis.rationale.toJson, - "isRationaleRequired" -> isRationaleRequired.toJson + "id" -> obj.patientHypothesis.id.toJson, + "patientId" -> obj.patientHypothesis.patientId.toJson, + "hypothesisId" -> obj.patientHypothesis.hypothesisId.toJson, + "matchedTrials" -> obj.patientHypothesis.matchedTrials.toJson, + "rationale" -> obj.patientHypothesis.rationale.toJson, + "isRationaleRequired" -> obj.isRequired.toJson + ) + } + } + + implicit val patientHypothesisWriter: RootJsonWriter[PatientHypothesis] = + new RootJsonWriter[PatientHypothesis] { + override def write(obj: PatientHypothesis): JsValue = { + JsObject( + "id" -> obj.id.toJson, + "patientId" -> obj.patientId.toJson, + "hypothesisId" -> obj.hypothesisId.toJson, + "matchedTrials" -> obj.matchedTrials.toJson, + "rationale" -> obj.rationale.toJson ) } } |