Search in sources :

Example 6 with DispositionService

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;
            }
        }
    };
}
Also used : DispositionService(org.openmrs.module.emrapi.disposition.DispositionService) PersonService(org.openmrs.api.PersonService) DispositionDescriptor(org.openmrs.module.emrapi.disposition.DispositionDescriptor) Date(java.util.Date) ApplicationContext(org.springframework.context.ApplicationContext) HtmlForm(org.openmrs.module.htmlformentry.HtmlForm) Encounter(org.openmrs.Encounter) FormEntrySession(org.openmrs.module.htmlformentry.FormEntrySession) DispositionAction(org.openmrs.module.emrapi.disposition.actions.DispositionAction) Before(org.junit.Before)

Aggregations

DispositionService (org.openmrs.module.emrapi.disposition.DispositionService)6 Before (org.junit.Before)2 Encounter (org.openmrs.Encounter)2 ConceptService (org.openmrs.api.ConceptService)2 EmrApiProperties (org.openmrs.module.emrapi.EmrApiProperties)2 Date (java.util.Date)1 AdministrationService (org.openmrs.api.AdministrationService)1 LocationService (org.openmrs.api.LocationService)1 PersonService (org.openmrs.api.PersonService)1 SerializedObjectDAO (org.openmrs.api.db.SerializedObjectDAO)1 Module (org.openmrs.module.Module)1 TestUiUtils (org.openmrs.module.appui.TestUiUtils)1 CodedOrFreeTextObsTagHandler (org.openmrs.module.coreapps.htmlformentry.CodedOrFreeTextObsTagHandler)1 EncounterDiagnosesTagHandler (org.openmrs.module.coreapps.htmlformentry.EncounterDiagnosesTagHandler)1 EncounterDispositionTagHandler (org.openmrs.module.coreapps.htmlformentry.EncounterDispositionTagHandler)1 AdtService (org.openmrs.module.emrapi.adt.AdtService)1 EmrConceptService (org.openmrs.module.emrapi.concept.EmrConceptService)1 DispositionDescriptor (org.openmrs.module.emrapi.disposition.DispositionDescriptor)1 DispositionAction (org.openmrs.module.emrapi.disposition.actions.DispositionAction)1 FormEntrySession (org.openmrs.module.htmlformentry.FormEntrySession)1