diff options
author | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-10-30 16:29:46 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-30 16:29:46 +0700 |
commit | 604fbf0a7a082bc440c0778abd6f90005b210c16 (patch) | |
tree | fd846d42448b2d3f432056898f0c3433475ea0da /src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientLabelFormatSuite.scala | |
parent | 8811d60442d060097027b33784ece9a704458e1d (diff) | |
parent | d92a2795a02b9711aa9aed92a770f85377b31460 (diff) | |
download | rest-query-604fbf0a7a082bc440c0778abd6f90005b210c16.tar.gz rest-query-604fbf0a7a082bc440c0778abd6f90005b210c16.tar.bz2 rest-query-604fbf0a7a082bc440c0778abd6f90005b210c16.zip |
Merge pull request #54 from drivergroup/PDSUI-2336v0.11.0
PDSUI-2336 Cleanup
Diffstat (limited to 'src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientLabelFormatSuite.scala')
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientLabelFormatSuite.scala | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientLabelFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientLabelFormatSuite.scala new file mode 100644 index 0000000..95dfa68 --- /dev/null +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientLabelFormatSuite.scala @@ -0,0 +1,79 @@ +package xyz.driver.pdsuidomain.formats.json + +import java.time.LocalDate + +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._ +import xyz.driver.pdsuidomain.services.PatientLabelService.RichPatientLabel + +class PatientLabelFormatSuite extends FlatSpec with Matchers { + + "Json format for RichPatientLabel" should "read and write correct JSON" in { + import xyz.driver.pdsuidomain.formats.json.patientlabel._ + val orig = PatientLabel( + id = LongId(1), + patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), + labelId = LongId(20), + primaryValue = Some(LabelValue.Yes), + verifiedPrimaryValue = None, + isVisible = true, + score = 1, + isImplicitMatch = false + ) + val writtenJson = richPatientLabelWriter.write(RichPatientLabel(orig, isVerified = true)) + + writtenJson should be( + """{"id":1,"labelId":20,"primaryValue":"Yes","verifiedPrimaryValue":null,"isVisible":true,"isVerified":true, + "score":1,"isImplicitMatch":false}""".parseJson) + + val updatePatientLabelJson = """{"verifiedPrimaryValue":"No"}""".parseJson + val expectedUpdatedPatientLabel = orig.copy(verifiedPrimaryValue = Some(LabelValue.No)) + val parsedUpdatePatientLabel = applyUpdateToPatientLabel(updatePatientLabelJson, orig) + parsedUpdatePatientLabel should be(expectedUpdatedPatientLabel) + } + + "Json format for PatientLabelEvidence" should "read and write correct JSON" in { + import xyz.driver.pdsuidomain.formats.json.patientlabel._ + val orig = PatientLabelEvidenceView( + id = LongId(1), + value = LabelValue.Maybe, + evidenceText = "evidence text", + documentId = Some(LongId(21)), + evidenceId = Some(LongId(10)), + reportId = None, + documentType = DocumentType.LaboratoryReport, + date = Some(LocalDate.parse("2017-08-10")), + providerType = ProviderType.EmergencyMedicine, + patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), + labelId = LongId(20), + isImplicitMatch = false + ) + val writtenJson = patientLabelEvidenceWriter.write(orig) + + writtenJson should be( + """{"id":1,"value":"Maybe","evidenceText":"evidence text","documentId":21,"evidenceId":10,"reportId":null, + "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 { + import xyz.driver.pdsuidomain.formats.json.patientdefiningcriteria._ + val orig = PatientLabel( + id = LongId(1), + patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), + labelId = LongId(20), + primaryValue = Some(LabelValue.Yes), + verifiedPrimaryValue = Some(LabelValue.Yes), + isVisible = true, + score = 1, + isImplicitMatch = false + ) + val writtenJson = patientLabelDefiningCriteriaWriter.write(orig) + + writtenJson should be("""{"id":1,"value":"Yes"}""".parseJson) + } + +} |