Search in sources :

Example 1 with FormService

use of org.openmrs.api.FormService in project openmrs-core by openmrs.

the class FormServiceImpl method duplicateFormResources.

/**
 * duplicates form resources from one form to another
 *
 * @param source the form to copy resources from
 * @param destination the form to copy resources to
 */
private void duplicateFormResources(Form source, Form destination) {
    FormService service = Context.getFormService();
    for (FormResource resource : service.getFormResourcesForForm(source)) {
        FormResource newResource = new FormResource(resource);
        newResource.setForm(destination);
        service.saveFormResource(newResource);
    }
}
Also used : FormService(org.openmrs.api.FormService) FormResource(org.openmrs.FormResource)

Example 2 with FormService

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

the class HtmlFormSetup method setupHtmlForms.

// 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
public static void setupHtmlForms(Config config) throws Exception {
    try {
        ResourceFactory resourceFactory = ResourceFactory.getInstance();
        FormService formService = Context.getFormService();
        HtmlFormEntryService htmlFormEntryService = Context.getService(HtmlFormEntryService.class);
        // forms installed across all implementations
        List<String> htmlforms = new ArrayList(Arrays.asList("pihcore:htmlforms/admissionNote.xml", "pihcore:htmlforms/patientRegistration.xml", "pihcore:htmlforms/patientRegistration-rs.xml", "pihcore:htmlforms/surgicalPostOpNote.xml", "pihcore:htmlforms/vitals.xml", "pihcore:htmlforms/transferNote.xml", "pihcore:htmlforms/dischargeNote.xml", "pihcore:htmlforms/outpatientConsult.xml", "pihcore:htmlforms/edNote.xml", "pihcore:htmlforms/deathCertificate.xml", "pihcore:htmlforms/oncologyConsult.xml", "pihcore:htmlforms/mentalHealth.xml", "pihcore:htmlforms/section-chief-complaint.xml", "pihcore:htmlforms/section-history.xml", "pihcore:htmlforms/section-exam.xml", "pihcore:htmlforms/section-dx.xml", "pihcore:htmlforms/section-peds-feeding.xml", "pihcore:htmlforms/section-peds-supplements.xml", "pihcore:htmlforms/section-plan.xml", "pihcore:htmlforms/section-ncd.xml", "pihcore:htmlforms/section-lab-order.xml", "pihcore:htmlforms/section-family-planning.xml", "pihcore:htmlforms/socio-econ.xml", "pihcore:htmlforms/primary-care-adult-initial.xml", "pihcore:htmlforms/primary-care-adult-followup.xml", "pihcore:htmlforms/primary-care-peds-initial.xml", "pihcore:htmlforms/primary-care-peds-followup.xml", "pihcore:htmlforms/ncd-adult-initial.xml", "pihcore:htmlforms/ncd-adult-followup.xml"));
        // add any country-specific forms
        if (config.getCountry().equals(ConfigDescriptor.Country.HAITI)) {
            htmlforms.addAll(Arrays.asList("pihcore:htmlforms/haiti/hiv/zl/hiv-intake.xml", "pihcore:htmlforms/haiti/patientRegistration-contact.xml", "pihcore:htmlforms/haiti/patientRegistration-social.xml", "pihcore:htmlforms/haiti/patientRegistration-insurance.xml", "pihcore:htmlforms/haiti/checkin.xml", "pihcore:htmlforms/haiti/liveCheckin.xml", "pihcore:htmlforms/haiti/hiv/zl/hiv-followup.xml", "pihcore:htmlforms/haiti/hiv/zl/vct.xml", "pihcore:htmlforms/haiti/hiv/zl/section-hiv-serology.xml", "pihcore:htmlforms/haiti/hiv/zl/section-symptoms.xml", "pihcore:htmlforms/haiti/hiv/zl/section-who-stages.xml", "pihcore:htmlforms/haiti/hiv/zl/section-hiv-oi.xml", "pihcore:htmlforms/haiti/hiv/zl/section-hiv-state.xml", "pihcore:htmlforms/haiti/hiv/iSantePlus/Adherence.xml", "pihcore:htmlforms/haiti/hiv/iSantePlus/SaisiePremiereVisiteAdult.xml", "pihcore:htmlforms/haiti/hiv/iSantePlus/SaisiePremiereVisitePediatrique.xml", "pihcore:htmlforms/haiti/hiv/iSantePlus/VisiteDeSuivi.xml", "pihcore:htmlforms/haiti/hiv/iSantePlus/VisiteDeSuiviPediatrique.xml"));
        } else if (config.getCountry().equals(ConfigDescriptor.Country.LIBERIA)) {
            htmlforms.addAll(Arrays.asList("pihcore:htmlforms/liberia/checkin.xml", "pihcore:htmlforms/liberia/liveCheckin.xml", "pihcore:htmlforms/liberia/patientRegistration-contact.xml", "pihcore:htmlforms/liberia/patientRegistration-social.xml"));
        } else if (config.getCountry().equals(ConfigDescriptor.Country.SIERRA_LEONE)) {
            htmlforms.addAll(Arrays.asList("pihcore:htmlforms/patientRegistration.xml", "pihcore:htmlforms/patientRegistration-rs.xml", "pihcore:htmlforms/sierra_leone/checkin.xml", "pihcore:htmlforms/sierra_leone/liveCheckin.xml", "pihcore:htmlforms/sierra_leone/patientRegistration-contact.xml", "pihcore:htmlforms/sierra_leone/patientRegistration-social.xml"));
        }
        if (htmlforms != null) {
            for (String htmlform : htmlforms) {
                HtmlFormUtil.getHtmlFormFromUiResource(resourceFactory, formService, htmlFormEntryService, htmlform);
            }
        }
    } catch (Exception e) {
        // this is a hack to get component test to pass until we find the proper way to mock this
        if (ResourceFactory.getInstance().getResourceProviders() == null) {
            log.error("Unable to load HTML forms--this error is expected when running component tests");
        } else {
            throw e;
        }
    }
}
Also used : HtmlFormEntryService(org.openmrs.module.htmlformentry.HtmlFormEntryService) FormService(org.openmrs.api.FormService) ArrayList(java.util.ArrayList) ResourceFactory(org.openmrs.ui.framework.resource.ResourceFactory)

Example 3 with FormService

use of org.openmrs.api.FormService in project openmrs-module-pihcore by PIH.

the class PihCoreActivator method started.

// TODO test
@Override
public void started() {
    try {
        MetadataMappingService metadataMappingService = Context.getService(MetadataMappingService.class);
        PatientService patientService = Context.getPatientService();
        FormService formService = Context.getFormService();
        LocationService locationService = Context.getLocationService();
        EncounterService encounterService = Context.getEncounterService();
        VisitService visitService = Context.getVisitService();
        IdentifierSourceService identifierSourceService = Context.getService(IdentifierSourceService.class);
        ConceptService conceptService = Context.getService(ConceptService.class);
        if (config == null) {
            // hack to allow injecting a mock config for testing
            // currently only one of these
            config = Context.getRegisteredComponents(Config.class).get(0);
        }
        setDispositionConfig(config);
        installMetadataBundles(config);
        setGlobalProperties(config);
        setExtraIdentifierTypes(metadataMappingService, patientService, config);
        MergeActionsSetup.registerMergeActions();
        LocationTagSetup.setupLocationTags(locationService, config);
        HtmlFormSetup.setupHtmlFormEntryTagHandlers();
        MetadataMappingsSetup.setupGlobalMetadataMappings(metadataMappingService, locationService, encounterService, visitService);
        MetadataMappingsSetup.setupPrimaryIdentifierTypeBasedOnCountry(metadataMappingService, patientService, config);
        MetadataMappingsSetup.setupFormMetadataMappings(metadataMappingService);
        PatientIdentifierSetup.setupIdentifierGeneratorsIfNecessary(identifierSourceService, locationService, config);
        PacIntegrationSetup.setup(config);
        AttachmentsSetup.migrateAttachmentsConceptsIfNecessary(conceptService);
    // RetireProvidersSetup.setupRetireProvidersTask();
    } catch (Exception e) {
        Module mod = ModuleFactory.getModuleById("pihcore");
        ModuleFactory.stopModule(mod);
        throw new RuntimeException("failed to setup the required modules", e);
    }
}
Also used : LocationService(org.openmrs.api.LocationService) VisitService(org.openmrs.api.VisitService) PatientService(org.openmrs.api.PatientService) FormService(org.openmrs.api.FormService) IdentifierSourceService(org.openmrs.module.idgen.service.IdentifierSourceService) Module(org.openmrs.module.Module) ConceptService(org.openmrs.api.ConceptService) EncounterService(org.openmrs.api.EncounterService) MetadataMappingService(org.openmrs.module.metadatamapping.api.MetadataMappingService)

Aggregations

FormService (org.openmrs.api.FormService)3 ArrayList (java.util.ArrayList)1 FormResource (org.openmrs.FormResource)1 ConceptService (org.openmrs.api.ConceptService)1 EncounterService (org.openmrs.api.EncounterService)1 LocationService (org.openmrs.api.LocationService)1 PatientService (org.openmrs.api.PatientService)1 VisitService (org.openmrs.api.VisitService)1 Module (org.openmrs.module.Module)1 HtmlFormEntryService (org.openmrs.module.htmlformentry.HtmlFormEntryService)1 IdentifierSourceService (org.openmrs.module.idgen.service.IdentifierSourceService)1 MetadataMappingService (org.openmrs.module.metadatamapping.api.MetadataMappingService)1 ResourceFactory (org.openmrs.ui.framework.resource.ResourceFactory)1