Search in sources :

Example 1 with AutoGenerationOption

use of org.openmrs.module.idgen.AutoGenerationOption in project openmrs-module-pihcore by PIH.

the class ConfigureHaitiIdGenerators method setAutoGenerationOptionsForDossierNumberGenerator.

public void setAutoGenerationOptionsForDossierNumberGenerator(IdentifierSource identifierSource, Location location) {
    AutoGenerationOption autoGenerationOption = identifierSourceService.getAutoGenerationOption(identifierSource.getIdentifierType(), location);
    if (autoGenerationOption == null) {
        autoGenerationOption = new AutoGenerationOption();
    }
    autoGenerationOption.setIdentifierType(identifierSource.getIdentifierType());
    autoGenerationOption.setSource(identifierSource);
    autoGenerationOption.setLocation(location);
    autoGenerationOption.setManualEntryEnabled(true);
    autoGenerationOption.setAutomaticGenerationEnabled(true);
    identifierSourceService.saveAutoGenerationOption(autoGenerationOption);
}
Also used : AutoGenerationOption(org.openmrs.module.idgen.AutoGenerationOption)

Example 2 with AutoGenerationOption

use of org.openmrs.module.idgen.AutoGenerationOption in project openmrs-module-pihcore by PIH.

the class ConfigureHaitiIdGenerators method setAutoGenerationOptionsForZlIdentifier.

public void setAutoGenerationOptionsForZlIdentifier(IdentifierSource identifierSource) {
    AutoGenerationOption autoGenerationOption = identifierSourceService.getAutoGenerationOption(identifierSource.getIdentifierType());
    if (autoGenerationOption == null) {
        autoGenerationOption = new AutoGenerationOption();
    }
    autoGenerationOption.setIdentifierType(identifierSource.getIdentifierType());
    autoGenerationOption.setSource(identifierSource);
    autoGenerationOption.setManualEntryEnabled(false);
    autoGenerationOption.setAutomaticGenerationEnabled(true);
    identifierSourceService.saveAutoGenerationOption(autoGenerationOption);
}
Also used : AutoGenerationOption(org.openmrs.module.idgen.AutoGenerationOption)

Example 3 with AutoGenerationOption

use of org.openmrs.module.idgen.AutoGenerationOption in project openmrs-module-pihcore by PIH.

the class ConfigureLiberiaIdGenerators method configureGenerators.

public static void configureGenerators(IdentifierSourceService identifierSourceService, Config config) {
    Location identifierLocation = MetadataUtils.existing(Location.class, LiberiaLocations.PLEEBO.uuid());
    SequentialIdentifierGenerator pleeboPrimaryIdentifierSource = (SequentialIdentifierGenerator) identifierSourceService.getIdentifierSourceByUuid(PLEEBO_PRIMARY_IDENTIFIER_SOURCE_UUID);
    if (pleeboPrimaryIdentifierSource == null) {
        pleeboPrimaryIdentifierSource = new SequentialIdentifierGenerator();
    }
    pleeboPrimaryIdentifierSource.setName("Pleebo Primary Identifier Source");
    pleeboPrimaryIdentifierSource.setDescription("Primary Identifier Generator for Pleebo");
    pleeboPrimaryIdentifierSource.setIdentifierType(MetadataUtils.existing(PatientIdentifierType.class, LiberiaPatientIdentifierTypes.PLEEBO_EMR_ID.uuid()));
    pleeboPrimaryIdentifierSource.setPrefix(config.getPrimaryIdentifierPrefix());
    pleeboPrimaryIdentifierSource.setMinLength(7 + pleeboPrimaryIdentifierSource.getPrefix().length());
    pleeboPrimaryIdentifierSource.setMaxLength(8 + pleeboPrimaryIdentifierSource.getPrefix().length());
    pleeboPrimaryIdentifierSource.setBaseCharacterSet("0123456789");
    pleeboPrimaryIdentifierSource.setFirstIdentifierBase("0000001");
    pleeboPrimaryIdentifierSource.setUuid(PLEEBO_PRIMARY_IDENTIFIER_SOURCE_UUID);
    identifierSourceService.saveIdentifierSource(pleeboPrimaryIdentifierSource);
    AutoGenerationOption autoGenerationOption = identifierSourceService.getAutoGenerationOption(pleeboPrimaryIdentifierSource.getIdentifierType(), identifierLocation);
    if (autoGenerationOption == null) {
        autoGenerationOption = new AutoGenerationOption();
    }
    autoGenerationOption.setIdentifierType(MetadataUtils.existing(PatientIdentifierType.class, LiberiaPatientIdentifierTypes.PLEEBO_EMR_ID.uuid()));
    autoGenerationOption.setSource(pleeboPrimaryIdentifierSource);
    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) PatientIdentifierType(org.openmrs.PatientIdentifierType) Location(org.openmrs.Location)

Example 4 with AutoGenerationOption

use of org.openmrs.module.idgen.AutoGenerationOption in project openmrs-module-pihcore by PIH.

the class ConfigureSierraLeoneIdGenerators method configureGenerators.

public static void configureGenerators(IdentifierSourceService identifierSourceService) {
    Location identifierLocation = MetadataUtils.existing(Location.class, SierraLeoneLocations.WELLBODY_HEALTH_CENTER.uuid());
    SequentialIdentifierGenerator wellbodyPrimaryIdentifierSource = (SequentialIdentifierGenerator) identifierSourceService.getIdentifierSourceByUuid(WELLBODY_PRIMARY_IDENTIFIER_SOURCE_UUID);
    if (wellbodyPrimaryIdentifierSource == null) {
        wellbodyPrimaryIdentifierSource = new SequentialIdentifierGenerator();
    }
    wellbodyPrimaryIdentifierSource.setName("Wellbody Primary Identifier Source");
    wellbodyPrimaryIdentifierSource.setDescription("Primary Identifier Generator for Wellbody");
    wellbodyPrimaryIdentifierSource.setIdentifierType(MetadataUtils.existing(PatientIdentifierType.class, SierraLeonePatientIdentifierTypes.WELLBODY_EMR_ID.uuid()));
    wellbodyPrimaryIdentifierSource.setPrefix("W");
    wellbodyPrimaryIdentifierSource.setMinLength(7 + wellbodyPrimaryIdentifierSource.getPrefix().length());
    wellbodyPrimaryIdentifierSource.setMaxLength(8 + wellbodyPrimaryIdentifierSource.getPrefix().length());
    wellbodyPrimaryIdentifierSource.setBaseCharacterSet("0123456789");
    wellbodyPrimaryIdentifierSource.setFirstIdentifierBase("0000001");
    wellbodyPrimaryIdentifierSource.setUuid(WELLBODY_PRIMARY_IDENTIFIER_SOURCE_UUID);
    identifierSourceService.saveIdentifierSource(wellbodyPrimaryIdentifierSource);
    AutoGenerationOption autoGenerationOption = identifierSourceService.getAutoGenerationOption(wellbodyPrimaryIdentifierSource.getIdentifierType(), identifierLocation);
    if (autoGenerationOption == null) {
        autoGenerationOption = new AutoGenerationOption();
    }
    autoGenerationOption.setIdentifierType(MetadataUtils.existing(PatientIdentifierType.class, SierraLeonePatientIdentifierTypes.WELLBODY_EMR_ID.uuid()));
    autoGenerationOption.setSource(wellbodyPrimaryIdentifierSource);
    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) PatientIdentifierType(org.openmrs.PatientIdentifierType) Location(org.openmrs.Location)

Example 5 with AutoGenerationOption

use of org.openmrs.module.idgen.AutoGenerationOption in project openmrs-module-coreapps by openmrs.

the class PatientHeaderFragmentController method controller.

public void controller(FragmentConfiguration config, @SpringBean("emrApiProperties") EmrApiProperties emrApiProperties, @SpringBean("coreAppsProperties") CoreAppsProperties coreAppsProperties, @SpringBean("baseIdentifierSourceService") IdentifierSourceService identifierSourceService, @FragmentParam(required = false, value = "appContextModel") AppContextModel appContextModel, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService, @FragmentParam("patient") Object patient, @InjectBeans PatientDomainWrapper wrapper, @SpringBean("adtService") AdtService adtService, UiSessionContext sessionContext, UiUtils uiUtils, FragmentModel model) {
    if (patient instanceof Patient) {
        wrapper.setPatient((Patient) patient);
    } else {
        wrapper = (PatientDomainWrapper) patient;
    }
    config.addAttribute("patient", wrapper);
    config.addAttribute("patientNames", getNames(wrapper.getPersonName()));
    if (appContextModel == null) {
        AppContextModel contextModel = sessionContext.generateAppContextModel();
        contextModel.put("patient", new PatientContextModel(wrapper.getPatient()));
        model.addAttribute("appContextModel", contextModel);
    }
    List<Extension> firstLineFragments = appFrameworkService.getExtensionsForCurrentUser("patientHeader.firstLineFragments");
    Collections.sort(firstLineFragments);
    model.addAttribute("firstLineFragments", firstLineFragments);
    List<Extension> secondLineFragments = appFrameworkService.getExtensionsForCurrentUser("patientHeader.secondLineFragments");
    Collections.sort(secondLineFragments);
    model.addAttribute("secondLineFragments", secondLineFragments);
    List<ExtraPatientIdentifierType> extraPatientIdentifierTypes = new ArrayList<ExtraPatientIdentifierType>();
    for (PatientIdentifierType type : emrApiProperties.getExtraPatientIdentifierTypes()) {
        List<AutoGenerationOption> options = identifierSourceService.getAutoGenerationOptions(type);
        // TODO note that this may allow use to edit a identifier that should not be editable, or vice versa, in the rare case where there are multiple autogeneration
        // TODO options for a single identifier type (which is possible if you have multiple locations) and the manual entry boolean is different between those two generators
        extraPatientIdentifierTypes.add(new ExtraPatientIdentifierType(type, options.size() > 0 ? options.get(0).isManualEntryEnabled() : true));
    }
    config.addAttribute("extraPatientIdentifierTypes", extraPatientIdentifierTypes);
    config.addAttribute("extraPatientIdentifiersMappedByType", wrapper.getExtraIdentifiersMappedByType(sessionContext.getSessionLocation()));
    config.addAttribute("dashboardUrl", coreAppsProperties.getDashboardUrl());
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) PatientContextModel(org.openmrs.module.coreapps.contextmodel.PatientContextModel) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) ArrayList(java.util.ArrayList) Patient(org.openmrs.Patient) AutoGenerationOption(org.openmrs.module.idgen.AutoGenerationOption) PatientIdentifierType(org.openmrs.PatientIdentifierType)

Aggregations

AutoGenerationOption (org.openmrs.module.idgen.AutoGenerationOption)5 PatientIdentifierType (org.openmrs.PatientIdentifierType)3 Location (org.openmrs.Location)2 SequentialIdentifierGenerator (org.openmrs.module.idgen.SequentialIdentifierGenerator)2 ArrayList (java.util.ArrayList)1 Patient (org.openmrs.Patient)1 AppContextModel (org.openmrs.module.appframework.context.AppContextModel)1 Extension (org.openmrs.module.appframework.domain.Extension)1 PatientContextModel (org.openmrs.module.coreapps.contextmodel.PatientContextModel)1