From 7b8ac40ab6501ec53c5a55962fe4a3d54666ae8d Mon Sep 17 00:00:00 2001 From: vlad Date: Wed, 14 Jun 2017 14:46:19 -0700 Subject: Update for recent PDS UI changes --- .../driver/pdsuidomain/entities/DirectReport.scala | 42 ---------------------- .../xyz/driver/pdsuidomain/entities/Document.scala | 23 ++++++------ .../entities/PatientEligibleTrial.scala | 9 ++--- .../driver/pdsuidomain/entities/PatientLabel.scala | 15 ++++---- .../pdsuidomain/entities/RawPatientDocument.scala | 4 +-- .../pdsuidomain/entities/RawPatientLabel.scala | 6 ++-- .../ExportPatientLabelEvidenceDocument.scala | 4 +-- 7 files changed, 29 insertions(+), 74 deletions(-) delete mode 100644 src/main/scala/xyz/driver/pdsuidomain/entities/DirectReport.scala (limited to 'src/main/scala/xyz/driver/pdsuidomain/entities') diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/DirectReport.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/DirectReport.scala deleted file mode 100644 index 4f1f1b9..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/DirectReport.scala +++ /dev/null @@ -1,42 +0,0 @@ -package xyz.driver.pdsuidomain.entities - -import java.time.LocalDateTime - -import xyz.driver.pdsuicommon.domain.UuidId -import xyz.driver.pdsuicommon.logging._ -import xyz.driver.pdsuicommon.utils.Utils -import xyz.driver.pdsuidomain.entities.DirectReport.ReportType - -object DirectReport { - - sealed trait ReportType extends Product with Serializable { - def oneOf(xs: ReportType*): Boolean = xs.contains(this) - - def oneOf(xs: Set[ReportType]): Boolean = xs.contains(this) - } - - object ReportType { - case object IHC extends ReportType - case object DNA extends ReportType - case object CFDNA extends ReportType - - val All = Set(IHC, DNA, CFDNA) - implicit def toPhiString(x: ReportType): PhiString = Unsafe(Utils.getClassSimpleName(x.getClass)) - } - - implicit def toPhiString(x: DirectReport): PhiString = { - import x._ - phi"DirectReport(id=$id, patientId=$patientId, reportType=$reportType, date=${Unsafe(date)}, " + - phi"documentType=${Unsafe(documentType)}, providerType=${Unsafe(providerType)}, " + - phi"providerName=${Unsafe(providerName)})" - } - -} - -case class DirectReport(id: UuidId[DirectReport], - patientId: UuidId[Patient], - reportType: ReportType, - date: LocalDateTime, - documentType: String, - providerType: String, - providerName: String) diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala index b10f67a..9fc1992 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala @@ -1,6 +1,6 @@ package xyz.driver.pdsuidomain.entities -import java.time.LocalDateTime +import java.time.{LocalDate, LocalDateTime} import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.core.{JsonGenerator, JsonParser} @@ -101,15 +101,15 @@ object Document { startDate <- Validators.nonEmpty("startDate")(input.startDate) isOrderRight <- input.endDate match { - case Some(endDate) if startDate.isAfter(endDate) => - Validators.fail("The start date should be less, than the end one") + case Some(endDate) if startDate.isAfter(endDate) => + Validators.fail("The start date should be less, than the end one") - case _ => Validators.success(true) - } + case _ => Validators.success(true) + } areDatesInThePast <- { - val dates = List(input.startDate, input.endDate).flatten - val now = LocalDateTime.now() + val dates = List(input.startDate, input.endDate).flatten + val now = LocalDate.now() val hasInvalid = dates.exists(_.isAfter(now)) if (hasInvalid) Validators.fail("Dates should be in the past") @@ -129,17 +129,18 @@ case class Document(id: LongId[Document] = LongId(0L), recordId: LongId[MedicalRecord], physician: Option[String], typeId: Option[LongId[DocumentType]], // not null - providerName: Option[String], // not null + providerName: Option[String], // not null providerTypeId: Option[LongId[ProviderType]], // not null meta: Option[TextJson[Meta]], // not null - startDate: Option[LocalDateTime], // not null - endDate: Option[LocalDateTime], + startDate: Option[LocalDate], // not null + endDate: Option[LocalDate], lastUpdate: LocalDateTime) { import Document.Status._ if (previousStatus.nonEmpty) { - assert(AllPrevious.contains(previousStatus.get), s"Previous status has invalid value: ${previousStatus.get}") + assert(AllPrevious.contains(previousStatus.get), + s"Previous status has invalid value: ${previousStatus.get}") } // TODO: with the current business logic code this constraint sometimes harmful diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala index 5df5253..c0ead6f 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala @@ -23,12 +23,9 @@ object PatientCriterion { case None => None case Some(FuzzyValue.Maybe) => Some(FuzzyValue.Maybe) case Some(_) if criterionValue.isEmpty => Some(FuzzyValue.Maybe) - case Some(status) => - Some( - FuzzyValue.fromBoolean( - FuzzyValue.fromBoolean( - criterionValue.getOrElse(throw new IllegalArgumentException("Criterion should not be empty"))) == status - )) + case Some(status) => Some(FuzzyValue.fromBoolean( + FuzzyValue.fromBoolean(criterionValue.get) == status + )) } } diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabel.scala index 633a347..cb6f8a0 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabel.scala @@ -25,14 +25,13 @@ object PatientLabelEvidence { implicit def toPhiString(x: PatientLabelEvidence): PhiString = { import x._ phi"PatientLabelEvidence(id=$id, patientLabelId=$patientLabelId, value=${Unsafe(value)}, " + - phi"documentId=$documentId, evidenceId=$evidenceId, reportId=$reportId)" + phi"documentId=$documentId, evidenceId=$evidenceId)" } } -final case class PatientLabelEvidence(id: LongId[PatientLabelEvidence], - patientLabelId: LongId[PatientLabel], - value: FuzzyValue, - evidenceText: String, - reportId: Option[UuidId[DirectReport]], - documentId: Option[LongId[Document]], - evidenceId: Option[LongId[ExtractedData]]) +case class PatientLabelEvidence(id: LongId[PatientLabelEvidence], + patientLabelId: LongId[PatientLabel], + value: FuzzyValue, + evidenceText: String, + documentId: LongId[Document], + evidenceId: LongId[ExtractedData]) diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientDocument.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientDocument.scala index 88e1a45..8e72023 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientDocument.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientDocument.scala @@ -1,6 +1,6 @@ package xyz.driver.pdsuidomain.entities -import java.time.LocalDateTime +import java.time.LocalDate import xyz.driver.pdsuicommon.domain.{LongId, UuidId} import xyz.driver.pdsuicommon.logging._ @@ -13,7 +13,7 @@ case class RawPatientDocument(disease: String, documentId: LongId[Document], documentType: String, documentProviderType: String, - documentStartDate: LocalDateTime, + documentStartDate: LocalDate, documentStatus: Document.Status) object RawPatientDocument { diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientLabel.scala index e0cf06b..052b2fa 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientLabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientLabel.scala @@ -1,6 +1,6 @@ package xyz.driver.pdsuidomain.entities -import java.time.LocalDateTime +import java.time.LocalDate import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, UuidId} import xyz.driver.pdsuicommon.logging._ @@ -16,8 +16,8 @@ case class RawPatientLabel(patientId: UuidId[Patient], requestId: RecordRequestId, documentType: String, providerType: String, - startDate: LocalDateTime, - endDate: Option[LocalDateTime]) + startDate: LocalDate, + endDate: Option[LocalDate]) object RawPatientLabel { diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabelEvidenceDocument.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabelEvidenceDocument.scala index d696569..978c4b8 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabelEvidenceDocument.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/export/patient/ExportPatientLabelEvidenceDocument.scala @@ -1,6 +1,6 @@ package xyz.driver.pdsuidomain.entities.export.patient -import java.time.LocalDateTime +import java.time.LocalDate import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuicommon.logging._ @@ -10,7 +10,7 @@ case class ExportPatientLabelEvidenceDocument(documentId: LongId[Document], requestId: RecordRequestId, documentType: String, providerType: String, - date: LocalDateTime) + date: LocalDate) object ExportPatientLabelEvidenceDocument extends PhiLogging { -- cgit v1.2.3