Skip to content

Commit

Permalink
Add subgroup decoding, program, entity type and test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
saquino0827 committed Oct 4, 2023
1 parent 2ee6e30 commit a0b4c1e
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ClinicalDocumentDecoder extends QrdaDecoder {
public static final String ENTITY_APM = "apm";
static final String ENTITY_GROUP = "group";
static final String ENTITY_INDIVIDUAL = "individual";
static final String ENTITY_SUBGROUP = "subgroup";
public static final String ENTITY_SUBGROUP = "subgroup";
public static final String ENTITY_VIRTUAL_GROUP = "virtualGroup";
public static final String APP_PROGRAM_NAME = "app1";
public static final String MIPS = "MIPS";
Expand All @@ -57,8 +57,8 @@ public class ClinicalDocumentDecoder extends QrdaDecoder {
public static final String PCF = "PCF";
public static final String APP = "APP";
public static final String CPCPLUS = "CPCPLUS";
private static final String MIPS_GROUP = "MIPS_GROUP";
private static final String MIPS_INDIVIDUAL = "MIPS_INDIV";
public static final String MIPS_GROUP = "MIPS_GROUP";
public static final String MIPS_INDIVIDUAL = "MIPS_INDIV";
public static final String MIPS_APM = "MIPS_APMENTITY";
public static final String MIPS_VIRTUAL_GROUP = "MIPS_VIRTUALGROUP";
public static final String MIPS_SUBGROUP = "MIPS_SUBGROUP";
Expand All @@ -82,9 +82,12 @@ protected DecodeResult decode(Element element, Node thisNode) {
setProgramNameOnNode(element, thisNode);
setPracticeSiteAddress(element, thisNode);
setCehrtOnNode(element, thisNode);
String entityType = thisNode.getValue(ENTITY_TYPE);
String entityType = thisNode.getValueOrDefault(ENTITY_TYPE, "");
if (MVP_ENTITIES.contains(entityType) && Program.isMips(thisNode)) {
setMvpIdOnNode(element, thisNode);
setValueOnNode(element, thisNode, MVP_ID);
if (ENTITY_SUBGROUP.equalsIgnoreCase(entityType)) {
setValueOnNode(element, thisNode, SUBGROUP_ID);
}
}
if (ENTITY_APM.equalsIgnoreCase(entityType)) {
setEntityIdOnNode(element, thisNode);
Expand Down Expand Up @@ -157,9 +160,15 @@ private void setMvpIdOnNode(Element element, Node thisNode) {
setOnNode(element, getXpath(MVP_ID), consumer, Filters.attribute(), true);
}

private void setSubgroupIdOnNode(Element element, Node thisNode, String entityLocationId) {
Consumer<? super Attribute> consumer = p -> thisNode.putValue(SUBGROUP_ID, p.getValue());
setOnNode(element, getXpath(entityLocationId), consumer, Filters.attribute(), true);
/**
* Sets a specific value as an element on the Node class decoder
* @param element current xml element to find the value via xpath
* @param thisNode current node
* @param currentValue to be added to the Node
*/
private void setValueOnNode(Element element, Node thisNode, String currentValue) {
Consumer<? super Attribute> consumer = p -> thisNode.putValue(currentValue, p.getValue());
setOnNode(element, getXpath(currentValue), consumer, Filters.attribute(), true);
}

/**
Expand Down Expand Up @@ -279,6 +288,10 @@ private Pair<String, String> getProgramNameEntityPair(String name) {
pair = new ImmutablePair<>(PCF_PROGRAM_NAME, ENTITY_APM);
break;

case MIPS_SUBGROUP:
pair = new ImmutablePair<>(MIPS_PROGRAM_NAME, ENTITY_SUBGROUP);
break;

default:
pair = new ImmutablePair<>(name.toLowerCase(Locale.ENGLISH), ENTITY_INDIVIDUAL);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Construct that helps categorize submissions by program name.
*/
public enum Program {
MIPS("MIPS_GROUP", "MIPS_INDIV", "MIPS_VIRTUALGROUP", "MIPS", "MIPS_APMENTITY"),
MIPS("MIPS_GROUP", "MIPS_INDIV", "MIPS_VIRTUALGROUP", "MIPS", "MIPS_APMENTITY", "MIPS_SUBGROUP"),
PCF("PCF"),
APP("MIPS_APP1_INDIV", "MIPS_APP1_GROUP", "MIPS_APP1_APMENTITY"),
ALL;
Expand Down
2 changes: 1 addition & 1 deletion converter/src/main/resources/pathing/path-correlation.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
"subgroupId"
],
"goods": {
"relativeXPath": "./*[local-name() = 'documentationOf' and namespace-uri() = '<nsuri>']/*[local-name() = 'serviceEvent' and namespace-uri() = '<nsuri>']/*[local-name() = 'performer' and namespace-uri() = '<nsuri>']/*[local-name() = 'assignedEntity' and namespace-uri() = '<nsuri>']/*[local-name() = 'representedOrganization' and namespace-uri() = '<nsuri>']/*[local-name() = 'id' and namespace-uri() = '<nsuri>'][@root='2.16.840.1.113883.4.2']/@extension",
"relativeXPath": "./*[local-name() = 'documentationOf' and namespace-uri() = '<nsuri>']/*[local-name() = 'serviceEvent' and namespace-uri() = '<nsuri>']/*[local-name() = 'performer' and namespace-uri() = '<nsuri>']/*[local-name() = 'assignedEntity' and namespace-uri() = '<nsuri>']/*[local-name() = 'representedOrganization' and namespace-uri() = '<nsuri>']/*[local-name() = 'id' and namespace-uri() = '<nsuri>'][@root='2.16.840.1.113883.3.249.5.5']/@extension",
"xmltype": "attribute"
}
}
Expand Down
Loading

0 comments on commit a0b4c1e

Please sign in to comment.