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);
}
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);
}
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);
}
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);
}
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());
}
Aggregations