use of org.openmrs.api.LocationService 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);
}
}
use of org.openmrs.api.LocationService in project openmrs-core by openmrs.
the class MigrationHelper method importLocations.
/**
* Takes XML like: <something> <location name="Cerca-la-Source"/> </something> returns the
* number of locations added
*/
public static int importLocations(Document document) {
int ret = 0;
LocationService ls = Context.getLocationService();
List<Node> toAdd = new ArrayList<>();
findNodesNamed(document, "location", toAdd);
for (Node node : toAdd) {
Element e = (Element) node;
String name = e.getAttribute("name");
if (name == null || name.length() == 0) {
throw new IllegalArgumentException("each <location /> element must define a name attribute");
}
if (ls.getLocation(name) != null) {
continue;
}
Location location = new Location();
location.setName(name);
ls.saveLocation(location);
++ret;
}
return ret;
}
Aggregations