aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvlad <vlad@driver.xyz>2017-11-02 13:38:23 -0700
committervlad <vlad@driver.xyz>2017-11-02 13:38:23 -0700
commit144d8da225d18584dbc19589ba735b84cf3b6637 (patch)
tree17f8f196f857ed1cb36399c9efd6c78ab4382fe1 /src
parent022e55f0723cbb957e77a06e717e3df847abb00c (diff)
downloadrest-query-144d8da225d18584dbc19589ba735b84cf3b6637.tar.gz
rest-query-144d8da225d18584dbc19589ba735b84cf3b6637.tar.bz2
rest-query-144d8da225d18584dbc19589ba735b84cf3b6637.zip
PDSUI-2329 Removing `isRationaleRequired` field from the `PatientHypothesis`v0.12.3
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/xyz/driver/pdsuicommon/resources/ResourcesStorage.scala36
-rw-r--r--src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala8
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala10
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/formats/json/patienthypothesis.scala15
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/services/PatientHypothesisService.scala12
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHypothesisFormatSuite.scala21
6 files changed, 7 insertions, 95 deletions
diff --git a/src/main/scala/xyz/driver/pdsuicommon/resources/ResourcesStorage.scala b/src/main/scala/xyz/driver/pdsuicommon/resources/ResourcesStorage.scala
deleted file mode 100644
index 2be7ed7..0000000
--- a/src/main/scala/xyz/driver/pdsuicommon/resources/ResourcesStorage.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-package xyz.driver.pdsuicommon.resources
-
-import scala.io.{Codec, Source}
-
-trait ResourcesStorage {
-
- /**
- * @param resourcePath Don't forget / at start
- */
- def getFirstLine(resourcePath: String): String
-}
-
-object RealResourcesStorage extends ResourcesStorage {
-
- def getFirstLine(resourcePath: String): String = {
- val resourceUrl = getClass.getResource(resourcePath)
- Option(resourceUrl) match {
- case Some(url) =>
- val source = Source.fromURL(resourceUrl)(Codec.UTF8)
- try {
- val lines = source.getLines()
- if (lines.isEmpty) throw new RuntimeException(s"'$resourcePath' is empty")
- else lines.next()
- } finally {
- source.close()
- }
- case None =>
- throw new RuntimeException(s"Can not find the '$resourcePath'!")
- }
- }
-}
-
-object FakeResourcesStorage extends ResourcesStorage {
-
- def getFirstLine(resourcePath: String): String = ""
-}
diff --git a/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala b/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala
index 4ff3993..f617a20 100644
--- a/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala
+++ b/src/main/scala/xyz/driver/pdsuicommon/utils/CustomSwaggerJsonFormats.scala
@@ -20,7 +20,6 @@ import xyz.driver.pdsuidomain.services.CriterionService.RichCriterion
import xyz.driver.pdsuidomain.services.ExtractedDataService.RichExtractedData
import xyz.driver.pdsuidomain.services.PatientCriterionService.{DraftPatientCriterion, RichPatientCriterion}
import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial
-import xyz.driver.pdsuidomain.services.PatientHypothesisService.RichPatientHypothesis
import xyz.driver.pdsuidomain.services.PatientLabelService.RichPatientLabel
import scala.collection.immutable
@@ -56,7 +55,7 @@ object CustomSwaggerJsonFormats {
trait RichPatientLabelListResponse
trait RichPatientCriterionListResponse
trait RichPatientEligibleTrialListResponse
- trait RichPatientHypothesisListResponse
+ trait PatientHypothesisListResponse
trait PatientLabelEvidenceViewListResponse
trait QueueUploadItemListResponse
@@ -200,7 +199,6 @@ object CustomSwaggerJsonFormats {
classOf[PatientLabelEvidenceView] -> patientLabelEvidenceWriter.write(nextPatientLabelEvidenceView()),
classOf[RichPatientEligibleTrial] -> patientEligibleTrialWriter.write(nextRichPatientEligibleTrial()),
classOf[PatientHypothesis] -> patientHypothesisWriter.write(nextPatientHypothesis()),
- classOf[RichPatientHypothesis] -> richPatientHypothesisWriter.write(nextRichPatientHypothesis()),
classOf[PatientHistory] -> patientHistoryFormat.write(nextPatientHistory()),
classOf[PatientIssue] -> patientIssueWriter.write(nextPatientIssue()),
classOf[PatientListResponse] -> listResponseWriter[Patient].write(nextPatientListResponse()),
@@ -213,8 +211,8 @@ object CustomSwaggerJsonFormats {
nextPatientLabelEvidenceViewListResponse()),
classOf[RichPatientEligibleTrialListResponse] -> listResponseWriter[RichPatientEligibleTrial].write(
nextRichPatientEligibleTrialListResponse()),
- classOf[RichPatientHypothesisListResponse] -> listResponseWriter[RichPatientHypothesis].write(
- nextRichPatientHypothesisListResponse()),
+ classOf[PatientHypothesisListResponse] -> listResponseWriter[PatientHypothesis].write(
+ nextPatientHypothesisListResponse()),
classOf[PatientIssueListResponse] -> listResponseWriter[PatientIssue].write(nextPatientIssuesListResponse()),
classOf[PatientHistoryListResponse] -> listResponseWriter[PatientHistory].write(nextPatientHistoryListResponse())
) ++ customCommonObjectsExamples
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala
index e4d7de6..713c711 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/treatmentmatching.scala
@@ -8,7 +8,6 @@ import xyz.driver.pdsuidomain.ListResponse
import xyz.driver.pdsuidomain.entities._
import xyz.driver.pdsuidomain.services.PatientCriterionService.{DraftPatientCriterion, RichPatientCriterion}
import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial
-import xyz.driver.pdsuidomain.services.PatientHypothesisService.RichPatientHypothesis
import xyz.driver.pdsuidomain.services.PatientLabelService.RichPatientLabel
import eu.timepit.refined.{refineV, refineMV}
@@ -173,11 +172,6 @@ object treatmentmatching {
}
)
- def nextRichPatientHypothesis(): RichPatientHypothesis = RichPatientHypothesis(
- patientHypothesis = nextPatientHypothesis(),
- isRequired = generators.nextBoolean()
- )
-
def nextPatientIssue(): PatientIssue = PatientIssue(
id = nextLongId[PatientIssue],
userId = nextStringId[User],
@@ -222,8 +216,8 @@ object treatmentmatching {
nextListResponse(xs)
}
- def nextRichPatientHypothesisListResponse(): ListResponse[RichPatientHypothesis] = {
- val xs: Seq[RichPatientHypothesis] = Seq.fill(3)(nextRichPatientHypothesis())
+ def nextPatientHypothesisListResponse(): ListResponse[PatientHypothesis] = {
+ val xs: Seq[PatientHypothesis] = Seq.fill(3)(nextPatientHypothesis())
nextListResponse(xs)
}
diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienthypothesis.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienthypothesis.scala
index a459158..da991a4 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienthypothesis.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/patienthypothesis.scala
@@ -2,7 +2,6 @@ package xyz.driver.pdsuidomain.formats.json
import spray.json._
import xyz.driver.pdsuidomain.entities._
-import xyz.driver.pdsuidomain.services.PatientHypothesisService.RichPatientHypothesis
object patienthypothesis {
import DefaultJsonProtocol._
@@ -20,20 +19,6 @@ object patienthypothesis {
case _ => deserializationError(s"Expected Json Object as partial PatientHypothesis, but got $json")
}
- implicit val richPatientHypothesisWriter: RootJsonWriter[RichPatientHypothesis] =
- new RootJsonWriter[RichPatientHypothesis] {
- override def write(obj: RichPatientHypothesis): JsValue = {
- JsObject(
- "id" -> obj.patientHypothesis.id.toJson,
- "patientId" -> obj.patientHypothesis.patientId.toJson,
- "hypothesisId" -> obj.patientHypothesis.hypothesisId.toJson,
- "matchedTrials" -> obj.patientHypothesis.matchedTrials.toJson,
- "rationale" -> obj.patientHypothesis.rationale.toJson,
- "isRationaleRequired" -> obj.isRequired.toJson
- )
- }
- }
-
implicit val patientHypothesisWriter: RootJsonWriter[PatientHypothesis] =
new RootJsonWriter[PatientHypothesis] {
override def write(obj: PatientHypothesis): JsValue = {
diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/PatientHypothesisService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/PatientHypothesisService.scala
index 07734ed..1e655d5 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/services/PatientHypothesisService.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/services/PatientHypothesisService.scala
@@ -23,17 +23,9 @@ object PatientHypothesisService {
def userMessage: String = "Access denied"
}
- final case class RichPatientHypothesis(patientHypothesis: PatientHypothesis, isRequired: Boolean)
-
- object RichPatientHypothesis {
- implicit def toPhiString(x: RichPatientHypothesis): PhiString = {
- phi"RichPatientHypothesis(patientHypothesis=${x.patientHypothesis}, isRequired=${x.isRequired})"
- }
- }
-
sealed trait GetListReply
object GetListReply {
- final case class EntityList(xs: Seq[RichPatientHypothesis], totalFound: Int) extends GetListReply
+ final case class EntityList(xs: Seq[PatientHypothesis], totalFound: Int) extends GetListReply
case object AuthorizationError
extends GetListReply with DomainError.AuthorizationError with DefaultAccessDeniedError
@@ -46,7 +38,7 @@ object PatientHypothesisService {
sealed trait GetByIdReply
object GetByIdReply {
- final case class Entity(x: RichPatientHypothesis) extends GetByIdReply
+ final case class Entity(x: PatientHypothesis) extends GetByIdReply
type Error = GetByIdReply with DomainError
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHypothesisFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHypothesisFormatSuite.scala
index 7ff1109..560b1b6 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHypothesisFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHypothesisFormatSuite.scala
@@ -5,32 +5,11 @@ import spray.json._
import org.scalatest.{FlatSpec, Matchers}
import xyz.driver.pdsuicommon.domain.UuidId
import xyz.driver.pdsuidomain.entities.PatientHypothesis
-import xyz.driver.pdsuidomain.services.PatientHypothesisService.RichPatientHypothesis
import eu.timepit.refined.refineMV
class PatientHypothesisFormatSuite extends FlatSpec with Matchers {
import xyz.driver.pdsuidomain.formats.json.patienthypothesis._
- "Json format for RichPatientHypothesis" 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 = refineMV[NonNegative](1)
- )
- val writtenJson = richPatientHypothesisWriter.write(RichPatientHypothesis(orig, isRequired = 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)
- }
-
"Json format for patientHypothesis" should "read and write correct JSON" in {
val orig = PatientHypothesis(
id = UuidId("815d9715-1089-4775-b120-3afb983b9a97"),