Skip to content

Commit

Permalink
chore: update the event handler with medical technology data
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-acampora committed May 9, 2023
1 parent 7ac9b68 commit ab454ae
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/main/kotlin/application/handler/ProcessEventHandlers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,22 @@ object ProcessEventHandlers {
MedicalDeviceServices.GetMedicalDeviceUsageByProcessId(
surgicalProcess.id,
medicalDeviceRepository
).execute().toList().mapNotNull {
).execute().mapNotNull {
MedicalDeviceServices.GetMedicalDeviceById(it, medicalDeviceRepository).execute()
}
},
MedicalDeviceServices.GetMedicalTechnologyUsageByProcessId(
surgicalProcess.id,
medicalDeviceRepository
).execute().map {
Pair(
it.first,
MedicalDeviceServices.GetMedicalTechnologyById(
it.second,
medicalDeviceRepository,
it.third
).execute()
)
}.filterPairs()
)
)
)
Expand All @@ -291,6 +304,12 @@ object ProcessEventHandlers {
).execute()
}
PatientDataServices.DeletePatient(surgicalProcess.patientId, patientRepository).execute()
MedicalDeviceServices.GetMedicalDeviceUsageByProcessId(
surgicalProcess.id,
medicalDeviceRepository
).execute().forEach {
MedicalDeviceServices.DeleteImplantableMedicalDevice(it, medicalDeviceRepository).execute()
}
}
}

Expand Down Expand Up @@ -386,6 +405,14 @@ object ProcessEventHandlers {
operation()
} else false

/**
* Utility function to filter the null values of a list of pair.
*/
fun <T, U> List<Pair<T?, U?>>.filterPairs(): List<Pair<T, U>> =
mapNotNull { (t, u) ->
if (t == null || u == null) null else t to u
}

/**
* Utility function to check if a [SurgicalProcess] is over.
*/
Expand Down

0 comments on commit ab454ae

Please sign in to comment.