use of org.openmrs.Location in project openmrs-module-pihcore by PIH.
the class DailyIndicatorByLocationDataSetManager method getLocations.
public List<Location> getLocations() {
List<String> locationsToExclude = Arrays.asList(// Unknown location
"8d6c993e-c2cc-11de-8d13-0010c6dffd0f", // Hôpital Universitaire de Mirebalais - Prensipal
"24bd1390-5959-11e4-8ed6-0800200c9a66", // Mirebalais
"a084f714-a536-473b-94e6-ec317b152b43");
List<Location> ret = new ArrayList<>();
for (Location l : locationService.getAllLocations(false)) {
String uuid = l.getUuid();
if (!locationsToExclude.contains(uuid)) {
ret.add(l);
}
}
return ret;
}
use of org.openmrs.Location in project openmrs-module-pihcore by PIH.
the class DailyIndicatorByLocationDataSetManager method getParameterOptions.
protected List<Map<String, Object>> getParameterOptions() {
List<Map<String, Object>> options = new ArrayList<Map<String, Object>>();
List<Location> locations = getLocations();
for (Location location : locations) {
Map<String, Object> option = new HashMap<String, Object>();
option.put("location", location);
options.add(option);
}
return options;
}
use of org.openmrs.Location in project openmrs-module-pihcore by PIH.
the class ConfigureLiberiaIdGenerators method configureGenerators.
public static void configureGenerators(IdentifierSourceService identifierSourceService, Config config) {
Location identifierLocation = getIdentifierLocation(config);
SequentialIdentifierGenerator liberiaPrimaryIdentifierSource = (SequentialIdentifierGenerator) identifierSourceService.getIdentifierSourceByUuid(LIBERIA_PRIMARY_IDENTIFIER_SOURCE_UUID);
if (liberiaPrimaryIdentifierSource == null) {
liberiaPrimaryIdentifierSource = new SequentialIdentifierGenerator();
}
liberiaPrimaryIdentifierSource.setName("Liberia Primary Identifier Source");
liberiaPrimaryIdentifierSource.setDescription("Primary Identifier Generator for Liberia");
liberiaPrimaryIdentifierSource.setIdentifierType(Context.getPatientService().getPatientIdentifierTypeByUuid(LiberiaConfigConstants.PATIENTIDENTIFIERTYPE_LIBERIAEMRID_UUID));
liberiaPrimaryIdentifierSource.setPrefix(config.getPrimaryIdentifierPrefix());
liberiaPrimaryIdentifierSource.setMinLength(7 + liberiaPrimaryIdentifierSource.getPrefix().length());
liberiaPrimaryIdentifierSource.setMaxLength(8 + liberiaPrimaryIdentifierSource.getPrefix().length());
liberiaPrimaryIdentifierSource.setBaseCharacterSet("0123456789");
if (config.getSite().equalsIgnoreCase("HARPER")) {
liberiaPrimaryIdentifierSource.setFirstIdentifierBase("0100000");
} else {
liberiaPrimaryIdentifierSource.setFirstIdentifierBase("0000001");
}
liberiaPrimaryIdentifierSource.setUuid(LIBERIA_PRIMARY_IDENTIFIER_SOURCE_UUID);
identifierSourceService.saveIdentifierSource(liberiaPrimaryIdentifierSource);
AutoGenerationOption autoGenerationOption = identifierSourceService.getAutoGenerationOption(liberiaPrimaryIdentifierSource.getIdentifierType());
if (autoGenerationOption == null) {
autoGenerationOption = new AutoGenerationOption();
}
autoGenerationOption.setIdentifierType(Context.getPatientService().getPatientIdentifierTypeByUuid(LiberiaConfigConstants.PATIENTIDENTIFIERTYPE_LIBERIAEMRID_UUID));
autoGenerationOption.setSource(liberiaPrimaryIdentifierSource);
autoGenerationOption.setAutomaticGenerationEnabled(true);
autoGenerationOption.setManualEntryEnabled(false);
autoGenerationOption.setLocation(identifierLocation);
identifierSourceService.saveAutoGenerationOption(autoGenerationOption);
}
use of org.openmrs.Location in project openmrs-module-pihcore by PIH.
the class ConfigurePeruIdGenerators method configureGenerators.
public static void configureGenerators(IdentifierSourceService identifierSourceService, Config config) {
Location identifierLocation = Context.getLocationService().getLocationByUuid(PERU_ID_LOCATION_UUID);
SequentialIdentifierGenerator peruPrimaryIdentifierSource = (SequentialIdentifierGenerator) identifierSourceService.getIdentifierSourceByUuid(PERU_PRIMARY_IDENTIFIER_SOURCE_UUID);
if (peruPrimaryIdentifierSource == null) {
peruPrimaryIdentifierSource = new SequentialIdentifierGenerator();
}
peruPrimaryIdentifierSource.setName("SES Primary Identifier Source");
peruPrimaryIdentifierSource.setDescription("Primary Identifier Generator for PIH Peru / SES");
peruPrimaryIdentifierSource.setIdentifierType(Context.getPatientService().getPatientIdentifierTypeByUuid(SesConfigConstants.PATIENTIDENTIFIERTYPE_SESEMRID_UUID));
String prefixForSite = config.getPrimaryIdentifierPrefix();
peruPrimaryIdentifierSource.setPrefix(prefixForSite);
peruPrimaryIdentifierSource.setMinLength(4 + peruPrimaryIdentifierSource.getPrefix().length());
peruPrimaryIdentifierSource.setMaxLength(4 + peruPrimaryIdentifierSource.getPrefix().length());
peruPrimaryIdentifierSource.setBaseCharacterSet("ACDEFGHIJKLMNOPQRSTUVWXYZ");
peruPrimaryIdentifierSource.setFirstIdentifierBase("AAAA");
peruPrimaryIdentifierSource.setUuid(PERU_PRIMARY_IDENTIFIER_SOURCE_UUID);
identifierSourceService.saveIdentifierSource(peruPrimaryIdentifierSource);
AutoGenerationOption autoGenerationOption = identifierSourceService.getAutoGenerationOption(peruPrimaryIdentifierSource.getIdentifierType());
if (autoGenerationOption == null) {
autoGenerationOption = new AutoGenerationOption();
}
autoGenerationOption.setIdentifierType(Context.getPatientService().getPatientIdentifierTypeByUuid(SesConfigConstants.PATIENTIDENTIFIERTYPE_SESEMRID_UUID));
autoGenerationOption.setSource(peruPrimaryIdentifierSource);
autoGenerationOption.setAutomaticGenerationEnabled(true);
autoGenerationOption.setManualEntryEnabled(false);
autoGenerationOption.setLocation(identifierLocation);
identifierSourceService.saveAutoGenerationOption(autoGenerationOption);
}
use of org.openmrs.Location in project openmrs-module-pihcore by PIH.
the class DailyClinicalEncountersDataSetManager method constructDataSetDefinition.
@Override
public DataSetDefinition constructDataSetDefinition(DataSetDescriptor dataSetDescriptor, File file) {
String messagePrefix = "mirebalaisreports.dailyClinicalEncounters.";
EncounterType vitalsEncounterType = encounterService.getEncounterTypeByUuid(PihEmrConfigConstants.ENCOUNTERTYPE_VITALS_UUID);
EncounterType consultEncounterType = encounterService.getEncounterTypeByUuid(PihEmrConfigConstants.ENCOUNTERTYPE_CONSULTATION_UUID);
CohortDefinition clinicalCheckIns = pihCohorts.getClinicalCheckInAtLocation();
clinicalCheckIns.setName("clinicalCheckIns");
clinicalCheckIns.setDescription(messagePrefix + "clinicalCheckIns");
Mapped<CohortDefinition> mappedClinicalCheckIns = Mapped.map(clinicalCheckIns, "startDate=${day},endDate=${day+1d-1ms},location=${location}");
EncounterCohortDefinition vitals = new EncounterCohortDefinition();
vitals.setName("vitals");
vitals.setDescription("ui.i18n.EncounterType.name." + vitalsEncounterType.getUuid());
vitals.addParameter(new Parameter("locationList", "Location", Location.class));
vitals.addParameter(new Parameter("onOrAfter", "On Or After", Date.class));
vitals.addParameter(new Parameter("onOrBefore", "On Or Before", Date.class));
vitals.addEncounterType(vitalsEncounterType);
Mapped<CohortDefinition> mappedVitals = Mapped.map(vitals, "onOrAfter=${day},onOrBefore=${day+1d-1ms},locationList=${location}");
EncounterCohortDefinition consults = new EncounterCohortDefinition();
consults.setName("consults");
consults.setDescription("ui.i18n.EncounterType.name." + consultEncounterType.getUuid());
consults.addParameter(new Parameter("locationList", "Location", Location.class));
consults.addParameter(new Parameter("onOrAfter", "On Or After", Date.class));
consults.addParameter(new Parameter("onOrBefore", "On Or Before", Date.class));
consults.addEncounterType(consultEncounterType);
Mapped<CohortDefinition> mappedConsults = Mapped.map(consults, "onOrAfter=${day},onOrBefore=${day+1d-1ms},locationList=${location}");
CompositionCohortDefinition consultWithoutVitals = new CompositionCohortDefinition();
consultWithoutVitals.setName("consultWithoutVitals");
consultWithoutVitals.setDescription(messagePrefix + "consultWithoutVitals");
consultWithoutVitals.addParameter(getDayParameter());
consultWithoutVitals.addParameter(getLocationParameter());
consultWithoutVitals.addSearch("consult", mappedConsults);
consultWithoutVitals.addSearch("vitals", mappedVitals);
consultWithoutVitals.setCompositionString("consult AND NOT vitals");
CohortsWithVaryingParametersDataSetDefinition byLocationDsd = new CohortsWithVaryingParametersDataSetDefinition();
byLocationDsd.setName("byLocation");
byLocationDsd.addParameter(getDayParameter());
byLocationDsd.addColumn(mappedClinicalCheckIns);
byLocationDsd.addColumn(mappedVitals);
byLocationDsd.addColumn(mappedConsults);
byLocationDsd.addColumn(Mapped.mapStraightThrough(consultWithoutVitals));
byLocationDsd.setVaryingParameters(getParameterOptions());
byLocationDsd.setRowLabelTemplate("{{ location.name }}");
return byLocationDsd;
}
Aggregations