diff options
author | Vlad Uspensky <v.uspenskiy@icloud.com> | 2017-11-02 20:40:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-02 20:40:31 -0700 |
commit | aedb5274932db81a32f9d89938636df114dc9a44 (patch) | |
tree | 13a0a8a51f477a4fce2bb8f4d5cd8248de54a73b /src/main/scala/xyz/driver/pdsuidomain/formats/json/record.scala | |
parent | 4583af5213b9f7b1e8a06f58321813556763f2d1 (diff) | |
parent | 5515c834853cbe3ce60460a4819a94805cfe24f7 (diff) | |
download | rest-query-aedb5274932db81a32f9d89938636df114dc9a44.tar.gz rest-query-aedb5274932db81a32f9d89938636df114dc9a44.tar.bz2 rest-query-aedb5274932db81a32f9d89938636df114dc9a44.zip |
Merge pull request #59 from drivergroup/common-contextsv0.13.1
Using common request contexts and user objects
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/record.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/formats/json/record.scala | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/record.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/record.scala index b6ed103..083796b 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/record.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/record.scala @@ -1,10 +1,11 @@ package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime -import java.util.UUID import spray.json._ -import xyz.driver.core.json.{EnumJsonFormat, GadtJsonFormat} +import xyz.driver.core.Id +import xyz.driver.core.json._ +import xyz.driver.entities.clinic.ClinicalRecord import xyz.driver.pdsuicommon.domain.{LongId, TextJson, UuidId} import xyz.driver.pdsuidomain.entities.MedicalRecord.Meta._ import xyz.driver.pdsuidomain.entities._ @@ -14,7 +15,7 @@ object record { import MedicalRecord._ import common._ - implicit val recordStatusFormat = new EnumJsonFormat[Status]( + implicit val recordStatusFormat: EnumJsonFormat[Status] = new EnumJsonFormat[Status]( "PreCleaning" -> Status.PreCleaning, "Unprocessed" -> Status.Unprocessed, "PreOrganized" -> Status.PreOrganized, @@ -29,14 +30,6 @@ object record { "Archived" -> Status.Archived ) - implicit val requestIdFormat = new RootJsonFormat[RecordRequestId] { - override def write(requestId: RecordRequestId): JsString = JsString(requestId.toString) - override def read(json: JsValue): RecordRequestId = json match { - case JsString(value) => RecordRequestId(UUID.fromString(value)) - case _ => deserializationError(s"Expected string as RecordRequestId, but got $json") - } - } - implicit val providerTypeFormat: RootJsonFormat[ProviderType] = new RootJsonFormat[ProviderType] { override def read(json: JsValue): ProviderType = json match { case JsObject(fields) => @@ -56,14 +49,6 @@ object record { JsObject("id" -> obj.id.toJson, "name" -> obj.name.toJson) } - implicit val caseIdFormat = new RootJsonFormat[CaseId] { - override def write(caseId: CaseId): JsString = JsString(caseId.toString) - override def read(json: JsValue): CaseId = json match { - case JsString(value) => CaseId(value) - case _ => deserializationError(s"Expected string as CaseId, but got $json") - } - } - implicit val duplicateMetaFormat: RootJsonFormat[Duplicate] = new RootJsonFormat[Duplicate] { override def write(obj: Duplicate) = JsObject( @@ -149,7 +134,7 @@ object record { } } - implicit val recordMetaFormat = new RootJsonFormat[TextJson[List[Meta]]] { + implicit val recordMetaFormat: RootJsonFormat[TextJson[List[Meta]]] = new RootJsonFormat[TextJson[List[Meta]]] { override def write(obj: TextJson[List[Meta]]): JsArray = JsArray(obj.content.map(_.toJson).toVector) override def read(json: JsValue): TextJson[List[Meta]] = json match { case JsArray(values) => TextJson[List[Meta]](values.map(_.convertTo[Meta]).toList) @@ -191,7 +176,7 @@ object record { val requestId = fields .get("requestId") - .map(_.convertTo[RecordRequestId]) + .map(_.convertTo[Id[ClinicalRecord]]) .getOrElse(deserializationError(s"MedicalRecord json object does not contain `requestId` field: $json")) MedicalRecord( |