aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patienthypothesis.scala
diff options
context:
space:
mode:
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.scala34
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
)
}
}