use of org.openmrs.PatientIdentifierType in project openmrs-module-pihcore by PIH.
the class AssignDossierNumber method afterPatientCreated.
@Override
public synchronized void afterPatientCreated(Patient patient, Map<String, String[]> map) {
PatientIdentifierType dossierIdentifierType = patientService.getPatientIdentifierTypeByUuid(ZlConfigConstants.PATIENTIDENTIFIERTYPE_DOSSIERNUMBER_UUID);
Location medicalRecordLocation = getMedicalRecordLocation();
String dossierId = "";
dossierId = identifierSourceService.generateIdentifier(dossierIdentifierType, medicalRecordLocation, "generating a new dossier number");
// double check to make sure this identifier is not in use--since manual entry is allowed, it could be
while (dossierIdentifierInUse(dossierId, dossierIdentifierType, medicalRecordLocation)) {
log.error("Attempted to generate duplicate dossier identifier " + dossierId);
dossierId = identifierSourceService.generateIdentifier(dossierIdentifierType, medicalRecordLocation, "generating a new dossier number");
}
if (StringUtils.isBlank(dossierId)) {
throw new APIException("Unable to generate dossier number for patient " + patient);
}
PatientIdentifier dossierIdentifier = new PatientIdentifier(dossierId, dossierIdentifierType, medicalRecordLocation);
patient.addIdentifier(dossierIdentifier);
patientService.savePatientIdentifier(dossierIdentifier);
}
use of org.openmrs.PatientIdentifierType in project openmrs-module-pihcore by PIH.
the class ConfigureHaitiIdGenerators method createDossierNumberGenerator.
public static void createDossierNumberGenerator(LocationService locationService, ConfigureHaitiIdGenerators configureHaitiIdGenerators, Config config) {
PatientIdentifierType dossierIdentifierType = getDossierIdentifierType();
// special, legacy case for Mirebalais
if (config.getSite().equalsIgnoreCase("MIREBALAIS")) {
SequentialIdentifierGenerator sequentialIdentifierGeneratorForUHM = configureHaitiIdGenerators.sequentialIdentifierGeneratorForDossier(dossierIdentifierType, PihCoreConstants.UHM_DOSSIER_NUMBER_PREFIX, PihCoreConstants.UHM_DOSSIER_NUMBER_IDENTIFIER_SOURCE_UUID);
configureHaitiIdGenerators.setAutoGenerationOptionsForDossierNumberGenerator(sequentialIdentifierGeneratorForUHM, // Hôpital Universitaire de Mirebalais - Prensipal
locationService.getLocationByUuid("24bd1390-5959-11e4-8ed6-0800200c9a66"));
SequentialIdentifierGenerator sequentialIdentifierGeneratorForCDI = configureHaitiIdGenerators.sequentialIdentifierGeneratorForDossier(dossierIdentifierType, PihCoreConstants.CDI_DOSSIER_NUMBER_PREFIX, PihCoreConstants.CDI_DOSSIER_NUMBER_IDENTIFIER_SOURCE_UUID);
configureHaitiIdGenerators.setAutoGenerationOptionsForDossierNumberGenerator(sequentialIdentifierGeneratorForCDI, // CDI Klinik Ekstèn Jeneral
locationService.getLocationByUuid("083e75b0-5959-11e4-8ed6-0800200c9a66"));
} else if (config.getDossierIdentifierPrefix() != null) {
SequentialIdentifierGenerator sequentialIdentifierGenerator = configureHaitiIdGenerators.sequentialIdentifierGeneratorForDossier(dossierIdentifierType, config.getDossierIdentifierPrefix().toString(), ZL_DOSSIER_NUMBER_IDENTIFIER_SOURCE_UUID);
configureHaitiIdGenerators.setAutoGenerationOptionsForDossierNumberGenerator(sequentialIdentifierGenerator, null);
}
}
use of org.openmrs.PatientIdentifierType in project openmrs-module-pihcore by PIH.
the class ConfigureMexicoIdGenerators method createDossierNumberGenerator.
private static void createDossierNumberGenerator(IdentifierSourceService identifierSourceService, Config config) {
PatientIdentifierType dossierIdentifierType = Context.getPatientService().getPatientIdentifierTypeByUuid(CesConfigConstants.PATIENTIDENTIFIERTYPE_MEXICODOSSIERNUMBER_UUID);
String prefix = config.getDossierIdentifierPrefix();
if (prefix == null) {
log.warn("dossierIdentifierPrefix not configured; Dossier ID Generator will not be configured");
} else {
SequentialIdentifierGenerator sequentialIdentifierGenerator = (SequentialIdentifierGenerator) Context.getService(IdentifierSourceService.class).getIdentifierSourceByUuid(CHIAPAS_DOSSIER_SOURCE_UUID);
if (sequentialIdentifierGenerator == null) {
sequentialIdentifierGenerator = new SequentialIdentifierGenerator();
sequentialIdentifierGenerator.setName("Sequential Generator for Dossier");
sequentialIdentifierGenerator.setUuid(CHIAPAS_DOSSIER_SOURCE_UUID);
sequentialIdentifierGenerator.setMaxLength(6 + prefix.length());
sequentialIdentifierGenerator.setMinLength(6 + prefix.length());
sequentialIdentifierGenerator.setPrefix(prefix);
sequentialIdentifierGenerator.setBaseCharacterSet("0123456789");
sequentialIdentifierGenerator.setFirstIdentifierBase("000001");
sequentialIdentifierGenerator.setIdentifierType(dossierIdentifierType);
identifierSourceService.saveIdentifierSource(sequentialIdentifierGenerator);
}
setAutoGenerationOptionsForDossierNumberGenerator(identifierSourceService, sequentialIdentifierGenerator);
}
}
use of org.openmrs.PatientIdentifierType in project openmrs-module-pihcore by PIH.
the class ZplLabLabelTemplate method getIdentifier.
protected String getIdentifier(Patient patient) {
PatientIdentifierType idType = emrApiProperties.getPrimaryIdentifierType();
PatientIdentifier pi = patient.getPatientIdentifier(idType);
if (pi == null || pi.isVoided()) {
pi = patient.getPatientIdentifier();
}
return pi == null ? "" : pi.getIdentifier();
}
use of org.openmrs.PatientIdentifierType in project openmrs-module-pihcore by PIH.
the class ConfigurationSetup method configureNonConceptDependencies.
// Anything in here depends on configuration settings and needs to be refreshed in a specific order,
// as some configurations depend on settings or metadata setup in previous configurations.
// Ideally we will get rid of this non-concept vs concept dependencies. Just need to speed up the concept loading component.
public void configureNonConceptDependencies() throws Exception {
setStatus("Configuration Setup Initiated");
// Load in PIH Config
setStatus("Loading pih.config descriptor");
config.reload(ConfigLoader.loadFromRuntimeProperties());
// Configure the Name Template based on the config (TODO: Move this to config / configure outside of Java code)
// hack: configure both name support beans, since two actually exist (?)
setStatus("Configuring name template");
NameTemplateSetup.configureNameTemplate(nameSupport, config);
NameTemplateSetup.configureNameTemplate(NameSupport.getInstance(), config);
// Execute any liquibase changesets defined in the pih/liquibase domain
setStatus("Executing liquibase scripts in configuration");
LiquibaseSetup.setup();
// Setup all metadata that are before Concepts in Iniz loading order
setStatus("Loading initializer pre-concept domains");
InitializerSetup.loadPreConceptDomains(config);
// Setup any global properties defined in pih config (TODO: Move this to gp iniz domain)
// TODO: We need to consider the setting component GPs here
setStatus("Setting additional global properties");
setGlobalProperties(config);
// TODO: Confirm that moving this here makes sense - these refer to concepts, but in the same way that GPs refer to concepts
if (config != null && config.getDispositionConfig() != null) {
setStatus("Configuring disposition config");
dispositionService.setDispositionConfig(config.getDispositionConfig());
}
// Setup Metadata Mappings for Extra Identifier Types, as specified in PIH Config (TODO: Move this to metadatamapping iniz domain)
if (config != null && config.getExtraIdentifierTypes() != null && config.getExtraIdentifierTypes().size() > 0) {
setStatus("Configuring extra identifier types metadata mappings");
List<PatientIdentifierType> extraIdentifierTypes = new ArrayList<PatientIdentifierType>();
for (String uuid : config.getExtraIdentifierTypes()) {
extraIdentifierTypes.add(patientService.getPatientIdentifierTypeByUuid(uuid));
}
metadataMappingService.mapMetadataItems(extraIdentifierTypes, EmrApiConstants.EMR_METADATA_SOURCE_NAME, EmrApiConstants.GP_EXTRA_PATIENT_IDENTIFIER_TYPES);
}
// Setup Location Tags from PIH Config (TODO: Move this to use locations or locationtagmaps domains in Iniz)
setStatus("Configuring location tags from pih config");
LocationTagSetup.setupLocationTags(locationService, config);
// Setup primary identifier type metadata mappings (TODO: Move this to metadatamapping iniz domain with site-based exclusion filters)
setStatus("Configuring primary identifier type");
MetadataMappingsSetup.setupPrimaryIdentifierTypeBasedOnCountry(metadataMappingService, patientService, config);
// Setup identifier generators (TODO: This is a remaining configuration initiative piece. Move to iniz and/or pih config)
setStatus("Configuring identifier generators");
PatientIdentifierSetup.setupIdentifierGeneratorsIfNecessary(identifierSourceService, locationService, config);
// TODO: Move the below to config. All this is ultimately doing is ensuring the setting of a single global property:
// registrationcore.identifierSourceId = <uuid of identifier source configured as autogeneration option for the emrapi primary identifier type>
setStatus("Configuring global properties for registration modules");
ModuleFactory.getStartedModuleById("registrationapp").getModuleActivator().started();
// Initialize PACS HL7 listener, if the PACS_INTEGRATION component is enabled in pih config
// TODO: 1. Determine if we can just enable this all the time, and if that will cause any adverse effects
// TODO: 2. Or determine if we can enable it all the time, but switch inside the listener on the component, to determine whether to act or not
// TODO: 3. If we leave this like this, determine if we can call this setup method over and over in a running server, or if we need to code around that
// In testing, when running configure, I get this: java.lang.RuntimeException: java.net.BindException: Address already in use (Bind failed)
setStatus("Configuring PACS HL7 Listener");
PacIntegrationSetup.setup(config);
// TODO: This seems harmless here for refreshing, but we should determine if
// TODO: 1. Has this run everywhere it needs to, and can we remove this code altogether now
// TODO: 2. If not, can we move this to a liquibase changeset instead
setStatus("Migrating attachment concepts if necessary");
AttachmentsSetup.migrateAttachmentsConceptsIfNecessary(conceptService);
// Configure global scripts and css files defined in the configuration directory
setStatus("Configuring global resources");
GlobalResourceSetup.includeGlobalResources();
// Rebuild search index (TODO: Confirm this is intended to run here, prior to metadata loading, rather than at the end of the process(
if (config.shouldRebuildSearchIndex()) {
setStatus("Rebuilding search index");
Context.updateSearchIndex();
}
// c) if it's used, we could likely try to make it more entirely configurable from config
if (config.isComponentEnabled(Components.LEGACY_MPI)) {
setStatus("Setting up connection to Legacy MPI");
LegacyMasterPatientIndexSetup.setupConnectionToMasterPatientIndex(new RuntimeProperties());
}
if (config.isComponentEnabled(Components.APPOINTMENT_SCHEDULING)) {
if (config.getCountry().equals(ConfigDescriptor.Country.HAITI)) {
// TODO: This seems like something that should be moved to configuration. We should add a GP to the appointment scheduling module
// or wherever this is created to control which identifier type to use in the report, and then set this GP in Iniz config
AppointmentSchedulingSetup.customizeDailyAppointmentsDataSet();
}
}
setStatus("Reloading all apps and extensions");
reloadAppsAndExtensions();
setStatus("Configuration Setup Completed Successfully");
}
Aggregations