Skip to content

Commit

Permalink
chore: add control to check if process is over
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-acampora committed Apr 18, 2023
1 parent 75357b0 commit 49fcdbb
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/main/kotlin/application/handler/PatientEventHandlers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package application.handler

import application.handler.ProcessEventHandlers.cast
import application.handler.ProcessEventHandlers.isSurgicalProcessOver
import application.presenter.event.model.Event
import application.presenter.event.model.ProcessEvent
import application.presenter.event.model.payloads.ProcessEventsPayloads
Expand Down Expand Up @@ -38,18 +39,22 @@ object PatientEventHandlers {

override fun consume(event: Event<*>) {
event.cast<ProcessEvent<ProcessEventsPayloads.PatientOnOperatingTable>> {
SurgicalProcessServices.UpdateSurgicalProcessState(
ProcessData.ProcessId(this.data.processId),
Instant.parse(this.dateTime),
ProcessData.ProcessState.SURGERY,
surgicalProcessRepository
).execute() &&
SurgicalProcessServices.UpdateSurgicalProcessStep(
if (!isSurgicalProcessOver(this.data.processId, surgicalProcessRepository)) {
SurgicalProcessServices.UpdateSurgicalProcessState(
ProcessData.ProcessId(this.data.processId),
Instant.parse(this.dateTime),
ProcessData.ProcessStep.PATIENT_ON_OPERATING_TABLE,
ProcessData.ProcessState.SURGERY,
surgicalProcessRepository
).execute()
).execute() &&
SurgicalProcessServices.UpdateSurgicalProcessStep(
ProcessData.ProcessId(this.data.processId),
Instant.parse(this.dateTime),
ProcessData.ProcessStep.PATIENT_ON_OPERATING_TABLE,
surgicalProcessRepository
).execute()
} else {
false
}
}
}
}
Expand Down

0 comments on commit 49fcdbb

Please sign in to comment.