Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,9 @@ public interface FlagService extends OpenmrsService {

@Transactional(readOnly = true)
public List<PatientFlag> getPatientFlags(Patient patient, Set<Role> roles, String displayPointName);

/**
* Delete all patient f lags.
*/
public void deleteAllPatientFLags();
}
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ public Future<?> evaluateAllFlags() {
if (executor == null) {
executor = Executors.newSingleThreadExecutor();
}
dao.deleteAllPatientFlags();
return executor.submit(PatientFlagTask.evaluateAllFlags());
}

Expand Down Expand Up @@ -708,4 +707,10 @@ public List<PatientFlag> getPatientFlags(Patient patient) {
public List<PatientFlag> getPatientFlags(Patient patient, Set<Role> roles, String displayPointName) {
return getPatientFlags(patient, getFilter(roles, getDisplayPoint(displayPointName)));
}

@Override
public void deleteAllPatientFLags() {
dao.deleteAllPatientFlags();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public void generatePatientFlags(Flag flag) {
}

private static void generatePatientFlags(Flag flag, FlagService service) {

service.deletePatientFlagsForFlag(flag);
generatePatientFlagsForFlagAndPatient(flag,service);
}
Expand Down Expand Up @@ -127,7 +126,7 @@ private static class AllFlagsEvaluator implements Runnable {
@Override
public void run() {
FlagService flagService = Context.getService(FlagService.class);

flagService.deleteAllPatientFLags();
flagService.getAllFlags().forEach(flag -> Daemon.runInNewDaemonThread(new PatientFlagGenerator(flag)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,14 @@ public void getPatientFlags_shouldAcceptNullParameters() {
assertFalse(patientFlags.isEmpty());
}

@Test
public void deleteAllPatientFags_shouldDeleteAllPatientFlags() {
Patient patient = Context.getService(PatientService.class).getPatient(1);
flagService.deleteAllPatientFLags();
List<PatientFlag> patientFlags = flagService.getPatientFlags(patient,null,"");
assertTrue(patientFlags.isEmpty());
}

/**
* Utility methods
*/
Expand Down