Skip to content

Commit

Permalink
mimick what is happening in api-2.5 pom
Browse files Browse the repository at this point in the history
  • Loading branch information
mherman22 committed Nov 24, 2023
1 parent 2c757fd commit 07f2377
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 55 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -199,6 +200,7 @@ See the [documentation on Initializer's logging properties](readme/rtprops.md#lo
* Added support for 'queues' domain.
* Added support for 'addresshierarchy' domain.
* Fix for Liquibase Loader to ensure compatibility with OpenMRS versions 2.5.5+
* Added support for 'fhircontactpointmap' domain.

#### Version 2.6.0
* Added support for 'cohorttypes' and 'cohortattributetypes' domains.
Expand Down
29 changes: 29 additions & 0 deletions api-2.6/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@
<type>test-jar</type>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-api-2.5</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-api-2.5</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-api-2.4</artifactId>
Expand Down Expand Up @@ -88,6 +103,13 @@
<type>test-jar</type>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>fhir2-api-2.5</artifactId>
<version>${fhir2Version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>fhir2-api-2.6</artifactId>
Expand All @@ -102,6 +124,13 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>queue-api</artifactId>
<version>${queueVersion}</version>
<scope>provided</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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<FhirContactPointMap, BaseLineProcessor<FhirContactPointMap>> {

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";

Expand All @@ -45,8 +47,9 @@ public class FhirContactPointMapCsvParser extends CsvParser<FhirContactPointMap,
private final FhirContactPointMapService fhirContactPointMapService;

@Autowired
protected FhirContactPointMapCsvParser(FhirContactPointMapService fhirContactPointMapService,BaseLineProcessor<FhirContactPointMap> lineProcessor,
LocationService locationService, PersonService personService, ProviderService providerService) {
protected FhirContactPointMapCsvParser(FhirContactPointMapService fhirContactPointMapService,
BaseLineProcessor<FhirContactPointMap> lineProcessor, LocationService locationService, PersonService personService,
ProviderService providerService) {
super(lineProcessor);
this.fhirContactPointMapService = fhirContactPointMapService;
this.locationService = locationService;
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -97,7 +99,6 @@ public FhirContactPointMap bootstrap(CsvLine line) throws IllegalArgumentExcepti

return new FhirContactPointMap();
}


@Override
public FhirContactPointMap save(FhirContactPointMap instance) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FhirContactPointMap> {

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FhirContactPointMap, FhirContactPointMapCsvParser> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import static org.hamcrest.Matchers.is;

public class FhirPatientContactPointMapIntegrationTest extends DomainBaseModuleContextSensitive_2_6_Test {

@Autowired
private FhirContactPointMapService fhirContactPointMapService;

Expand All @@ -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
Expand All @@ -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<FhirContactPointMap> contactPointMap = fhirContactPointMapService.getFhirContactPointMapForPersonAttributeType(attributeType);
Optional<FhirContactPointMap> contactPointMap = fhirContactPointMapService
.getFhirContactPointMapForPersonAttributeType(attributeType);
assertThat(contactPointMap.isPresent(), is(true));
return contactPointMap.get();
}

protected FhirContactPointMap assertBaseAttributeType(BaseAttributeType<?> attributeType) {
Optional<FhirContactPointMap> contactPointMap = fhirContactPointMapService.getFhirContactPointMapForAttributeType(attributeType);
Optional<FhirContactPointMap> contactPointMap = fhirContactPointMapService
.getFhirContactPointMapForAttributeType(attributeType);
assertThat(contactPointMap.isPresent(), is(true));
return contactPointMap.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand All @@ -45,6 +46,7 @@ public void getLoaders_shouldBeUnequivocallyOrdered() {

List<Loader> runtimeLoaders = getService().getLoaders();
assertThat(runtimeLoaders, everyItem(hasExpectedDomain()));

assertThat(runtimeLoaders, coversAllDomains());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
6 changes: 6 additions & 0 deletions omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
<artifactId>${project.parent.artifactId}-api-2.5</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-api-2.6</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<openmrsVersion2.3>2.3.6</openmrsVersion2.3>
<openmrsVersion2.4>2.4.0</openmrsVersion2.4>
<openmrsVersion2.5>2.5.5</openmrsVersion2.5>
<openmrsVersion2.6>2.6.3-SNAPSHOT</openmrsVersion2.6>
<openmrsVersion2.6>2.6.3</openmrsVersion2.6>

<openmrsPlatformVersion>${openmrsVersion2.1}</openmrsPlatformVersion>

Expand Down
8 changes: 4 additions & 4 deletions readme/fhir.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Loading

0 comments on commit 07f2377

Please sign in to comment.