-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new FhirContactPoints domain #253
Open
mherman22
wants to merge
7
commits into
mekomsolutions:main
Choose a base branch
from
mherman22:ContactPointMap-impl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4ca8ddc
add fhir contact point map to initializer
mherman22 1922f29
suggestions from talk post
mherman22 84f445b
mimick what is happening in api-2.5 pom
mherman22 fa1360f
fix build in validator
mherman22 c372bae
change encoding class
mherman22 55f1658
fix according to reviews
mherman22 0b5dac5
change to 2.8.0-snapshot
mherman22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<parent> | ||
<groupId>org.openmrs.module</groupId> | ||
<artifactId>initializer</artifactId> | ||
<version>2.7.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>initializer-api-2.6</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Initializer API 2.6</name> | ||
<description>API 2.6 project for Initializer</description> | ||
|
||
<properties> | ||
<openmrsPlatformVersion>${openmrsVersion2.6}</openmrsPlatformVersion> | ||
<fhir2Version>1.11.0</fhir2Version> | ||
<datafilterVersion>2.2.0</datafilterVersion> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.openmrs.test</groupId> | ||
<artifactId>openmrs-test</artifactId> | ||
<type>pom</type> | ||
<version>${openmrsPlatformVersion}</version> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-api-mockito2</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-api</artifactId> | ||
<version>${project.parent.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-api</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.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> | ||
<version>${project.parent.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-api-2.3</artifactId> | ||
<version>${project.parent.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-api-2.3</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.2</artifactId> | ||
<version>${project.parent.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-api-2.2</artifactId> | ||
<version>${project.parent.version}</version> | ||
<scope>test</scope> | ||
<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> | ||
<version>${fhir2Version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.openmrs.module</groupId> | ||
<artifactId>datafilter-api</artifactId> | ||
<version>${datafilterVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.openmrs.module</groupId> | ||
<artifactId>queue-api</artifactId> | ||
<version>${queueVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
146 changes: 146 additions & 0 deletions
146
...c/main/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapCsvParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/** | ||
* 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. | ||
* <p> | ||
* 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; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@OpenmrsProfile(modules = { "fhir2:1.11.0" }, openmrsPlatformVersion = "2.6.3") | ||
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"; | ||
|
||
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<FhirContactPointMap> 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; | ||
} | ||
|
||
return personService.getPersonAttributeTypeByUuid(attributeType); | ||
} | ||
|
||
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; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...in/java/org/openmrs/module/initializer/api/fhir/cpm/FhirContactPointMapLineProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* 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. | ||
* <p> | ||
* 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 org.springframework.stereotype.Component; | ||
|
||
import static org.openmrs.module.initializer.api.fhir.cpm.FhirContactPointMapCsvParser.ATTRIBUTE_TYPE_DOMAIN_HEADER; | ||
|
||
@Component | ||
@OpenmrsProfile(modules = { "fhir2:1.11.0" }, openmrsPlatformVersion = "2.6.3") | ||
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(); | ||
|
||
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; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update this now that 2.7.0 is released. I guess this should be 2.8.0-SNAPSHOT.