Skip to content

Commit

Permalink
Update and Refactor the rollover and shift start task
Browse files Browse the repository at this point in the history
  • Loading branch information
SooryaKumaranC-tw committed Apr 13, 2024
1 parent f852bec commit 9d8e166
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,15 @@ public void handleEvent(IPDEvent event) {
List<String> taskNames = eventConfig.getTasks().stream()
.map(TaskDetail::getName)
.collect(Collectors.toList());

List<Task> rolloverTasks = taskService.getTasksByNameAndStatus(taskNames, TASK_STATUS);

List<Task> rolloverTasks = taskService.getTasksByNameAndStatus(taskNames, FhirTask.TaskStatus.REQUESTED);
List<FhirTaskRequestedPeriod> fhirTaskRequestedPeriods = new ArrayList<FhirTaskRequestedPeriod>();
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,11 @@ public class ShiftStartTaskEventHandler implements IPDEventHandler {
@Override
public void handleEvent(IPDEvent event) {
List<AdmittedPatient> admittedPatients = wardService.getAdmittedPatients();

ConfigDetail eventConfig = getEventConfig(event);

List<Task> tasks = new ArrayList<Task>();
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);
Expand All @@ -61,6 +57,4 @@ private ConfigDetail getEventConfig(IPDEvent event){
.orElse(null);
return eventConfig;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
public class IPDEvent {
private String encounterUuid;
private String patientUuid;
private String visitUuid;
private IPDEventType ipdEventType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9d8e166

Please sign in to comment.