Skip to content

Commit adde82a

Browse files
authored
HTML-882 Create tag to schedule appointment (#340)
* HTML-882: Create tag to schedule appointment * add ability to make scheduling appointment optional + show message in view / edit mode * address feedback comments * add restrictToCurrentVisitLocation param; address feedback * update Schedule Appointment tag to suport duration and all-day appointments and save appointment uuid as obs * add controlId to ScheduleAppointment tag * make duration required * fix tests; separate inline style into CSS * add translations for: es, fr, ht * address feedback * add additional tests
1 parent 40945b0 commit adde82a

14 files changed

Lines changed: 1964 additions & 3 deletions

File tree

api-tests/src/test/java/org/openmrs/module/htmlformentry/ScheduleAppointmentTagTest.java

Lines changed: 860 additions & 0 deletions
Large diffs are not rendered by default.

api/src/main/java/org/openmrs/module/htmlformentry/FormEntrySession.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,14 +434,14 @@ public String createForm(String xml) throws Exception {
434434
xml = htmlGenerator.applyRepeats(xml);
435435
xml = htmlGenerator.applyTranslations(xml, context);
436436
xml = htmlGenerator.applyTags(this, xml);
437-
437+
438438
if (context.hasUnmatchedObsGroupEntities() && (context.getMode() == Mode.EDIT || context.getMode() == Mode.VIEW)) {
439439
if (context.getUnmatchedObsGroupEntities().size() > 1 && context.getExistingObsInGroupsCount() > 0)
440440
context.setGuessingInd(true);
441441
context.setUnmatchedMode(true);
442442
xml = htmlGenerator.applyUnmatchedTags(this, xml);
443443
}
444-
444+
445445
xml = htmlGenerator.wrapInDiv(xml);
446446
return xml;
447447
}
@@ -648,6 +648,10 @@ public void applyActions() throws BadFormDesignException {
648648
new AppointmentsAbstractor().disassociateAppointmentsFromEncounter(
649649
submissionActions.getAppointmentsToDisassociateFromEncounter(), encounter);
650650
}
651+
652+
if (!submissionActions.getAppointmentsToCreate().isEmpty()) {
653+
new AppointmentsAbstractor().createAppointments(submissionActions.getAppointmentsToCreate());
654+
}
651655

652656
//deal with relationships
653657
if (submissionActions.getRelationshipsToCreate() != null) {

api/src/main/java/org/openmrs/module/htmlformentry/FormSubmissionActions.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ public class FormSubmissionActions {
8080
private List<PatientIdentifier> identifiersToVoid = new Vector<PatientIdentifier>();
8181

8282
private List<Object> appointmentsToMarkCheckedInAndAssociateWithEncounter = new Vector<Object>();
83-
83+
8484
private List<Object> appointmentsToDisassociateFromEncounter = new Vector<Object>();
85+
86+
private List<Object> appointmentsToCreate = new Vector<Object>();
8587

8688
private ExitFromCareProperty exitFromCareProperty;
8789

@@ -967,4 +969,12 @@ public List<Object> getAppointmentsToDisassociateFromEncounter() {
967969
public void setAppointmentsToDisassociateFromEncounter(List<Object> appointmentsToDisassociateFromEncounter) {
968970
this.appointmentsToDisassociateFromEncounter = appointmentsToDisassociateFromEncounter;
969971
}
972+
973+
public List<Object> getAppointmentsToCreate() {
974+
return appointmentsToCreate;
975+
}
976+
977+
public void addAppointmentToCreate(Object appointment) {
978+
appointmentsToCreate.add(appointment);
979+
}
970980
}

api/src/main/java/org/openmrs/module/htmlformentry/appointment/AppointmentsAbstractor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,11 @@ public void disassociateAppointmentsFromEncounter(List<Object> appointments, Enc
4343
}
4444
}
4545
}
46+
47+
public void createAppointments(List<Object> appointments) {
48+
for (Object obj : appointments) {
49+
Appointment appointment = (Appointment) obj;
50+
Context.getService(AppointmentsService.class).validateAndSave(appointment);
51+
}
52+
}
4653
}

0 commit comments

Comments
 (0)