Search in sources :

Example 81 with Location

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;
}
Also used : ArrayList(java.util.ArrayList) Location(org.openmrs.Location)

Example 82 with Location

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) Location(org.openmrs.Location)

Example 83 with Location

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);
}
Also used : AutoGenerationOption(org.openmrs.module.idgen.AutoGenerationOption) SequentialIdentifierGenerator(org.openmrs.module.idgen.SequentialIdentifierGenerator) Location(org.openmrs.Location)

Example 84 with Location

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);
}
Also used : AutoGenerationOption(org.openmrs.module.idgen.AutoGenerationOption) SequentialIdentifierGenerator(org.openmrs.module.idgen.SequentialIdentifierGenerator) Location(org.openmrs.Location)

Example 85 with Location

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;
}
Also used : CompositionCohortDefinition(org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition) CohortDefinition(org.openmrs.module.reporting.cohort.definition.CohortDefinition) EncounterCohortDefinition(org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter) CompositionCohortDefinition(org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition) EncounterType(org.openmrs.EncounterType) CohortsWithVaryingParametersDataSetDefinition(org.openmrs.module.reporting.dataset.definition.CohortsWithVaryingParametersDataSetDefinition) EncounterCohortDefinition(org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition) Date(java.util.Date) Location(org.openmrs.Location)

Aggregations

Location (org.openmrs.Location)235 Test (org.junit.Test)161 Date (java.util.Date)80 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)74 Patient (org.openmrs.Patient)66 Encounter (org.openmrs.Encounter)38 SimpleObject (org.openmrs.ui.framework.SimpleObject)32 PatientIdentifierType (org.openmrs.PatientIdentifierType)31 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)31 Visit (org.openmrs.Visit)28 AppContextModel (org.openmrs.module.appframework.context.AppContextModel)28 Obs (org.openmrs.Obs)27 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)27 PatientIdentifier (org.openmrs.PatientIdentifier)26 Concept (org.openmrs.Concept)19 EncounterType (org.openmrs.EncounterType)18 DateTime (org.joda.time.DateTime)17 ArrayList (java.util.ArrayList)15 VisitContextModel (org.openmrs.module.coreapps.contextmodel.VisitContextModel)15 BindException (org.springframework.validation.BindException)15