diff options
author | vlad <vlad@driver.xyz> | 2017-11-13 22:44:29 -0800 |
---|---|---|
committer | vlad <vlad@driver.xyz> | 2017-11-13 22:44:29 -0800 |
commit | 29ee5de759374ceed9c856a51443a3f7c2cec029 (patch) | |
tree | 3212765de5288fc0cc3327b8799b706040ce39a1 /src/main/scala/xyz/driver/pdsuidomain/formats | |
parent | eae48b0256db8efc6417bede691bf7a1e33ab351 (diff) | |
download | rest-query-29ee5de759374ceed9c856a51443a3f7c2cec029.tar.gz rest-query-29ee5de759374ceed9c856a51443a3f7c2cec029.tar.bz2 rest-query-29ee5de759374ceed9c856a51443a3f7c2cec029.zip |
Fixing Document parsingv0.14.8
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/formats/json/document.scala | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/document.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/document.scala index 8ab6f13..66e95f3 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/document.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/document.scala @@ -141,6 +141,14 @@ object document { .map(_.convertTo[LongId[MedicalRecord]]) .getOrElse(deserializationError(s"Document create json object does not contain `recordId` field: $json")) + val status = fields + .get("status") + .flatMap(_.convertTo[Option[Document.Status]]) + + val previousStatus = fields + .get("previousStatus") + .flatMap(_.convertTo[Option[Document.Status]]) + val physician = fields .get("physician") .flatMap(_.convertTo[Option[String]]) @@ -149,6 +157,10 @@ object document { .get("typeId") .flatMap(_.convertTo[Option[LongId[DocumentType]]]) + val requiredType = fields + .get("requiredType") + .flatMap(_.convertTo[Option[Document.RequiredType]]) + val provider = fields .get("provider") .flatMap(_.convertTo[Option[String]]) @@ -173,25 +185,33 @@ object document { .get("endDate") .flatMap(_.convertTo[Option[LocalDate]]) + val lastUpdate = fields + .get("lastUpdate") + .flatMap(_.convertTo[Option[LocalDateTime]]) + + val labelVersion = fields + .get("labelVersion") + .flatMap(_.convertTo[Option[Int]]) + Document( id = id.getOrElse(LongId(0)), recordId = recordId, - status = Document.Status.New, + status = status.getOrElse(Document.Status.New), physician = physician, typeId = typeId, startDate = startDate, endDate = endDate, providerName = provider, providerTypeId = providerTypeId, - requiredType = None, + requiredType = requiredType, institutionName = institutionName, meta = meta, - previousStatus = None, + previousStatus = previousStatus, assignee = None, previousAssignee = None, lastActiveUserId = None, - lastUpdate = LocalDateTime.MIN, - labelVersion = 0 + lastUpdate = lastUpdate.getOrElse(LocalDateTime.MIN), + labelVersion = labelVersion.getOrElse(0) ) case _ => deserializationError(s"Expected Json Object as Document, but got $json") |