aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats')
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatSuite.scala36
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala32
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala68
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala74
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentHistoryFormatSuite.scala32
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentIssueFormatSuite.scala47
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala124
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala95
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/HypothesisFormatSuite.scala28
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala63
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala77
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordHistoryFormatSuite.scala32
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordIssueFormatSuite.scala47
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala55
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala62
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala36
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHistoryFormatSuite.scala32
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala31
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientIssueFormatSuite.scala44
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala76
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/StudyDesignFormatSuite.scala24
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala50
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialHistoryFormatSuite.scala32
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialIssueFormatSuite.scala49
24 files changed, 0 insertions, 1246 deletions
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatSuite.scala
deleted file mode 100644
index e7d37a0..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatSuite.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId}
-import xyz.driver.pdsuidomain.entities.Arm
-
-class ArmFormatSuite extends FlatSpec with Matchers {
- import arm._
-
- "Json format for Arm" should "read and write correct JSON" in {
- val arm = Arm(
- id = LongId(10),
- trialId = StringId("NCT000001"),
- name = "arm name",
- originalName = "orig arm name"
- )
- val writtenJson = armFormat.write(arm)
-
- writtenJson should be("""{"id":10,"trialId":"NCT000001","name":"arm name","originalName":"orig arm name"}""".parseJson)
-
- val createArmJson = """{"trialId":"NCT000001","name":"arm name"}""".parseJson
- val parsedArm = armFormat.read(createArmJson)
- val expectedCreatedArm = arm.copy(
- id = LongId(0),
- originalName = "arm name"
- )
- parsedArm should be(expectedCreatedArm)
-
- val updateArmJson = """{"name":"new arm name"}""".parseJson
- val expectedUpdatedArm = arm.copy(name = "new arm name")
- val parsedUpdateArm = applyUpdateToArm(updateArmJson, arm)
- parsedUpdateArm should be(expectedUpdatedArm)
- }
-
-}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala
deleted file mode 100644
index 854f51f..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import java.time.LocalDateTime
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueue
-
-class BridgeUploadQueueFormat extends FlatSpec with Matchers {
- import bridgeuploadqueue._
-
- "Json format for BridgeUploadQueue.Item" should "read and write correct JSON" in {
- val item = BridgeUploadQueue.Item(
- kind = "kind",
- tag = "tag",
- created = LocalDateTime.parse("2017-08-10T18:00:00"),
- attempts = 0,
- nextAttempt = LocalDateTime.parse("2017-08-10T18:10:00"),
- completed = false,
- dependencyKind = Some("dependency king"),
- dependencyTag = None
- )
- val writtenJson = queueUploadItemFormat.write(item)
-
- writtenJson should be(
- """{"kind":"kind","tag":"tag","created":"2017-08-10T18:00Z","attempts":0,"nextAttempt":"2017-08-10T18:10Z","completed":false}""".parseJson)
-
- val parsedItem = queueUploadItemFormat.read(writtenJson)
- parsedItem should be(item.copy(dependencyKind = None, completed = true))
- }
-
-}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala
deleted file mode 100644
index d24c4c1..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala
+++ /dev/null
@@ -1,68 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId}
-import xyz.driver.pdsuidomain.entities.{Arm, Criterion, CriterionLabel}
-import xyz.driver.pdsuidomain.services.CriterionService.RichCriterion
-
-class CriterionFormatSuite extends FlatSpec with Matchers {
- import criterion._
-
- "Json format for Criterion" should "read and write correct JSON" in {
- val criterion = Criterion(
- id = LongId(10),
- trialId = StringId("NCT000001"),
- text = Some("text"),
- isCompound = false,
- meta = "{}"
- )
- val labels = List(
- CriterionLabel(
- id = LongId(1L),
- labelId = Some(LongId(101)),
- criterionId = criterion.id,
- categoryId = Some(LongId(3)),
- value = Some(true),
- isDefining = true
- ),
- CriterionLabel(
- id = LongId(2L),
- labelId = Some(LongId(102)),
- criterionId = criterion.id,
- categoryId = Some(LongId(3)),
- value = Some(false),
- isDefining = true
- )
- )
- val arms = List(LongId[Arm](20), LongId[Arm](21), LongId[Arm](21))
- val richCriterion = RichCriterion(
- criterion = criterion,
- armIds = arms,
- labels = labels
- )
- val writtenJson = richCriterionFormat.write(richCriterion)
-
- writtenJson should be(
- """{"text":"text","isCompound":false,"trialId":"NCT000001","arms":[20,21,21],"id":10,"meta":"{}",
- "labels":[{"labelId":101,"categoryId":3,"value":"Yes","isDefining":true},
- {"labelId":102,"categoryId":3,"value":"No","isDefining":true}]}""".parseJson)
-
- val createCriterionJson =
- """{"text":"text","isCompound":false,"trialId":"NCT000001",
- "arms":[20,21,21],"meta":"{}","labels":[{"labelId":101,"categoryId":3,"value":"Yes","isDefining":true},
- {"labelId":102,"categoryId":3,"value":"No","isDefining":true}]}""".parseJson
- val parsedRichCriterion = richCriterionFormat.read(createCriterionJson)
- val expectedRichCriterion = richCriterion.copy(
- criterion = criterion.copy(id = LongId(0)),
- labels = labels.map(_.copy(id = LongId(0), criterionId = LongId(0)))
- )
- parsedRichCriterion should be(expectedRichCriterion)
-
- val updateCriterionJson = """{"meta":null,"text":"new text","isCompound":true}""".parseJson
- val expectedUpdatedCriterion = richCriterion.copy(criterion = criterion.copy(text = Some("new text"), isCompound = true, meta = "{}"))
- val parsedUpdateCriterion = applyUpdateToCriterion(updateCriterionJson, richCriterion)
- parsedUpdateCriterion should be(expectedUpdatedCriterion)
- }
-
-}
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
deleted file mode 100644
index 9394735..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala
+++ /dev/null
@@ -1,74 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import java.time.{LocalDate, LocalDateTime}
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{LongId, TextJson}
-import xyz.driver.pdsuidomain.entities.Document
-
-class DocumentFormatSuite extends FlatSpec with Matchers {
- import document._
-
- "Json format for Document" should "read and write correct JSON" in {
- val orig = Document(
- id = LongId(1),
- status = Document.Status.New,
- assignee = None,
- previousStatus = None,
- previousAssignee = None,
- lastActiveUserId = None,
- lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"),
- recordId = LongId(101),
- physician = Some("physician"),
- typeId = Some(LongId(10)),
- providerName = Some("provider 21"),
- providerTypeId = Some(LongId(21)),
- requiredType = Some(Document.RequiredType.OPN),
- meta = None,
- startDate = None,
- endDate = None
- )
- val writtenJson = documentFormat.write(orig)
-
- 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,
- "previousAssignee":null,"lastActiveUser":null,"lastUpdate":"2017-08-10T18:00Z","meta":null}""".parseJson)
-
- val createDocumentJson =
- """{"recordId":101,"physician":"physician","typeId":10,"provider":"provider 21","providerTypeId":21}""".parseJson
- val expectedCreatedDocument = orig.copy(
- id = LongId(0),
- lastUpdate = LocalDateTime.MIN,
- requiredType = 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
- 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)))
- )
- 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 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)))
- }
-
-}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentHistoryFormatSuite.scala
deleted file mode 100644
index ddbda1d..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentHistoryFormatSuite.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import java.time.LocalDateTime
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId}
-import xyz.driver.pdsuidomain.entities.DocumentHistory
-
-class DocumentHistoryFormatSuite extends FlatSpec with Matchers {
- import documenthistory._
-
- "Json format for DocumentHistory" should "read and write correct JSON" in {
- val documentHistory = DocumentHistory(
- id = LongId(10),
- documentId = LongId(1),
- executor = StringId("userId-001"),
- state = DocumentHistory.State.Extract,
- action = DocumentHistory.Action.Start,
- created = LocalDateTime.parse("2017-08-10T18:00:00")
- )
- val writtenJson = documentHistoryFormat.write(documentHistory)
-
- writtenJson should be(
- """{"id":10,"executor":"userId-001","documentId":1,"state":"Extract",
- "action":"Start","created":"2017-08-10T18:00Z"}""".parseJson)
-
- val parsedDocumentHistory = documentHistoryFormat.read(writtenJson)
- parsedDocumentHistory should be(documentHistory)
- }
-
-}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentIssueFormatSuite.scala
deleted file mode 100644
index 1a8e3f0..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentIssueFormatSuite.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import java.time.LocalDateTime
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId}
-import xyz.driver.pdsuidomain.entities.DocumentIssue
-
-class DocumentIssueFormatSuite extends FlatSpec with Matchers {
- import documentissue._
-
- "Json format for DocumentIssue" should "read and write correct JSON" in {
- val documentIssue = DocumentIssue(
- id = LongId(10),
- documentId = LongId(1),
- userId = StringId("userId-001"),
- lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"),
- isDraft = false,
- text = "message text",
- archiveRequired = false,
- startPage = Some(1.0),
- endPage = Some(2.0)
- )
- val writtenJson = documentIssueWriter.write(documentIssue)
-
- writtenJson should be(
- """{"id":10,"userId":"userId-001","lastUpdate":"2017-08-10T18:00Z","isDraft":false,
- "text":"message text","archiveRequired":false,"startPage":1.0,"endPage":2.0}""".parseJson)
-
- val createDocumentIssueJson = """{"text":"message text","startPage":1.0,"endPage":2.0}""".parseJson
- val expectedCreatedDocumentIssue = documentIssue.copy(id = LongId(0), lastUpdate = LocalDateTime.MIN, isDraft = true)
- val parsedCreateDocumentIssue = jsValueToDocumentIssue(createDocumentIssueJson, LongId(1), StringId("userId-001"))
- parsedCreateDocumentIssue should be(expectedCreatedDocumentIssue)
-
- val updateDocumentIssueJson =
- """{"text":"new issue text","evidence":"issue evidence","archiveRequired":true,"startPage":1.0,"endPage":4.0}""".parseJson
- val expectedUpdatedDocumentIssue = documentIssue.copy(
- text = "new issue text",
- archiveRequired = true,
- endPage = Some(4.0)
- )
- val parsedUpdateDocumentIssue = applyUpdateToDocumentIssue(updateDocumentIssueJson, documentIssue)
- parsedUpdateDocumentIssue should be(expectedUpdatedDocumentIssue)
- }
-
-}
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
deleted file mode 100644
index d0d4d1a..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala
+++ /dev/null
@@ -1,124 +0,0 @@
-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 xyz.driver.pdsuidomain.entities.RecordRequestId
-
-class ExportFormatSuite extends FlatSpec with Matchers {
- import export._
-
- "Json format for ExportPatientWithLabels" should "read and write correct JSON" in {
- import xyz.driver.pdsuidomain.entities.export.patient._
- val document = ExportPatientLabelEvidenceDocument(
- documentId = LongId(101),
- requestId = RecordRequestId(UUID.fromString("7b54a75d-4197-4b27-9045-b9b6cb131be9")),
- documentType = "document type",
- providerType = "provider type",
- date = LocalDate.parse("2017-08-10")
- )
- val labels = List(
- ExportPatientLabel(
- id = LongId(1),
- evidences = List(
- ExportPatientLabelEvidence(
- id = LongId(11),
- value = FuzzyValue.Yes,
- evidenceText = "evidence text 11",
- document = document
- ),
- ExportPatientLabelEvidence(
- id = LongId(12),
- value = FuzzyValue.No,
- evidenceText = "evidence text 12",
- document = document
- )
- )
- ),
- ExportPatientLabel(
- id = LongId(2),
- evidences = List(
- ExportPatientLabelEvidence(
- id = LongId(12),
- value = FuzzyValue.Yes,
- evidenceText = "evidence text 12",
- document = document
- ),
- ExportPatientLabelEvidence(
- id = LongId(13),
- value = FuzzyValue.Yes,
- evidenceText = "evidence text 13",
- document = document
- )
- )
- )
- )
- val patientWithLabels = ExportPatientWithLabels(
- patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"),
- labelVersion = 1L,
- labels = labels
- )
-
- val writtenJson = patientWithLabelsWriter.write(patientWithLabels)
- writtenJson should be(
- """{"patientId":"748b5884-3528-4cb9-904b-7a8151d6e343","labelVersion":1,"labels":[{"labelId":1,"evidence":[{"evidenceId":11,
- "labelValue":"Yes","evidenceText":"evidence text 11","document":{"documentId":101,"requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9",
- "documentType":"document type","providerType":"provider type","date":"2017-08-10"}},{"evidenceId":12,"labelValue":"No",
- "evidenceText":"evidence text 12","document":{"documentId":101,"requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9",
- "documentType":"document type","providerType":"provider type","date":"2017-08-10"}}]},
- {"labelId":2,"evidence":[{"evidenceId":12,"labelValue":"Yes","evidenceText":"evidence text 12","document":
- {"documentId":101,"requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","documentType":"document type",
- "providerType":"provider type","date":"2017-08-10"}},{"evidenceId":13,"labelValue":"Yes","evidenceText":"evidence text 13",
- "document":{"documentId":101,"requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","documentType":"document type",
- "providerType":"provider type","date":"2017-08-10"}}]}]}""".parseJson)
- }
-
- "Json format for ApiExportTrialWithLabels" should "read and write correct JSON" in {
- import xyz.driver.pdsuidomain.entities.export.trial._
- val arms = List(
- ExportTrialArm(armId = LongId(1), armName = "arm 1"),
- ExportTrialArm(armId = LongId(2), armName = "arm 2")
- )
- val criteriaList = List(
- ExportTrialLabelCriterion(
- criterionId = LongId(10),
- value = Some(true),
- labelId = LongId(21),
- armIds = Set(LongId(1), LongId(2)),
- criteria = "criteria 10 text",
- isCompound = false,
- isDefining = false
- ),
- ExportTrialLabelCriterion(
- criterionId = LongId(11),
- value = None,
- labelId = LongId(21),
- armIds = Set(LongId(2)),
- criteria = "criteria 11 text",
- isCompound = true,
- isDefining = false
- )
- )
- 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,
- criteria = criteriaList
- )
-
- val writtenJson = trialWithLabelsWriter.write(trialWithLabels)
- writtenJson should be(
- """{"nctId":"NCT000001","trialId":"40892a07-c638-49d2-9795-1edfefbbcc7c","disease":"Breast","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
deleted file mode 100644
index a4b8bab..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala
+++ /dev/null
@@ -1,95 +0,0 @@
-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.pdsuidomain.entities.ExtractedData.Meta
-import xyz.driver.pdsuidomain.entities.{ExtractedData, ExtractedDataLabel}
-import xyz.driver.pdsuidomain.services.ExtractedDataService.RichExtractedData
-
-class ExtractedDataFormatSuite extends FlatSpec with Matchers {
- import extracteddata._
-
- "Json format for ExtractedData" should "read and write correct JSON" in {
- val extractedData = ExtractedData(
- id = LongId(1),
- documentId = LongId(101),
- keywordId = Some(LongId(201)),
- evidenceText = Some("evidence text"),
- meta = None
- )
- val extractedDataLabels = List(
- ExtractedDataLabel(
- id = LongId(1),
- dataId = extractedData.id,
- labelId = None,
- categoryId = None,
- value = Some(FuzzyValue.Yes)
- ),
- ExtractedDataLabel(
- id = LongId(2),
- dataId = extractedData.id,
- labelId = Some(LongId(12)),
- categoryId = Some(LongId(1)),
- value = Some(FuzzyValue.No)
- )
- )
- val origRichExtractedData = RichExtractedData(
- extractedData = extractedData,
- labels = extractedDataLabels
- )
- val writtenJson = extractedDataFormat.write(origRichExtractedData)
-
- writtenJson should be (
- """{"id":1,"documentId":101,"keywordId":201,"evidence":"evidence text","meta":null,
- "labels":[{"id":null,"categoryId":null,"value":"Yes"},{"id":12,"categoryId":1,"value":"No"}]}""".parseJson)
-
- val createExtractedDataJson =
- """{"documentId":101,"keywordId":201,"evidence":"evidence text",
- "labels":[{"value":"Yes"},{"id":12,"categoryId":1,"value":"No"}]}""".parseJson
- val expectedCreatedExtractedData = origRichExtractedData.copy(
- extractedData = extractedData.copy(id = LongId(0)),
- labels = extractedDataLabels.map(_.copy(id = LongId(0), dataId = LongId(0)))
- )
- val parsedCreatedExtractedData = extractedDataFormat.read(createExtractedDataJson)
- parsedCreatedExtractedData should be(expectedCreatedExtractedData)
-
- val updateExtractedDataJson =
- """{"evidence":"new evidence text","meta":{"keyword":{"page":1,"index":2,"sortIndex":"ASC"},
- "evidence":{"pageRatio":1.0,"start":{"page":1,"index":3,"offset":2},"end":{"page":2,"index":3,"offset":10}}},
- "labels":[{"id":20,"categoryId":1,"value":"Yes"},{"id":12,"categoryId":1,"value":"No"}]}""".parseJson
- val updatedExtractedDataLabels = List(
- ExtractedDataLabel(
- id = LongId(0),
- dataId = extractedData.id,
- labelId = Some(LongId(20)),
- categoryId = Some(LongId(1)),
- value = Some(FuzzyValue.Yes)
- ),
- ExtractedDataLabel(
- id = LongId(0),
- dataId = extractedData.id,
- labelId = Some(LongId(12)),
- categoryId = Some(LongId(1)),
- value = Some(FuzzyValue.No)
- )
- )
- val expectedUpdatedExtractedData = origRichExtractedData.copy(
- extractedData = extractedData.copy(
- evidenceText = Some("new evidence text"),
- meta = Some(TextJson(Meta(
- keyword = Meta.Keyword(page = 1, pageRatio = None, index = 2, sortIndex = "ASC"),
- evidence = Meta.Evidence(
- pageRatio = 1.0,
- start = Meta.TextLayerPosition(page = 1, index = 3, offset = 2),
- end = Meta.TextLayerPosition(page = 2, index = 3, offset = 10)
- )
- )))
- ),
- labels = updatedExtractedDataLabels
- )
- val parsedUpdatedExtractedData = applyUpdateToExtractedData(updateExtractedDataJson, origRichExtractedData)
- parsedUpdatedExtractedData should be(expectedUpdatedExtractedData)
- }
-
-}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/HypothesisFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/HypothesisFormatSuite.scala
deleted file mode 100644
index 306fb17..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/HypothesisFormatSuite.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.UuidId
-import xyz.driver.pdsuidomain.entities.Hypothesis
-
-class HypothesisFormatSuite extends FlatSpec with Matchers {
- import hypothesis._
-
- "Json format for Hypothesis" should "read and write correct JSON" in {
- val hypothesis = Hypothesis(
- id = UuidId("3b80b2e2-5372-4cf5-a342-6e4ebe10fafd"),
- name = "hypothesis name",
- treatmentType = "treatment type",
- description = "descr"
- )
- val writtenJson = hypothesisFormat.write(hypothesis)
-
- writtenJson should be(
- """{"id":"3b80b2e2-5372-4cf5-a342-6e4ebe10fafd","name":"hypothesis name",
- "treatmentType":"treatment type","description":"descr"}""".parseJson)
-
- val parsedHypothesis = hypothesisFormat.read(writtenJson)
- parsedHypothesis should be(hypothesis)
- }
-
-}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala
deleted file mode 100644
index 784a655..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala
+++ /dev/null
@@ -1,63 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId}
-import xyz.driver.pdsuidomain.entities.{Intervention, InterventionArm, InterventionType, InterventionWithArms}
-
-class InterventionFormatSuite extends FlatSpec with Matchers {
- import intervention._
-
- "Json format for Intervention" should "read and write correct JSON" in {
- val intervention = Intervention(
- id = LongId(1),
- trialId = StringId("NCT000001"),
- name = "intervention name",
- originalName = "orig name",
- typeId = Some(LongId(10)),
- originalType = Some("orig type"),
- description = "",
- originalDescription = "",
- isActive = true
- )
- val arms = List(
- InterventionArm(interventionId = intervention.id, armId = LongId(20)),
- InterventionArm(interventionId = intervention.id, armId = LongId(21)),
- InterventionArm(interventionId = intervention.id, armId = LongId(22))
- )
- val orig = InterventionWithArms(
- intervention = intervention,
- arms = arms
- )
- val writtenJson = interventionWriter.write(orig)
-
- writtenJson should be(
- """{"id":1,"name":"intervention name","typeId":10,"description":"","isActive":true,"arms":[20,21,22],
- "trialId":"NCT000001","originalName":"orig name","originalDescription":"","originalType":"orig type"}""".parseJson)
-
- val updateInterventionJson = """{"description":"descr","arms":[21,22]}""".parseJson
- val expectedUpdatedIntervention = orig.copy(
- intervention = intervention.copy(description = "descr"),
- arms = List(
- InterventionArm(interventionId = intervention.id, armId = LongId(21)),
- InterventionArm(interventionId = intervention.id, armId = LongId(22))
- )
- )
- val parsedUpdateIntervention = applyUpdateToInterventionWithArms(updateInterventionJson, orig)
- parsedUpdateIntervention should be(expectedUpdatedIntervention)
- }
-
- "Json format for InterventionType" should "read and write correct JSON" in {
- val interventionType = InterventionType(
- id = LongId(10),
- name = "type name"
- )
- val writtenJson = interventionTypeFormat.write(interventionType)
-
- writtenJson should be("""{"id":10,"name":"type name"}""".parseJson)
-
- val parsedInterventionType = interventionTypeFormat.read(writtenJson)
- parsedInterventionType should be(interventionType)
- }
-
-}
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
deleted file mode 100644
index 899e5c9..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala
+++ /dev/null
@@ -1,77 +0,0 @@
-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, TextJson, UuidId}
-import xyz.driver.pdsuidomain.entities.{MedicalRecord, RecordRequestId}
-
-class MedicalRecordFormatSuite extends FlatSpec with Matchers {
- import record._
- import MedicalRecord._
-
- "Json format for MedicalRecord" should "read and 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,
- predictedMeta = None,
- predictedDocuments = None,
- disease = "Breast",
- requestId = RecordRequestId(UUID.fromString("7b54a75d-4197-4b27-9045-b9b6cb131be9")),
- caseId = None,
- patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343")
- )
- val writtenJson = recordFormat.write(orig)
-
- writtenJson should be (
- """{"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"}""".parseJson)
-
- val createRecordJson =
- """{"disease":"Breast","patientId":"748b5884-3528-4cb9-904b-7a8151d6e343","requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9"}""".parseJson
- val expectedCreatedRecord = MedicalRecord(
- id = LongId(0),
- status = MedicalRecord.Status.New,
- previousStatus = None,
- assignee = None,
- previousAssignee = None,
- lastActiveUserId = None,
- patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"),
- requestId = RecordRequestId(UUID.fromString("7b54a75d-4197-4b27-9045-b9b6cb131be9")),
- disease = "Breast",
- 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},
- {"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))
- )))
- )
- val parsedUpdatedRecord = applyUpdateToMedicalRecord(updateRecordJson, orig)
- parsedUpdatedRecord should be(expectedUpdatedRecord)
- }
-
-}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordHistoryFormatSuite.scala
deleted file mode 100644
index 5cd6c8d..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordHistoryFormatSuite.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import java.time.LocalDateTime
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId}
-import xyz.driver.pdsuidomain.entities.MedicalRecordHistory
-
-class MedicalRecordHistoryFormatSuite extends FlatSpec with Matchers {
- import recordhistory._
-
- "Json format for MedicalRecordHistory" should "read and write correct JSON" in {
- val recordHistory = MedicalRecordHistory(
- id = LongId(10),
- recordId = LongId(1),
- executor = StringId("userId-001"),
- state = MedicalRecordHistory.State.Clean,
- action = MedicalRecordHistory.Action.Start,
- created = LocalDateTime.parse("2017-08-10T18:00:00")
- )
- val writtenJson = recordHistoryFormat.write(recordHistory)
-
- writtenJson should be(
- """{"id":10,"executor":"userId-001","recordId":1,"state":"Clean",
- "action":"Start","created":"2017-08-10T18:00Z"}""".parseJson)
-
- val parsedRecordHistory = recordHistoryFormat.read(writtenJson)
- parsedRecordHistory should be(recordHistory)
- }
-
-}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordIssueFormatSuite.scala
deleted file mode 100644
index 9b89c97..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordIssueFormatSuite.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import java.time.LocalDateTime
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId}
-import xyz.driver.pdsuidomain.entities.MedicalRecordIssue
-
-class MedicalRecordIssueFormatSuite extends FlatSpec with Matchers {
- import recordissue._
-
- "Json format for MedicalRecordIssue" should "read and write correct JSON" in {
- val recordIssue = MedicalRecordIssue(
- id = LongId(10),
- recordId = LongId(1),
- userId = StringId("userId-001"),
- lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"),
- isDraft = false,
- text = "message text",
- archiveRequired = false,
- startPage = Some(1.0),
- endPage = Some(2.0)
- )
- val writtenJson = recordIssueWriter.write(recordIssue)
-
- writtenJson should be(
- """{"id":10,"userId":"userId-001","lastUpdate":"2017-08-10T18:00Z","isDraft":false,
- "text":"message text","archiveRequired":false,"startPage":1.0,"endPage":2.0}""".parseJson)
-
- val createRecordIssueJson = """{"text":"message text","startPage":1.0,"endPage":2.0}""".parseJson
- val expectedCreatedRecordIssue = recordIssue.copy(id = LongId(0), lastUpdate = LocalDateTime.MIN, isDraft = true)
- val parsedCreateRecordIssue = jsValueToRecordIssue(createRecordIssueJson, LongId(1), StringId("userId-001"))
- parsedCreateRecordIssue should be(expectedCreatedRecordIssue)
-
- val updateRecordIssueJson =
- """{"text":"new issue text","evidence":"issue evidence","archiveRequired":true,"startPage":1.0,"endPage":4.0}""".parseJson
- val expectedUpdatedRecordIssue = recordIssue.copy(
- text = "new issue text",
- archiveRequired = true,
- endPage = Some(4.0)
- )
- val parsedUpdateRecordIssue = applyUpdateToRecordIssue(updateRecordIssueJson, recordIssue)
- parsedUpdateRecordIssue should be(expectedUpdatedRecordIssue)
- }
-
-}
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
deleted file mode 100644
index 0f5e4e2..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala
+++ /dev/null
@@ -1,55 +0,0 @@
-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}
-import xyz.driver.pdsuidomain.entities.{PatientCriterion, PatientCriterionArm}
-import xyz.driver.pdsuidomain.services.PatientCriterionService.DraftPatientCriterion
-
-class PatientCriterionFormatSuite extends FlatSpec with Matchers {
- import patientcriterion._
-
- "Json format for PatientCriterion" should "read and write correct JSON" in {
- val orig = PatientCriterion(
- id = LongId(1),
- patientLabelId = LongId(1),
- trialId = 0L,
- nctId = StringId("NCT00001"),
- criterionId = LongId(101),
- criterionText = "criterion text",
- criterionValue = Some(true),
- criterionIsDefining = false,
- eligibilityStatus = Some(FuzzyValue.Yes),
- verifiedEligibilityStatus = None,
- isVisible = true,
- isVerified = true,
- lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00")
- )
- val arms = List(
- 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))
-
- writtenJson should be (
- """{"id":1,"labelId":21,"nctId":"NCT00001","criterionId":101,"criterionText":"criterion text","criterionValue":"Yes",
- "criterionIsDefining":false,"criterionIsCompound":false,"eligibilityStatus":"Yes","verifiedEligibilityStatus":null,
- "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 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(2), eligibilityStatus = None, isVerified = Some(false))
- )
- val parsedDraftPatientCriterionList = draftPatientCriterionListReader.read(updateBulkPatientCriterionJson)
- parsedDraftPatientCriterionList should be(expectedDraftPatientCriterionList)
- }
-
-}
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
deleted file mode 100644
index ad54946..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala
+++ /dev/null
@@ -1,62 +0,0 @@
-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 xyz.driver.pdsuidomain.entities.{PatientCriterionArm, PatientTrialArmGroupView, Trial}
-import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial
-
-class PatientEligibleTrialFormatSuite extends FlatSpec with Matchers {
- import patienteligibletrial._
-
- "Json format for PatientEligibleTrial" should "read and write correct JSON" in {
- val trial = Trial(
- id = StringId("NCT000001"),
- externalId = UuidId("40892a07-c638-49d2-9795-1edfefbbcc7c"),
- status = Trial.Status.Done,
- assignee = None,
- previousStatus = None,
- previousAssignee = None,
- lastActiveUserId = None,
- lastUpdate = LocalDateTime.parse("2017-08-10T18:16:19"),
- condition = Trial.Condition.Breast,
- phase = "",
- hypothesisId = Some(UuidId("e76e2fc4-a29c-44fb-a81b-8856d06bb1d4")),
- studyDesignId = Some(LongId(321)),
- originalStudyDesign = None,
- isPartner = false,
- overview = None,
- overviewTemplate = "",
- isUpdated = false,
- title = "trial title",
- originalTitle = "orig trial title"
- )
- val group = PatientTrialArmGroupView(
- id = LongId(1),
- 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),
- isVerified = false
- )
- val arms = List(
- PatientCriterionArm(patientCriterionId = LongId(1), armId = LongId(31), armName = "arm 31"),
- PatientCriterionArm(patientCriterionId = LongId(1), armId = LongId(32), armName = "arm 32")
- )
- val orig = RichPatientEligibleTrial(trial, group, arms)
- val writtenJson = patientEligibleTrialWriter.write(orig)
-
- writtenJson should be (
- """{"id":1,"patientId":"748b5884-3528-4cb9-904b-7a8151d6e343","trialId":"NCT000001","trialTitle":"trial title",
- "hypothesisId":"e76e2fc4-a29c-44fb-a81b-8856d06bb1d4","verifiedEligibilityStatus":"Yes","isVerified":false,"arms":["arm 31","arm 32"]}""".parseJson)
-
- val updatePatientEligibleTrialJson = """{"isVerified":true}""".parseJson
- val expectedUpdatedPatientTrialArmGroup = group.copy(isVerified = true)
- val parsedUpdatePatientTrialArmGroup = applyUpdateToTrialArmGroup(updatePatientEligibleTrialJson, group)
- parsedUpdatePatientTrialArmGroup should be(expectedUpdatedPatientTrialArmGroup)
- }
-
-}
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
deleted file mode 100644
index 2761d6a..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import java.time.{LocalDate, LocalDateTime}
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.UuidId
-import xyz.driver.pdsuidomain.entities.{Patient, PatientOrderId}
-
-class PatientFormatSuite extends FlatSpec with Matchers {
- import patient._
-
- "Json format for Patient" should "read and write correct JSON" in {
- val orig = Patient(
- id = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"),
- status = Patient.Status.New,
- name = "John Doe",
- dob = LocalDate.parse("1980-06-30"),
- assignee = None,
- previousStatus = None,
- previousAssignee = None,
- lastActiveUserId = None,
- isUpdateRequired = false,
- condition = "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,
- "previousStatus":null,"previousAssignee":null,"lastActiveUser":null,"lastUpdate":"2017-08-10T18:00Z",
- "orderId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","condition":"breast"}""".parseJson)
- }
-
-}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHistoryFormatSuite.scala
deleted file mode 100644
index c6a5a9f..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHistoryFormatSuite.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import java.time.LocalDateTime
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId}
-import xyz.driver.pdsuidomain.entities.PatientHistory
-
-class PatientHistoryFormatSuite extends FlatSpec with Matchers {
- import patienthistory._
-
- "Json format for PatientHistory" should "read and write correct JSON" in {
- val patientHistory = PatientHistory(
- id = LongId(10),
- patientId = UuidId("40892a07-c638-49d2-9795-1edfefbbcc7c"),
- executor = StringId("userId-001"),
- state = PatientHistory.State.Verify,
- action = PatientHistory.Action.Start,
- created = LocalDateTime.parse("2017-08-10T18:00:00")
- )
- val writtenJson = patientHistoryFormat.write(patientHistory)
-
- writtenJson should be(
- """{"id":10,"executor":"userId-001","patientId":"40892a07-c638-49d2-9795-1edfefbbcc7c","state":"Verify",
- "action":"Start","created":"2017-08-10T18:00Z"}""".parseJson)
-
- val parsedPatientHistory = patientHistoryFormat.read(writtenJson)
- parsedPatientHistory should be(patientHistory)
- }
-
-}
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
deleted file mode 100644
index 2999cc1..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.UuidId
-import xyz.driver.pdsuidomain.entities.PatientHypothesis
-
-class PatientHypothesisFormatSuite extends FlatSpec with Matchers {
- import patienthypothesis._
-
- "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, true))
-
- 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,"isRationaleRequired":true}""".parseJson)
-
- val updatePatientHypothesisJson = """{"rationale":"rationale"}""".parseJson
- val expectedUpdatedPatientHypothesis = orig.copy(rationale = Some("rationale"))
- val parsedUpdatePatientHypothesis = applyUpdateToPatientHypothesis(updatePatientHypothesisJson, orig)
- parsedUpdatePatientHypothesis should be(expectedUpdatedPatientHypothesis)
- }
-
-}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientIssueFormatSuite.scala
deleted file mode 100644
index 1e2a11e..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientIssueFormatSuite.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import java.time.LocalDateTime
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId}
-import xyz.driver.pdsuidomain.entities.PatientIssue
-
-class PatientIssueFormatSuite extends FlatSpec with Matchers {
- import patientissue._
-
- "Json format for PatientIssue" should "read and write correct JSON" in {
- val patientIssue = PatientIssue(
- id = LongId(10),
- patientId = UuidId("40892a07-c638-49d2-9795-1edfefbbcc7c"),
- userId = StringId("userId-001"),
- lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"),
- isDraft = false,
- text = "message text",
- archiveRequired = false
- )
- val writtenJson = patientIssueWriter.write(patientIssue)
-
- writtenJson should be(
- """{"id":10,"userId":"userId-001","lastUpdate":"2017-08-10T18:00Z","isDraft":false,
- "text":"message text","archiveRequired":false}""".parseJson)
-
- val createPatientIssueJson = """{"text":"message text"}""".parseJson
- val expectedCreatedPatientIssue = patientIssue.copy(id = LongId(0), lastUpdate = LocalDateTime.MIN, isDraft = true)
- val parsedCreatePatientIssue = jsValueToPatientIssue(createPatientIssueJson, UuidId("40892a07-c638-49d2-9795-1edfefbbcc7c"), StringId("userId-001"))
- parsedCreatePatientIssue should be(expectedCreatedPatientIssue)
-
- val updatePatientIssueJson =
- """{"text":"new issue text","evidence":"issue evidence","archiveRequired":true}""".parseJson
- val expectedUpdatedPatientIssue = patientIssue.copy(
- text = "new issue text",
- archiveRequired = true
- )
- val parsedUpdatePatientIssue = applyUpdateToPatientIssue(updatePatientIssueJson, patientIssue)
- parsedUpdatePatientIssue should be(expectedUpdatedPatientIssue)
- }
-
-}
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
deleted file mode 100644
index e18239c..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala
+++ /dev/null
@@ -1,76 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-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}
-
-class PatientLabelFormatSuite extends FlatSpec with Matchers {
-
- "Json format for PatientLabel" 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),
- verifiedPrimaryValue = None,
- isVisible = true,
- score = 1,
- isImplicitMatch = false
- )
- val writtenJson = patientLabelWriter.write((orig, 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 parsedUpdatePatientLabel = applyUpdateToPatientLabel(updatePatientLabelJson, orig)
- parsedUpdatePatientLabel should be(expectedUpdatedPatientLabel)
- }
-
- "Json format for PatientLabelEvidence" should "read and write correct JSON" in {
- import patientlabel._
- val orig = PatientLabelEvidenceView(
- id = LongId(1),
- value = FuzzyValue.Maybe,
- evidenceText = "evidence text",
- documentId = Some(LongId(21)),
- evidenceId = Some(LongId(10)),
- reportId = None,
- documentType = "document type",
- date = Some(LocalDate.parse("2017-08-10")),
- providerType = "provider type",
- 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":"document type","date":"2017-08-10","providerType":"provider type"}""".parseJson)
- }
-
- "Json format for PatientLabelDefiningCriteria" should "read and write correct JSON" in {
- import patientdefiningcriteria._
- val orig = PatientLabel(
- id = LongId(1),
- patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"),
- labelId = LongId(20),
- primaryValue = Some(FuzzyValue.Yes),
- verifiedPrimaryValue = Some(FuzzyValue.Yes),
- isVisible = true,
- score = 1,
- isImplicitMatch = false
- )
- val writtenJson = patientLabelDefiningCriteriaWriter.write(orig)
-
- writtenJson should be ("""{"id":1,"value":"Yes"}""".parseJson)
- }
-
-}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/StudyDesignFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/StudyDesignFormatSuite.scala
deleted file mode 100644
index 9cf9b5f..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/StudyDesignFormatSuite.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.LongId
-import xyz.driver.pdsuidomain.entities.StudyDesign
-
-class StudyDesignFormatSuite extends FlatSpec with Matchers {
- import studydesign._
-
- "Json format for StudyDesign" should "read and write correct JSON" in {
- val studyDesign = StudyDesign(
- id = LongId(10),
- name = "study design name"
- )
- val writtenJson = studyDesignFormat.write(studyDesign)
-
- writtenJson should be("""{"id":10,"name":"study design name"}""".parseJson)
-
- val parsedStudyDesign = studyDesignFormat.read(writtenJson)
- parsedStudyDesign should be(studyDesign)
- }
-
-}
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
deleted file mode 100644
index 59cf779..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala
+++ /dev/null
@@ -1,50 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import java.time.LocalDateTime
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId}
-import xyz.driver.pdsuidomain.entities.Trial
-
-class TrialFormatSuite extends FlatSpec with Matchers {
- import trial._
-
- "Json format for Trial" should "read and write correct JSON" in {
- val orig = Trial(
- id = StringId("NCT000001"),
- externalId = UuidId("40892a07-c638-49d2-9795-1edfefbbcc7c"),
- status = Trial.Status.New,
- assignee = None,
- previousStatus = None,
- previousAssignee = None,
- lastActiveUserId = None,
- lastUpdate = LocalDateTime.parse("2017-08-10T18:16:19"),
- condition = Trial.Condition.Breast,
- phase = "",
- hypothesisId = Some(UuidId("3b80b2e2-5372-4cf5-a342-6e4ebe10fafd")),
- studyDesignId = Some(LongId(321)),
- originalStudyDesign = None,
- isPartner = false,
- overview = None,
- overviewTemplate = "",
- isUpdated = false,
- title = "trial title",
- originalTitle = "orig trial title"
- )
- val writtenJson = trialWriter.write(orig)
-
- writtenJson should be (
- """{"isPartner":false,"assignee":null,"lastUpdate":"2017-08-10T18:16:19Z","previousStatus":null,
- "isUpdated":false,"overviewTemplate":"","phase":"","originalStudyDesignId":null,
- "hypothesisId":"3b80b2e2-5372-4cf5-a342-6e4ebe10fafd","originalTitle":"orig trial title",
- "studyDesignId":321,"lastActiveUser":null,"externalid":"40892a07-c638-49d2-9795-1edfefbbcc7c",
- "id":"NCT000001","condition":"Breast","status":"New","overview":null,"previousAssignee":null,"title":"trial title"}""".parseJson)
-
- val updateTrialJson = """{"hypothesisId":null,"overview":"new overview"}""".parseJson
- val expectedUpdatedTrial = orig.copy(hypothesisId = None, overview = Some("new overview"))
- val parsedUpdateTrial = applyUpdateToTrial(updateTrialJson, orig)
- parsedUpdateTrial should be(expectedUpdatedTrial)
- }
-
-}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialHistoryFormatSuite.scala
deleted file mode 100644
index dbb143c..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialHistoryFormatSuite.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import java.time.LocalDateTime
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId}
-import xyz.driver.pdsuidomain.entities.TrialHistory
-
-class TrialHistoryFormatSuite extends FlatSpec with Matchers {
- import trialhistory._
-
- "Json format for TrialHistory" should "read and write correct JSON" in {
- val trialHistory = TrialHistory(
- id = LongId(10),
- trialId = StringId("NCT000001"),
- executor = StringId("userId-001"),
- state = TrialHistory.State.Summarize,
- action = TrialHistory.Action.Start,
- created = LocalDateTime.parse("2017-08-10T18:00:00")
- )
- val writtenJson = trialHistoryFormat.write(trialHistory)
-
- writtenJson should be(
- """{"id":10,"executor":"userId-001","trialId":"NCT000001","state":"Summarize",
- "action":"Start","created":"2017-08-10T18:00Z"}""".parseJson)
-
- val parsedTrialHistory = trialHistoryFormat.read(writtenJson)
- parsedTrialHistory should be(trialHistory)
- }
-
-}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialIssueFormatSuite.scala
deleted file mode 100644
index 02e14ba..0000000
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialIssueFormatSuite.scala
+++ /dev/null
@@ -1,49 +0,0 @@
-package xyz.driver.pdsuidomain.formats.json.sprayformats
-
-import java.time.LocalDateTime
-
-import spray.json._
-import org.scalatest.{FlatSpec, Matchers}
-import xyz.driver.pdsuicommon.domain.{LongId, StringId}
-import xyz.driver.pdsuidomain.entities.TrialIssue
-
-class TrialIssueFormatSuite extends FlatSpec with Matchers {
- import trialissue._
-
- "Json format for TrialIssue" should "read and write correct JSON" in {
- val trialIssue = TrialIssue(
- id = LongId(10),
- trialId = StringId("NCT000001"),
- userId = StringId("userId-001"),
- lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"),
- isDraft = false,
- text = "message text",
- evidence = "evidence",
- archiveRequired = false,
- meta = "{}"
- )
- val writtenJson = trialIssueWriter.write(trialIssue)
-
- writtenJson should be(
- """{"id":10,"userId":"userId-001","lastUpdate":"2017-08-10T18:00Z","isDraft":false,
- "text":"message text","evidence":"evidence","archiveRequired":false,"meta":"{}"}""".parseJson)
-
- val createTrialIssueJson = """{"text":"message text","evidence":"evidence","meta":"{}"}""".parseJson
- val expectedCreatedTrialIssue = trialIssue.copy(id = LongId(0), lastUpdate = LocalDateTime.MIN, isDraft = true)
- val parsedCreateTrialIssue = jsValueToTrialIssue(createTrialIssueJson, StringId("NCT000001"), StringId("userId-001"))
- parsedCreateTrialIssue should be(expectedCreatedTrialIssue)
-
- val updateTrialIssueJson =
- """{"text":"new issue text","evidence":"issue evidence","archiveRequired":true,
- "meta":"{\"startPage\":1.0,\"endPage\":2.0}"}""".parseJson
- val expectedUpdatedTrialIssue = trialIssue.copy(
- text = "new issue text",
- evidence = "issue evidence",
- archiveRequired = true,
- meta = """{"startPage":1.0,"endPage":2.0}"""
- )
- val parsedUpdateTrialIssue = applyUpdateToTrialIssue(updateTrialIssueJson, trialIssue)
- parsedUpdateTrialIssue should be(expectedUpdatedTrialIssue)
- }
-
-}