From 7d8712a62d30b412717e1b730c0ad267cd207aa4 Mon Sep 17 00:00:00 2001 From: vlad Date: Mon, 9 Oct 2017 12:24:59 -0700 Subject: Getting rid of the FuzzyValues, Name as a string, and condition --- .../pdsuidomain/formats/json/sprayformats/patientlabel.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala') diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala index b36949e..ff6d24d 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala @@ -1,9 +1,10 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import spray.json._ -import xyz.driver.pdsuicommon.domain.FuzzyValue +import xyz.driver.entities.labels.LabelValue import xyz.driver.pdsuidomain.entities._ import xyz.driver.pdsuidomain.services.PatientLabelService.RichPatientLabel +import xyz.driver.formats.json.labels._ object patientlabel { import DefaultJsonProtocol._ @@ -13,12 +14,12 @@ object patientlabel { case JsObject(fields) => val primaryValue = fields .get("primaryValue") - .map(_.convertTo[Option[FuzzyValue]]) + .map(_.convertTo[Option[LabelValue]]) .getOrElse(orig.primaryValue) val verifiedPrimaryValue = fields .get("verifiedPrimaryValue") - .map(_.convertTo[Option[FuzzyValue]]) + .map(_.convertTo[Option[LabelValue]]) .getOrElse(orig.verifiedPrimaryValue) orig.copy( -- cgit v1.2.3 From c404ab936d5c2ebaae8246ed658086d66e7c9a61 Mon Sep 17 00:00:00 2001 From: vlad Date: Mon, 9 Oct 2017 20:00:22 -0700 Subject: Update PatientLabelEvidenceView to support to Provider and Document type --- .../driver/pdsuidomain/entities/PatientLabelEvidenceView.scala | 4 ++-- .../formats/json/evidence/ApiPatientLabelEvidence.scala | 4 ++-- .../pdsuidomain/formats/json/sprayformats/patientlabel.scala | 2 ++ .../formats/json/sprayformats/PatientLabelFormatSuite.scala | 9 +++++---- 4 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala') diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabelEvidenceView.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabelEvidenceView.scala index 2dbe099..6055921 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabelEvidenceView.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabelEvidenceView.scala @@ -21,9 +21,9 @@ final case class PatientLabelEvidenceView(id: LongId[PatientLabelEvidence], documentId: Option[LongId[Document]], evidenceId: Option[LongId[ExtractedData]], reportId: Option[UuidId[DirectReport]], - documentType: String, + documentType: DocumentType, date: Option[LocalDate], // Document.startDate is optional - providerType: String, + providerType: ProviderType, patientId: UuidId[Patient], labelId: LongId[Label], isImplicitMatch: Boolean) diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/evidence/ApiPatientLabelEvidence.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/evidence/ApiPatientLabelEvidence.scala index 7409e90..c7a6de9 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/evidence/ApiPatientLabelEvidence.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/evidence/ApiPatientLabelEvidence.scala @@ -26,8 +26,8 @@ object ApiPatientLabelEvidence { documentId = x.documentId.map(_.id), evidenceId = x.evidenceId.map(_.id), reportId = x.reportId.map(_.toString), - documentType = x.documentType, + documentType = x.documentType.name, date = x.date.get, - providerType = x.providerType + providerType = x.providerType.name ) } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala index ff6d24d..57dca1e 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/patientlabel.scala @@ -5,6 +5,8 @@ import xyz.driver.entities.labels.LabelValue import xyz.driver.pdsuidomain.entities._ import xyz.driver.pdsuidomain.services.PatientLabelService.RichPatientLabel import xyz.driver.formats.json.labels._ +import xyz.driver.pdsuidomain.formats.json.sprayformats.record._ +import xyz.driver.pdsuidomain.formats.json.sprayformats.document._ object patientlabel { import DefaultJsonProtocol._ diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala index 47b251a..e837861 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala @@ -6,7 +6,7 @@ import spray.json._ import org.scalatest.{FlatSpec, Matchers} import xyz.driver.entities.labels.LabelValue import xyz.driver.pdsuicommon.domain.{LongId, UuidId} -import xyz.driver.pdsuidomain.entities.{PatientLabel, PatientLabelEvidenceView} +import xyz.driver.pdsuidomain.entities._ import xyz.driver.pdsuidomain.services.PatientLabelService.RichPatientLabel class PatientLabelFormatSuite extends FlatSpec with Matchers { @@ -44,9 +44,9 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers { documentId = Some(LongId(21)), evidenceId = Some(LongId(10)), reportId = None, - documentType = "document type", + documentType = DocumentType.LaboratoryReport, date = Some(LocalDate.parse("2017-08-10")), - providerType = "provider type", + providerType = ProviderType.EmergencyMedicine, patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), labelId = LongId(20), isImplicitMatch = false @@ -55,7 +55,8 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers { writtenJson should be ( """{"id":1,"value":"Maybe","evidenceText":"evidence text","documentId":21,"evidenceId":10,"reportId":null, - "documentType":"document type","date":"2017-08-10","providerType":"provider type"}""".parseJson) + "documentType":{"id":3,"name":"Laboratory Report"},"date":"2017-08-10", + "providerType":{"id":26,"name":"Emergency Medicine"}}""".parseJson) } "Json format for PatientLabelDefiningCriteria" should "read and write correct JSON" in { -- cgit v1.2.3