From 4ca8ddc96e5a8e0dfa47bcaaa9c65f47828330ee Mon Sep 17 00:00:00 2001 From: herman Date: Wed, 23 Aug 2023 11:14:38 +0300 Subject: [PATCH 1/7] add fhir contact point map to initializer --- README.md | 1 + api-2.6/pom.xml | 46 ++++++ .../cpm/FhirContactPointMapCsvParser.java | 147 ++++++++++++++++++ .../cpm/FhirContactPointMapLineProcessor.java | 59 +++++++ .../fhir/cpm/FhirContactPointMapLoader.java | 25 +++ ...inBaseModuleContextSensitive_2_6_Test.java | 18 +++ ...PatientContactPointMapIntegrationTest.java | 108 +++++++++++++ .../fhircontactpointmap/contactPointMap.csv | 5 + .../openmrs/module/initializer/Domain.java | 1 + .../attributetypes/attribute_types.csv | 3 +- pom.xml | 4 +- readme/fhir.md | 39 ++++- 12 files changed, 453 insertions(+), 3 deletions(-) create mode 100644 api-2.6/pom.xml create mode 100644 api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapCsvParser.java create mode 100644 api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLineProcessor.java create mode 100644 api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLoader.java create mode 100644 api-2.6/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_6_Test.java create mode 100644 api-2.6/src/test/java/org/openmrs/module/initializer/api/FhirPatientContactPointMapIntegrationTest.java create mode 100644 api-2.6/src/test/resources/testAppDataDir/configuration/fhircontactpointmap/contactPointMap.csv diff --git a/README.md b/README.md index 98cbf8c69..5850f9669 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ configuration/ ├── encounterroles/ ├── fhirconceptsources/ ├── fhirpatientidentifiersystems/ + ├── fhirContactPointMap/ ├── globalproperties/ ├── htmlforms/ ├── idgen/ diff --git a/api-2.6/pom.xml b/api-2.6/pom.xml new file mode 100644 index 000000000..830bf16b0 --- /dev/null +++ b/api-2.6/pom.xml @@ -0,0 +1,46 @@ + + + + + org.openmrs.module + initializer + 2.7.0-SNAPSHOT + + 4.0.0 + + initializer-api-2.6 + jar + Initializer API 2.6 + API 2.6 project for Initializer + + + ${openmrsVersion2.6} + + + + + ${project.parent.groupId} + ${project.parent.artifactId}-api + ${project.parent.version} + provided + + + + ${project.parent.groupId} + ${project.parent.artifactId}-api + ${project.parent.version} + test + test-jar + + + + ${project.parent.groupId} + ${project.parent.artifactId}-api-2.4 + ${project.parent.version} + provided + + + + diff --git a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapCsvParser.java b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapCsvParser.java new file mode 100644 index 000000000..fd98ad5a5 --- /dev/null +++ b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapCsvParser.java @@ -0,0 +1,147 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + *

+ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.initializer.api.fhir.cpm; + +import org.openmrs.PersonAttributeType; +import org.openmrs.annotation.OpenmrsProfile; +import org.openmrs.api.LocationService; +import org.openmrs.api.PersonService; +import org.openmrs.api.ProviderService; +import org.openmrs.attribute.BaseAttributeType; +import org.openmrs.module.fhir2.api.FhirContactPointMapService; +import org.openmrs.module.initializer.Domain; +import org.openmrs.module.fhir2.model.FhirContactPointMap; +import org.openmrs.module.initializer.api.BaseLineProcessor; +import org.openmrs.module.initializer.api.CsvLine; +import org.openmrs.module.initializer.api.CsvParser; +import org.springframework.beans.factory.annotation.Autowired; + +@OpenmrsProfile(modules = { "fhir2:1.11.* - 9.*" }, openmrsPlatformVersion = "2.6.3 - 2.6.*, 2.7.* - 9.*") +public class FhirContactPointMapCsvParser extends CsvParser> { + + public static final String ATTRIBUTE_TYPE_DOMAIN_HEADER = "Entity name"; + + public static final String ATTRIBUTE_TYPE = "Attribute type"; + + private static final String LOCATION = "location"; + + private static final String PERSON = "person"; + + private static final String PROVIDER = "provider"; + + private final LocationService locationService; + + private final PersonService personService; + + private final ProviderService providerService; + + private final FhirContactPointMapService fhirContactPointMapService; + + @Autowired + protected FhirContactPointMapCsvParser(FhirContactPointMapService fhirContactPointMapService,BaseLineProcessor lineProcessor, + LocationService locationService, PersonService personService, ProviderService providerService) { + super(lineProcessor); + this.fhirContactPointMapService = fhirContactPointMapService; + this.locationService = locationService; + this.personService = personService; + this.providerService = providerService; + } + + @Override + public FhirContactPointMap bootstrap(CsvLine line) throws IllegalArgumentException { + FhirContactPointMap contactPointMap = null; + if (line.getUuid() != null) { + contactPointMap = fhirContactPointMapService.getFhirContactPointMapByUuid(line.getUuid()) + .orElse(null); + } + + if (contactPointMap != null) { + return contactPointMap; + } + + String attributeTypeDomain = line.get(ATTRIBUTE_TYPE_DOMAIN_HEADER, true); + String attributeType = line.get(ATTRIBUTE_TYPE, true); + + if (attributeTypeDomain.equals(PERSON)) { + PersonAttributeType personAttributeType = getPersonAttributeType(attributeType); + + if (personAttributeType == null) { + throw new IllegalArgumentException("PersonAttributeType " + attributeType + + " does not exist. Please ensure your Initializer configuration contains this attribute type."); + } + + contactPointMap = fhirContactPointMapService.getFhirContactPointMapForPersonAttributeType(personAttributeType) + .orElse(null); + } else { + BaseAttributeType baseAttributeType = getBaseAttributeType(attributeTypeDomain, attributeType); + + if (baseAttributeType == null) { + throw new IllegalArgumentException( + "Could not find attribute type " + attributeType + " for attribute domain " + attributeTypeDomain); + } + + contactPointMap = fhirContactPointMapService.getFhirContactPointMapForAttributeType(baseAttributeType) + .orElse(null); + } + + if (contactPointMap != null) { + return contactPointMap; + } + + return new FhirContactPointMap(); + } + + + @Override + public FhirContactPointMap save(FhirContactPointMap instance) { + return fhirContactPointMapService.saveFhirContactPointMap(instance); + } + + @Override + public Domain getDomain() { + return Domain.FHIR_CONTACT_POINT_MAP; + } + + protected PersonAttributeType getPersonAttributeType(String attributeType) { + PersonAttributeType personAttributeType = personService.getPersonAttributeTypeByName(attributeType); + + if (personAttributeType != null) { + return personAttributeType; + } + + personAttributeType = personService.getPersonAttributeTypeByUuid(attributeType); + + return personAttributeType; + } + + protected BaseAttributeType getBaseAttributeType(String attributeDomain, String attributeType) { + BaseAttributeType baseAttributeType = null; + + switch (attributeDomain) { + case LOCATION: + baseAttributeType = locationService.getLocationAttributeTypeByName(attributeType); + + if (baseAttributeType != null) { + return baseAttributeType; + } + + return locationService.getLocationAttributeTypeByUuid(attributeType); + case PROVIDER: + baseAttributeType = providerService.getProviderAttributeTypeByName(attributeType); + + if (baseAttributeType != null) { + return baseAttributeType; + } + + return providerService.getProviderAttributeTypeByUuid(attributeType); + } + return baseAttributeType; + } +} diff --git a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLineProcessor.java b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLineProcessor.java new file mode 100644 index 000000000..25dde14fd --- /dev/null +++ b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLineProcessor.java @@ -0,0 +1,59 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + *

+ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.initializer.api.fhir.cpm; + +import org.apache.commons.lang3.StringUtils; +import org.hl7.fhir.r4.model.ContactPoint; +import org.openmrs.annotation.OpenmrsProfile; +import org.openmrs.module.fhir2.model.FhirContactPointMap; +import org.openmrs.module.initializer.api.BaseLineProcessor; +import org.openmrs.module.initializer.api.CsvLine; + +import static org.openmrs.module.initializer.api.fhir.cpm.FhirContactPointMapCsvParser.ATTRIBUTE_TYPE_DOMAIN_HEADER; + +@OpenmrsProfile(modules = { "fhir2:1.11.* - 9.*" }, openmrsPlatformVersion = "2.6.3 - 2.6.*, 2.7.* - 9.*") +public class FhirContactPointMapLineProcessor extends BaseLineProcessor { + + private static final String SYSTEM_HEADER = "system"; + private static final String USE_HEADER = "use"; + private static final String RANK_HEADER = "rank"; + @Override + public FhirContactPointMap fill(FhirContactPointMap instance, CsvLine line) throws IllegalArgumentException { + String uuid = line.getUuid(); + + if (StringUtils.isNotBlank(uuid)) { + instance.setUuid(line.getUuid()); + } + + line.get(ATTRIBUTE_TYPE_DOMAIN_HEADER, true); + + String system = line.get(SYSTEM_HEADER, false); + String use = line.get(USE_HEADER, false); + String rank = line.get(RANK_HEADER, false); + + if (system != null) { + instance.setSystem(ContactPoint.ContactPointSystem.valueOf(system)); + } + + if (use != null) { + instance.setUse(ContactPoint.ContactPointUse.valueOf(use)); + } + + if (rank != null) { + int rankInt = Integer.parseInt(rank); + if (rankInt < 1) { + throw new IllegalArgumentException("Rank must be a positive integer, i.e., 1+"); + } + instance.setRank(rankInt); + } + + return instance; + } +} diff --git a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLoader.java b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLoader.java new file mode 100644 index 000000000..5b148cbc6 --- /dev/null +++ b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLoader.java @@ -0,0 +1,25 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + *

+ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.initializer.api.fhir.cpm; + +import org.openmrs.annotation.OpenmrsProfile; +import org.openmrs.module.fhir2.model.FhirContactPointMap; +import org.openmrs.module.initializer.api.loaders.BaseCsvLoader; +import org.springframework.beans.factory.annotation.Autowired; + +@OpenmrsProfile(modules = { "fhir2:1.11.* - 9.*" }, openmrsPlatformVersion = "2.6.3 - 2.6.*, 2.7.* - 9.*") +public class FhirContactPointMapLoader extends BaseCsvLoader { + + @Autowired + public void setParser(FhirContactPointMapCsvParser parser) { + this.parser = parser; + } + +} diff --git a/api-2.6/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_6_Test.java b/api-2.6/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_6_Test.java new file mode 100644 index 000000000..018fc5c00 --- /dev/null +++ b/api-2.6/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_6_Test.java @@ -0,0 +1,18 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + *

+ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.initializer; + +public abstract class DomainBaseModuleContextSensitive_2_6_Test extends DomainBaseModuleContextSensitiveTest { + + @Override + public void updateSearchIndex() { + // to prevent Data Filter's 'Illegal Record Access' + } +} diff --git a/api-2.6/src/test/java/org/openmrs/module/initializer/api/FhirPatientContactPointMapIntegrationTest.java b/api-2.6/src/test/java/org/openmrs/module/initializer/api/FhirPatientContactPointMapIntegrationTest.java new file mode 100644 index 000000000..d0b1dde2b --- /dev/null +++ b/api-2.6/src/test/java/org/openmrs/module/initializer/api/FhirPatientContactPointMapIntegrationTest.java @@ -0,0 +1,108 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + *

+ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.initializer.api; + +import org.hl7.fhir.r4.model.ContactPoint; +import org.junit.Before; +import org.junit.Test; +import org.openmrs.LocationAttributeType; +import org.openmrs.PersonAttributeType; +import org.openmrs.ProviderAttributeType; +import org.openmrs.api.LocationService; +import org.openmrs.api.PersonService; +import org.openmrs.api.ProviderService; +import org.openmrs.attribute.BaseAttributeType; +import org.openmrs.module.fhir2.api.FhirContactPointMapService; +import org.openmrs.module.fhir2.model.FhirContactPointMap; +import org.openmrs.module.initializer.DomainBaseModuleContextSensitive_2_6_Test; +import org.openmrs.module.initializer.api.fhir.cpm.FhirContactPointMapLoader; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Optional; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; + +public class FhirPatientContactPointMapIntegrationTest extends DomainBaseModuleContextSensitive_2_6_Test { + + @Autowired + private FhirContactPointMapService fhirContactPointMapService; + + @Autowired + private FhirContactPointMapLoader fhirContactPointMapLoader; + + @Autowired + private LocationService locationService; + + @Autowired + private PersonService personService; + + @Autowired + private ProviderService providerService; + + FhirContactPointMap fhirContactPointMap; + + PersonAttributeType personAttributeType; + + LocationAttributeType locationAttributeType; + + ProviderAttributeType providerAttributeType; + + @Before + public void setup() { + personAttributeType = new PersonAttributeType(); + providerAttributeType = new ProviderAttributeType(); + locationAttributeType = new LocationAttributeType(); + + fhirContactPointMap = new FhirContactPointMap(); + fhirContactPointMap.setUuid("fa48acc4-ef1f-46d6-b0af-150b00ddee9d"); + fhirContactPointMap.setAttributeTypeDomain("person"); + fhirContactPointMap.setAttributeTypeId(10001); + fhirContactPointMap.setSystem(ContactPoint.ContactPointSystem.PHONE); + fhirContactPointMap.setUse(ContactPoint.ContactPointUse.WORK); + fhirContactPointMap.setRank(1); + fhirContactPointMapService.saveFhirContactPointMap(fhirContactPointMap); + personService.savePersonAttributeType(personAttributeType); + } + + @Test + public void loader_shouldLoadFhirContactPointMapAccordingToCSVFiles() { + fhirContactPointMapLoader.load(); + + FhirContactPointMap firstFhirContactPointMap = assertPersonAttributeType(personAttributeType); + FhirContactPointMap secondFhirContactPointMap = assertBaseAttributeType(providerAttributeType); + FhirContactPointMap thirdFhirContactPointMap = assertBaseAttributeType(locationAttributeType); + + assertThat(firstFhirContactPointMap.getAttributeTypeDomain(), equalTo("person")); + assertThat(firstFhirContactPointMap.getSystem(), equalTo(ContactPoint.ContactPointSystem.PHONE)); + assertThat(firstFhirContactPointMap.getUse(), equalTo(ContactPoint.ContactPointUse.WORK)); + + assertThat(secondFhirContactPointMap.getAttributeTypeDomain(), equalTo("provider")); + assertThat(firstFhirContactPointMap.getSystem(), equalTo(ContactPoint.ContactPointSystem.EMAIL)); + assertThat(firstFhirContactPointMap.getUse(), equalTo(ContactPoint.ContactPointUse.HOME)); + + assertThat(thirdFhirContactPointMap.getAttributeTypeDomain(), equalTo("location")); + assertThat(firstFhirContactPointMap.getSystem(), equalTo(ContactPoint.ContactPointSystem.URL)); + assertThat(firstFhirContactPointMap.getUse(), equalTo(ContactPoint.ContactPointUse.TEMP)); + } + + protected FhirContactPointMap assertPersonAttributeType(PersonAttributeType attributeType) { + Optional contactPointMap = fhirContactPointMapService.getFhirContactPointMapForPersonAttributeType(attributeType); + assertThat(contactPointMap.isPresent(), is(true)); + return contactPointMap.get(); + } + + protected FhirContactPointMap assertBaseAttributeType(BaseAttributeType attributeType) { + Optional contactPointMap = fhirContactPointMapService.getFhirContactPointMapForAttributeType(attributeType); + assertThat(contactPointMap.isPresent(), is(true)); + return contactPointMap.get(); + } +} diff --git a/api-2.6/src/test/resources/testAppDataDir/configuration/fhircontactpointmap/contactPointMap.csv b/api-2.6/src/test/resources/testAppDataDir/configuration/fhircontactpointmap/contactPointMap.csv new file mode 100644 index 000000000..7f35b5098 --- /dev/null +++ b/api-2.6/src/test/resources/testAppDataDir/configuration/fhircontactpointmap/contactPointMap.csv @@ -0,0 +1,5 @@ +Uuid,Void/Retire,Entity name,Attribute Type,System,Use,Rank,_order:1000 +fa48acc4-ef1f-46d6-b0af-150b00ddee9d,,person,717ec942-3c4a-11ea-b024-ffc81a23382e,phone,work,1, +,,person,PAT_RENAME_NEW_NAME,phone,home,, +bcf23315-a236-42aa-be95-b9e0931e22b0,,provider,Provider Speciality,email,home,2, +800e48ba-666c-445c-b871-68e54eec6de8,,location,e7aacc6e-d151-4d9e-a808-6ed9ff761212,phone,temp,3, diff --git a/api/src/main/java/org/openmrs/module/initializer/Domain.java b/api/src/main/java/org/openmrs/module/initializer/Domain.java index ac1e66e26..6c725e30d 100644 --- a/api/src/main/java/org/openmrs/module/initializer/Domain.java +++ b/api/src/main/java/org/openmrs/module/initializer/Domain.java @@ -47,6 +47,7 @@ public enum Domain { COHORT_ATTRIBUTE_TYPES, FHIR_CONCEPT_SOURCES, FHIR_PATIENT_IDENTIFIER_SYSTEMS, + FHIR_CONTACT_POINT_MAP, AMPATH_FORMS, AMPATH_FORMS_TRANSLATIONS, HTML_FORMS; diff --git a/api/src/test/resources/testAppDataDir/configuration/attributetypes/attribute_types.csv b/api/src/test/resources/testAppDataDir/configuration/attributetypes/attribute_types.csv index 581eaba89..8801b8f8c 100644 --- a/api/src/test/resources/testAppDataDir/configuration/attributetypes/attribute_types.csv +++ b/api/src/test/resources/testAppDataDir/configuration/attributetypes/attribute_types.csv @@ -1,5 +1,6 @@ Uuid,Void/Retire,Entity name,Name,Description,Min occurs,Max occurs,Datatype classname,Datatype config,Preferred handler classname,Handler config,_order:1000 0bb29984-3193-11e7-93ae-92367f002671,,Location,Location Height,Location Height's description,1,1,org.openmrs.customdatatype.datatype.FloatDatatype,,,, +e7aacc6e-d151-4d9e-a808-6ed9ff761212,,Location,Location Phone Number,Location Phone Numbers's description,1,1,org.openmrs.customdatatype.datatype.FreeTextDataType,,,, 0bc29982-3193-11e3-93ae-92367f222671,,Visit,Visit Color,Visit Color's description,1,1,org.openmrs.customdatatype.datatype.FreeTextDatatype,,,, 9eca4f4e-707f-4bb8-8289-2f9b6e93803c,,Location,Location ISO Code,Location ISO Code's description,1,10,org.openmrs.customdatatype.datatype.FreeTextDatatype,,,, ,,Provider,Provider Speciality,Clinical speciality for this provider,0,7,org.openmrs.customdatatype.datatype.FreeTextDatatype,,,, @@ -8,4 +9,4 @@ Uuid,Void/Retire,Entity name,Name,Description,Min occurs,Max occurs,Datatype cla 3884c889-35f5-47b4-a6b7-5b1165cee218,,Program,Program Assessment,Program Assessment's description,1,,org.openmrs.customdatatype.datatype.FreeTextDatatype,,,, 9398c839-4f39-428c-9022-e457980ccfa8,,Program,CodedConcept attribute type,This is a Program's CodedConcept attribute type,0,1,org.bahmni.module.bahmnicore.customdatatype.datatype.CodedConceptDatatype,8295308d-e5b2-41c7-adc1-2e0e83f0f16e,,, b1d98f27-c058-46f2-9c12-87dd7c92f7e3,,Program,Program Efficiency Indicator,Metric of the program efficiency,0,1,org.openmrs.customdatatype.datatype.FloatDatatype,,,, -,TRUE,Concept,Concept Family,,,,,,,, \ No newline at end of file +,TRUE,Concept,Concept Family,,,,,,,, diff --git a/pom.xml b/pom.xml index 5fad3c9d4..3203d0878 100644 --- a/pom.xml +++ b/pom.xml @@ -37,6 +37,7 @@ api-2.3 api-2.4 api-2.5 + api-2.6 omod @@ -56,6 +57,7 @@ 2.3.6 2.4.0 2.5.5 + 2.6.3-SNAPSHOT ${openmrsVersion2.1} @@ -69,7 +71,7 @@ 1.2.2 1.3.4 1.2.9 - 1.6.0 + 1.11.0 1.0.0 diff --git a/readme/fhir.md b/readme/fhir.md index 97b9adfb5..3651376e7 100644 --- a/readme/fhir.md +++ b/readme/fhir.md @@ -73,4 +73,41 @@ This is the URL of the code system in FHIR. For terminologies identified [in the FHIR CodeSystem registry](https://www.hl7.org/fhir/terminologies-systems.html), this should be the preferred URL for that code system, e.g. SNOMED CT is "http://snomed.info/sct". If the code system is not defined by HL7 or that table, then the code systems own preferred URL should be used, e.g., for CIEL we tend to use -"https://api.openconceptlab.org/orgs/CIEL/sources/CIEL". \ No newline at end of file +"https://api.openconceptlab.org/orgs/CIEL/sources/CIEL". + +## Domain 'fhirContactPointMap' + +The **fhirContactPointMap** subfolder contains CSV import files for defining contact point fields like system, use, rank for any of person, provider and location in your OpenMRS instance. +These are used in data exchange to store contact attributes a person, provider or location may have. If none are provided, the identifier type UUID is used as the "system" for these attributes. + +This is a possible example of its contents: +```bash +fhirContactPointMap/ + ├──contactPointMap.csv + └── ... +``` +The format of this CSV should be as follows: + +| Uuid | Void/Retire | Entity name | Attribute Type | System | Use | Rank | _order:1000 | +|--------------------------------------|-------------|-------------|--------------------------------------|--------|------|------|-------------| +| fa48acc4-ef1f-46d6-b0af-150b00ddee9d | | person | 717ec942-3c4a-11ea-b024-ffc81a23382e | phone | work | 1 | | +| | | person | PAT_RENAME_NEW_NAME | phone | home | | | +| bcf23315-a236-42aa-be95-b9e0931e22b0 | | provider | Provider Speciality | email | home | 2 | | +| 800e48ba-666c-445c-b871-68e54eec6de8 | | location | e7aacc6e-d151-4d9e-a808-6ed9ff761212 | phone | temp | 3 | | + +Headers that start with an underscore such as `_order:1000` are metadata headers. The values in the columns under those headers are never read by the CSV parser. + +###### Attribute Type Domain(mandatory) +This is a *required* field for every entry. This can either be person, provider or location which represent the **Person Attribute Type**, **Provider Attribute Type** and **Location Attribute Type** respectively. + +###### System(mandatory) + +This can be any of phone, fax, email, pager, url, sms. Take a look at [ContactPointSystem](https://www.hl7.org/fhir/valueset-contact-point-system.html) for more information. + +###### Use(mandatory) + +This represents the actual purpose of the contact point. It could be any of home ,work ,temp ,old ,mobile. Take a deeper look at [ContactPointUse](https://www.hl7.org/fhir/valueset-contact-point-use.html). + +###### Rank(mandatory) + +This specifies the preferred order of use (1 = highest). From 1922f29a8f7ba2828cf228edc2a669d3f6da995b Mon Sep 17 00:00:00 2001 From: mherman22 Date: Tue, 14 Nov 2023 19:11:02 +0300 Subject: [PATCH 2/7] suggestions from talk post --- api-2.6/pom.xml | 61 ++++++++++++++++++++++++++++++ omod/src/main/resources/config.xml | 4 ++ pom.xml | 2 +- 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/api-2.6/pom.xml b/api-2.6/pom.xml index 830bf16b0..16bd92feb 100644 --- a/api-2.6/pom.xml +++ b/api-2.6/pom.xml @@ -17,9 +17,25 @@ ${openmrsVersion2.6} + 1.11.0 + 2.2.0 + + org.openmrs.test + openmrs-test + pom + ${openmrsPlatformVersion} + test + + + org.powermock + powermock-api-mockito2 + + + + ${project.parent.groupId} ${project.parent.artifactId}-api @@ -41,6 +57,51 @@ ${project.parent.version} provided + + + ${project.parent.groupId} + ${project.parent.artifactId}-api-2.3 + ${project.parent.version} + provided + + + + ${project.parent.groupId} + ${project.parent.artifactId}-api-2.3 + ${project.parent.version} + test + test-jar + + + + ${project.parent.groupId} + ${project.parent.artifactId}-api-2.2 + ${project.parent.version} + provided + + + + ${project.parent.groupId} + ${project.parent.artifactId}-api-2.2 + ${project.parent.version} + test + test-jar + + + + org.openmrs.module + fhir2-api-2.6 + ${fhir2Version} + provided + + + + org.openmrs.module + datafilter-api + ${datafilterVersion} + provided + + diff --git a/omod/src/main/resources/config.xml b/omod/src/main/resources/config.xml index 24e0e6690..1d3523373 100644 --- a/omod/src/main/resources/config.xml +++ b/omod/src/main/resources/config.xml @@ -23,6 +23,10 @@ /lib/initializer-api-2.5-${project.version}.jar 2.5.* - 9.* + + /lib/initializer-api-2.6-${project.version}.jar + 2.6.* - 9.* + diff --git a/pom.xml b/pom.xml index 3203d0878..473abef74 100644 --- a/pom.xml +++ b/pom.xml @@ -71,7 +71,7 @@ 1.2.2 1.3.4 1.2.9 - 1.11.0 + 1.6.0 1.0.0 From 84f445b1d832a4fdc8983bf61e472fb740534079 Mon Sep 17 00:00:00 2001 From: mherman22 Date: Tue, 14 Nov 2023 19:59:36 +0300 Subject: [PATCH 3/7] mimick what is happening in api-2.5 pom --- README.md | 2 + api-2.6/pom.xml | 29 +++++++ .../cpm/FhirContactPointMapCsvParser.java | 25 +++--- .../cpm/FhirContactPointMapLineProcessor.java | 5 ++ .../fhir/cpm/FhirContactPointMapLoader.java | 2 + ...inBaseModuleContextSensitive_2_6_Test.java | 6 +- ...PatientContactPointMapIntegrationTest.java | 84 ++++++++++++++----- .../initializer/api}/LoadersOrderTest.java | 8 +- .../fhircontactpointmap/contactPointMap.csv | 8 +- omod/pom.xml | 6 ++ pom.xml | 2 +- readme/fhir.md | 8 +- validator/pom.xml | 17 ++-- 13 files changed, 147 insertions(+), 55 deletions(-) rename {api-2.3/src/test/java/org/openmrs/module/initializer/api/loaders => api-2.6/src/test/java/org/openmrs/module/initializer/api}/LoadersOrderTest.java (96%) diff --git a/README.md b/README.md index 5850f9669..03b4c5ddd 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ This is the list of currently supported domains in their loading order: 1. [Cohort Attribute Types (CSV files)](readme/cohort.md#domain-cohortattributetypes) 1. [FHIR Concept Sources (CSV files)](readme/fhir.md#domain-fhirconceptsources) 1. [FHIR Patient Identifier Systems (CSV Files)](readme/fhir.md#domain-fhirpatientidentifiersystems) +2. [FHIR ContactPointMap (CSV Files)](https://github.com/mherman22/openmrs-module-initializer/blob/ContactPointMap-impl/readme/fhir.md#domain-fhircontactpointmap) 1. [AMPATH Forms (JSON files)](readme/ampathforms.md) 1. [AMPATH Forms Translations (JSON files)](readme/ampathformstranslations.md) 1. [HTML Forms (XML files)](readme/htmlforms.md) @@ -202,6 +203,7 @@ See the [documentation on Initializer's logging properties](readme/rtprops.md#lo * Fix for OCL Loader to ensure it throws an Exception if the OCL import fails. * Fix for Validator to not encounter failure upon repeated execution on the same JVM process. * Fix for null config directory path in `DeleteDomainChecksumsChangeset`. +* Added support for 'fhircontactpointmap' domain. #### Version 2.6.0 * Added support for 'cohorttypes' and 'cohortattributetypes' domains. diff --git a/api-2.6/pom.xml b/api-2.6/pom.xml index 16bd92feb..f5215465f 100644 --- a/api-2.6/pom.xml +++ b/api-2.6/pom.xml @@ -51,6 +51,21 @@ test-jar + + ${project.parent.groupId} + ${project.parent.artifactId}-api-2.5 + ${project.parent.version} + provided + + + + ${project.parent.groupId} + ${project.parent.artifactId}-api-2.5 + ${project.parent.version} + test + test-jar + + ${project.parent.groupId} ${project.parent.artifactId}-api-2.4 @@ -88,6 +103,13 @@ test-jar + + org.openmrs.module + fhir2-api-2.5 + ${fhir2Version} + provided + + org.openmrs.module fhir2-api-2.6 @@ -102,6 +124,13 @@ provided + + org.openmrs.module + queue-api + ${queueVersion} + provided + + diff --git a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapCsvParser.java b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapCsvParser.java index fd98ad5a5..1f369f0e8 100644 --- a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapCsvParser.java +++ b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapCsvParser.java @@ -22,13 +22,15 @@ import org.openmrs.module.initializer.api.CsvLine; import org.openmrs.module.initializer.api.CsvParser; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +@Component @OpenmrsProfile(modules = { "fhir2:1.11.* - 9.*" }, openmrsPlatformVersion = "2.6.3 - 2.6.*, 2.7.* - 9.*") public class FhirContactPointMapCsvParser extends CsvParser> { public static final String ATTRIBUTE_TYPE_DOMAIN_HEADER = "Entity name"; - public static final String ATTRIBUTE_TYPE = "Attribute type"; + public static final String ATTRIBUTE_TYPE = "Attribute Type"; private static final String LOCATION = "location"; @@ -45,8 +47,9 @@ public class FhirContactPointMapCsvParser extends CsvParser lineProcessor, - LocationService locationService, PersonService personService, ProviderService providerService) { + protected FhirContactPointMapCsvParser(FhirContactPointMapService fhirContactPointMapService, + BaseLineProcessor lineProcessor, LocationService locationService, PersonService personService, + ProviderService providerService) { super(lineProcessor); this.fhirContactPointMapService = fhirContactPointMapService; this.locationService = locationService; @@ -58,8 +61,7 @@ protected FhirContactPointMapCsvParser(FhirContactPointMapService fhirContactPoi public FhirContactPointMap bootstrap(CsvLine line) throws IllegalArgumentException { FhirContactPointMap contactPointMap = null; if (line.getUuid() != null) { - contactPointMap = fhirContactPointMapService.getFhirContactPointMapByUuid(line.getUuid()) - .orElse(null); + contactPointMap = fhirContactPointMapService.getFhirContactPointMapByUuid(line.getUuid()).orElse(null); } if (contactPointMap != null) { @@ -74,21 +76,21 @@ public FhirContactPointMap bootstrap(CsvLine line) throws IllegalArgumentExcepti if (personAttributeType == null) { throw new IllegalArgumentException("PersonAttributeType " + attributeType - + " does not exist. Please ensure your Initializer configuration contains this attribute type."); + + " does not exist. Please ensure your Initializer configuration contains this attribute type."); } contactPointMap = fhirContactPointMapService.getFhirContactPointMapForPersonAttributeType(personAttributeType) - .orElse(null); + .orElse(null); } else { BaseAttributeType baseAttributeType = getBaseAttributeType(attributeTypeDomain, attributeType); if (baseAttributeType == null) { throw new IllegalArgumentException( - "Could not find attribute type " + attributeType + " for attribute domain " + attributeTypeDomain); + "Could not find attribute type " + attributeType + " for attribute domain " + attributeTypeDomain); } contactPointMap = fhirContactPointMapService.getFhirContactPointMapForAttributeType(baseAttributeType) - .orElse(null); + .orElse(null); } if (contactPointMap != null) { @@ -97,7 +99,6 @@ public FhirContactPointMap bootstrap(CsvLine line) throws IllegalArgumentExcepti return new FhirContactPointMap(); } - @Override public FhirContactPointMap save(FhirContactPointMap instance) { @@ -116,9 +117,7 @@ protected PersonAttributeType getPersonAttributeType(String attributeType) { return personAttributeType; } - personAttributeType = personService.getPersonAttributeTypeByUuid(attributeType); - - return personAttributeType; + return personService.getPersonAttributeTypeByUuid(attributeType); } protected BaseAttributeType getBaseAttributeType(String attributeDomain, String attributeType) { diff --git a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLineProcessor.java b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLineProcessor.java index 25dde14fd..6d58bfd42 100644 --- a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLineProcessor.java +++ b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLineProcessor.java @@ -15,15 +15,20 @@ import org.openmrs.module.fhir2.model.FhirContactPointMap; import org.openmrs.module.initializer.api.BaseLineProcessor; import org.openmrs.module.initializer.api.CsvLine; +import org.springframework.stereotype.Component; import static org.openmrs.module.initializer.api.fhir.cpm.FhirContactPointMapCsvParser.ATTRIBUTE_TYPE_DOMAIN_HEADER; +@Component @OpenmrsProfile(modules = { "fhir2:1.11.* - 9.*" }, openmrsPlatformVersion = "2.6.3 - 2.6.*, 2.7.* - 9.*") public class FhirContactPointMapLineProcessor extends BaseLineProcessor { private static final String SYSTEM_HEADER = "system"; + private static final String USE_HEADER = "use"; + private static final String RANK_HEADER = "rank"; + @Override public FhirContactPointMap fill(FhirContactPointMap instance, CsvLine line) throws IllegalArgumentException { String uuid = line.getUuid(); diff --git a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLoader.java b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLoader.java index 5b148cbc6..b6eeb2ca4 100644 --- a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLoader.java +++ b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLoader.java @@ -13,7 +13,9 @@ import org.openmrs.module.fhir2.model.FhirContactPointMap; import org.openmrs.module.initializer.api.loaders.BaseCsvLoader; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +@Component @OpenmrsProfile(modules = { "fhir2:1.11.* - 9.*" }, openmrsPlatformVersion = "2.6.3 - 2.6.*, 2.7.* - 9.*") public class FhirContactPointMapLoader extends BaseCsvLoader { diff --git a/api-2.6/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_6_Test.java b/api-2.6/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_6_Test.java index 018fc5c00..2a588cc31 100644 --- a/api-2.6/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_6_Test.java +++ b/api-2.6/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_6_Test.java @@ -9,10 +9,6 @@ */ package org.openmrs.module.initializer; -public abstract class DomainBaseModuleContextSensitive_2_6_Test extends DomainBaseModuleContextSensitiveTest { +public abstract class DomainBaseModuleContextSensitive_2_6_Test extends DomainBaseModuleContextSensitive_2_3_Test { - @Override - public void updateSearchIndex() { - // to prevent Data Filter's 'Illegal Record Access' - } } diff --git a/api-2.6/src/test/java/org/openmrs/module/initializer/api/FhirPatientContactPointMapIntegrationTest.java b/api-2.6/src/test/java/org/openmrs/module/initializer/api/FhirPatientContactPointMapIntegrationTest.java index d0b1dde2b..1cc3b1dfb 100644 --- a/api-2.6/src/test/java/org/openmrs/module/initializer/api/FhirPatientContactPointMapIntegrationTest.java +++ b/api-2.6/src/test/java/org/openmrs/module/initializer/api/FhirPatientContactPointMapIntegrationTest.java @@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.is; public class FhirPatientContactPointMapIntegrationTest extends DomainBaseModuleContextSensitive_2_6_Test { - + @Autowired private FhirContactPointMapService fhirContactPointMapService; @@ -58,19 +58,61 @@ public class FhirPatientContactPointMapIntegrationTest extends DomainBaseModuleC @Before public void setup() { - personAttributeType = new PersonAttributeType(); - providerAttributeType = new ProviderAttributeType(); - locationAttributeType = new LocationAttributeType(); - - fhirContactPointMap = new FhirContactPointMap(); - fhirContactPointMap.setUuid("fa48acc4-ef1f-46d6-b0af-150b00ddee9d"); - fhirContactPointMap.setAttributeTypeDomain("person"); - fhirContactPointMap.setAttributeTypeId(10001); - fhirContactPointMap.setSystem(ContactPoint.ContactPointSystem.PHONE); - fhirContactPointMap.setUse(ContactPoint.ContactPointUse.WORK); - fhirContactPointMap.setRank(1); - fhirContactPointMapService.saveFhirContactPointMap(fhirContactPointMap); - personService.savePersonAttributeType(personAttributeType); + { + personAttributeType = new PersonAttributeType(); + personAttributeType.setId(10001); + personAttributeType.setUuid("717ec942-3c4a-11ea-b024-ffc81a23382e"); + + fhirContactPointMap = new FhirContactPointMap(); + fhirContactPointMap.setUuid("fa48acc4-ef1f-46d6-b0af-150b00ddee9d"); + fhirContactPointMap.setAttributeTypeDomain("person"); + fhirContactPointMap.setAttributeTypeId(10001); + fhirContactPointMap.setSystem(ContactPoint.ContactPointSystem.PHONE); + fhirContactPointMap.setUse(ContactPoint.ContactPointUse.WORK); + fhirContactPointMap.setRank(1); + fhirContactPointMapService.saveFhirContactPointMap(fhirContactPointMap); + } + { + personAttributeType = new PersonAttributeType(); + personAttributeType.setId(10002); + personAttributeType.setUuid("PAT_RENAME_NEW_NAME"); + + fhirContactPointMap = new FhirContactPointMap(); + fhirContactPointMap.setUuid(""); + fhirContactPointMap.setAttributeTypeDomain("person"); + fhirContactPointMap.setAttributeTypeId(10002); + fhirContactPointMap.setSystem(ContactPoint.ContactPointSystem.PHONE); + fhirContactPointMap.setUse(ContactPoint.ContactPointUse.WORK); + fhirContactPointMapService.saveFhirContactPointMap(fhirContactPointMap); + } + { + providerAttributeType = new ProviderAttributeType(); + providerAttributeType.setId(10003); + providerAttributeType.setUuid("Provider Speciality"); + + fhirContactPointMap = new FhirContactPointMap(); + fhirContactPointMap.setUuid("bcf23315-a236-42aa-be95-b9e0931e22b0"); + fhirContactPointMap.setAttributeTypeDomain("provider"); + fhirContactPointMap.setAttributeTypeId(10003); + fhirContactPointMap.setSystem(ContactPoint.ContactPointSystem.EMAIL); + fhirContactPointMap.setUse(ContactPoint.ContactPointUse.HOME); + fhirContactPointMap.setRank(2); + fhirContactPointMapService.saveFhirContactPointMap(fhirContactPointMap); + } + { + locationAttributeType = new LocationAttributeType(); + locationAttributeType.setId(10004); + locationAttributeType.setUuid("e7aacc6e-d151-4d9e-a808-6ed9ff761212"); + + fhirContactPointMap = new FhirContactPointMap(); + fhirContactPointMap.setUuid("800e48ba-666c-445c-b871-68e54eec6de8"); + fhirContactPointMap.setAttributeTypeDomain("location"); + fhirContactPointMap.setAttributeTypeId(10004); + fhirContactPointMap.setSystem(ContactPoint.ContactPointSystem.PHONE); + fhirContactPointMap.setUse(ContactPoint.ContactPointUse.TEMP); + fhirContactPointMap.setRank(3); + fhirContactPointMapService.saveFhirContactPointMap(fhirContactPointMap); + } } @Test @@ -86,22 +128,24 @@ public void loader_shouldLoadFhirContactPointMapAccordingToCSVFiles() { assertThat(firstFhirContactPointMap.getUse(), equalTo(ContactPoint.ContactPointUse.WORK)); assertThat(secondFhirContactPointMap.getAttributeTypeDomain(), equalTo("provider")); - assertThat(firstFhirContactPointMap.getSystem(), equalTo(ContactPoint.ContactPointSystem.EMAIL)); - assertThat(firstFhirContactPointMap.getUse(), equalTo(ContactPoint.ContactPointUse.HOME)); + assertThat(secondFhirContactPointMap.getSystem(), equalTo(ContactPoint.ContactPointSystem.EMAIL)); + assertThat(secondFhirContactPointMap.getUse(), equalTo(ContactPoint.ContactPointUse.HOME)); assertThat(thirdFhirContactPointMap.getAttributeTypeDomain(), equalTo("location")); - assertThat(firstFhirContactPointMap.getSystem(), equalTo(ContactPoint.ContactPointSystem.URL)); - assertThat(firstFhirContactPointMap.getUse(), equalTo(ContactPoint.ContactPointUse.TEMP)); + assertThat(thirdFhirContactPointMap.getSystem(), equalTo(ContactPoint.ContactPointSystem.PHONE)); + assertThat(thirdFhirContactPointMap.getUse(), equalTo(ContactPoint.ContactPointUse.TEMP)); } protected FhirContactPointMap assertPersonAttributeType(PersonAttributeType attributeType) { - Optional contactPointMap = fhirContactPointMapService.getFhirContactPointMapForPersonAttributeType(attributeType); + Optional contactPointMap = fhirContactPointMapService + .getFhirContactPointMapForPersonAttributeType(attributeType); assertThat(contactPointMap.isPresent(), is(true)); return contactPointMap.get(); } protected FhirContactPointMap assertBaseAttributeType(BaseAttributeType attributeType) { - Optional contactPointMap = fhirContactPointMapService.getFhirContactPointMapForAttributeType(attributeType); + Optional contactPointMap = fhirContactPointMapService + .getFhirContactPointMapForAttributeType(attributeType); assertThat(contactPointMap.isPresent(), is(true)); return contactPointMap.get(); } diff --git a/api-2.3/src/test/java/org/openmrs/module/initializer/api/loaders/LoadersOrderTest.java b/api-2.6/src/test/java/org/openmrs/module/initializer/api/LoadersOrderTest.java similarity index 96% rename from api-2.3/src/test/java/org/openmrs/module/initializer/api/loaders/LoadersOrderTest.java rename to api-2.6/src/test/java/org/openmrs/module/initializer/api/LoadersOrderTest.java index 2fafaa5b7..3382a7e17 100644 --- a/api-2.3/src/test/java/org/openmrs/module/initializer/api/loaders/LoadersOrderTest.java +++ b/api-2.6/src/test/java/org/openmrs/module/initializer/api/LoadersOrderTest.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.initializer.api.loaders; +package org.openmrs.module.initializer.api; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.everyItem; @@ -23,9 +23,10 @@ import org.hamcrest.TypeSafeDiagnosingMatcher; import org.junit.Test; import org.openmrs.module.initializer.Domain; -import org.openmrs.module.initializer.DomainBaseModuleContextSensitive_2_3_Test; +import org.openmrs.module.initializer.DomainBaseModuleContextSensitive_2_6_Test; +import org.openmrs.module.initializer.api.loaders.Loader; -public class LoadersOrderTest extends DomainBaseModuleContextSensitive_2_3_Test { +public class LoadersOrderTest extends DomainBaseModuleContextSensitive_2_6_Test { @Test public void getLoaders_shouldBeUnequivocallyOrdered() { @@ -45,6 +46,7 @@ public void getLoaders_shouldBeUnequivocallyOrdered() { List runtimeLoaders = getService().getLoaders(); assertThat(runtimeLoaders, everyItem(hasExpectedDomain())); + assertThat(runtimeLoaders, coversAllDomains()); } diff --git a/api-2.6/src/test/resources/testAppDataDir/configuration/fhircontactpointmap/contactPointMap.csv b/api-2.6/src/test/resources/testAppDataDir/configuration/fhircontactpointmap/contactPointMap.csv index 7f35b5098..f01f1d715 100644 --- a/api-2.6/src/test/resources/testAppDataDir/configuration/fhircontactpointmap/contactPointMap.csv +++ b/api-2.6/src/test/resources/testAppDataDir/configuration/fhircontactpointmap/contactPointMap.csv @@ -1,5 +1,5 @@ Uuid,Void/Retire,Entity name,Attribute Type,System,Use,Rank,_order:1000 -fa48acc4-ef1f-46d6-b0af-150b00ddee9d,,person,717ec942-3c4a-11ea-b024-ffc81a23382e,phone,work,1, -,,person,PAT_RENAME_NEW_NAME,phone,home,, -bcf23315-a236-42aa-be95-b9e0931e22b0,,provider,Provider Speciality,email,home,2, -800e48ba-666c-445c-b871-68e54eec6de8,,location,e7aacc6e-d151-4d9e-a808-6ed9ff761212,phone,temp,3, +fa48acc4-ef1f-46d6-b0af-150b00ddee9d,,person,717ec942-3c4a-11ea-b024-ffc81a23382e,PHONE,WORK,1, +,,person,PAT_RENAME_NEW_NAME,PHONE,HOME,, +bcf23315-a236-42aa-be95-b9e0931e22b0,,provider,Provider Speciality,EMAIL,HOME,2, +800e48ba-666c-445c-b871-68e54eec6de8,,location,e7aacc6e-d151-4d9e-a808-6ed9ff761212,PHONE,TEMP,3, diff --git a/omod/pom.xml b/omod/pom.xml index 92a6e2a1a..f5a216d0a 100644 --- a/omod/pom.xml +++ b/omod/pom.xml @@ -42,6 +42,12 @@ ${project.parent.artifactId}-api-2.5 ${project.parent.version} + + + ${project.parent.groupId} + ${project.parent.artifactId}-api-2.6 + ${project.parent.version} + ${project.parent.groupId} diff --git a/pom.xml b/pom.xml index 473abef74..12353bfbf 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 2.3.6 2.4.0 2.5.5 - 2.6.3-SNAPSHOT + 2.6.3 ${openmrsVersion2.1} diff --git a/readme/fhir.md b/readme/fhir.md index 3651376e7..67865a4bd 100644 --- a/readme/fhir.md +++ b/readme/fhir.md @@ -90,10 +90,10 @@ The format of this CSV should be as follows: | Uuid | Void/Retire | Entity name | Attribute Type | System | Use | Rank | _order:1000 | |--------------------------------------|-------------|-------------|--------------------------------------|--------|------|------|-------------| -| fa48acc4-ef1f-46d6-b0af-150b00ddee9d | | person | 717ec942-3c4a-11ea-b024-ffc81a23382e | phone | work | 1 | | -| | | person | PAT_RENAME_NEW_NAME | phone | home | | | -| bcf23315-a236-42aa-be95-b9e0931e22b0 | | provider | Provider Speciality | email | home | 2 | | -| 800e48ba-666c-445c-b871-68e54eec6de8 | | location | e7aacc6e-d151-4d9e-a808-6ed9ff761212 | phone | temp | 3 | | +| fa48acc4-ef1f-46d6-b0af-150b00ddee9d | | person | 717ec942-3c4a-11ea-b024-ffc81a23382e | PHONE | WORK | 1 | | +| | | person | PAT_RENAME_NEW_NAME | PHONE | HOME | | | +| bcf23315-a236-42aa-be95-b9e0931e22b0 | | provider | Provider Speciality | EMAIL | HOME | 2 | | +| 800e48ba-666c-445c-b871-68e54eec6de8 | | location | e7aacc6e-d151-4d9e-a808-6ed9ff761212 | PHONE | TEMP | 3 | | Headers that start with an underscore such as `_order:1000` are metadata headers. The values in the columns under those headers are never read by the CSV parser. diff --git a/validator/pom.xml b/validator/pom.xml index 5c85525dd..4e1c0145a 100644 --- a/validator/pom.xml +++ b/validator/pom.xml @@ -14,12 +14,12 @@ Validator project for Initializer - 4.1.4.RELEASE + 5.3.23 - 2.3.6 + 2.6.3 2.0.6 1.7.2 - 1.15.3 + 1.17.6 1.9.0 1.6.0 @@ -58,7 +58,7 @@ org.mockito mockito-core - 3.6.28 + 3.12.4 jar @@ -86,7 +86,7 @@ mysql mysql-connector-java - 5.1.45 + 8.0.30 jar runtime @@ -140,6 +140,13 @@ jar + + ${project.parent.groupId} + ${project.parent.artifactId}-api-2.6 + ${project.parent.version} + jar + + org.openmrs.api openmrs-api From fa1360ffc33b865e3a00b53a27c1ca6de87f7a0a Mon Sep 17 00:00:00 2001 From: mherman22 Date: Mon, 27 Nov 2023 22:13:19 +0300 Subject: [PATCH 4/7] fix build in validator --- .../module/initializer/validator/ConfigurationTester.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/validator/src/main/java/org/openmrs/module/initializer/validator/ConfigurationTester.java b/validator/src/main/java/org/openmrs/module/initializer/validator/ConfigurationTester.java index 585467bb6..98313a2d6 100644 --- a/validator/src/main/java/org/openmrs/module/initializer/validator/ConfigurationTester.java +++ b/validator/src/main/java/org/openmrs/module/initializer/validator/ConfigurationTester.java @@ -2,6 +2,7 @@ import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.is; +import org.openmrs.liquibase.ChangeSetExecutorCallback; import static org.openmrs.module.initializer.InitializerConstants.ARG_DOMAINS; import static org.openmrs.module.initializer.InitializerConstants.ARG_EXCLUDE; import static org.openmrs.module.initializer.InitializerConstants.PROPS_DOMAINS; @@ -172,9 +173,9 @@ public ConfigurationTester() throws Exception { getRuntimeProperties().put(PROPS_SKIPCHECKSUMS, "true"); } // Setting up initial core database - DatabaseUpdater.executeChangelog("liquibase-schema-only.xml", null); - DatabaseUpdater.executeChangelog("liquibase-core-data.xml", null); - DatabaseUpdater.executeChangelog("liquibase-update-to-latest.xml", null); + DatabaseUpdater.executeChangelog("liquibase-schema-only.xml", (ChangeSetExecutorCallback) null); + DatabaseUpdater.executeChangelog("liquibase-core-data.xml", (ChangeSetExecutorCallback) null); + DatabaseUpdater.executeChangelog("liquibase-update-to-latest.xml", (ChangeSetExecutorCallback) null); } @Before From c372bae44f4bbfcedd746a49d2bdd97a339c16e7 Mon Sep 17 00:00:00 2001 From: mherman22 Date: Tue, 28 Nov 2023 10:00:41 +0300 Subject: [PATCH 5/7] change encoding class --- .../openmrs/module/initializer/validator/ValidatorTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/validator/src/test/java/org/openmrs/module/initializer/validator/ValidatorTest.java b/validator/src/test/java/org/openmrs/module/initializer/validator/ValidatorTest.java index 668463bcc..d0e0080e9 100644 --- a/validator/src/test/java/org/openmrs/module/initializer/validator/ValidatorTest.java +++ b/validator/src/test/java/org/openmrs/module/initializer/validator/ValidatorTest.java @@ -1,6 +1,5 @@ package org.openmrs.module.initializer.validator; -import static groovy.json.internal.Charsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -8,6 +7,7 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; @@ -35,9 +35,9 @@ public void test_trimCielSql() throws URISyntaxException, IOException { File trimmedCielFile = Validator.trimCielSqlFile(cielFile); // verify - String trimmedSql = readFile(trimmedCielFile.getAbsolutePath(), UTF_8); + String trimmedSql = readFile(trimmedCielFile.getAbsolutePath(), StandardCharsets.UTF_8); File expectedFile = new File(getClass().getClassLoader().getResource("trimmed_ciel_excerpt.txt").toURI()); - String expectedSql = readFile(expectedFile.getAbsolutePath(), UTF_8); + String expectedSql = readFile(expectedFile.getAbsolutePath(), StandardCharsets.UTF_8); assertEquals(expectedSql, trimmedSql); } From 55f1658b1eb472feafd070b519630d14d4b6e67e Mon Sep 17 00:00:00 2001 From: mherman22 Date: Mon, 1 Jul 2024 18:24:22 +0300 Subject: [PATCH 6/7] fix according to reviews --- README.md | 4 ++-- .../api/fhir/cpm/FhirContactPointMapCsvParser.java | 4 ++-- .../api/fhir/cpm/FhirContactPointMapLineProcessor.java | 8 ++++---- .../api/fhir/cpm/FhirContactPointMapLoader.java | 2 +- readme/fhir.md | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 03b4c5ddd..4178b9499 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ configuration/ ├── encounterroles/ ├── fhirconceptsources/ ├── fhirpatientidentifiersystems/ - ├── fhirContactPointMap/ + ├── fhircontactpointmaps/ ├── globalproperties/ ├── htmlforms/ ├── idgen/ @@ -150,7 +150,7 @@ This is the list of currently supported domains in their loading order: 1. [Cohort Attribute Types (CSV files)](readme/cohort.md#domain-cohortattributetypes) 1. [FHIR Concept Sources (CSV files)](readme/fhir.md#domain-fhirconceptsources) 1. [FHIR Patient Identifier Systems (CSV Files)](readme/fhir.md#domain-fhirpatientidentifiersystems) -2. [FHIR ContactPointMap (CSV Files)](https://github.com/mherman22/openmrs-module-initializer/blob/ContactPointMap-impl/readme/fhir.md#domain-fhircontactpointmap) +2. [FHIR Contact Point Map (CSV Files)](readme/fhir.md#domain-fhircontactpointmap) 1. [AMPATH Forms (JSON files)](readme/ampathforms.md) 1. [AMPATH Forms Translations (JSON files)](readme/ampathformstranslations.md) 1. [HTML Forms (XML files)](readme/htmlforms.md) diff --git a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapCsvParser.java b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapCsvParser.java index 1f369f0e8..2e26bb6e5 100644 --- a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapCsvParser.java +++ b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapCsvParser.java @@ -25,12 +25,12 @@ import org.springframework.stereotype.Component; @Component -@OpenmrsProfile(modules = { "fhir2:1.11.* - 9.*" }, openmrsPlatformVersion = "2.6.3 - 2.6.*, 2.7.* - 9.*") +@OpenmrsProfile(modules = { "fhir2:1.11.0" }, openmrsPlatformVersion = "2.6.3") public class FhirContactPointMapCsvParser extends CsvParser> { public static final String ATTRIBUTE_TYPE_DOMAIN_HEADER = "Entity name"; - public static final String ATTRIBUTE_TYPE = "Attribute Type"; + public static final String ATTRIBUTE_TYPE = "Attribute type"; private static final String LOCATION = "location"; diff --git a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLineProcessor.java b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLineProcessor.java index 6d58bfd42..3973394ab 100644 --- a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLineProcessor.java +++ b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLineProcessor.java @@ -20,14 +20,14 @@ import static org.openmrs.module.initializer.api.fhir.cpm.FhirContactPointMapCsvParser.ATTRIBUTE_TYPE_DOMAIN_HEADER; @Component -@OpenmrsProfile(modules = { "fhir2:1.11.* - 9.*" }, openmrsPlatformVersion = "2.6.3 - 2.6.*, 2.7.* - 9.*") +@OpenmrsProfile(modules = { "fhir2:1.11.0" }, openmrsPlatformVersion = "2.6.3") public class FhirContactPointMapLineProcessor extends BaseLineProcessor { - private static final String SYSTEM_HEADER = "system"; + private static final String SYSTEM_HEADER = "System"; - private static final String USE_HEADER = "use"; + private static final String USE_HEADER = "Use"; - private static final String RANK_HEADER = "rank"; + private static final String RANK_HEADER = "Rank"; @Override public FhirContactPointMap fill(FhirContactPointMap instance, CsvLine line) throws IllegalArgumentException { diff --git a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLoader.java b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLoader.java index b6eeb2ca4..3c6f7176b 100644 --- a/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLoader.java +++ b/api-2.6/src/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLoader.java @@ -16,7 +16,7 @@ import org.springframework.stereotype.Component; @Component -@OpenmrsProfile(modules = { "fhir2:1.11.* - 9.*" }, openmrsPlatformVersion = "2.6.3 - 2.6.*, 2.7.* - 9.*") +@OpenmrsProfile(modules = { "fhir2:1.11.0" }, openmrsPlatformVersion = "2.6.3") public class FhirContactPointMapLoader extends BaseCsvLoader { @Autowired diff --git a/readme/fhir.md b/readme/fhir.md index 67865a4bd..3f6c7cab0 100644 --- a/readme/fhir.md +++ b/readme/fhir.md @@ -88,7 +88,7 @@ fhirContactPointMap/ ``` The format of this CSV should be as follows: -| Uuid | Void/Retire | Entity name | Attribute Type | System | Use | Rank | _order:1000 | +| Uuid | Void/Retire | Entity name | Attribute type | System | Use | Rank | _order:1000 | |--------------------------------------|-------------|-------------|--------------------------------------|--------|------|------|-------------| | fa48acc4-ef1f-46d6-b0af-150b00ddee9d | | person | 717ec942-3c4a-11ea-b024-ffc81a23382e | PHONE | WORK | 1 | | | | | person | PAT_RENAME_NEW_NAME | PHONE | HOME | | | From 0b5dac59ac807400a5aa74b99dbef7a725eeb82a Mon Sep 17 00:00:00 2001 From: mherman22 Date: Mon, 1 Jul 2024 20:07:00 +0300 Subject: [PATCH 7/7] change to 2.8.0-snapshot --- api-2.6/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api-2.6/pom.xml b/api-2.6/pom.xml index f5215465f..308c5bcee 100644 --- a/api-2.6/pom.xml +++ b/api-2.6/pom.xml @@ -6,7 +6,7 @@ org.openmrs.module initializer - 2.7.0-SNAPSHOT + 2.8.0-SNAPSHOT 4.0.0