aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/xyz/driver/pdsuidomain/formats
diff options
context:
space:
mode:
authorMarvin Bertin <marvin.bertin@gmail.com>2017-10-10 17:17:18 -0700
committerMarvin Bertin <marvin.bertin@gmail.com>2017-10-10 17:17:18 -0700
commitb124608a4faa9cb94474f27c1d4605e5cb0ab63d (patch)
treec3439f756f023facbbae4deea1972ad2f511dda3 /src/test/scala/xyz/driver/pdsuidomain/formats
parentf55212361d6126a05075a1f00f3915484b4f334e (diff)
parent385a9a99e5a95c3d623cddd927c37564e32dbd2d (diff)
downloadrest-query-b124608a4faa9cb94474f27c1d4605e5cb0ab63d.tar.gz
rest-query-b124608a4faa9cb94474f27c1d4605e5cb0ab63d.tar.bz2
rest-query-b124608a4faa9cb94474f27c1d4605e5cb0ab63d.zip
fix merge conflictsv0.7.5
Diffstat (limited to 'src/test/scala/xyz/driver/pdsuidomain/formats')
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala22
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala16
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala11
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ListResponseSuite.scala104
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala21
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala14
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala9
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala11
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala20
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala27
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala2
11 files changed, 189 insertions, 68 deletions
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala
index 481e92f..e6dd4a1 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala
@@ -24,6 +24,7 @@ class DocumentFormatSuite extends FlatSpec with Matchers {
typeId = Some(LongId(10)),
providerName = Some("provider 21"),
providerTypeId = Some(LongId(21)),
+ institutionName = Some("institution name"),
requiredType = Some(Document.RequiredType.OPN),
meta = None,
startDate = None,
@@ -33,7 +34,7 @@ class DocumentFormatSuite extends FlatSpec with Matchers {
writtenJson should be(
"""{"id":1,"recordId":101,"physician":"physician","typeId":10,"provider":"provider 21","providerTypeId":21,
- "requiredType":"OPN","startDate":null,"endDate":null,"status":"New","assignee":null,"previousStatus":null,
+ "requiredType":"OPN","institutionName":"institution name","startDate":null,"endDate":null,"status":"New","assignee":null,"previousStatus":null,
"previousAssignee":null,"lastActiveUser":null,"lastUpdate":"2017-08-10T18:00Z","meta":null}""".parseJson)
val createDocumentJson =
@@ -41,34 +42,31 @@ class DocumentFormatSuite extends FlatSpec with Matchers {
val expectedCreatedDocument = orig.copy(
id = LongId(0),
lastUpdate = LocalDateTime.MIN,
- requiredType = None
+ requiredType = None,
+ institutionName = None
)
val parsedCreatedDocument = documentFormat.read(createDocumentJson)
parsedCreatedDocument should be(expectedCreatedDocument)
val updateDocumentJson =
- """{"startDate":"2017-08-10","endDate":"2018-08-10","meta":{"predicted":true,"startPage":1.0,"endPage":2.0}}""".parseJson
+ """{"startDate":"2017-08-10","endDate":"2018-08-10","meta":{"startPage":1.0,"endPage":2.0}}""".parseJson
val expectedUpdatedDocument = orig.copy(
startDate = Some(LocalDate.parse("2017-08-10")),
endDate = Some(LocalDate.parse("2018-08-10")),
- meta = Some(TextJson(Document.Meta(predicted = Some(true), startPage = 1.0, endPage = 2.0)))
+ meta = Some(TextJson(Document.Meta(startPage = 1.0, endPage = 2.0)))
)
val parsedUpdatedDocument = applyUpdateToDocument(updateDocumentJson, orig)
parsedUpdatedDocument should be(expectedUpdatedDocument)
}
"Json format for Document.Meta" should "read and write correct JSON" in {
- val meta = Document.Meta(predicted = None, startPage = 1.0, endPage = 2.0)
+ val meta = Document.Meta(startPage = 1.0, endPage = 2.0)
val writtenJson = documentMetaFormat.write(meta)
writtenJson should be("""{"startPage":1.0,"endPage":2.0}""".parseJson)
- val metaJsonWithoutPredicted = """{"startPage":1.0,"endPage":2.0}""".parseJson
- val parsedMetaWithoutPredicted = documentMetaFormat.read(metaJsonWithoutPredicted)
- parsedMetaWithoutPredicted should be(meta)
-
- val metaJsonWithPredicted = """{"predicted":true,"startPage":1.0,"endPage":2.0}""".parseJson
- val parsedMetaWithPredicted = documentMetaFormat.read(metaJsonWithPredicted)
- parsedMetaWithPredicted should be(meta.copy(predicted = Some(true)))
+ val metaJson = """{"startPage":1.0,"endPage":2.0}""".parseJson
+ val parsedMeta = documentMetaFormat.read(metaJson)
+ parsedMeta should be(meta)
}
}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala
index a451905..3eaf93f 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala
@@ -3,9 +3,10 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats
import java.time.{LocalDate, LocalDateTime}
import java.util.UUID
-import spray.json._
import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, StringId, UuidId}
+import spray.json._
+import xyz.driver.entities.labels.LabelValue
+import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId}
import xyz.driver.pdsuidomain.entities.{DocumentType, ProviderType, RecordRequestId}
class ExportFormatSuite extends FlatSpec with Matchers {
@@ -27,13 +28,13 @@ class ExportFormatSuite extends FlatSpec with Matchers {
evidences = List(
ExportPatientLabelEvidence(
id = LongId(11),
- value = FuzzyValue.Yes,
+ value = LabelValue.Yes,
evidenceText = "evidence text 11",
document = document
),
ExportPatientLabelEvidence(
id = LongId(12),
- value = FuzzyValue.No,
+ value = LabelValue.No,
evidenceText = "evidence text 12",
document = document
)
@@ -44,13 +45,13 @@ class ExportFormatSuite extends FlatSpec with Matchers {
evidences = List(
ExportPatientLabelEvidence(
id = LongId(12),
- value = FuzzyValue.Yes,
+ value = LabelValue.Yes,
evidenceText = "evidence text 12",
document = document
),
ExportPatientLabelEvidence(
id = LongId(13),
- value = FuzzyValue.Yes,
+ value = LabelValue.Yes,
evidenceText = "evidence text 13",
document = document
)
@@ -106,7 +107,6 @@ class ExportFormatSuite extends FlatSpec with Matchers {
val trialWithLabels = ExportTrialWithLabels(
nctId = StringId("NCT000001"),
trialId = UuidId("40892a07-c638-49d2-9795-1edfefbbcc7c"),
- condition = "Breast",
lastReviewed = LocalDateTime.parse("2017-08-10T18:00:00"),
labelVersion = 1L,
arms = arms,
@@ -115,7 +115,7 @@ class ExportFormatSuite extends FlatSpec with Matchers {
val writtenJson = trialWithLabelsFormat.write(trialWithLabels)
writtenJson should be(
- """{"nctId":"NCT000001","trialId":"40892a07-c638-49d2-9795-1edfefbbcc7c","disease":"Breast","lastReviewed":"2017-08-10T18:00Z",
+ """{"nctId":"NCT000001","trialId":"40892a07-c638-49d2-9795-1edfefbbcc7c","lastReviewed":"2017-08-10T18:00Z",
"labelVersion":1,"arms":[{"armId":1,"armName":"arm 1"},{"armId":2,"armName":"arm 2"}],"criteria":[
{"value":"Yes","labelId":21,"criterionId":10,"criterionText":"criteria 10 text","armIds":[1,2],"isCompound":false,"isDefining":false},
{"value":"Unknown","labelId":21,"criterionId":11,"criterionText":"criteria 11 text","armIds":[2],"isCompound":true,"isDefining":false}]}""".parseJson)
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala
index c3df80a..1feca6a 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala
@@ -2,7 +2,8 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats
import spray.json._
import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, TextJson}
+import xyz.driver.entities.labels.LabelValue
+import xyz.driver.pdsuicommon.domain.{LongId, TextJson}
import xyz.driver.pdsuidomain.entities.ExtractedData.Meta
import xyz.driver.pdsuidomain.entities.{ExtractedData, ExtractedDataLabel}
import xyz.driver.pdsuidomain.services.ExtractedDataService.RichExtractedData
@@ -24,14 +25,14 @@ class ExtractedDataFormatSuite extends FlatSpec with Matchers {
dataId = extractedData.id,
labelId = None,
categoryId = None,
- value = Some(FuzzyValue.Yes)
+ value = Some(LabelValue.Yes)
),
ExtractedDataLabel(
id = LongId(2),
dataId = extractedData.id,
labelId = Some(LongId(12)),
categoryId = Some(LongId(1)),
- value = Some(FuzzyValue.No)
+ value = Some(LabelValue.No)
)
)
val origRichExtractedData = RichExtractedData(
@@ -64,14 +65,14 @@ class ExtractedDataFormatSuite extends FlatSpec with Matchers {
dataId = extractedData.id,
labelId = Some(LongId(20)),
categoryId = Some(LongId(1)),
- value = Some(FuzzyValue.Yes)
+ value = Some(LabelValue.Yes)
),
ExtractedDataLabel(
id = LongId(0),
dataId = extractedData.id,
labelId = Some(LongId(12)),
categoryId = Some(LongId(1)),
- value = Some(FuzzyValue.No)
+ value = Some(LabelValue.No)
)
)
val expectedUpdatedExtractedData = origRichExtractedData.copy(
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ListResponseSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ListResponseSuite.scala
new file mode 100644
index 0000000..17d4cfb
--- /dev/null
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ListResponseSuite.scala
@@ -0,0 +1,104 @@
+package xyz.driver.pdsuidomain.formats.json.sprayformats
+
+import java.time.LocalDateTime
+import java.util.UUID
+
+import spray.json._
+import org.scalatest.{FlatSpec, Matchers}
+import xyz.driver.pdsuicommon.domain.{LongId, UuidId}
+import xyz.driver.pdsuidomain.entities.MedicalRecord.Status
+import xyz.driver.pdsuidomain.entities._
+import xyz.driver.pdsuidomain.formats.json.sprayformats.record.recordFormat
+
+class ListResponseSuite extends FlatSpec with Matchers {
+
+ private val lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00")
+ private val lastUpdateToLocal = "2017-08-10T18:00Z"
+
+ private def metaJsonObjectAsString(meta: ListResponse.Meta) = {
+ import meta._
+ val lastUpdate = meta.lastUpdate
+ .map(_ => s""","lastUpdate":"$lastUpdateToLocal"""")
+ .getOrElse("")
+
+ s"""{"itemsCount":$itemsCount,"pageNumber":$pageNumber,"pageSize":$pageSize$lastUpdate}"""
+ }
+
+ "Json format for ListResponse.Meta" should "read and write correct JSON" in {
+ val meta1 =
+ ListResponse.Meta(
+ itemsCount = 5,
+ pageNumber = 6,
+ pageSize = 7,
+ lastUpdate = None
+ )
+
+ val writtenJson1 =
+ ListResponse.listResponseMetaFormat.write(meta1)
+
+ writtenJson1 should be(metaJsonObjectAsString(meta1).parseJson)
+
+ val parsedItem1: ListResponse.Meta =
+ ListResponse.listResponseMetaFormat.read(writtenJson1)
+
+ meta1 shouldBe parsedItem1
+
+ val meta2 =
+ ListResponse.Meta(
+ itemsCount = 1,
+ pageNumber = 4,
+ pageSize = 3,
+ lastUpdate = Some(lastUpdate)
+ )
+
+ val writtenJson2 =
+ ListResponse.listResponseMetaFormat.write(meta2)
+
+ writtenJson2 should be(metaJsonObjectAsString(meta2).parseJson)
+
+ val parsedItem2: ListResponse.Meta =
+ ListResponse.listResponseMetaFormat.read(writtenJson2)
+
+ meta2 shouldBe parsedItem2
+ }
+
+ "Json format for ListResponse" should "write correct JSON" in {
+
+ val orig = MedicalRecord(
+ id = LongId(1),
+ status = Status.New,
+ assignee = None,
+ previousStatus = None,
+ previousAssignee = None,
+ lastActiveUserId = None,
+ lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"),
+ physician = Some("physician"),
+ meta = None,
+ disease = "Breast",
+ requestId = RecordRequestId(UUID.fromString("7b54a75d-4197-4b27-9045-b9b6cb131be9")),
+ caseId = None,
+ patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343")
+ )
+
+ val recordJsonAsString =
+ """{"id":1,"status":"New","assignee":null,"previousStatus":null,"previousAssignee":null,"lastActiveUser":null,
+ "lastUpdate":"2017-08-10T18:00Z","meta":[],"patientId":"748b5884-3528-4cb9-904b-7a8151d6e343","caseId":null,
+ "requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","disease":"Breast","physician":"physician"}"""
+
+ val meta =
+ ListResponse.Meta(
+ itemsCount = 5,
+ pageNumber = 6,
+ pageSize = 7,
+ lastUpdate = None
+ )
+
+ val listResponse = ListResponse(Seq(orig), meta)
+
+ val writtenJson = ListResponse.listResponseMetaWriter.write(listResponse)
+ val expectedJson = s"""{"items":[$recordJsonAsString],"meta":${metaJsonObjectAsString(meta)}}"""
+
+ writtenJson should be(expectedJson.parseJson)
+ }
+
+}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala
index feedf2f..d9fb232 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala
@@ -23,8 +23,6 @@ class MedicalRecordFormatSuite extends FlatSpec with Matchers {
lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"),
physician = Some("physician"),
meta = None,
- predictedMeta = None,
- predictedDocuments = None,
disease = "Breast",
requestId = RecordRequestId(UUID.fromString("7b54a75d-4197-4b27-9045-b9b6cb131be9")),
caseId = None,
@@ -52,28 +50,23 @@ class MedicalRecordFormatSuite extends FlatSpec with Matchers {
caseId = None,
physician = None,
meta = None,
- predictedMeta = None,
- predictedDocuments = None,
lastUpdate = LocalDateTime.now()
)
val parsedCreatedRecord = recordFormat.read(createRecordJson).copy(lastUpdate = expectedCreatedRecord.lastUpdate)
parsedCreatedRecord should be(expectedCreatedRecord)
val updateRecordJson =
- """{"meta":[{"type":"duplicate","predicted":true,"startPage":1.0,"endPage":2.0,"startOriginalPage":1.0},
+ """{"meta":[{"type":"duplicate","startPage":1.0,"endPage":2.0,"startOriginalPage":1.0},
{"type":"reorder","items":[1,2]},
{"type":"rotation","items":{"item1":1,"item2":2}}]}""".parseJson
val expectedUpdatedRecord = orig.copy(
meta = Some(
- TextJson(List(
- Meta.Duplicate(predicted = Some(true),
- startPage = 1.0,
- endPage = 2.0,
- startOriginalPage = 1.0,
- endOriginalPage = None),
- Meta.Reorder(predicted = None, items = Seq(1, 2)),
- Meta.Rotation(predicted = None, items = Map("item1" -> 1, "item2" -> 2))
- )))
+ TextJson(
+ List(
+ Meta.Duplicate(startPage = 1.0, endPage = 2.0, startOriginalPage = 1.0, endOriginalPage = None),
+ Meta.Reorder(Seq(1, 2)),
+ Meta.Rotation(Map("item1" -> 1, "item2" -> 2))
+ )))
)
val parsedUpdatedRecord = applyUpdateToMedicalRecord(updateRecordJson, orig)
parsedUpdatedRecord should be(expectedUpdatedRecord)
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala
index 43f9b48..b254013 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala
@@ -4,9 +4,10 @@ import java.time.LocalDateTime
import spray.json._
import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, StringId}
+import xyz.driver.entities.labels.LabelValue
+import xyz.driver.pdsuicommon.domain.{LongId, StringId}
import xyz.driver.pdsuidomain.entities.{PatientCriterion, PatientCriterionArm}
-import xyz.driver.pdsuidomain.services.PatientCriterionService.DraftPatientCriterion
+import xyz.driver.pdsuidomain.services.PatientCriterionService.{DraftPatientCriterion, RichPatientCriterion}
class PatientCriterionFormatSuite extends FlatSpec with Matchers {
import patientcriterion._
@@ -21,7 +22,7 @@ class PatientCriterionFormatSuite extends FlatSpec with Matchers {
criterionText = "criterion text",
criterionValue = Some(true),
criterionIsDefining = false,
- eligibilityStatus = Some(FuzzyValue.Yes),
+ eligibilityStatus = Some(LabelValue.Yes),
verifiedEligibilityStatus = None,
isVisible = true,
isVerified = true,
@@ -31,7 +32,8 @@ class PatientCriterionFormatSuite extends FlatSpec with Matchers {
PatientCriterionArm(patientCriterionId = LongId(1), armId = LongId(31), armName = "arm 31"),
PatientCriterionArm(patientCriterionId = LongId(1), armId = LongId(32), armName = "arm 32")
)
- val writtenJson = patientCriterionWriter.write((orig, LongId(21), arms))
+ val richPatientCriterion = RichPatientCriterion(orig, LongId(21), arms)
+ val writtenJson = patientCriterionWriter.write(richPatientCriterion)
writtenJson should be(
"""{"id":1,"labelId":21,"nctId":"NCT00001","criterionId":101,"criterionText":"criterion text","criterionValue":"Yes",
@@ -39,14 +41,14 @@ class PatientCriterionFormatSuite extends FlatSpec with Matchers {
"isVisible":true,"isVerified":true,"lastUpdate":"2017-08-10T18:00Z","arms":["arm 31","arm 32"]}""".parseJson)
val updatePatientCriterionJson = """{"verifiedEligibilityStatus":"No"}""".parseJson
- val expectedUpdatedPatientCriterion = orig.copy(verifiedEligibilityStatus = Some(FuzzyValue.No))
+ val expectedUpdatedPatientCriterion = orig.copy(verifiedEligibilityStatus = Some(LabelValue.No))
val parsedUpdatePatientCriterion = applyUpdateToPatientCriterion(updatePatientCriterionJson, orig)
parsedUpdatePatientCriterion should be(expectedUpdatedPatientCriterion)
val updateBulkPatientCriterionJson =
"""[{"id":1,"eligibilityStatus":"No"},{"id":2,"isVerified":false}]""".parseJson
val expectedDraftPatientCriterionList = List(
- DraftPatientCriterion(id = LongId(1), eligibilityStatus = Some(FuzzyValue.No), isVerified = None),
+ DraftPatientCriterion(id = LongId(1), eligibilityStatus = Some(LabelValue.No), isVerified = None),
DraftPatientCriterion(id = LongId(2), eligibilityStatus = None, isVerified = Some(false))
)
val parsedDraftPatientCriterionList = draftPatientCriterionListReader.read(updateBulkPatientCriterionJson)
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala
index 1d28b2e..b8f6f8e 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala
@@ -2,9 +2,10 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats
import java.time.LocalDateTime
-import spray.json._
import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, StringId, UuidId}
+import spray.json._
+import xyz.driver.entities.labels.LabelValue
+import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId}
import xyz.driver.pdsuidomain.entities.{PatientCriterionArm, PatientTrialArmGroupView, Trial}
import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial
@@ -37,8 +38,8 @@ class PatientEligibleTrialFormatSuite extends FlatSpec with Matchers {
patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"),
trialId = StringId("NCT000001"),
hypothesisId = UuidId("e76e2fc4-a29c-44fb-a81b-8856d06bb1d4"),
- eligibilityStatus = Some(FuzzyValue.Yes),
- verifiedEligibilityStatus = Some(FuzzyValue.Yes),
+ eligibilityStatus = Some(LabelValue.Yes),
+ verifiedEligibilityStatus = Some(LabelValue.Yes),
isVerified = false
)
val arms = List(
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala
index b1b6b2a..128cad1 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala
@@ -4,6 +4,8 @@ import java.time.{LocalDate, LocalDateTime}
import spray.json._
import org.scalatest.{FlatSpec, Matchers}
+import xyz.driver.entities.common.FullName
+import xyz.driver.entities.patient.CancerType
import xyz.driver.pdsuicommon.domain.UuidId
import xyz.driver.pdsuidomain.entities.{Patient, PatientOrderId}
@@ -14,23 +16,24 @@ class PatientFormatSuite extends FlatSpec with Matchers {
val orig = Patient(
id = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"),
status = Patient.Status.New,
- name = "John Doe",
+ name = FullName.fromStrings("John", "", "Doe"),
dob = LocalDate.parse("1980-06-30"),
assignee = None,
previousStatus = None,
previousAssignee = None,
lastActiveUserId = None,
isUpdateRequired = false,
- condition = "breast",
+ disease = CancerType.Breast,
orderId = PatientOrderId("7b54a75d-4197-4b27-9045-b9b6cb131be9"),
lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00")
)
val writtenJson = patientWriter.write(orig)
writtenJson should be(
- """{"id":"748b5884-3528-4cb9-904b-7a8151d6e343","dob":"1980-06-30","name":"John Doe","status":"New","assignee":null,
+ """{"id":"748b5884-3528-4cb9-904b-7a8151d6e343","dob":"1980-06-30",
+ "name":{"firstName":"John","middleName":"","lastName":"Doe"},"status":"New","assignee":null,
"previousStatus":null,"previousAssignee":null,"lastActiveUser":null,"lastUpdate":"2017-08-10T18:00Z",
- "orderId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","condition":"breast"}""".parseJson)
+ "orderId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","disease":"Breast"}""".parseJson)
}
}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala
index 0e628a8..71cbbad 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala
@@ -4,11 +4,12 @@ import spray.json._
import org.scalatest.{FlatSpec, Matchers}
import xyz.driver.pdsuicommon.domain.UuidId
import xyz.driver.pdsuidomain.entities.PatientHypothesis
+import xyz.driver.pdsuidomain.services.PatientHypothesisService.RichPatientHypothesis
class PatientHypothesisFormatSuite extends FlatSpec with Matchers {
import patienthypothesis._
- "Json format for PatientHypothesis" should "read and write correct JSON" in {
+ "Json format for RichPatientHypothesis" should "read and write correct JSON" in {
val orig = PatientHypothesis(
id = UuidId("815d9715-1089-4775-b120-3afb983b9a97"),
patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"),
@@ -16,7 +17,7 @@ class PatientHypothesisFormatSuite extends FlatSpec with Matchers {
rationale = None,
matchedTrials = 1
)
- val writtenJson = patientHypothesisWriter.write((orig, true))
+ val writtenJson = richPatientHypothesisWriter.write(RichPatientHypothesis(orig, isRequired = true))
writtenJson should be(
"""{"id":"815d9715-1089-4775-b120-3afb983b9a97","patientId":"748b5884-3528-4cb9-904b-7a8151d6e343",
@@ -28,4 +29,19 @@ class PatientHypothesisFormatSuite extends FlatSpec with Matchers {
parsedUpdatePatientHypothesis should be(expectedUpdatedPatientHypothesis)
}
+ "Json format for patientHypothesis" should "read and write correct JSON" in {
+ val orig = PatientHypothesis(
+ id = UuidId("815d9715-1089-4775-b120-3afb983b9a97"),
+ patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"),
+ hypothesisId = UuidId("e76e2fc4-a29c-44fb-a81b-8856d06bb1d4"),
+ rationale = None,
+ matchedTrials = 1
+ )
+ val writtenJson = patientHypothesisWriter.write(orig)
+
+ writtenJson should be(
+ """{"id":"815d9715-1089-4775-b120-3afb983b9a97","patientId":"748b5884-3528-4cb9-904b-7a8151d6e343",
+ "hypothesisId":"e76e2fc4-a29c-44fb-a81b-8856d06bb1d4","rationale":null,"matchedTrials":1}""".parseJson)
+ }
+
}
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 67d678c..2122777 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
@@ -4,31 +4,33 @@ import java.time.LocalDate
import spray.json._
import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, UuidId}
-import xyz.driver.pdsuidomain.entities.{PatientLabel, PatientLabelEvidenceView}
+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 PatientLabel" should "read and write correct JSON" in {
+ "Json format for RichPatientLabel" should "read and write correct JSON" in {
import patientlabel._
val orig = PatientLabel(
id = LongId(1),
patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"),
labelId = LongId(20),
- primaryValue = Some(FuzzyValue.Yes),
+ primaryValue = Some(LabelValue.Yes),
verifiedPrimaryValue = None,
isVisible = true,
score = 1,
isImplicitMatch = false
)
- val writtenJson = patientLabelWriter.write((orig, true))
+ 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(FuzzyValue.No))
+ val expectedUpdatedPatientLabel = orig.copy(verifiedPrimaryValue = Some(LabelValue.No))
val parsedUpdatePatientLabel = applyUpdateToPatientLabel(updatePatientLabelJson, orig)
parsedUpdatePatientLabel should be(expectedUpdatedPatientLabel)
}
@@ -37,14 +39,14 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers {
import patientlabel._
val orig = PatientLabelEvidenceView(
id = LongId(1),
- value = FuzzyValue.Maybe,
+ value = LabelValue.Maybe,
evidenceText = "evidence text",
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
@@ -53,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 {
@@ -62,8 +65,8 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers {
id = LongId(1),
patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"),
labelId = LongId(20),
- primaryValue = Some(FuzzyValue.Yes),
- verifiedPrimaryValue = Some(FuzzyValue.Yes),
+ primaryValue = Some(LabelValue.Yes),
+ verifiedPrimaryValue = Some(LabelValue.Yes),
isVisible = true,
score = 1,
isImplicitMatch = false
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala
index a3da52f..c9dc85f 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala
@@ -2,8 +2,8 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats
import java.time.LocalDateTime
-import spray.json._
import org.scalatest.{FlatSpec, Matchers}
+import spray.json._
import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId}
import xyz.driver.pdsuidomain.entities.Trial