diff options
author | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-11-13 18:29:45 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-13 18:29:45 +0700 |
commit | f9057970bcd4c5692ab519a1ee4f0e153999b1c3 (patch) | |
tree | ecc6eef91d2efc770e0ead65156ec098d47e6543 /src/main/scala/xyz/driver/pdsuidomain/entities | |
parent | 005b186725fac14b5361292456dd5025742b7646 (diff) | |
parent | 77b54e459d6478ae9685e8cac56ae21f08c263ef (diff) | |
download | rest-query-f9057970bcd4c5692ab519a1ee4f0e153999b1c3.tar.gz rest-query-f9057970bcd4c5692ab519a1ee4f0e153999b1c3.tar.bz2 rest-query-f9057970bcd4c5692ab519a1ee4f0e153999b1c3.zip |
Merge pull request #61 from drivergroup/PDSUI-2382
Fixed calculation of eligibility status with "Unknown" value
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/entities')
4 files changed, 26 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..193e8cb 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,14 @@ 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 + import scalaz.syntax.equal._ + 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) |