diff options
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/formats/json/patienteligibletrial.scala | 26 | ||||
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/formats/json/trialhistory.scala | 10 |
2 files changed, 23 insertions, 13 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 index f21b0cb..4c006f9 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienteligibletrial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienteligibletrial.scala @@ -8,14 +8,13 @@ import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEl object patienteligibletrial { import DefaultJsonProtocol._ import common._ - import xyz.driver.pdsuidomain.formats.json.trial._ - import xyz.driver.pdsuidomain.formats.json.patientcriterion._ def applyUpdateToTrialArmGroup(json: JsValue, orig: PatientTrialArmGroupView): PatientTrialArmGroupView = json match { case JsObject(fields) => - val isVerified = fields.get("group").map(_.asJsObject) - .flatMap(_.fields.get("isVerified")).map(_.convertTo[Boolean]) + val isVerified = fields + .get("isVerified") + .map(_.convertTo[Boolean]) .getOrElse(orig.isVerified) orig.copy(isVerified = isVerified) @@ -23,10 +22,19 @@ object patienteligibletrial { case _ => deserializationError(s"Expected Json Object as partial PatientTrialArmGroupView, but got $json") } - implicit val patientEligibleArmGroupView: RootJsonFormat[PatientTrialArmGroupView] = - jsonFormat7(PatientTrialArmGroupView.apply) - - implicit val patientEligibleTrialFormat: RootJsonFormat[RichPatientEligibleTrial] = - jsonFormat3(RichPatientEligibleTrial.apply) + 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 + ) + } } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/trialhistory.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/trialhistory.scala index c8df1d8..f71ec12 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/trialhistory.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/trialhistory.scala @@ -10,10 +10,12 @@ object trialhistory { import common._ implicit val trialStateFormat = new EnumJsonFormat[State]( - "Summarize" -> State.Summarize, - "Criteriarize" -> State.Criteriarize, - "Review" -> State.Review, - "Flag" -> State.Flag + "Summarize" -> State.Summarize, + "Criteriarize" -> State.Criteriarize, + "Review" -> State.Review, + "ReviewSummary" -> State.ReviewSummary, + "ReviewCriteria" -> State.ReviewCriteria, + "Flag" -> State.Flag ) implicit val trialActionFormat = new EnumJsonFormat[Action]( |