From d478f15e31ad3227b8ca777fe22cde3752685384 Mon Sep 17 00:00:00 2001 From: Soorya Kumaran C <90232857+SooryaKumaranC-tw@users.noreply.github.com> Date: Thu, 4 Apr 2024 20:45:55 +0530 Subject: [PATCH 01/10] Add scheduler, liquibase and handleEvent for shift start task --- .../ipd/api/dao/impl/HibernateWardDAO.java | 8 +++- .../module/ipd/api/service/WardService.java | 2 + .../ipd/api/service/impl/WardServiceImpl.java | 4 ++ api/src/main/resources/liquibase.xml | 16 +++++++ omod/pom.xml | 5 +++ .../impl/ShiftStartTaskEventHandler.java | 45 ++++++++++++++++++- .../module/ipd/scheduler/ShiftStartTasks.java | 22 +++++++++ 7 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 omod/src/main/java/org/openmrs/module/ipd/scheduler/ShiftStartTasks.java diff --git a/api/src/main/java/org/openmrs/module/ipd/api/dao/impl/HibernateWardDAO.java b/api/src/main/java/org/openmrs/module/ipd/api/dao/impl/HibernateWardDAO.java index ffecf28..ebe2a19 100644 --- a/api/src/main/java/org/openmrs/module/ipd/api/dao/impl/HibernateWardDAO.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/dao/impl/HibernateWardDAO.java @@ -61,8 +61,12 @@ public List getAdmittedPatients(Location location, Provider pro "LEFT JOIN careTeam.participants ctp ON ctp.voided = 0 " + "LEFT JOIN org.openmrs.Order o on o.encounter = e " + "LEFT JOIN Slot s on s.order = o " + - "where assignment.endDatetime is null and v.stopDatetime is null and l.parentLocation = :location "; - + "where assignment.endDatetime is null and v.stopDatetime is null "; + + if(location != null){ + queryString += "and l.parentLocation = :location "; + } + if (provider != null) { queryString += "and ctp.provider = :provider "; } diff --git a/api/src/main/java/org/openmrs/module/ipd/api/service/WardService.java b/api/src/main/java/org/openmrs/module/ipd/api/service/WardService.java index e358643..070999a 100644 --- a/api/src/main/java/org/openmrs/module/ipd/api/service/WardService.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/service/WardService.java @@ -15,4 +15,6 @@ public interface WardService { List searchWardPatients(String wardUuid, List searchKeys, String searchValue, String sortBy); List getPatientsByWardAndProvider(String wardUuid, String providerUuid, String sortBy); + + List getAdmittedPatients(); } diff --git a/api/src/main/java/org/openmrs/module/ipd/api/service/impl/WardServiceImpl.java b/api/src/main/java/org/openmrs/module/ipd/api/service/impl/WardServiceImpl.java index f91506d..72dc5dd 100644 --- a/api/src/main/java/org/openmrs/module/ipd/api/service/impl/WardServiceImpl.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/service/impl/WardServiceImpl.java @@ -55,4 +55,8 @@ public List searchWardPatients(String wardUuid, List se return wardDAO.searchAdmittedPatients(location,searchKeys,searchValue,sortBy); } + @Override + public List getAdmittedPatients() { + return wardDAO.getAdmittedPatients(null,null, null, null); + } } diff --git a/api/src/main/resources/liquibase.xml b/api/src/main/resources/liquibase.xml index dd87526..6f73d85 100644 --- a/api/src/main/resources/liquibase.xml +++ b/api/src/main/resources/liquibase.xml @@ -404,4 +404,20 @@ + + + + SELECT COUNT(*) FROM scheduler_task_config WHERE name = "Mark Slots As Missed"; + + + + INSERT INTO + scheduler_task_config(name, description, schedulable_class, start_time, start_time_pattern, repeat_interval, + start_on_startup, created_by, date_created, uuid) + VALUES + ('Shift Start Tasks', 'Shift Start Tasks', 'org.openmrs.module.ipd.scheduler.ShiftStartTasks', + TIMESTAMP(CURDATE()), 'MM/dd/yyyy HH:mm:ss', 120, false, 1, NOW(), UUID()); + + + diff --git a/omod/pom.xml b/omod/pom.xml index 11a3f26..156e1d2 100644 --- a/omod/pom.xml +++ b/omod/pom.xml @@ -181,6 +181,11 @@ 2.1 compile + + ${project.parent.groupId} + ${project.parent.artifactId}-api + ${project.parent.version} + \ No newline at end of file diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/handler/impl/ShiftStartTaskEventHandler.java b/omod/src/main/java/org/openmrs/module/ipd/events/handler/impl/ShiftStartTaskEventHandler.java index 603e59a..c829f74 100644 --- a/omod/src/main/java/org/openmrs/module/ipd/events/handler/impl/ShiftStartTaskEventHandler.java +++ b/omod/src/main/java/org/openmrs/module/ipd/events/handler/impl/ShiftStartTaskEventHandler.java @@ -1,28 +1,69 @@ package org.openmrs.module.ipd.events.handler.impl; +import org.openmrs.api.EncounterService; +import org.openmrs.api.context.Context; +import org.openmrs.module.emrapi.encounter.ActiveEncounterParameters; +import org.openmrs.module.emrapi.encounter.EmrEncounterService; +import org.openmrs.module.emrapi.encounter.domain.EncounterTransaction; +import org.openmrs.module.fhirExtension.model.Task; +import org.openmrs.module.fhirExtension.web.contract.TaskRequest; +import org.openmrs.module.fhirExtension.web.mapper.TaskMapper; +import org.openmrs.module.ipd.api.model.AdmittedPatient; +import org.openmrs.module.ipd.api.service.WardService; import org.openmrs.module.ipd.events.ConfigLoader; +import org.openmrs.module.ipd.events.IPDEventUtils; +import org.openmrs.module.ipd.events.handler.IPDEventHandler; import org.openmrs.module.ipd.events.model.ConfigDetail; import org.openmrs.module.ipd.events.model.IPDEvent; -import org.openmrs.module.ipd.events.handler.IPDEventHandler; +import org.openmrs.module.ipd.events.model.TaskDetail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.ArrayList; import java.util.List; @Component public class ShiftStartTaskEventHandler implements IPDEventHandler { + private static final String CONSULTATION_ENCOUNTER_TYPE = "Consultation"; @Autowired ConfigLoader configLoader; + private EncounterService encounterService; + private EmrEncounterService emrEncounterService; + + @Autowired + private TaskMapper taskMapper; @Override public void handleEvent(IPDEvent event) { + + WardService wardService = Context.getService(WardService.class); + // - getAdmit - wardDAO.getAdmittedPatients + List admittedPatients = wardService.getAdmittedPatients(); + +// encounterService.setEncounterType(); + List configList = configLoader.getConfigs(); ConfigDetail eventConfig = configList.stream() .filter(config -> config.getType().equals(event.getIpdEventType().name())) .findFirst() .orElse(null); - //create task based on configuration + List tasks = new ArrayList(); + for(AdmittedPatient admittedPatient: admittedPatients){ + ActiveEncounterParameters activeEncounterParameters = new ActiveEncounterParameters(); + String patientUuid = admittedPatient.getBedPatientAssignment().getPatient().getUuid(); + activeEncounterParameters.setPatientUuid(patientUuid); + activeEncounterParameters.setEncounterTypeUuid(encounterService.getEncounterType(CONSULTATION_ENCOUNTER_TYPE).getUuid()); + EncounterTransaction encounterTransaction = emrEncounterService.getActiveEncounter(activeEncounterParameters); + IPDEvent ipdEvent = new IPDEvent(encounterTransaction.getEncounterUuid(), patientUuid, event.getIpdEventType()); + for(TaskDetail taskDetail : eventConfig.getTasks()) { + TaskRequest taskRequest = IPDEventUtils.createNonMedicationTaskRequest(ipdEvent, taskDetail.getName(), "nursing_activity_system"); + Task task = taskMapper.fromRequest(taskRequest); + tasks.add(task); + } + } + +// bulkSaveTasks(List tasks); } } \ No newline at end of file diff --git a/omod/src/main/java/org/openmrs/module/ipd/scheduler/ShiftStartTasks.java b/omod/src/main/java/org/openmrs/module/ipd/scheduler/ShiftStartTasks.java new file mode 100644 index 0000000..2276d4e --- /dev/null +++ b/omod/src/main/java/org/openmrs/module/ipd/scheduler/ShiftStartTasks.java @@ -0,0 +1,22 @@ +package org.openmrs.module.ipd.scheduler; + +import org.openmrs.module.ipd.events.IPDEventManager; +import org.openmrs.module.ipd.events.model.IPDEvent; +import org.openmrs.module.ipd.events.model.IPDEventType; +import org.openmrs.scheduler.tasks.AbstractTask; +import org.springframework.beans.factory.annotation.Autowired; + +public class ShiftStartTasks extends AbstractTask { + + @Autowired + private IPDEventManager eventManager; + + @Override + public void execute() { + IPDEventType eventType = eventManager.getEventTypeForEncounter(String.valueOf(IPDEventType.SHIFT_START_TASK)); + if (eventType != null) { + IPDEvent ipdEvent = new IPDEvent(null, null, eventType); + eventManager.processEvent(ipdEvent); + } + } +} From 78f9673f2f84930c53298079144f2c6c31a0b6e8 Mon Sep 17 00:00:00 2001 From: Soorya Kumaran C <90232857+SooryaKumaranC-tw@users.noreply.github.com> Date: Tue, 9 Apr 2024 12:37:49 +0530 Subject: [PATCH 02/10] Move Events to api, refactor and include shift start task scheduler --- .../module/ipd/api}/events/ConfigLoader.java | 4 +-- .../ipd/api}/events/IPDEventManager.java | 10 +++--- .../module/ipd/api}/events/IPDEventUtils.java | 4 +-- .../api/events/factory/IPDEventFactory.java | 8 +++++ .../factory/impl/IPDEventFactoryImpl.java | 14 ++++---- .../api/events/handler/IPDEventHandler.java | 7 ++++ .../impl/PatientAdmitEventHandler.java | 14 ++++---- .../impl/RolloverTaskEventHandler.java | 10 +++--- .../impl/ShiftStartTaskEventHandler.java | 28 ++++++++++------ .../ipd/api}/events/model/ConfigDetail.java | 2 +- .../ipd/api}/events/model/IPDEvent.java | 2 +- .../ipd/api}/events/model/IPDEventType.java | 2 +- .../ipd/api}/events/model/TaskDetail.java | 2 +- .../api/scheduler/tasks/ShiftStartTasks.java | 32 +++++++++++++++++++ api/src/main/resources/liquibase.xml | 4 +-- .../ipd/events/factory/IPDEventFactory.java | 8 ----- .../ipd/events/handler/IPDEventHandler.java | 7 ---- .../postprocessor/IPDTransactionHandler.java | 6 ++-- .../module/ipd/scheduler/ShiftStartTasks.java | 22 ------------- 19 files changed, 102 insertions(+), 84 deletions(-) rename {omod/src/main/java/org/openmrs/module/ipd => api/src/main/java/org/openmrs/module/ipd/api}/events/ConfigLoader.java (92%) rename {omod/src/main/java/org/openmrs/module/ipd => api/src/main/java/org/openmrs/module/ipd/api}/events/IPDEventManager.java (74%) rename {omod/src/main/java/org/openmrs/module/ipd => api/src/main/java/org/openmrs/module/ipd/api}/events/IPDEventUtils.java (88%) create mode 100644 api/src/main/java/org/openmrs/module/ipd/api/events/factory/IPDEventFactory.java rename {omod/src/main/java/org/openmrs/module/ipd => api/src/main/java/org/openmrs/module/ipd/api}/events/factory/impl/IPDEventFactoryImpl.java (64%) create mode 100644 api/src/main/java/org/openmrs/module/ipd/api/events/handler/IPDEventHandler.java rename {omod/src/main/java/org/openmrs/module/ipd => api/src/main/java/org/openmrs/module/ipd/api}/events/handler/impl/PatientAdmitEventHandler.java (79%) rename {omod/src/main/java/org/openmrs/module/ipd => api/src/main/java/org/openmrs/module/ipd/api}/events/handler/impl/RolloverTaskEventHandler.java (75%) rename {omod/src/main/java/org/openmrs/module/ipd => api/src/main/java/org/openmrs/module/ipd/api}/events/handler/impl/ShiftStartTaskEventHandler.java (75%) rename {omod/src/main/java/org/openmrs/module/ipd => api/src/main/java/org/openmrs/module/ipd/api}/events/model/ConfigDetail.java (90%) rename {omod/src/main/java/org/openmrs/module/ipd => api/src/main/java/org/openmrs/module/ipd/api}/events/model/IPDEvent.java (91%) rename {omod/src/main/java/org/openmrs/module/ipd => api/src/main/java/org/openmrs/module/ipd/api}/events/model/IPDEventType.java (64%) rename {omod/src/main/java/org/openmrs/module/ipd => api/src/main/java/org/openmrs/module/ipd/api}/events/model/TaskDetail.java (89%) create mode 100644 api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/ShiftStartTasks.java delete mode 100644 omod/src/main/java/org/openmrs/module/ipd/events/factory/IPDEventFactory.java delete mode 100644 omod/src/main/java/org/openmrs/module/ipd/events/handler/IPDEventHandler.java delete mode 100644 omod/src/main/java/org/openmrs/module/ipd/scheduler/ShiftStartTasks.java diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/ConfigLoader.java b/api/src/main/java/org/openmrs/module/ipd/api/events/ConfigLoader.java similarity index 92% rename from omod/src/main/java/org/openmrs/module/ipd/events/ConfigLoader.java rename to api/src/main/java/org/openmrs/module/ipd/api/events/ConfigLoader.java index 3b390fa..fc58629 100644 --- a/omod/src/main/java/org/openmrs/module/ipd/events/ConfigLoader.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/ConfigLoader.java @@ -1,9 +1,9 @@ -package org.openmrs.module.ipd.events; +package org.openmrs.module.ipd.api.events; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; -import org.openmrs.module.ipd.events.model.ConfigDetail; +import org.openmrs.module.ipd.api.events.model.ConfigDetail; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.FileSystemResource; import org.springframework.stereotype.Component; diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/IPDEventManager.java b/api/src/main/java/org/openmrs/module/ipd/api/events/IPDEventManager.java similarity index 74% rename from omod/src/main/java/org/openmrs/module/ipd/events/IPDEventManager.java rename to api/src/main/java/org/openmrs/module/ipd/api/events/IPDEventManager.java index 7614774..d98f77e 100644 --- a/omod/src/main/java/org/openmrs/module/ipd/events/IPDEventManager.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/IPDEventManager.java @@ -1,9 +1,9 @@ -package org.openmrs.module.ipd.events; +package org.openmrs.module.ipd.api.events; -import org.openmrs.module.ipd.events.factory.IPDEventFactory; -import org.openmrs.module.ipd.events.handler.IPDEventHandler; -import org.openmrs.module.ipd.events.model.IPDEvent; -import org.openmrs.module.ipd.events.model.IPDEventType; +import org.openmrs.module.ipd.api.events.model.IPDEvent; +import org.openmrs.module.ipd.api.events.factory.IPDEventFactory; +import org.openmrs.module.ipd.api.events.handler.IPDEventHandler; +import org.openmrs.module.ipd.api.events.model.IPDEventType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/IPDEventUtils.java b/api/src/main/java/org/openmrs/module/ipd/api/events/IPDEventUtils.java similarity index 88% rename from omod/src/main/java/org/openmrs/module/ipd/events/IPDEventUtils.java rename to api/src/main/java/org/openmrs/module/ipd/api/events/IPDEventUtils.java index 42abc30..b9da7ab 100644 --- a/omod/src/main/java/org/openmrs/module/ipd/events/IPDEventUtils.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/IPDEventUtils.java @@ -1,8 +1,8 @@ -package org.openmrs.module.ipd.events; +package org.openmrs.module.ipd.api.events; import org.openmrs.module.fhir2.model.FhirTask; import org.openmrs.module.fhirExtension.web.contract.TaskRequest; -import org.openmrs.module.ipd.events.model.IPDEvent; +import org.openmrs.module.ipd.api.events.model.IPDEvent; import java.util.Date; diff --git a/api/src/main/java/org/openmrs/module/ipd/api/events/factory/IPDEventFactory.java b/api/src/main/java/org/openmrs/module/ipd/api/events/factory/IPDEventFactory.java new file mode 100644 index 0000000..125fe81 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/factory/IPDEventFactory.java @@ -0,0 +1,8 @@ +package org.openmrs.module.ipd.api.events.factory; + +import org.openmrs.module.ipd.api.events.model.IPDEventType; +import org.openmrs.module.ipd.api.events.handler.IPDEventHandler; + +public interface IPDEventFactory { + IPDEventHandler createEventHandler(IPDEventType eventType); +} \ No newline at end of file diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/factory/impl/IPDEventFactoryImpl.java b/api/src/main/java/org/openmrs/module/ipd/api/events/factory/impl/IPDEventFactoryImpl.java similarity index 64% rename from omod/src/main/java/org/openmrs/module/ipd/events/factory/impl/IPDEventFactoryImpl.java rename to api/src/main/java/org/openmrs/module/ipd/api/events/factory/impl/IPDEventFactoryImpl.java index faf7ddb..cb13de8 100644 --- a/omod/src/main/java/org/openmrs/module/ipd/events/factory/impl/IPDEventFactoryImpl.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/factory/impl/IPDEventFactoryImpl.java @@ -1,11 +1,11 @@ -package org.openmrs.module.ipd.events.factory.impl; +package org.openmrs.module.ipd.api.events.factory.impl; -import org.openmrs.module.ipd.events.model.IPDEventType; -import org.openmrs.module.ipd.events.factory.IPDEventFactory; -import org.openmrs.module.ipd.events.handler.IPDEventHandler; -import org.openmrs.module.ipd.events.handler.impl.PatientAdmitEventHandler; -import org.openmrs.module.ipd.events.handler.impl.RolloverTaskEventHandler; -import org.openmrs.module.ipd.events.handler.impl.ShiftStartTaskEventHandler; +import org.openmrs.module.ipd.api.events.handler.impl.ShiftStartTaskEventHandler; +import org.openmrs.module.ipd.api.events.model.IPDEventType; +import org.openmrs.module.ipd.api.events.factory.IPDEventFactory; +import org.openmrs.module.ipd.api.events.handler.IPDEventHandler; +import org.openmrs.module.ipd.api.events.handler.impl.PatientAdmitEventHandler; +import org.openmrs.module.ipd.api.events.handler.impl.RolloverTaskEventHandler; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/api/src/main/java/org/openmrs/module/ipd/api/events/handler/IPDEventHandler.java b/api/src/main/java/org/openmrs/module/ipd/api/events/handler/IPDEventHandler.java new file mode 100644 index 0000000..4c75fdf --- /dev/null +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/handler/IPDEventHandler.java @@ -0,0 +1,7 @@ +package org.openmrs.module.ipd.api.events.handler; + +import org.openmrs.module.ipd.api.events.model.IPDEvent; + +public interface IPDEventHandler { + void handleEvent(IPDEvent event); +} \ No newline at end of file diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/handler/impl/PatientAdmitEventHandler.java b/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/PatientAdmitEventHandler.java similarity index 79% rename from omod/src/main/java/org/openmrs/module/ipd/events/handler/impl/PatientAdmitEventHandler.java rename to api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/PatientAdmitEventHandler.java index e9717da..9828da5 100644 --- a/omod/src/main/java/org/openmrs/module/ipd/events/handler/impl/PatientAdmitEventHandler.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/PatientAdmitEventHandler.java @@ -1,4 +1,4 @@ -package org.openmrs.module.ipd.events.handler.impl; +package org.openmrs.module.ipd.api.events.handler.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -6,12 +6,12 @@ import org.openmrs.module.fhirExtension.service.TaskService; import org.openmrs.module.fhirExtension.web.contract.TaskRequest; import org.openmrs.module.fhirExtension.web.mapper.TaskMapper; -import org.openmrs.module.ipd.events.ConfigLoader; -import org.openmrs.module.ipd.events.IPDEventUtils; -import org.openmrs.module.ipd.events.handler.IPDEventHandler; -import org.openmrs.module.ipd.events.model.ConfigDetail; -import org.openmrs.module.ipd.events.model.IPDEvent; -import org.openmrs.module.ipd.events.model.TaskDetail; +import org.openmrs.module.ipd.api.events.ConfigLoader; +import org.openmrs.module.ipd.api.events.IPDEventUtils; +import org.openmrs.module.ipd.api.events.model.ConfigDetail; +import org.openmrs.module.ipd.api.events.model.IPDEvent; +import org.openmrs.module.ipd.api.events.model.TaskDetail; +import org.openmrs.module.ipd.api.events.handler.IPDEventHandler; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/handler/impl/RolloverTaskEventHandler.java b/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/RolloverTaskEventHandler.java similarity index 75% rename from omod/src/main/java/org/openmrs/module/ipd/events/handler/impl/RolloverTaskEventHandler.java rename to api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/RolloverTaskEventHandler.java index 71f0def..de89020 100644 --- a/omod/src/main/java/org/openmrs/module/ipd/events/handler/impl/RolloverTaskEventHandler.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/RolloverTaskEventHandler.java @@ -1,9 +1,9 @@ -package org.openmrs.module.ipd.events.handler.impl; +package org.openmrs.module.ipd.api.events.handler.impl; -import org.openmrs.module.ipd.events.ConfigLoader; -import org.openmrs.module.ipd.events.model.ConfigDetail; -import org.openmrs.module.ipd.events.model.IPDEvent; -import org.openmrs.module.ipd.events.handler.IPDEventHandler; +import org.openmrs.module.ipd.api.events.model.ConfigDetail; +import org.openmrs.module.ipd.api.events.ConfigLoader; +import org.openmrs.module.ipd.api.events.model.IPDEvent; +import org.openmrs.module.ipd.api.events.handler.IPDEventHandler; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/handler/impl/ShiftStartTaskEventHandler.java b/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/ShiftStartTaskEventHandler.java similarity index 75% rename from omod/src/main/java/org/openmrs/module/ipd/events/handler/impl/ShiftStartTaskEventHandler.java rename to api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/ShiftStartTaskEventHandler.java index c829f74..930fb1c 100644 --- a/omod/src/main/java/org/openmrs/module/ipd/events/handler/impl/ShiftStartTaskEventHandler.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/handler/impl/ShiftStartTaskEventHandler.java @@ -1,4 +1,4 @@ -package org.openmrs.module.ipd.events.handler.impl; +package org.openmrs.module.ipd.api.events.handler.impl; import org.openmrs.api.EncounterService; import org.openmrs.api.context.Context; @@ -6,16 +6,17 @@ import org.openmrs.module.emrapi.encounter.EmrEncounterService; import org.openmrs.module.emrapi.encounter.domain.EncounterTransaction; import org.openmrs.module.fhirExtension.model.Task; +import org.openmrs.module.fhirExtension.service.TaskService; import org.openmrs.module.fhirExtension.web.contract.TaskRequest; import org.openmrs.module.fhirExtension.web.mapper.TaskMapper; +import org.openmrs.module.ipd.api.events.ConfigLoader; +import org.openmrs.module.ipd.api.events.IPDEventUtils; +import org.openmrs.module.ipd.api.events.handler.IPDEventHandler; +import org.openmrs.module.ipd.api.events.model.ConfigDetail; +import org.openmrs.module.ipd.api.events.model.IPDEvent; +import org.openmrs.module.ipd.api.events.model.TaskDetail; import org.openmrs.module.ipd.api.model.AdmittedPatient; import org.openmrs.module.ipd.api.service.WardService; -import org.openmrs.module.ipd.events.ConfigLoader; -import org.openmrs.module.ipd.events.IPDEventUtils; -import org.openmrs.module.ipd.events.handler.IPDEventHandler; -import org.openmrs.module.ipd.events.model.ConfigDetail; -import org.openmrs.module.ipd.events.model.IPDEvent; -import org.openmrs.module.ipd.events.model.TaskDetail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -33,10 +34,13 @@ public class ShiftStartTaskEventHandler implements IPDEventHandler { @Autowired private TaskMapper taskMapper; + @Autowired + private TaskService taskService; + @Override public void handleEvent(IPDEvent event) { - + System.out.println("Inside HandleEvent"); WardService wardService = Context.getService(WardService.class); // - getAdmit - wardDAO.getAdmittedPatients List admittedPatients = wardService.getAdmittedPatients(); @@ -56,6 +60,8 @@ public void handleEvent(IPDEvent event) { activeEncounterParameters.setPatientUuid(patientUuid); activeEncounterParameters.setEncounterTypeUuid(encounterService.getEncounterType(CONSULTATION_ENCOUNTER_TYPE).getUuid()); EncounterTransaction encounterTransaction = emrEncounterService.getActiveEncounter(activeEncounterParameters); + System.out.println("encounterTransaction "+encounterTransaction+ " - "+ encounterTransaction.getEncounterUuid()); + System.out.println("patientUuid "+ patientUuid); IPDEvent ipdEvent = new IPDEvent(encounterTransaction.getEncounterUuid(), patientUuid, event.getIpdEventType()); for(TaskDetail taskDetail : eventConfig.getTasks()) { TaskRequest taskRequest = IPDEventUtils.createNonMedicationTaskRequest(ipdEvent, taskDetail.getName(), "nursing_activity_system"); @@ -63,7 +69,9 @@ public void handleEvent(IPDEvent event) { tasks.add(task); } } - -// bulkSaveTasks(List tasks); + System.out.println("tasks --> "+tasks.size()); + if(tasks.size() > 0){ + taskService.bulkSaveTasks(tasks); + } } } \ No newline at end of file diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/model/ConfigDetail.java b/api/src/main/java/org/openmrs/module/ipd/api/events/model/ConfigDetail.java similarity index 90% rename from omod/src/main/java/org/openmrs/module/ipd/events/model/ConfigDetail.java rename to api/src/main/java/org/openmrs/module/ipd/api/events/model/ConfigDetail.java index 8eae262..284f2a5 100644 --- a/omod/src/main/java/org/openmrs/module/ipd/events/model/ConfigDetail.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/model/ConfigDetail.java @@ -1,4 +1,4 @@ -package org.openmrs.module.ipd.events.model; +package org.openmrs.module.ipd.api.events.model; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/model/IPDEvent.java b/api/src/main/java/org/openmrs/module/ipd/api/events/model/IPDEvent.java similarity index 91% rename from omod/src/main/java/org/openmrs/module/ipd/events/model/IPDEvent.java rename to api/src/main/java/org/openmrs/module/ipd/api/events/model/IPDEvent.java index e812c49..dc5cf9b 100644 --- a/omod/src/main/java/org/openmrs/module/ipd/events/model/IPDEvent.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/model/IPDEvent.java @@ -1,4 +1,4 @@ -package org.openmrs.module.ipd.events.model; +package org.openmrs.module.ipd.api.events.model; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/model/IPDEventType.java b/api/src/main/java/org/openmrs/module/ipd/api/events/model/IPDEventType.java similarity index 64% rename from omod/src/main/java/org/openmrs/module/ipd/events/model/IPDEventType.java rename to api/src/main/java/org/openmrs/module/ipd/api/events/model/IPDEventType.java index 52196f0..e74030c 100644 --- a/omod/src/main/java/org/openmrs/module/ipd/events/model/IPDEventType.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/model/IPDEventType.java @@ -1,4 +1,4 @@ -package org.openmrs.module.ipd.events.model; +package org.openmrs.module.ipd.api.events.model; public enum IPDEventType { PATIENT_ADMIT, diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/model/TaskDetail.java b/api/src/main/java/org/openmrs/module/ipd/api/events/model/TaskDetail.java similarity index 89% rename from omod/src/main/java/org/openmrs/module/ipd/events/model/TaskDetail.java rename to api/src/main/java/org/openmrs/module/ipd/api/events/model/TaskDetail.java index e5de905..7b1426f 100644 --- a/omod/src/main/java/org/openmrs/module/ipd/events/model/TaskDetail.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/events/model/TaskDetail.java @@ -1,4 +1,4 @@ -package org.openmrs.module.ipd.events.model; +package org.openmrs.module.ipd.api.events.model; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 new file mode 100644 index 0000000..1e421d1 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/ShiftStartTasks.java @@ -0,0 +1,32 @@ +package org.openmrs.module.ipd.api.scheduler.tasks; + +import org.openmrs.module.ipd.api.events.IPDEventManager; +import org.openmrs.module.ipd.api.events.model.IPDEvent; +import org.openmrs.module.ipd.api.events.model.IPDEventType; +import org.openmrs.module.ipd.api.service.SlotService; +import org.openmrs.scheduler.tasks.AbstractTask; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; + +public class ShiftStartTasks extends AbstractTask implements ApplicationContextAware { + + private ApplicationContext context; +// IPDEventManager eventManager; + @Override + public void execute() { + IPDEventManager eventManager = context.getBean(IPDEventManager.class); + System.out.println("Started Shift Schedule"); + System.out.println("Shift Start Task"+IPDEventType.SHIFT_START_TASK); + IPDEventType eventType = eventManager.getEventTypeForEncounter("SHIFT_START_TASK"); + System.out.println("eventType"+ eventType); + if (eventType != null) { + IPDEvent ipdEvent = new IPDEvent(null, null, eventType); + eventManager.processEvent(ipdEvent); + } + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) { + this.context = applicationContext; + } +} diff --git a/api/src/main/resources/liquibase.xml b/api/src/main/resources/liquibase.xml index 6f73d85..c40e067 100644 --- a/api/src/main/resources/liquibase.xml +++ b/api/src/main/resources/liquibase.xml @@ -407,7 +407,7 @@ - SELECT COUNT(*) FROM scheduler_task_config WHERE name = "Mark Slots As Missed"; + SELECT COUNT(*) FROM scheduler_task_config WHERE name = "Shift Start Tasks"; @@ -415,7 +415,7 @@ scheduler_task_config(name, description, schedulable_class, start_time, start_time_pattern, repeat_interval, start_on_startup, created_by, date_created, uuid) VALUES - ('Shift Start Tasks', 'Shift Start Tasks', 'org.openmrs.module.ipd.scheduler.ShiftStartTasks', + ('Shift Start Tasks', 'Shift Start Tasks', 'org.openmrs.module.ipd.api.scheduler.tasks.ShiftStartTasks', TIMESTAMP(CURDATE()), 'MM/dd/yyyy HH:mm:ss', 120, false, 1, NOW(), UUID()); diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/factory/IPDEventFactory.java b/omod/src/main/java/org/openmrs/module/ipd/events/factory/IPDEventFactory.java deleted file mode 100644 index 690a467..0000000 --- a/omod/src/main/java/org/openmrs/module/ipd/events/factory/IPDEventFactory.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.openmrs.module.ipd.events.factory; - -import org.openmrs.module.ipd.events.model.IPDEventType; -import org.openmrs.module.ipd.events.handler.IPDEventHandler; - -public interface IPDEventFactory { - IPDEventHandler createEventHandler(IPDEventType eventType); -} \ No newline at end of file diff --git a/omod/src/main/java/org/openmrs/module/ipd/events/handler/IPDEventHandler.java b/omod/src/main/java/org/openmrs/module/ipd/events/handler/IPDEventHandler.java deleted file mode 100644 index 27b1cca..0000000 --- a/omod/src/main/java/org/openmrs/module/ipd/events/handler/IPDEventHandler.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.openmrs.module.ipd.events.handler; - -import org.openmrs.module.ipd.events.model.IPDEvent; - -public interface IPDEventHandler { - void handleEvent(IPDEvent event); -} \ No newline at end of file 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 82c9825..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 @@ -3,12 +3,12 @@ import org.openmrs.Encounter; import org.openmrs.module.emrapi.encounter.domain.EncounterTransaction; import org.openmrs.module.emrapi.encounter.postprocessor.EncounterTransactionHandler; -import org.openmrs.module.ipd.events.model.IPDEvent; +import org.openmrs.module.ipd.api.events.model.IPDEvent; import org.openmrs.module.ipd.service.IPDScheduleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.openmrs.module.ipd.events.model.IPDEventType; -import org.openmrs.module.ipd.events.IPDEventManager; +import org.openmrs.module.ipd.api.events.model.IPDEventType; +import org.openmrs.module.ipd.api.events.IPDEventManager; @Component public class IPDTransactionHandler implements EncounterTransactionHandler { diff --git a/omod/src/main/java/org/openmrs/module/ipd/scheduler/ShiftStartTasks.java b/omod/src/main/java/org/openmrs/module/ipd/scheduler/ShiftStartTasks.java deleted file mode 100644 index 2276d4e..0000000 --- a/omod/src/main/java/org/openmrs/module/ipd/scheduler/ShiftStartTasks.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.openmrs.module.ipd.scheduler; - -import org.openmrs.module.ipd.events.IPDEventManager; -import org.openmrs.module.ipd.events.model.IPDEvent; -import org.openmrs.module.ipd.events.model.IPDEventType; -import org.openmrs.scheduler.tasks.AbstractTask; -import org.springframework.beans.factory.annotation.Autowired; - -public class ShiftStartTasks extends AbstractTask { - - @Autowired - private IPDEventManager eventManager; - - @Override - public void execute() { - IPDEventType eventType = eventManager.getEventTypeForEncounter(String.valueOf(IPDEventType.SHIFT_START_TASK)); - if (eventType != null) { - IPDEvent ipdEvent = new IPDEvent(null, null, eventType); - eventManager.processEvent(ipdEvent); - } - } -} From 98c8cf279abf7d873711407a1ef70a7dedc6b973 Mon Sep 17 00:00:00 2001 From: Soorya Kumaran C <90232857+SooryaKumaranC-tw@users.noreply.github.com> Date: Tue, 9 Apr 2024 12:53:16 +0530 Subject: [PATCH 03/10] Update api pom.xml --- api/pom.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/pom.xml b/api/pom.xml index cc20907..b4d1465 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -163,7 +163,6 @@ provided - org.openmrs.module webservices.rest-omod-common @@ -213,6 +212,11 @@ test + + org.openmrs.module + emrapi-api + provided + From 71af6caa771b71190a6f1789c97b48b6aea20ae4 Mon Sep 17 00:00:00 2001 From: Umair Fayaz Date: Tue, 9 Apr 2024 18:51:46 +0530 Subject: [PATCH 04/10] Add scheduler task for rollover medication tasks --- .../tasks/RollOverNonMedicationTasks.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/RollOverNonMedicationTasks.java 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 new file mode 100644 index 0000000..f7796c2 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/RollOverNonMedicationTasks.java @@ -0,0 +1,25 @@ +package org.openmrs.module.ipd.api.scheduler.tasks; + +import org.openmrs.module.ipd.api.events.IPDEventManager; +import org.openmrs.module.ipd.api.events.model.IPDEvent; +import org.openmrs.module.ipd.api.events.model.IPDEventType; +import org.openmrs.scheduler.tasks.AbstractTask; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +@Component +public class RollOverNonMedicationTasks extends AbstractTask { + + private ApplicationContext context; + + @Override + 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, eventType); + eventManager.processEvent(ipdEvent); + } + } +} From 66b96deab3fd88c148877df6ca97276e0229b2b2 Mon Sep 17 00:00:00 2001 From: Umair Fayaz Date: Tue, 9 Apr 2024 18:52:23 +0530 Subject: [PATCH 05/10] Gets rollover tasks from fhir task service using task names and status --- .../impl/RolloverTaskEventHandler.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) 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 de89020..a17d17b 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 @@ -1,13 +1,17 @@ package org.openmrs.module.ipd.api.events.handler.impl; -import org.openmrs.module.ipd.api.events.model.ConfigDetail; +import org.openmrs.module.fhirExtension.service.TaskService; import org.openmrs.module.ipd.api.events.ConfigLoader; -import org.openmrs.module.ipd.api.events.model.IPDEvent; import org.openmrs.module.ipd.api.events.handler.IPDEventHandler; +import org.openmrs.module.ipd.api.events.model.ConfigDetail; +import org.openmrs.module.ipd.api.events.model.TaskDetail; +import org.openmrs.module.ipd.api.events.model.IPDEvent; +import org.openmrs.module.fhirExtension.model.Task; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; +import java.util.stream.Collectors; @Component public class RolloverTaskEventHandler implements IPDEventHandler { @@ -15,6 +19,10 @@ public class RolloverTaskEventHandler implements IPDEventHandler { @Autowired ConfigLoader configLoader; + private TaskService taskService; + + private static final String TASK_STATUS = "REQUESTED"; + @Override public void handleEvent(IPDEvent event) { List configList = configLoader.getConfigs(); @@ -24,6 +32,16 @@ public void handleEvent(IPDEvent event) { .orElse(null); System.out.println("eventConfig type RolloverTaskEventHandler " + eventConfig.getType()); System.out.println("eventConfig tasks RolloverTaskEventHandler " + eventConfig.getTasks() + " size --- " + eventConfig.getTasks().size()); - //create task based on configuration + + List taskNames = eventConfig.getTasks().stream() + .map(TaskDetail::getName) + .collect(Collectors.toList()); + + List rolloverTasks = taskService.getTasksByNameAndStatus(taskNames, TASK_STATUS); + + for (Task task : rolloverTasks) { + System.out.println("Task : " + task.getFhirTask()); + + } } } \ No newline at end of file From c354016cf4d4dc5d2226c4d7359a99aba8ded65c Mon Sep 17 00:00:00 2001 From: Umair Fayaz Date: Tue, 9 Apr 2024 18:53:24 +0530 Subject: [PATCH 06/10] Add migration top add scheduler for rollover tasks --- api/src/main/resources/liquibase.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/api/src/main/resources/liquibase.xml b/api/src/main/resources/liquibase.xml index c40e067..08fc186 100644 --- a/api/src/main/resources/liquibase.xml +++ b/api/src/main/resources/liquibase.xml @@ -420,4 +420,20 @@ + + + + SELECT COUNT(*) FROM scheduler_task_config WHERE name = "Rollover Tasks"; + + + + INSERT INTO + scheduler_task_config(name, description, schedulable_class, start_time, start_time_pattern, repeat_interval, + start_on_startup, created_by, date_created, uuid) + VALUES + ('Rollover Tasks', 'Rollover Tasks', 'org.openmrs.module.ipd.api.scheduler.tasks.RollOverNonMedicationTasks', + TIMESTAMP(CURDATE()), 'MM/dd/yyyy HH:mm:ss', 120, false, 1, NOW(), UUID()); + + + From f852beccc848a4ed4d7d251066d6b04d376295f3 Mon Sep 17 00:00:00 2001 From: Soorya Kumaran C <90232857+SooryaKumaranC-tw@users.noreply.github.com> Date: Fri, 12 Apr 2024 01:24:32 +0530 Subject: [PATCH 07/10] Create start shift scheduler and roll over tasks --- .../ipd/api/dao/impl/HibernateWardDAO.java | 4 +- .../module/ipd/api/events/IPDEventUtils.java | 1 + .../impl/RolloverTaskEventHandler.java | 27 +++++++---- .../impl/ShiftStartTaskEventHandler.java | 45 +++++++---------- .../module/ipd/api/events/model/IPDEvent.java | 1 + .../tasks/RollOverNonMedicationTasks.java | 13 +++-- .../api/scheduler/tasks/ShiftStartTasks.java | 13 ++--- api/src/main/resources/liquibase.xml | 48 +++++++++++++++---- .../postprocessor/IPDTransactionHandler.java | 2 +- 9 files changed, 96 insertions(+), 58 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/ipd/api/dao/impl/HibernateWardDAO.java b/api/src/main/java/org/openmrs/module/ipd/api/dao/impl/HibernateWardDAO.java index ebe2a19..f161726 100644 --- a/api/src/main/java/org/openmrs/module/ipd/api/dao/impl/HibernateWardDAO.java +++ b/api/src/main/java/org/openmrs/module/ipd/api/dao/impl/HibernateWardDAO.java @@ -83,7 +83,9 @@ public List getAdmittedPatients(Location location, Provider pro Query query = session.createQuery(finalQuery); - query.setParameter("location", location); + if(location != null) { + query.setParameter("location", location); + } if (provider != null) { query.setParameter("provider", provider); 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 b9da7ab..1825821 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,6 +14,7 @@ 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 a17d17b..978e8c7 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 @@ -1,15 +1,20 @@ package org.openmrs.module.ipd.api.events.handler.impl; +import org.openmrs.module.fhir2.model.FhirTask; +import org.openmrs.module.fhirExtension.dao.TaskRequestedPeriodDao; +import org.openmrs.module.fhirExtension.model.FhirTaskRequestedPeriod; +import org.openmrs.module.fhirExtension.model.Task; import org.openmrs.module.fhirExtension.service.TaskService; import org.openmrs.module.ipd.api.events.ConfigLoader; import org.openmrs.module.ipd.api.events.handler.IPDEventHandler; import org.openmrs.module.ipd.api.events.model.ConfigDetail; -import org.openmrs.module.ipd.api.events.model.TaskDetail; import org.openmrs.module.ipd.api.events.model.IPDEvent; -import org.openmrs.module.fhirExtension.model.Task; +import org.openmrs.module.ipd.api.events.model.TaskDetail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -18,9 +23,10 @@ public class RolloverTaskEventHandler implements IPDEventHandler { @Autowired ConfigLoader configLoader; - + @Autowired private TaskService taskService; - + @Autowired + private TaskRequestedPeriodDao taskRequestedPeriodDao; private static final String TASK_STATUS = "REQUESTED"; @Override @@ -30,8 +36,6 @@ public void handleEvent(IPDEvent event) { .filter(config -> config.getType().equals(event.getIpdEventType().name())) .findFirst() .orElse(null); - System.out.println("eventConfig type RolloverTaskEventHandler " + eventConfig.getType()); - System.out.println("eventConfig tasks RolloverTaskEventHandler " + eventConfig.getTasks() + " size --- " + eventConfig.getTasks().size()); List taskNames = eventConfig.getTasks().stream() .map(TaskDetail::getName) @@ -39,9 +43,16 @@ public void handleEvent(IPDEvent event) { List rolloverTasks = taskService.getTasksByNameAndStatus(taskNames, TASK_STATUS); + List fhirTaskRequestedPeriods = new ArrayList(); for (Task task : rolloverTasks) { - System.out.println("Task : " + task.getFhirTask()); - + if (task.getFhirTaskRequestedPeriod() != null) { + FhirTaskRequestedPeriod fhirTaskRequestedPeriod = task.getFhirTaskRequestedPeriod(); + if(task.getFhirTask().getStatus() == FhirTask.TaskStatus.REQUESTED){ + fhirTaskRequestedPeriod.setRequestedStartTime(new Date()); + fhirTaskRequestedPeriods.add(fhirTaskRequestedPeriod); + } + } } + taskRequestedPeriodDao.bulkSave(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 930fb1c..f230d06 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 @@ -1,10 +1,5 @@ package org.openmrs.module.ipd.api.events.handler.impl; -import org.openmrs.api.EncounterService; -import org.openmrs.api.context.Context; -import org.openmrs.module.emrapi.encounter.ActiveEncounterParameters; -import org.openmrs.module.emrapi.encounter.EmrEncounterService; -import org.openmrs.module.emrapi.encounter.domain.EncounterTransaction; import org.openmrs.module.fhirExtension.model.Task; import org.openmrs.module.fhirExtension.service.TaskService; import org.openmrs.module.fhirExtension.web.contract.TaskRequest; @@ -26,52 +21,46 @@ @Component public class ShiftStartTaskEventHandler implements IPDEventHandler { - private static final String CONSULTATION_ENCOUNTER_TYPE = "Consultation"; @Autowired ConfigLoader configLoader; - private EncounterService encounterService; - private EmrEncounterService emrEncounterService; - @Autowired private TaskMapper taskMapper; @Autowired private TaskService taskService; - + @Autowired + private WardService wardService; @Override public void handleEvent(IPDEvent event) { - System.out.println("Inside HandleEvent"); - WardService wardService = Context.getService(WardService.class); - // - getAdmit - wardDAO.getAdmittedPatients List admittedPatients = wardService.getAdmittedPatients(); -// encounterService.setEncounterType(); - - List configList = configLoader.getConfigs(); - ConfigDetail eventConfig = configList.stream() - .filter(config -> config.getType().equals(event.getIpdEventType().name())) - .findFirst() - .orElse(null); + ConfigDetail eventConfig = getEventConfig(event); List tasks = new ArrayList(); for(AdmittedPatient admittedPatient: admittedPatients){ - ActiveEncounterParameters activeEncounterParameters = new ActiveEncounterParameters(); String patientUuid = admittedPatient.getBedPatientAssignment().getPatient().getUuid(); - activeEncounterParameters.setPatientUuid(patientUuid); - activeEncounterParameters.setEncounterTypeUuid(encounterService.getEncounterType(CONSULTATION_ENCOUNTER_TYPE).getUuid()); - EncounterTransaction encounterTransaction = emrEncounterService.getActiveEncounter(activeEncounterParameters); - System.out.println("encounterTransaction "+encounterTransaction+ " - "+ encounterTransaction.getEncounterUuid()); - System.out.println("patientUuid "+ patientUuid); - IPDEvent ipdEvent = new IPDEvent(encounterTransaction.getEncounterUuid(), patientUuid, event.getIpdEventType()); + String visituuid = admittedPatient.getBedPatientAssignment().getEncounter().getVisit().getUuid(); + + IPDEvent ipdEvent = new IPDEvent(null, patientUuid, visituuid, event.getIpdEventType()); for(TaskDetail taskDetail : eventConfig.getTasks()) { TaskRequest taskRequest = IPDEventUtils.createNonMedicationTaskRequest(ipdEvent, taskDetail.getName(), "nursing_activity_system"); Task task = taskMapper.fromRequest(taskRequest); tasks.add(task); } } - System.out.println("tasks --> "+tasks.size()); if(tasks.size() > 0){ taskService.bulkSaveTasks(tasks); } } + + private ConfigDetail getEventConfig(IPDEvent event){ + List configList = configLoader.getConfigs(); + ConfigDetail eventConfig = configList.stream() + .filter(config -> config.getType().equals(event.getIpdEventType().name())) + .findFirst() + .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 dc5cf9b..42dc8e8 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,5 +14,6 @@ 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 f7796c2..1a30c75 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 @@ -4,22 +4,27 @@ import org.openmrs.module.ipd.api.events.model.IPDEvent; import org.openmrs.module.ipd.api.events.model.IPDEventType; import org.openmrs.scheduler.tasks.AbstractTask; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; @Component -public class RollOverNonMedicationTasks extends AbstractTask { +public class RollOverNonMedicationTasks extends AbstractTask implements ApplicationContextAware { - private ApplicationContext context; + private static ApplicationContext context; @Override 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, eventType); + IPDEvent ipdEvent = new IPDEvent(null, null, null, eventType); eventManager.processEvent(ipdEvent); } } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) { + this.context = applicationContext; + } } 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 1e421d1..b363cb6 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 @@ -3,24 +3,21 @@ import org.openmrs.module.ipd.api.events.IPDEventManager; import org.openmrs.module.ipd.api.events.model.IPDEvent; import org.openmrs.module.ipd.api.events.model.IPDEventType; -import org.openmrs.module.ipd.api.service.SlotService; import org.openmrs.scheduler.tasks.AbstractTask; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; +@Component public class ShiftStartTasks extends AbstractTask implements ApplicationContextAware { - private ApplicationContext context; -// IPDEventManager eventManager; + private static ApplicationContext context; @Override public void execute() { IPDEventManager eventManager = context.getBean(IPDEventManager.class); - System.out.println("Started Shift Schedule"); - System.out.println("Shift Start Task"+IPDEventType.SHIFT_START_TASK); - IPDEventType eventType = eventManager.getEventTypeForEncounter("SHIFT_START_TASK"); - System.out.println("eventType"+ eventType); + IPDEventType eventType = eventManager.getEventTypeForEncounter(String.valueOf(IPDEventType.SHIFT_START_TASK)); if (eventType != null) { - IPDEvent ipdEvent = new IPDEvent(null, null, eventType); + IPDEvent ipdEvent = new IPDEvent(null, null, null, eventType); eventManager.processEvent(ipdEvent); } } diff --git a/api/src/main/resources/liquibase.xml b/api/src/main/resources/liquibase.xml index 08fc186..ce25f1d 100644 --- a/api/src/main/resources/liquibase.xml +++ b/api/src/main/resources/liquibase.xml @@ -404,10 +404,10 @@ - + - SELECT COUNT(*) FROM scheduler_task_config WHERE name = "Shift Start Tasks"; + SELECT COUNT(*) FROM scheduler_task_config WHERE name = "Shift Start Tasks First"; @@ -415,15 +415,15 @@ scheduler_task_config(name, description, schedulable_class, start_time, start_time_pattern, repeat_interval, start_on_startup, created_by, date_created, uuid) VALUES - ('Shift Start Tasks', 'Shift Start Tasks', 'org.openmrs.module.ipd.api.scheduler.tasks.ShiftStartTasks', - TIMESTAMP(CURDATE()), 'MM/dd/yyyy HH:mm:ss', 120, false, 1, NOW(), UUID()); + ('Shift Start Tasks First', 'Shift start tasks first shift', 'org.openmrs.module.ipd.api.scheduler.tasks.ShiftStartTasks', + '2024-04-11 08:00:00', 'MM/dd/yyyy HH:mm:ss', 86400, true, 1, NOW(), UUID()); - + - SELECT COUNT(*) FROM scheduler_task_config WHERE name = "Rollover Tasks"; + SELECT COUNT(*) FROM scheduler_task_config WHERE name = "Shift Start Tasks Second"; @@ -431,8 +431,40 @@ scheduler_task_config(name, description, schedulable_class, start_time, start_time_pattern, repeat_interval, start_on_startup, created_by, date_created, uuid) VALUES - ('Rollover Tasks', 'Rollover Tasks', 'org.openmrs.module.ipd.api.scheduler.tasks.RollOverNonMedicationTasks', - TIMESTAMP(CURDATE()), 'MM/dd/yyyy HH:mm:ss', 120, false, 1, NOW(), UUID()); + ('Shift Start Tasks Second', 'Shift start tasks second shift', 'org.openmrs.module.ipd.api.scheduler.tasks.ShiftStartTasks', + '2024-04-11 19:00:00', 'MM/dd/yyyy HH:mm:ss', 86400, true, 1, NOW(), UUID()); + + + + + + + SELECT COUNT(*) FROM scheduler_task_config WHERE name = "Rollover Tasks First"; + + + + INSERT INTO + scheduler_task_config(name, description, schedulable_class, start_time, start_time_pattern, repeat_interval, + start_on_startup, created_by, date_created, uuid) + VALUES + ('Rollover Tasks First', 'Rollover tasks first shift', 'org.openmrs.module.ipd.api.scheduler.tasks.RollOverNonMedicationTasks', + '2024-04-11 08:00:00', 'MM/dd/yyyy HH:mm:ss', 86400, true, 1, NOW(), UUID()); + + + + + + + SELECT COUNT(*) FROM scheduler_task_config WHERE name = "Rollover Tasks Second"; + + + + INSERT INTO + scheduler_task_config(name, description, schedulable_class, start_time, start_time_pattern, repeat_interval, + start_on_startup, created_by, date_created, uuid) + VALUES + ('Rollover Tasks Second', 'Rollover tasks second shift', 'org.openmrs.module.ipd.api.scheduler.tasks.RollOverNonMedicationTasks', + '2024-04-11 19:00:00', 'MM/dd/yyyy HH:mm:ss', 86400, true, 1, NOW(), UUID()); 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 d12737e..e2494ef 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(), eventType); + IPDEvent ipdEvent = new IPDEvent(encounter.getUuid(), encounter.getPatient().getUuid(), encounter.getVisit().getUuid(), eventType); eventManager.processEvent(ipdEvent); } ipdScheduleService.handlePostProcessEncounterTransaction(encounter,encounterTransaction); 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 08/10] 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); From 1324ca484b670a05b699e11ed1ba1ab5b3c3fa0c Mon Sep 17 00:00:00 2001 From: Soorya Kumaran C <90232857+SooryaKumaranC-tw@users.noreply.github.com> Date: Sun, 14 Apr 2024 01:16:20 +0530 Subject: [PATCH 09/10] Remove the emrapi dependency --- api/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index b4d1465..ecc0868 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -212,11 +212,6 @@ test - - org.openmrs.module - emrapi-api - provided - From cff31ac67140188758b51884e90953e339aa3d6b Mon Sep 17 00:00:00 2001 From: Soorya Kumaran C <90232857+SooryaKumaranC-tw@users.noreply.github.com> Date: Mon, 15 Apr 2024 12:47:12 +0530 Subject: [PATCH 10/10] Refactor the method names --- .../ipd/api/events/handler/impl/RolloverTaskEventHandler.java | 4 ++-- .../api/events/handler/impl/ShiftStartTaskEventHandler.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 59e59e3..9dc34a3 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,7 +40,7 @@ public void handleEvent(IPDEvent event) { List taskNames = eventConfig.getTasks().stream() .map(TaskDetail::getName) .collect(Collectors.toList()); - List rolloverTasks = taskService.getTasksByNameAndStatus(taskNames, FhirTask.TaskStatus.REQUESTED); + List rolloverTasks = taskService.searchTasks(taskNames, FhirTask.TaskStatus.REQUESTED); List fhirTaskRequestedPeriods = new ArrayList(); for (Task task : rolloverTasks) { if (task.getFhirTaskRequestedPeriod() != null) { @@ -49,6 +49,6 @@ public void handleEvent(IPDEvent event) { fhirTaskRequestedPeriods.add(fhirTaskRequestedPeriod); } } - taskRequestedPeriodDao.bulkUpdate(fhirTaskRequestedPeriods); + taskRequestedPeriodDao.update(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 12d1960..e97d620 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 @@ -45,7 +45,7 @@ public void handleEvent(IPDEvent event) { } } if(tasks.size() > 0){ - taskService.bulkSaveTasks(tasks); + taskService.saveTask(tasks); } }