diff options
author | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-11-10 20:48:44 +0700 |
---|---|---|
committer | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-11-10 20:48:44 +0700 |
commit | dfdb1c689615ab79bafa4e904dc61a15db3bbffe (patch) | |
tree | 3f01d7d4c49edad0f843546ba1d5b18dbaad723b /src/main/scala/xyz/driver/pdsuidomain/entities | |
parent | 005b186725fac14b5361292456dd5025742b7646 (diff) | |
download | rest-query-dfdb1c689615ab79bafa4e904dc61a15db3bbffe.tar.gz rest-query-dfdb1c689615ab79bafa4e904dc61a15db3bbffe.tar.bz2 rest-query-dfdb1c689615ab79bafa4e904dc61a15db3bbffe.zip |
Fixed calculation of eligibility status with "Unknown" value (instead of NULL)
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/entities')
4 files changed, 25 insertions, 27 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala index 471d345..e9085ec 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/Document.scala @@ -7,7 +7,6 @@ import com.fasterxml.jackson.core.{JsonGenerator, JsonParser} import com.fasterxml.jackson.databind._ import com.fasterxml.jackson.databind.annotation.{JsonDeserialize, JsonSerialize} import xyz.driver.core.auth.User -import xyz.driver.pdsuicommon.compat.Implicits._ import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuicommon.logging._ import xyz.driver.pdsuicommon.utils.Utils diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientCriterion.scala index 7027eef..5d84a5c 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientCriterion.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientCriterion.scala @@ -19,17 +19,16 @@ object PatientCriterion { /** * @see https://driverinc.atlassian.net/wiki/display/MTCH/EV+Business+Process */ - def getEligibilityStatus(criterionValue: Option[Boolean], primaryValue: Option[LabelValue]): Option[LabelValue] = { + def getEligibilityStatus(criterionValue: Option[Boolean], primaryValue: LabelValue): LabelValue = { primaryValue match { - case None => None - case Some(LabelValue.Maybe) => Some(LabelValue.Maybe) - case Some(_) if criterionValue.isEmpty => Some(LabelValue.Maybe) - case Some(status) => - Some( + case LabelValue.Unknown => LabelValue.Unknown + case LabelValue.Maybe => LabelValue.Maybe + case _ if criterionValue.isEmpty => LabelValue.Maybe + case status => + LabelValue.fromBoolean( LabelValue.fromBoolean( - LabelValue.fromBoolean( - criterionValue.getOrElse(throw new IllegalArgumentException("Criterion should not be empty"))) == status - )) + criterionValue.getOrElse(throw new IllegalArgumentException("Criterion should not be empty"))) == status + ) } } @@ -48,13 +47,13 @@ final case class PatientCriterion(id: LongId[PatientCriterion], criterionText: String, criterionValue: Option[Boolean], criterionIsDefining: Boolean, - eligibilityStatus: Option[LabelValue], - verifiedEligibilityStatus: Option[LabelValue], + eligibilityStatus: LabelValue, + verifiedEligibilityStatus: LabelValue, isVerified: Boolean, isVisible: Boolean, lastUpdate: LocalDateTime, inclusion: Option[Boolean]) { - def isIneligibleForEv: Boolean = eligibilityStatus.contains(LabelValue.No) && isVerified + def isIneligibleForEv: Boolean = eligibilityStatus == LabelValue.No && isVerified } object PatientCriterionArm { diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala index ff272a8..179056a 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientEligibleTrial.scala @@ -38,22 +38,22 @@ object PatientTrialArmGroup { /** * @see https://driverinc.atlassian.net/wiki/display/DMPD/EV+Business+Process */ - def getEligibilityStatusForRc(criterionList: TraversableOnce[PatientCriterion]): Option[LabelValue] = { - def isEligible: Boolean = criterionList.forall(_.verifiedEligibilityStatus.contains(LabelValue.Yes)) - def isIneligible: Boolean = criterionList.exists(_.verifiedEligibilityStatus.contains(LabelValue.No)) - def isUnknown: Boolean = criterionList.forall(_.verifiedEligibilityStatus.isEmpty) + def getEligibilityStatusForRc(criterionList: TraversableOnce[PatientCriterion]): LabelValue = { + def isEligible: Boolean = criterionList.forall(_.verifiedEligibilityStatus == LabelValue.Yes) + def isIneligible: Boolean = criterionList.exists(_.verifiedEligibilityStatus == LabelValue.No) + def isUnknown: Boolean = criterionList.forall(_.verifiedEligibilityStatus == LabelValue.Unknown) - if (isEligible) Some(LabelValue.Yes) - else if (isIneligible) Some(LabelValue.No) - else if (isUnknown) None - else Some(LabelValue.Maybe) + if (isEligible) LabelValue.Yes + else if (isIneligible) LabelValue.No + else if (isUnknown) LabelValue.Unknown + else LabelValue.Maybe } } final case class PatientTrialArmGroup(id: LongId[PatientTrialArmGroup], eligibleTrialId: UuidId[PatientEligibleTrial], - eligibilityStatus: Option[LabelValue], - verifiedEligibilityStatus: Option[LabelValue], + eligibilityStatus: LabelValue, + verifiedEligibilityStatus: LabelValue, isVerified: Boolean) object PatientTrialArmGroupView { @@ -70,8 +70,8 @@ final case class PatientTrialArmGroupView(id: LongId[PatientTrialArmGroup], patientId: UuidId[Patient], trialId: StringId[Trial], hypothesisId: UuidId[Hypothesis], - eligibilityStatus: Option[LabelValue], - verifiedEligibilityStatus: Option[LabelValue], + eligibilityStatus: LabelValue, + verifiedEligibilityStatus: LabelValue, isVerified: Boolean) { def applyTo(trialArmGroup: PatientTrialArmGroup) = { diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabel.scala index 4c0f4ef..df86175 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/PatientLabel.scala @@ -17,8 +17,8 @@ final case class PatientLabel(id: LongId[PatientLabel], patientId: UuidId[Patient], labelId: LongId[Label], score: Int, - primaryValue: Option[LabelValue], - verifiedPrimaryValue: Option[LabelValue], + primaryValue: LabelValue, + verifiedPrimaryValue: LabelValue, isImplicitMatch: Boolean, isVisible: Boolean) |