use of org.openmrs.module.emrapi.disposition.DispositionService 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