diff --git a/src/main/kotlin/application/handler/ProcessEventHandlers.kt b/src/main/kotlin/application/handler/ProcessEventHandlers.kt index 01445b0a..2593d6e6 100644 --- a/src/main/kotlin/application/handler/ProcessEventHandlers.kt +++ b/src/main/kotlin/application/handler/ProcessEventHandlers.kt @@ -14,6 +14,7 @@ import application.presenter.event.model.Event import application.presenter.event.model.ProcessEvent import application.presenter.event.model.SurgeryReportEvent import application.presenter.event.model.payloads.ProcessEventsPayloads +import application.presenter.event.serialization.toSurgeryReportDto import application.service.MedicalDeviceServices import application.service.PatientDataServices import application.service.SurgeryBookingServices @@ -292,7 +293,7 @@ object ProcessEventHandlers { ).execute(), ) }.filterPairs(), - ), + ).toSurgeryReportDto(), ), ) } diff --git a/src/main/kotlin/application/presenter/event/serialization/SurgeryReportDto.kt b/src/main/kotlin/application/presenter/event/serialization/SurgeryReportDto.kt new file mode 100644 index 00000000..a45bbda9 --- /dev/null +++ b/src/main/kotlin/application/presenter/event/serialization/SurgeryReportDto.kt @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023. Smart Operating Block + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + */ + +package application.presenter.event.serialization + +import entity.medicaldevice.ImplantableMedicalDevice +import entity.medicaldevice.MedicalTechnology +import entity.patient.PatientData +import entity.process.ProcessData +import entity.report.SurgeryReport +import kotlinx.serialization.Serializable + +/** + * The DTO of th Report of the Surgical Process. + * It includes: + * - the [processId] + * - the [processType] + * - the [patientId] + * - the [patientTaxCode] + * - the [healthProfessionalId] + * - the [preOperatingRoomId] + * - the [operatingRoomId] + * - the [processStates] + * - the [processSteps] + * - the [patientMedicalData] + * - the [medicalDeviceUsage] + * - the [medicalTechnologyUsage] + */ +@Serializable +data class SurgeryReportDto( + val processId: String, + val processType: String, + val patientId: String, + val patientTaxCode: String, + val healthProfessionalId: String, + val preOperatingRoomId: String, + val operatingRoomId: String, + val processStates: List>, + val processSteps: List>, + val patientMedicalData: List>, + val medicalDeviceUsage: List, + val medicalTechnologyUsage: List>, +) + +/** + * Extension function to convert a [SurgeryReport] to its [SurgeryReportDto]. + */ +fun SurgeryReport.toSurgeryReportDto() = + SurgeryReportDto( + this.processId.id, + this.processType, + this.patientId.id, + this.patientTaxCode?.code ?: "null", + this.healthProfessionalId?.id ?: "null", + this.preOperatingRoom?.id?.id ?: "null", + this.operatingRoom?.id?.id ?: "null", + this.processStates.map { Pair(it.first.toString(), it.second) }, + this.processSteps.map { Pair(it.first.toString(), it.second) }, + this.patientMedicalData.map { Pair(it.first.toString(), it.second) }, + this.medicalDeviceUsage, + this.medicalTechnologyUsage.map { Pair(it.first.toString(), it.second) }, + + )