Skip to content

Commit

Permalink
TaskRequest Object should only be created if incoming task is persist…
Browse files Browse the repository at this point in the history
…ed (#39)
  • Loading branch information
mozzy11 authored Oct 20, 2023
1 parent 6201727 commit 1e78054
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@ public void execute() {
taskBundle = client.loadPage().next(taskBundle).execute();
taskBundles.add(taskBundle);
}
updateTasksInBundle(taskBundles);

TaskRequest request = new TaskRequest();
request.setRequestDate(newDate);
labOnFhirService.saveOrUpdateTaskRequest(request);
Boolean tasksUpdated = updateTasksInBundle(taskBundles);
if (tasksUpdated) {
TaskRequest request = new TaskRequest();
request.setRequestDate(newDate);
labOnFhirService.saveOrUpdateTaskRequest(request);
}
}
catch (Exception e) {
log.error("ERROR executing FetchTaskUpdates : " + e.toString() + getStackTrace(e));
Expand All @@ -146,7 +147,8 @@ public void shutdown() {
this.stopExecuting();
}

private void updateTasksInBundle(List<Bundle> taskBundles) {
private Boolean updateTasksInBundle(List<Bundle> taskBundles) {
Boolean tasksUpdated = false;
for (Bundle bundle : taskBundles) {
for (Iterator tasks = bundle.getEntry().iterator(); tasks.hasNext();) {
String openmrsTaskUuid = null;
Expand All @@ -170,6 +172,7 @@ private void updateTasksInBundle(List<Bundle> taskBundles) {
}
if (taskOutPutUpdated) {
taskService.update(openmrsTaskUuid, openmrsTask);
tasksUpdated = taskOutPutUpdated;
}
}
}
Expand All @@ -178,6 +181,7 @@ private void updateTasksInBundle(List<Bundle> taskBundles) {
}
}
}
return tasksUpdated;
}

private Boolean updateOutput(List<Task.TaskOutputComponent> output, Task openmrsTask) {
Expand Down

0 comments on commit 1e78054

Please sign in to comment.