From 9d8e1662427a2875d773623100e4de20c66af614 Mon Sep 17 00:00:00 2001 From: Soorya Kumaran C <90232857+SooryaKumaranC-tw@users.noreply.github.com> Date: Sun, 14 Apr 2024 00:42:11 +0530 Subject: [PATCH] Update and Refactor the rollover and shift start task --- .../openmrs/module/ipd/api/events/IPDEventUtils.java | 1 - .../handler/impl/RolloverTaskEventHandler.java | 12 ++++-------- .../handler/impl/ShiftStartTaskEventHandler.java | 8 +------- .../module/ipd/api/events/model/IPDEvent.java | 1 - .../scheduler/tasks/RollOverNonMedicationTasks.java | 2 +- .../ipd/api/scheduler/tasks/ShiftStartTasks.java | 2 +- .../ipd/postprocessor/IPDTransactionHandler.java | 2 +- 7 files changed, 8 insertions(+), 20 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/ipd/api/events/IPDEventUtils.java b/api/src/main/java/org/openmrs/module/ipd/api/events/IPDEventUtils.java index 1825821..b9da7ab 100644 --- a/api/src/main/java/org/openmrs/module/ipd/api/events/IPDEventUtils.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/IPDEventUtils.java @@ -14,7 +14,6 @@ public static TaskRequest createNonMedicationTaskRequest(IPDEvent ipdEvent, Stri taskRequest.setTaskType(taskType); taskRequest.setEncounterUuid(ipdEvent.getEncounterUuid()); taskRequest.setPatientUuid(ipdEvent.getPatientUuid()); - taskRequest.setVisitUuid(ipdEvent.getVisitUuid()); taskRequest.setRequestedStartTime(new Date()); taskRequest.setIntent(FhirTask.TaskIntent.ORDER); taskRequest.setStatus(FhirTask.TaskStatus.REQUESTED); diff --git a/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/RolloverTaskEventHandler.java b/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/RolloverTaskEventHandler.java index 978e8c7..59e59e3 100644 --- a/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/RolloverTaskEventHandler.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/RolloverTaskEventHandler.java @@ -40,19 +40,15 @@ public void handleEvent(IPDEvent event) { List taskNames = eventConfig.getTasks().stream() .map(TaskDetail::getName) .collect(Collectors.toList()); - - List rolloverTasks = taskService.getTasksByNameAndStatus(taskNames, TASK_STATUS); - + List rolloverTasks = taskService.getTasksByNameAndStatus(taskNames, FhirTask.TaskStatus.REQUESTED); List fhirTaskRequestedPeriods = new ArrayList(); for (Task task : rolloverTasks) { if (task.getFhirTaskRequestedPeriod() != null) { FhirTaskRequestedPeriod fhirTaskRequestedPeriod = task.getFhirTaskRequestedPeriod(); - if(task.getFhirTask().getStatus() == FhirTask.TaskStatus.REQUESTED){ - fhirTaskRequestedPeriod.setRequestedStartTime(new Date()); - fhirTaskRequestedPeriods.add(fhirTaskRequestedPeriod); - } + fhirTaskRequestedPeriod.setRequestedStartTime(new Date()); + fhirTaskRequestedPeriods.add(fhirTaskRequestedPeriod); } } - taskRequestedPeriodDao.bulkSave(fhirTaskRequestedPeriods); + taskRequestedPeriodDao.bulkUpdate(fhirTaskRequestedPeriods); } } \ No newline at end of file diff --git a/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/ShiftStartTaskEventHandler.java b/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/ShiftStartTaskEventHandler.java index f230d06..12d1960 100644 --- a/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/ShiftStartTaskEventHandler.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/ShiftStartTaskEventHandler.java @@ -33,15 +33,11 @@ public class ShiftStartTaskEventHandler implements IPDEventHandler { @Override public void handleEvent(IPDEvent event) { List admittedPatients = wardService.getAdmittedPatients(); - ConfigDetail eventConfig = getEventConfig(event); - List tasks = new ArrayList(); for(AdmittedPatient admittedPatient: admittedPatients){ String patientUuid = admittedPatient.getBedPatientAssignment().getPatient().getUuid(); - String visituuid = admittedPatient.getBedPatientAssignment().getEncounter().getVisit().getUuid(); - - IPDEvent ipdEvent = new IPDEvent(null, patientUuid, visituuid, event.getIpdEventType()); + IPDEvent ipdEvent = new IPDEvent(null, patientUuid, event.getIpdEventType()); for(TaskDetail taskDetail : eventConfig.getTasks()) { TaskRequest taskRequest = IPDEventUtils.createNonMedicationTaskRequest(ipdEvent, taskDetail.getName(), "nursing_activity_system"); Task task = taskMapper.fromRequest(taskRequest); @@ -61,6 +57,4 @@ private ConfigDetail getEventConfig(IPDEvent event){ .orElse(null); return eventConfig; } - - } \ No newline at end of file diff --git a/api/src/main/java/org/openmrs/module/ipd/api/events/model/IPDEvent.java b/api/src/main/java/org/openmrs/module/ipd/api/events/model/IPDEvent.java index 42dc8e8..dc5cf9b 100644 --- a/api/src/main/java/org/openmrs/module/ipd/api/events/model/IPDEvent.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/model/IPDEvent.java @@ -14,6 +14,5 @@ public class IPDEvent { private String encounterUuid; private String patientUuid; - private String visitUuid; private IPDEventType ipdEventType; } diff --git a/api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/RollOverNonMedicationTasks.java b/api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/RollOverNonMedicationTasks.java index 1a30c75..4f2615e 100644 --- a/api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/RollOverNonMedicationTasks.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/RollOverNonMedicationTasks.java @@ -18,7 +18,7 @@ public void execute() { IPDEventManager eventManager = context.getBean(IPDEventManager.class); IPDEventType eventType = eventManager.getEventTypeForEncounter(String.valueOf(IPDEventType.ROLLOVER_TASK)); if (eventType != null) { - IPDEvent ipdEvent = new IPDEvent(null, null, null, eventType); + IPDEvent ipdEvent = new IPDEvent(null, null, eventType); eventManager.processEvent(ipdEvent); } } diff --git a/api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/ShiftStartTasks.java b/api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/ShiftStartTasks.java index b363cb6..59ce500 100644 --- a/api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/ShiftStartTasks.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/ShiftStartTasks.java @@ -17,7 +17,7 @@ public void execute() { IPDEventManager eventManager = context.getBean(IPDEventManager.class); IPDEventType eventType = eventManager.getEventTypeForEncounter(String.valueOf(IPDEventType.SHIFT_START_TASK)); if (eventType != null) { - IPDEvent ipdEvent = new IPDEvent(null, null, null, eventType); + IPDEvent ipdEvent = new IPDEvent(null, null, eventType); eventManager.processEvent(ipdEvent); } } diff --git a/omod/src/main/java/org/openmrs/module/ipd/postprocessor/IPDTransactionHandler.java b/omod/src/main/java/org/openmrs/module/ipd/postprocessor/IPDTransactionHandler.java index e2494ef..d12737e 100644 --- a/omod/src/main/java/org/openmrs/module/ipd/postprocessor/IPDTransactionHandler.java +++ b/omod/src/main/java/org/openmrs/module/ipd/postprocessor/IPDTransactionHandler.java @@ -28,7 +28,7 @@ public void forRead(Encounter encounter, EncounterTransaction encounterTransacti public void forSave(Encounter encounter, EncounterTransaction encounterTransaction) { IPDEventType eventType = eventManager.getEventTypeForEncounter(encounter.getEncounterType().getName()); if (eventType != null) { - IPDEvent ipdEvent = new IPDEvent(encounter.getUuid(), encounter.getPatient().getUuid(), encounter.getVisit().getUuid(), eventType); + IPDEvent ipdEvent = new IPDEvent(encounter.getUuid(), encounter.getPatient().getUuid(), eventType); eventManager.processEvent(ipdEvent); } ipdScheduleService.handlePostProcessEncounterTransaction(encounter,encounterTransaction);