Search in sources :

Example 11 with AdministrationService

use of org.openmrs.api.AdministrationService in project openmrs-module-coreapps by openmrs.

the class VisitTypeHelper method getOrderedVisitTypes.

/**
 * Returns a list of ordered visit types, provided by a global property
 * If a visit type is present in the visitTypes argument, but not found in the global property string,
 * it will be returned unordered, at the end of the visitTypesOrdered list
 *
 * @param visitTypes
 * @return visitTypesOrdered
 */
public List<VisitType> getOrderedVisitTypes(List<VisitType> visitTypes) {
    AdministrationService adminService = Context.getAdministrationService();
    String propertyValue = adminService.getGlobalProperty(CoreAppsConstants.VISIT_TYPES_ORDER_PROPERTY);
    VisitService vs = Context.getVisitService();
    return getOrderedVisitTypes(visitTypes, propertyValue, vs);
}
Also used : AdministrationService(org.openmrs.api.AdministrationService) VisitService(org.openmrs.api.VisitService)

Example 12 with AdministrationService

use of org.openmrs.api.AdministrationService in project openmrs-module-mirebalais by PIH.

the class PaperRecordServiceIT method setUp.

@Before
public void setUp() {
    paperRecordService = new PaperRecordServiceImpl();
    patientService = mock(PatientService.class);
    administrationService = mock(AdministrationService.class);
    paperRecordProperties = mock(PaperRecordProperties.class);
    paperRecordDAO = mock(PaperRecordDAO.class);
    ((PaperRecordServiceImpl) paperRecordService).setIdentifierSourceService(identifierSourceService);
    ((PaperRecordServiceImpl) paperRecordService).setPatientService(patientService);
    ((PaperRecordServiceImpl) paperRecordService).setPaperRecordProperties(paperRecordProperties);
    ((PaperRecordServiceImpl) paperRecordService).setPaperRecordDAO(paperRecordDAO);
    // so we handle the hack in PaperRecordServiceImpl where internal methods are fetched via Context.getService
    mockStatic(Context.class);
    when(Context.getService(PaperRecordService.class)).thenReturn(paperRecordService);
}
Also used : PaperRecordDAO(org.openmrs.module.paperrecord.db.PaperRecordDAO) AdministrationService(org.openmrs.api.AdministrationService) PatientService(org.openmrs.api.PatientService) PaperRecordProperties(org.openmrs.module.paperrecord.PaperRecordProperties) PaperRecordServiceImpl(org.openmrs.module.paperrecord.PaperRecordServiceImpl) Before(org.junit.Before)

Example 13 with AdministrationService

use of org.openmrs.api.AdministrationService in project openmrs-module-mirebalais by PIH.

the class MirebalaisHospitalActivator method started.

/**
 * @see ModuleActivator#started()
 */
public void started() {
    try {
        // currently only one of these
        Config config = Context.getRegisteredComponents(Config.class).get(0);
        AdministrationService administrationService = Context.getAdministrationService();
        ReportService reportService = Context.getService(ReportService.class);
        ReportDefinitionService reportDefinitionService = Context.getService(ReportDefinitionService.class);
        SerializedObjectDAO serializedObjectDAO = Context.getRegisteredComponents(SerializedObjectDAO.class).get(0);
        PrinterService printerService = Context.getService(PrinterService.class);
        DispositionService dispositionService = Context.getService(DispositionService.class);
        removeOldPrivileges();
        setDispositionConfig(config, dispositionService);
        // register our custom print handlers
        PrinterSetup.registerPrintHandlers(printerService);
        // set up html forms--this must happen *after* MDS packages are installed, so that forms defined in code/github
        // take precedent over any in MDS packages; therefore we still do this in the Mirebalais module, not PIH Core
        HtmlFormSetup.setupHtmlForms(config);
        // configure default dashboard in coreapps
        updateGlobalProperty(CoreAppsConstants.GP_DASHBOARD_URL, config.getDashboardUrl());
        // configure default visits page in coreapps
        updateGlobalProperty(CoreAppsConstants.GP_VISITS_PAGE_URL, config.getVisitPageUrl());
        // configure default specific visit detail page in coreapps
        updateGlobalProperty(CoreAppsConstants.GP_VISITS_PAGE_WITH_SPECIFIC_URL, config.getVisitsPageWithSpecificUrl());
        if (config.isComponentEnabled(Components.LEGACY_MPI)) {
            LegacyMasterPatientIndexSetup.setupConnectionToMasterPatientIndex(customProperties);
        }
        if (config.isComponentEnabled(Components.ARCHIVES)) {
            ArchivesSetup.setupCloseStaleCreateRequestsTask();
            ArchivesSetup.setupCloseStalePullRequestsTask();
        }
        if (config.isComponentEnabled(Components.APPOINTMENT_SCHEDULING)) {
            AppointmentSchedulingSetup.setupMarkAppointmentAsMissedOrCompletedTask();
            if (config.getCountry().equals(ConfigDescriptor.Country.HAITI)) {
                AppointmentSchedulingSetup.customizeDailyAppointmentsDataSet();
            }
        }
        if (config.isComponentEnabled(Components.RADIOLOGY) && config.getSite().equals(ConfigDescriptor.Site.MIREBALAIS)) {
            updateGlobalProperty(OpenmrsConstants.GP_ORDER_NUMBER_GENERATOR_BEAN_ID, MirebalaisConstants.RADIOLOGY_ORDER_NUMBER_GENERATOR_BEAN_ID);
        }
        if (!testMode) {
            if (config.isComponentEnabled(Components.OVERVIEW_REPORTS) || config.isComponentEnabled(Components.DATA_EXPORTS)) {
                // must happen after location tags have been configured
                ReportSetup.setupReports(reportService, reportDefinitionService, administrationService, serializedObjectDAO, config);
            }
            // do app and extension configuration
            Context.getRegisteredComponent("customAppLoaderFactory", CustomAppLoaderFactory.class).setReadyForRefresh(true);
            ModuleFactory.getStartedModuleById("appframework").getModuleActivator().contextRefreshed();
            // on first startup, these modules may not have been able to configure their global propertes correctly because
            // all metadata was not loaded; we call the started method here to complete setup
            ModuleFactory.getStartedModuleById("registrationapp").getModuleActivator().started();
        }
    } catch (Exception e) {
        Module mod = ModuleFactory.getModuleById(MirebalaisConstants.MIREBALAIS_MODULE_ID);
        ModuleFactory.stopModule(mod);
        throw new RuntimeException("failed to setup the required modules", e);
    }
    log.info("Mirebalais Hospital Module started");
}
Also used : DispositionService(org.openmrs.module.emrapi.disposition.DispositionService) ReportService(org.openmrs.module.reporting.report.service.ReportService) AdministrationService(org.openmrs.api.AdministrationService) ReportDefinitionService(org.openmrs.module.reporting.report.definition.service.ReportDefinitionService) CustomAppLoaderFactory(org.openmrs.module.mirebalais.apploader.CustomAppLoaderFactory) Config(org.openmrs.module.pihcore.config.Config) PrinterService(org.openmrs.module.printer.PrinterService) Module(org.openmrs.module.Module) SerializedObjectDAO(org.openmrs.api.db.SerializedObjectDAO)

Example 14 with AdministrationService

use of org.openmrs.api.AdministrationService in project openmrs-module-mirebalais by PIH.

the class MirebalaisHospitalActivator method updateGlobalProperty.

private void updateGlobalProperty(String name, Object value) {
    AdministrationService administrationService = Context.getAdministrationService();
    GlobalProperty gp = administrationService.getGlobalPropertyObject(name);
    gp.setPropertyValue(value == null ? "" : value.toString());
    administrationService.saveGlobalProperty(gp);
}
Also used : AdministrationService(org.openmrs.api.AdministrationService) GlobalProperty(org.openmrs.GlobalProperty)

Example 15 with AdministrationService

use of org.openmrs.api.AdministrationService in project openmrs-module-coreapps by openmrs.

the class VisitTypeHelper method setTransferEncounter.

/**
 * Creates a transfer encounter when visit type is changed
 *
 * @param visit
 * @param vs
 * @param es
 * @param encounter
 * @param patient
 * @param person
 * @param loginLocation
 * @param previousType
 * @param isTransferType
 */
protected void setTransferEncounter(Visit visit, VisitService vs, EncounterService es, Encounter encounter, Patient patient, Person person, Location loginLocation, VisitType previousType, boolean isTransferType) {
    AdministrationService adminService = Context.getAdministrationService();
    String transferEncounterUuid = adminService.getGlobalProperty(CoreAppsConstants.TRANSFER_ENCOUNTER_TYPE_UUID);
    EncounterType transferEncounterType = es.getEncounterTypeByUuid(transferEncounterUuid);
    if (previousType != null && isTransferType) {
        // add Transfer encounter
        encounter.setEncounterType(transferEncounterType);
        encounter.setPatient(patient);
        encounter.setEncounterDatetime(new Date());
        encounter.setProvider(person);
        encounter.setLocation(loginLocation);
        es.saveEncounter(encounter);
        visit.addEncounter(encounter);
        vs.saveVisit(visit);
    }
}
Also used : AdministrationService(org.openmrs.api.AdministrationService) EncounterType(org.openmrs.EncounterType) Date(java.util.Date)

Aggregations

AdministrationService (org.openmrs.api.AdministrationService)25 GlobalProperty (org.openmrs.GlobalProperty)8 ArrayList (java.util.ArrayList)5 User (org.openmrs.User)4 Test (org.junit.Test)3 IOException (java.io.IOException)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 List (java.util.List)2 EncounterType (org.openmrs.EncounterType)2 APIException (org.openmrs.api.APIException)2 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)2 BindException (org.springframework.validation.BindException)2 Errors (org.springframework.validation.Errors)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1