From deba20326e3269fee3ef51f8e6841f17453b4155 Mon Sep 17 00:00:00 2001 From: vlad Date: Thu, 28 Sep 2017 13:12:32 -0700 Subject: Simplified Export entities for EVLS --- .../pdsuidomain/entities/RawPatientLabel.scala | 4 +- .../ExportPatientLabelEvidenceDocument.scala | 6 +- .../json/export/ApiExportPatientLabel.scala | 28 ------- .../export/ApiExportPatientLabelEvidence.scala | 38 --------- .../ApiExportPatientLabelEvidenceDocument.scala | 46 ---------- .../json/export/ApiExportPatientWithLabels.scala | 31 ------- .../formats/json/export/ApiExportTrialArm.scala | 27 ------ .../json/export/ApiExportTrialLabelCriterion.scala | 55 ------------ .../json/export/ApiExportTrialWithLabels.scala | 53 ------------ .../formats/json/sprayformats/document.scala | 2 + .../formats/json/sprayformats/export.scala | 97 ++++++++++++---------- .../formats/json/sprayformats/record.scala | 2 + .../services/rest/RestExtractedDataService.scala | 9 +- .../services/rest/RestTrialService.scala | 8 +- 14 files changed, 74 insertions(+), 332 deletions(-) delete mode 100644 src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabel.scala delete mode 100644 src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidence.scala delete mode 100644 src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidenceDocument.scala delete mode 100644 src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala delete mode 100644 src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialArm.scala delete mode 100644 src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialLabelCriterion.scala delete mode 100644 src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala (limited to 'src/main/scala/xyz/driver') diff --git a/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientLabel.scala index 6114661..184782b 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientLabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/entities/RawPatientLabel.scala @@ -13,8 +13,8 @@ final case class RawPatientLabel(patientId: UuidId[Patient], disease: String, documentId: LongId[Document], requestId: RecordRequestId, - documentType: String, - providerType: String, + documentType: DocumentType, + providerType: ProviderType, startDate: LocalDate, endDate: Option[LocalDate]) 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 99912bc..7003615 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 @@ -4,12 +4,12 @@ import java.time.LocalDate import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuicommon.logging._ -import xyz.driver.pdsuidomain.entities.{Document, RawPatientLabel, RecordRequestId} +import xyz.driver.pdsuidomain.entities._ final case class ExportPatientLabelEvidenceDocument(documentId: LongId[Document], requestId: RecordRequestId, - documentType: String, - providerType: String, + documentType: DocumentType, + providerType: ProviderType, date: LocalDate) object ExportPatientLabelEvidenceDocument extends PhiLogging { diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabel.scala deleted file mode 100644 index 0ef1c68..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabel.scala +++ /dev/null @@ -1,28 +0,0 @@ -package xyz.driver.pdsuidomain.formats.json.export - -import play.api.libs.functional.syntax._ -import play.api.libs.json.{Format, JsPath} -import xyz.driver.pdsuicommon.domain.LongId -import xyz.driver.pdsuidomain.entities.export.patient.ExportPatientLabel - -final case class ApiExportPatientLabel(id: String, evidences: List[ApiExportPatientLabelEvidence]) { - - def toDomain = ExportPatientLabel( - id = LongId(this.id.toLong), - evidences = this.evidences.map(_.toDomain) - ) - -} - -object ApiExportPatientLabel { - - implicit val format: Format[ApiExportPatientLabel] = ( - (JsPath \ "labelId").format[String] and - (JsPath \ "evidence").format[List[ApiExportPatientLabelEvidence]] - )(ApiExportPatientLabel.apply, unlift(ApiExportPatientLabel.unapply)) - - def fromDomain(label: ExportPatientLabel) = ApiExportPatientLabel( - id = label.id.toString, - evidences = label.evidences.map(ApiExportPatientLabelEvidence.fromDomain) - ) -} diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidence.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidence.scala deleted file mode 100644 index d141762..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidence.scala +++ /dev/null @@ -1,38 +0,0 @@ -package xyz.driver.pdsuidomain.formats.json.export - -import play.api.libs.functional.syntax._ -import play.api.libs.json._ -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId} -import xyz.driver.pdsuidomain.entities.export.patient.ExportPatientLabelEvidence - -final case class ApiExportPatientLabelEvidence(evidenceId: String, - labelValue: String, - evidenceText: String, - document: ApiExportPatientLabelEvidenceDocument) { - - def toDomain = ExportPatientLabelEvidence( - id = LongId(this.evidenceId.toLong), - value = FuzzyValue.fromString - .applyOrElse(this.labelValue, (s: String) => throw new NoSuchElementException(s"Unknown fuzzy value $s")), - evidenceText = this.evidenceText, - document = this.document.toDomain - ) - -} - -object ApiExportPatientLabelEvidence { - - implicit val format: Format[ApiExportPatientLabelEvidence] = ( - (JsPath \ "evidenceId").format[String] and - (JsPath \ "labelValue").format[String](Writes[String](x => JsString(x.toUpperCase))) and - (JsPath \ "evidenceText").format[String] and - (JsPath \ "document").format[ApiExportPatientLabelEvidenceDocument] - )(ApiExportPatientLabelEvidence.apply, unlift(ApiExportPatientLabelEvidence.unapply)) - - def fromDomain(evidence: ExportPatientLabelEvidence) = ApiExportPatientLabelEvidence( - evidenceId = evidence.id.toString, - labelValue = FuzzyValue.valueToString(evidence.value), - evidenceText = evidence.evidenceText, - document = ApiExportPatientLabelEvidenceDocument.fromDomain(evidence.document) - ) -} diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidenceDocument.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidenceDocument.scala deleted file mode 100644 index 6999301..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidenceDocument.scala +++ /dev/null @@ -1,46 +0,0 @@ -package xyz.driver.pdsuidomain.formats.json.export - -import java.time.LocalDate -import java.util.UUID - -import play.api.libs.functional.syntax._ -import play.api.libs.json.{Format, JsPath} -import xyz.driver.pdsuicommon.domain.LongId -import xyz.driver.pdsuidomain.entities.RecordRequestId -import xyz.driver.pdsuidomain.entities.export.patient.ExportPatientLabelEvidenceDocument - -final case class ApiExportPatientLabelEvidenceDocument(documentId: String, - requestId: String, - documentType: String, - providerType: String, - date: LocalDate) { - - def toDomain = ExportPatientLabelEvidenceDocument( - documentId = LongId(this.documentId.toLong), - requestId = RecordRequestId(UUID.fromString(this.requestId)), - documentType = this.documentType, - providerType = this.providerType, - date = this.date - ) - -} - -object ApiExportPatientLabelEvidenceDocument { - - implicit val format: Format[ApiExportPatientLabelEvidenceDocument] = ( - (JsPath \ "documentId").format[String] and - (JsPath \ "requestId").format[String] and - (JsPath \ "documentType").format[String] and - (JsPath \ "providerType").format[String] and - (JsPath \ "date").format[LocalDate] - )(ApiExportPatientLabelEvidenceDocument.apply, unlift(ApiExportPatientLabelEvidenceDocument.unapply)) - - def fromDomain(document: ExportPatientLabelEvidenceDocument) = - ApiExportPatientLabelEvidenceDocument( - documentId = document.documentId.toString, - requestId = document.requestId.toString, - documentType = document.documentType, - providerType = document.providerType, - date = document.date - ) -} diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala deleted file mode 100644 index fc9bab7..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala +++ /dev/null @@ -1,31 +0,0 @@ -package xyz.driver.pdsuidomain.formats.json.export - -import play.api.libs.functional.syntax._ -import play.api.libs.json.{Format, JsPath} -import xyz.driver.pdsuicommon.domain.UuidId -import xyz.driver.pdsuidomain.entities.export.patient.ExportPatientWithLabels - -final case class ApiExportPatientWithLabels(patientId: String, labelVersion: Long, labels: List[ApiExportPatientLabel]) { - - def toDomain = ExportPatientWithLabels( - patientId = UuidId(this.patientId), - labelVersion = this.labelVersion, - labels = this.labels.map(_.toDomain) - ) - -} - -object ApiExportPatientWithLabels { - - implicit val format: Format[ApiExportPatientWithLabels] = ( - (JsPath \ "patientId").format[String] and - (JsPath \ "labelVersion").format[Long] and - (JsPath \ "labels").format[List[ApiExportPatientLabel]] - )(ApiExportPatientWithLabels.apply, unlift(ApiExportPatientWithLabels.unapply)) - - def fromDomain(patient: ExportPatientWithLabels) = ApiExportPatientWithLabels( - patientId = patient.patientId.toString, - labelVersion = patient.labelVersion, - labels = patient.labels.map(ApiExportPatientLabel.fromDomain) - ) -} diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialArm.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialArm.scala deleted file mode 100644 index ea96f58..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialArm.scala +++ /dev/null @@ -1,27 +0,0 @@ -package xyz.driver.pdsuidomain.formats.json.export - -import play.api.libs.functional.syntax._ -import play.api.libs.json._ -import xyz.driver.pdsuicommon.domain.LongId -import xyz.driver.pdsuidomain.entities.Arm -import xyz.driver.pdsuidomain.entities.export.trial.ExportTrialArm - -final case class ApiExportTrialArm(armId: String, armName: String) { - - def toDomain: ExportTrialArm = { - ExportTrialArm(LongId[Arm](armId.toLong), armName) - } -} - -object ApiExportTrialArm { - - implicit val format: Format[ApiExportTrialArm] = ( - (JsPath \ "armId").format[String] and - (JsPath \ "armName").format[String] - )(ApiExportTrialArm.apply, unlift(ApiExportTrialArm.unapply)) - - def fromDomain(arm: ExportTrialArm) = ApiExportTrialArm( - armId = arm.armId.toString, - armName = arm.armName - ) -} diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialLabelCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialLabelCriterion.scala deleted file mode 100644 index df1ebb4..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialLabelCriterion.scala +++ /dev/null @@ -1,55 +0,0 @@ -package xyz.driver.pdsuidomain.formats.json.export - -import play.api.libs.functional.syntax._ -import play.api.libs.json._ -import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId} -import xyz.driver.pdsuidomain.entities.export.trial.ExportTrialLabelCriterion -import xyz.driver.pdsuidomain.entities.{Arm, Criterion, Label} - -final case class ApiExportTrialLabelCriterion(value: String, - labelId: String, - criterionId: String, - criterionText: String, - armIds: List[String], - isCompound: Boolean, - isDefining: Boolean) { - - def toDomain: ExportTrialLabelCriterion = { - ExportTrialLabelCriterion( - LongId[Criterion](criterionId.toLong), - FuzzyValue.fromString.lift(value).map(_ == FuzzyValue.Yes), - LongId[Label](labelId.toLong), - armIds.map(armId => LongId[Arm](armId.toLong)).toSet, - criterionText, - isCompound, - isDefining - ) - } -} - -object ApiExportTrialLabelCriterion { - - implicit val format: Format[ApiExportTrialLabelCriterion] = ( - (JsPath \ "value").format[String](Writes[String](x => JsString(x.toUpperCase))) and - (JsPath \ "labelId").format[String] and - (JsPath \ "criterionId").format[String] and - (JsPath \ "criterionText").format[String] and - (JsPath \ "armIds").format[List[String]] and - (JsPath \ "isCompound").format[Boolean] and - (JsPath \ "isDefining").format[Boolean] - )(ApiExportTrialLabelCriterion.apply, unlift(ApiExportTrialLabelCriterion.unapply)) - - def fromDomain(x: ExportTrialLabelCriterion) = ApiExportTrialLabelCriterion( - value = x.value - .map { x => - FuzzyValue.valueToString(FuzzyValue.fromBoolean(x)) - } - .getOrElse("Unknown"), - labelId = x.labelId.toString, - criterionId = x.criterionId.toString, - criterionText = x.criteria, - armIds = x.armIds.map(_.toString).toList, - isCompound = x.isCompound, - isDefining = x.isDefining - ) -} diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala deleted file mode 100644 index e383a1f..0000000 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala +++ /dev/null @@ -1,53 +0,0 @@ -package xyz.driver.pdsuidomain.formats.json.export - -import java.time.{Instant, ZoneId} - -import play.api.libs.functional.syntax._ -import play.api.libs.json.{Format, JsPath} -import xyz.driver.pdsuicommon.domain.{StringId, UuidId} -import xyz.driver.pdsuidomain.entities.Trial -import xyz.driver.pdsuidomain.entities.export.trial.ExportTrialWithLabels - -final case class ApiExportTrialWithLabels(nctId: String, - trialId: String, - condition: String, - lastReviewed: Long, - labelVersion: Long, - arms: List[ApiExportTrialArm], - criteria: List[ApiExportTrialLabelCriterion]) { - - def toDomain: ExportTrialWithLabels = { - ExportTrialWithLabels( - StringId[Trial](nctId), - UuidId[Trial](trialId), - condition, - lastReviewed = Instant.ofEpochMilli(lastReviewed).atZone(ZoneId.of("Z")).toLocalDateTime, - labelVersion, - arms.map(_.toDomain), - criteria.map(_.toDomain) - ) - } -} - -object ApiExportTrialWithLabels { - - implicit val format: Format[ApiExportTrialWithLabels] = ( - (JsPath \ "nctId").format[String] and - (JsPath \ "trialId").format[String] and - (JsPath \ "disease").format[String] and - (JsPath \ "lastReviewed").format[Long] and - (JsPath \ "labelVersion").format[Long] and - (JsPath \ "arms").format[List[ApiExportTrialArm]] and - (JsPath \ "criteria").format[List[ApiExportTrialLabelCriterion]] - )(ApiExportTrialWithLabels.apply, unlift(ApiExportTrialWithLabels.unapply)) - - def fromDomain(x: ExportTrialWithLabels) = ApiExportTrialWithLabels( - nctId = x.nctId.id, - trialId = x.trialId.toString, - condition = x.condition, - lastReviewed = x.lastReviewed.atZone(ZoneId.of("Z")).toEpochSecond, - labelVersion = x.labelVersion, - arms = x.arms.map(ApiExportTrialArm.fromDomain), - criteria = x.criteria.map(ApiExportTrialLabelCriterion.fromDomain) - ) -} diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/document.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/document.scala index baf1b4e..ff0603a 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/document.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/document.scala @@ -28,6 +28,8 @@ object document { implicit val documentMetaFormat: RootJsonFormat[Meta] = jsonFormat3(Meta.apply) + implicit val documentTypeFormat: RootJsonFormat[DocumentType] = jsonFormat2(DocumentType.apply) + implicit val fullDocumentMetaFormat = new RootJsonFormat[TextJson[Meta]] { override def write(obj: TextJson[Meta]): JsValue = obj.content.toJson override def read(json: JsValue) = TextJson(documentMetaFormat.read(json)) diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala index 20b6ed0..2a1fe46 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/export.scala @@ -1,6 +1,7 @@ package xyz.driver.pdsuidomain.formats.json.sprayformats import spray.json._ +import xyz.driver.pdsuidomain.entities.{Arm, Criterion, Label} import xyz.driver.pdsuidomain.entities.export.patient._ import xyz.driver.pdsuidomain.entities.export.trial.{ExportTrialArm, ExportTrialLabelCriterion, ExportTrialWithLabels} @@ -8,42 +9,24 @@ object export { import DefaultJsonProtocol._ import common._ import record._ + import document._ - implicit val patientLabelEvidenceDocumentFormat: RootJsonFormat[ExportPatientLabelEvidenceDocument] = jsonFormat5( - ExportPatientLabelEvidenceDocument.apply) + implicit val patientLabelEvidenceDocumentFormat: RootJsonFormat[ExportPatientLabelEvidenceDocument] = + jsonFormat5(ExportPatientLabelEvidenceDocument.apply) - implicit val patientLabelEvidenceWriter: JsonWriter[ExportPatientLabelEvidence] = - new JsonWriter[ExportPatientLabelEvidence] { - override def write(obj: ExportPatientLabelEvidence): JsValue = - JsObject( - "evidenceId" -> obj.id.toJson, - "labelValue" -> obj.value.toJson, - "evidenceText" -> obj.evidenceText.toJson, - "document" -> obj.document.toJson - ) - } + implicit val patientLabelEvidenceFormat: RootJsonFormat[ExportPatientLabelEvidence] = + jsonFormat(ExportPatientLabelEvidence.apply, "evidenceId", "labelValue", "evidenceText", "document") - implicit val patientLabelWriter: JsonWriter[ExportPatientLabel] = new JsonWriter[ExportPatientLabel] { - override def write(obj: ExportPatientLabel): JsValue = - JsObject( - "labelId" -> obj.id.toJson, - "evidence" -> obj.evidences.map(_.toJson).toJson - ) - } + implicit val patientLabelFormat: RootJsonFormat[ExportPatientLabel] = + jsonFormat(ExportPatientLabel.apply, "labelId", "evidence") - implicit val patientWithLabelsWriter: JsonWriter[ExportPatientWithLabels] = new JsonWriter[ExportPatientWithLabels] { - override def write(obj: ExportPatientWithLabels): JsValue = - JsObject( - "patientId" -> obj.patientId.toJson, - "labelVersion" -> obj.labelVersion.toJson, - "labels" -> obj.labels.map(_.toJson).toJson - ) - } + implicit val patientWithLabelsFormat: RootJsonFormat[ExportPatientWithLabels] = + jsonFormat(ExportPatientWithLabels.apply, "patientId", "labelVersion", "labels") implicit val trialArmFormat: RootJsonFormat[ExportTrialArm] = jsonFormat2(ExportTrialArm.apply) - implicit val trialLabelCriterionWriter: JsonWriter[ExportTrialLabelCriterion] = - new JsonWriter[ExportTrialLabelCriterion] { + implicit val trialLabelCriterionFormat: RootJsonFormat[ExportTrialLabelCriterion] = + new RootJsonFormat[ExportTrialLabelCriterion] { override def write(obj: ExportTrialLabelCriterion): JsValue = JsObject( "value" -> obj.value @@ -60,19 +43,49 @@ object export { "isCompound" -> obj.isCompound.toJson, "isDefining" -> obj.isDefining.toJson ) - } - implicit val trialWithLabelsWriter: JsonWriter[ExportTrialWithLabels] = new JsonWriter[ExportTrialWithLabels] { - override def write(obj: ExportTrialWithLabels) = - JsObject( - "nctId" -> obj.nctId.toJson, - "trialId" -> obj.trialId.toJson, - "disease" -> obj.condition.toJson, - "lastReviewed" -> obj.lastReviewed.toJson, - "labelVersion" -> obj.labelVersion.toJson, - "arms" -> obj.arms.toJson, - "criteria" -> obj.criteria.map(_.toJson).toJson - ) - } + override def read(json: JsValue): ExportTrialLabelCriterion = { + + val fields = Seq("value", "labelId", "criterionId", "criterionText", "armIds", "isCompound", "isDefining") + + json.asJsObject.getFields(fields: _*) match { + case Seq(JsString(valueString), + labelId, + criterionId, + JsString(criterionText), + JsArray(armIdsVector), + JsBoolean(isCompound), + JsBoolean(isDefining)) => + val value = valueString match { + case "Yes" => Option(true) + case "No" => Option(false) + case "Unknown" => Option.empty[Boolean] + } + + ExportTrialLabelCriterion( + longIdFormat[Criterion].read(criterionId), + value, + longIdFormat[Label].read(labelId), + armIdsVector.map(longIdFormat[Arm].read).toSet, + criterionText, + isCompound, + isDefining + ) + + case _ => + deserializationError( + s"Cannot find required fields ${fields.mkString(", ")} in ExportTrialLabelCriterion object!") + } + } + } + implicit val trialWithLabelsFormat: RootJsonFormat[ExportTrialWithLabels] = + jsonFormat(ExportTrialWithLabels.apply, + "nctId", + "trialId", + "disease", + "lastReviewed", + "labelVersion", + "arms", + "criteria") } diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/record.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/record.scala index e378dbd..6b69873 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/record.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/record.scala @@ -36,6 +36,8 @@ object record { } } + implicit val providerTypeFormat = jsonFormat2(ProviderType.apply) + implicit val caseIdFormat = new RootJsonFormat[CaseId] { override def write(caseId: CaseId): JsString = JsString(caseId.toString) override def read(json: JsValue): CaseId = json match { diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestExtractedDataService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestExtractedDataService.scala index 53b9f38..a65e1f4 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestExtractedDataService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestExtractedDataService.scala @@ -1,7 +1,6 @@ package xyz.driver.pdsuidomain.services.rest import scala.concurrent.{ExecutionContext, Future} - import akka.http.scaladsl.marshalling.Marshal import akka.http.scaladsl.model._ import akka.stream.Materializer @@ -10,10 +9,12 @@ import xyz.driver.pdsuicommon.auth._ import xyz.driver.pdsuicommon.db._ import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuidomain.entities._ +import xyz.driver.pdsuidomain.entities.export.patient.ExportPatientWithLabels import xyz.driver.pdsuidomain.formats.json.ListResponse -import xyz.driver.pdsuidomain.formats.json.export.ApiExportPatientWithLabels import xyz.driver.pdsuidomain.formats.json.extracteddata.ApiExtractedData import xyz.driver.pdsuidomain.services.ExtractedDataService +import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ +import xyz.driver.pdsuidomain.formats.json.sprayformats.export._ class RestExtractedDataService(transport: ServiceTransport, baseUri: Uri)( implicit protected val materializer: Materializer, @@ -88,9 +89,9 @@ class RestExtractedDataService(transport: ServiceTransport, baseUri: Uri)( val request = HttpRequest(HttpMethods.GET, endpointUri(baseUri, s"/v1/export/patient/$id")) for { response <- transport.sendRequestGetResponse(requestContext)(request) - reply <- apiResponse[ApiExportPatientWithLabels](response) + reply <- apiResponse[ExportPatientWithLabels](response) } yield { - GetPatientLabelsReply.Entity(reply.toDomain) + GetPatientLabelsReply.Entity(reply) } } diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestTrialService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestTrialService.scala index b77e6df..7e33919 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestTrialService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestTrialService.scala @@ -12,10 +12,12 @@ import xyz.driver.pdsuicommon.auth._ import xyz.driver.pdsuicommon.db._ import xyz.driver.pdsuicommon.domain._ import xyz.driver.pdsuidomain.entities._ +import xyz.driver.pdsuidomain.entities.export.trial.ExportTrialWithLabels import xyz.driver.pdsuidomain.formats.json.ListResponse -import xyz.driver.pdsuidomain.formats.json.export.ApiExportTrialWithLabels import xyz.driver.pdsuidomain.formats.json.trial.ApiTrial import xyz.driver.pdsuidomain.services.TrialService +import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ +import xyz.driver.pdsuidomain.formats.json.sprayformats.export._ class RestTrialService(transport: ServiceTransport, baseUri: Uri)(implicit protected val materializer: Materializer, protected val exec: ExecutionContext) @@ -39,9 +41,9 @@ class RestTrialService(transport: ServiceTransport, baseUri: Uri)(implicit prote val request = HttpRequest(HttpMethods.GET, endpointUri(baseUri, s"/v1/export/trial/$disease/$trialId")) for { response <- transport.sendRequestGetResponse(requestContext)(request) - reply <- apiResponse[ApiExportTrialWithLabels](response) + reply <- apiResponse[ExportTrialWithLabels](response) } yield { - GetTrialWithLabelsReply.Entity(reply.toDomain) + GetTrialWithLabelsReply.Entity(reply) } } -- cgit v1.2.3