diff options
author | Aleksandr <ognelisar@gmail.com> | 2017-10-12 10:44:54 +0700 |
---|---|---|
committer | Aleksandr <ognelisar@gmail.com> | 2017-10-12 10:44:54 +0700 |
commit | f525ab2604cc5d1366c852bdbcb4d912bbcea800 (patch) | |
tree | 4fe4b35e1f474e2dc85a8885dc4c9002f3ea46c2 /src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityCreateArm.scala | |
parent | 9198729ebf3d20b650b4467daa0d484a3148f01c (diff) | |
parent | e15415d69ec990d5243e58704e232e619b80aa6f (diff) | |
download | rest-query-f525ab2604cc5d1366c852bdbcb4d912bbcea800.tar.gz rest-query-f525ab2604cc5d1366c852bdbcb4d912bbcea800.tar.bz2 rest-query-f525ab2604cc5d1366c852bdbcb4d912bbcea800.zip |
All merge conflicts are resolved
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityCreateArm.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityCreateArm.scala | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityCreateArm.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityCreateArm.scala new file mode 100644 index 0000000..087fed5 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/eligibilityarm/ApiEligibilityCreateArm.scala @@ -0,0 +1,33 @@ +package xyz.driver.pdsuidomain.formats.json.eligibilityarm + +import play.api.libs.json.{Format, Json} +import xyz.driver.entities.patient.CancerType +import xyz.driver.pdsuicommon.domain.{LongId, StringId} +import xyz.driver.pdsuidomain.entities.{EligibilityArm, EligibilityArmDisease, EligibilityArmWithDiseases} + +final case class ApiCreateEligibilityArm(name: String, trialId: String, diseases: Seq[String]) { + + def toDomain: EligibilityArmWithDiseases = { + val eligibilityArm = EligibilityArm( + id = LongId(0), + name = name, + trialId = StringId(trialId), + originalName = name + ) + + EligibilityArmWithDiseases( + eligibilityArm, + diseases.map { disease => + val condition = CancerType + .fromString(disease) + .getOrElse(throw new NoSuchElementException(s"unknown condition $disease")) + EligibilityArmDisease(eligibilityArm.id, condition) + } + ) + } +} + +object ApiCreateEligibilityArm { + + implicit val format: Format[ApiCreateEligibilityArm] = Json.format[ApiCreateEligibilityArm] +} |