use of org.openmrs.module.htmlformentry.HtmlForm in project openmrs-module-pihcore by PIH.
the class HtmlFormComponentTest method testHtmlForms.
@Test
public void testHtmlForms() throws Exception {
String[] formsToTest = { "patientRegistration.xml", "patientRegistration-rs.xml", "patientRegistration-contact.xml", "patientRegistration-social.xml", // "vitals.xml",
"transferNote.xml", "dischargeNote.xml", // "edNote.xml",
"deathCertificate.xml", // "haiti/section-exam.xml",
"section-dx.xml", // "haiti/liveCheckin.xml",
"haiti/patientRegistration-contact.xml", "haiti/patientRegistration-social.xml" // "liberia/checkin.xml",
// "liberia/liveCheckin.xml",
};
for (String formName : formsToTest) {
// loading up all of the UI Framework beans to fetch this resource is problematic, so just get it directly:
InputStream in = getClass().getClassLoader().getResourceAsStream("web/module/resources/htmlforms/" + formName);
String xml = IOUtils.toString(in);
IOUtils.closeQuietly(in);
try {
HtmlForm form = HtmlFormUtil.getHtmlFormFromResourceXml(Context.getFormService(), Context.getService(HtmlFormEntryService.class), xml);
FormEntrySession fes = new FormEntrySession(new Patient(), form, FormEntryContext.Mode.ENTER, new MockHttpSession());
String html = fes.getHtmlToDisplay();
} catch (Exception ex) {
ex.printStackTrace();
Assert.fail("Failed to load " + formName + ": " + ex.getMessage());
}
}
}
use of org.openmrs.module.htmlformentry.HtmlForm in project openmrs-module-pihcore by PIH.
the class ApplyDispositionActionsTest method setUp.
@Before
public void setUp() throws Exception {
encounter = new Encounter(1);
encounter.setDateCreated(new Date());
encounter.setPatient(patient);
encounter.setVisit(visit);
deathDispositionObsGroup.setConcept(dispositionObsGroupConcept);
deathDispositionObs.setConcept(dispositionObsConcept);
deathDispositionObs.setValueCoded(death);
deathDispositionObsGroup.addGroupMember(deathDispositionObs);
nonDispositionObsGroup.setConcept(nonDispositionObsGroupConcept);
nonDispositionObs.setConcept(nonDispositionObsConcept);
nonDispositionObsGroup.addGroupMember(nonDispositionObs);
deathDisposition.setActions(Arrays.asList("dischargeIfAdmittedDispositionAction", "markPatientDeadDispositionAction"));
dispositionService = mock(DispositionService.class);
dischargeIfAdmittedDispositionAction = mock(DispositionAction.class);
markPatientDeadDispositionAction = mock(DispositionAction.class);
ServiceContext.getInstance().setPersonService(mock(PersonService.class));
ServiceContext.getInstance().setApplicationContext(mock(ApplicationContext.class));
HtmlForm htmlForm = new HtmlForm();
htmlForm.setXmlData("<htmlform></htmlform>");
session = new FormEntrySession(patient, encounter, FormEntryContext.Mode.ENTER, htmlForm, null);
DispositionDescriptor dispositionDescriptor = new DispositionDescriptor();
dispositionDescriptor.setDispositionConcept(dispositionObsConcept);
dispositionDescriptor.setDispositionSetConcept(dispositionObsGroupConcept);
when(dispositionService.getDispositionDescriptor()).thenReturn(dispositionDescriptor);
when(dispositionService.getDispositionFromObsGroup(deathDispositionObsGroup)).thenReturn(deathDisposition);
applyDispositionActions = new ApplyDispositionAction() {
@Override
<T> T getBean(String beanId, Class<T> clazz) {
if (beanId.equals("dischargeIfAdmittedDispositionAction")) {
return (T) dischargeIfAdmittedDispositionAction;
} else if (beanId.equals("markPatientDeadDispositionAction")) {
return (T) markPatientDeadDispositionAction;
} else {
return null;
}
}
};
}
Aggregations