Skip to content

Commit

Permalink
chore: add method to update room in azure dt
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-acampora committed Apr 18, 2023
1 parent 49fcdbb commit b0ca8a2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/kotlin/infrastructure/digitaltwin/DigitalTwinManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import entity.patient.Patient
import entity.patient.PatientData
import entity.process.ProcessData
import entity.process.SurgicalProcess
import entity.room.Room
import entity.room.RoomData
import infrastructure.digitaltwin.presenter.PatientAdt.toDigitalTwin
import infrastructure.digitaltwin.presenter.SurgeryBookingAdt
Expand Down Expand Up @@ -137,6 +138,8 @@ class DigitalTwinManager :
),
BasicRelationship::class.java
)
process.preOperatingRoom?.let { room -> updateSurgicalProcessRoom(process.id, room) }
process.operatingRoom?.let { room -> updateSurgicalProcessRoom(process.id, room) }
}
true
}
Expand All @@ -157,6 +160,28 @@ class DigitalTwinManager :
true
}

override fun updateSurgicalProcessRoom(processId: ProcessData.ProcessId, room: Room): Boolean =
this.dtClient.applySafeDigitalTwinOperation(false) {
this.listRelationships(processId.id, BasicRelationship::class.java).forEach {
if (it.targetId == room.id.id) {
this.deleteRelationship(it.sourceId, it.id)
}
}.let {
this.createOrReplaceRelationship(
processId.id,
"${processId.id}-${room.id.id}",
BasicRelationship(
"${processId.id}-${room.id.id}",
processId.id,
room.id.id,
SurgicalProcessAdt.ROOM_RELATIONSHIP
),
BasicRelationship::class.java
)
}
true
}

override fun getSurgeryBookingByPatient(patientId: PatientData.PatientId): SurgeryBooking? =
this.dtClient.applySafeDigitalTwinOperation(null) {
val bookingId: String? = query(
Expand Down

0 comments on commit b0ca8a2

Please sign in to comment.