Skip to content

Commit

Permalink
chore: create dto for surgery report event
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-acampora committed May 17, 2023
1 parent 3b0de8d commit 8c9593d
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/kotlin/application/handler/ProcessEventHandlers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -292,7 +293,7 @@ object ProcessEventHandlers {
).execute(),
)
}.filterPairs(),
),
).toSurgeryReportDto(),
),
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Pair<String, ProcessData.ProcessState>>,
val processSteps: List<Pair<String, ProcessData.ProcessStep>>,
val patientMedicalData: List<Pair<String, PatientData.MedicalData>>,
val medicalDeviceUsage: List<ImplantableMedicalDevice>,
val medicalTechnologyUsage: List<Pair<String, MedicalTechnology>>,
)

/**
* 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) },

)

0 comments on commit 8c9593d

Please sign in to comment.