Skip to content

Commit

Permalink
add. check to avoid multiple save (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
abinaya-u authored Feb 2, 2024
1 parent 1ecd098 commit 4c325b6
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public Schedule saveMedicationSchedule(ScheduleMedicationRequest scheduleMedicat
savedSchedule = scheduleService.saveSchedule(schedule);
}
DrugOrder order = (DrugOrder) orderService.getOrderByUuid(scheduleMedicationRequest.getOrderUuid());
List<Slot> existingSlots = getMedicationSlots(patient.getUuid(),ServiceType.MEDICATION_REQUEST,new ArrayList<>(Arrays.asList(new String[]{order.getUuid()})));
if (existingSlots !=null && !existingSlots.isEmpty()) {
throw new RuntimeException("Slots already created for this drug order");
}
List<LocalDateTime> slotsStartTime = slotTimeCreationService.createSlotsStartTimeFrom(scheduleMedicationRequest, order);
slotFactory.createSlotsForMedicationFrom(savedSchedule, slotsStartTime, order, null, SCHEDULED, ServiceType.MEDICATION_REQUEST, scheduleMedicationRequest.getComments())
.forEach(slotService::saveSlot);
Expand Down

0 comments on commit 4c325b6

Please sign in to comment.