diff options
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/patienteligibletrial.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/formats/json/patienteligibletrial.scala | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienteligibletrial.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienteligibletrial.scala new file mode 100644 index 0000000..4c006f9 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienteligibletrial.scala @@ -0,0 +1,40 @@ +package xyz.driver.pdsuidomain.formats.json + +import spray.json._ +import xyz.driver.formats.json.labels._ +import xyz.driver.pdsuidomain.entities._ +import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial + +object patienteligibletrial { + import DefaultJsonProtocol._ + import common._ + + def applyUpdateToTrialArmGroup(json: JsValue, orig: PatientTrialArmGroupView): PatientTrialArmGroupView = + json match { + case JsObject(fields) => + val isVerified = fields + .get("isVerified") + .map(_.convertTo[Boolean]) + .getOrElse(orig.isVerified) + + orig.copy(isVerified = isVerified) + + case _ => deserializationError(s"Expected Json Object as partial PatientTrialArmGroupView, but got $json") + } + + implicit val patientEligibleTrialWriter: RootJsonWriter[RichPatientEligibleTrial] = + new RootJsonWriter[RichPatientEligibleTrial] { + override def write(obj: RichPatientEligibleTrial) = + JsObject( + "id" -> obj.group.id.toJson, + "patientId" -> obj.group.patientId.toJson, + "trialId" -> obj.group.trialId.toJson, + "trialTitle" -> obj.trial.title.toJson, + "arms" -> obj.arms.map(_.armName).toJson, + "hypothesisId" -> obj.trial.hypothesisId.toJson, + "verifiedEligibilityStatus" -> obj.group.verifiedEligibilityStatus.toJson, + "isVerified" -> obj.group.isVerified.toJson + ) + } + +} |