diff options
author | Jakob Odersky <jakob@driver.xyz> | 2017-10-30 17:06:11 -0700 |
---|---|---|
committer | Jakob Odersky <jakob@driver.xyz> | 2017-10-30 17:06:11 -0700 |
commit | ff8729639c7067aee7dca130c0a0fc3f425488f0 (patch) | |
tree | b8384f4ef79fe7c57f2ad4033b1cb98d7296166d /src/main/scala/xyz/driver/pdsuidomain/formats/json/patientlabel.scala | |
parent | 18c226b95abbb1c86067bc62cd5c0260bf3af6d1 (diff) | |
parent | 91b33aaeb61160da4395e6093e23a947688e12c5 (diff) | |
download | rest-query-ff8729639c7067aee7dca130c0a0fc3f425488f0.tar.gz rest-query-ff8729639c7067aee7dca130c0a0fc3f425488f0.tar.bz2 rest-query-ff8729639c7067aee7dca130c0a0fc3f425488f0.zip |
Merge branch 'PDSUI-2360'v0.12.0
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/patientlabel.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/formats/json/patientlabel.scala | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patientlabel.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patientlabel.scala index 15fec45..d944e42 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patientlabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patientlabel.scala @@ -33,18 +33,17 @@ object patientlabel { case _ => deserializationError(s"Expected Json Object as PatientLabel, but got $json") } - implicit val richPatientLabelWriter: RootJsonWriter[RichPatientLabel] = new RootJsonWriter[RichPatientLabel] { + implicit val patientLabelFormat: RootJsonFormat[PatientLabel] = jsonFormat8(PatientLabel.apply) + + implicit val richPatientLabelFormat: RootJsonFormat[RichPatientLabel] = new RootJsonFormat[RichPatientLabel] { + override def read(json: JsValue): RichPatientLabel = { + val isVerified = + json.asJsObject.fields.getOrElse("isVerified", deserializationError("isVerified field is missing")) + RichPatientLabel(json.convertTo[PatientLabel], isVerified.convertTo[Boolean]) + } override def write(obj: RichPatientLabel): JsValue = { - JsObject( - "id" -> obj.patientLabel.id.toJson, - "labelId" -> obj.patientLabel.labelId.toJson, - "primaryValue" -> obj.patientLabel.primaryValue.toJson, - "verifiedPrimaryValue" -> obj.patientLabel.verifiedPrimaryValue.toJson, - "score" -> obj.patientLabel.score.toJson, - "isImplicitMatch" -> obj.patientLabel.isImplicitMatch.toJson, - "isVisible" -> obj.patientLabel.isVisible.toJson, - "isVerified" -> obj.isVerified.toJson - ) + val labelFields = obj.patientLabel.toJson.asJsObject.fields + JsObject(labelFields ++ Map("isVerified" -> obj.isVerified.toJson)) } } |