Skip to content

Commit

Permalink
Merge pull request #1463 from CMSgov/feature/QPPSE-317-Refactor_Stati…
Browse files Browse the repository at this point in the history
…c_Variables

QPPSE-317: Refactor decocer/encoder static variables
  • Loading branch information
sivaksb authored Oct 8, 2024
2 parents 4c91dab + c39448b commit 6c753d1
Show file tree
Hide file tree
Showing 83 changed files with 654 additions and 615 deletions.
6 changes: 4 additions & 2 deletions commons/src/main/resources/measures-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -5508,9 +5508,11 @@
"category": "quality",
"isRegistryMeasure": false,
"isRiskAdjusted": false,
"icdImpacted": [],
"icdImpacted": [
"registry"
],
"isClinicalGuidelineChanged": false,
"isIcdImpacted": false,
"isIcdImpacted": true,
"clinicalGuidelineChanged": [],
"metricType": "singlePerformanceRate",
"companionMeasureId": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

import java.util.function.Consumer;

import static gov.cms.qpp.conversion.model.Constants.AGGREGATE_COUNT;

/**
* Decoder to parse an Aggregate Count value type.
*/
@Decoder(TemplateId.PI_AGGREGATE_COUNT)
public class AggregateCountDecoder extends QrdaDecoder {

public static final String AGGREGATE_COUNT = "aggregateCount";

public AggregateCountDecoder(Context context) {
super(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,58 +14,16 @@

import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.function.Consumer;

import static gov.cms.qpp.conversion.model.Constants.*;

/**
* Decoder to parse the root element of the Document-Level Template: QRDA Category III Report (ClinicalDocument).
*/
@Decoder(TemplateId.CLINICAL_DOCUMENT)
public class ClinicalDocumentDecoder extends QrdaDecoder {

/* Constants for lookups and tests */
// Identifier constants for: Node(Identifier, Value) and xpathlocation
public static final String NATIONAL_PROVIDER_IDENTIFIER = "nationalProviderIdentifier";
public static final String TAX_PAYER_IDENTIFICATION_NUMBER = "taxpayerIdentificationNumber";
public static final String PROGRAM_NAME = "programName";
public static final String ENTITY_TYPE = "entityType";
public static final String RAW_PROGRAM_NAME = "rawProgramName";
public static final String PRACTICE_SITE_ADDR = "practiceSiteAddr";
public static final String PRACTICE_ID = "practiceId";
public static final String ENTITY_ID = "entityId";
public static final String PCF_ENTITY_ID = "pcfEntityId";
public static final String APM_ENTITY_ID = "apmEntityId";
public static final String VG_ID = "virtualGroupId";
public static final String CEHRT = "cehrtId";
public static final String MVP_ID = "mvpId";
public static final String SUBGROUP_ID = "subgroupId";

//QPP Json value constants for: Node(Identifier, value)
public static final String MIPS_PROGRAM_NAME = "mips";
public static final String PCF_PROGRAM_NAME = "pcf";
public static final String CPCPLUS_PROGRAM_NAME = "cpcPlus";
public static final String ENTITY_APM = "apm";
static final String ENTITY_GROUP = "group";
static final String ENTITY_INDIVIDUAL = "individual";
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";
public static final Set<String> MVP_ENTITIES = Set.of(ENTITY_INDIVIDUAL, ENTITY_GROUP, ENTITY_SUBGROUP, ENTITY_APM);

// Program names in XML format
public static final String PCF = "PCF";
public static final String APP = "APP";
public static final String CPCPLUS = "CPCPLUS";
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";
private static final String APP_GROUP = "MIPS_APP1_GROUP";
private static final String APP_INDIVIDUAL = "MIPS_APP1_INDIV";
public static final String APP_APM = "MIPS_APP1_APMENTITY";

public ClinicalDocumentDecoder(Context context) {
super(context);
}
Expand Down Expand Up @@ -99,7 +57,7 @@ protected DecodeResult decode(Element element, Node thisNode) {
setNationalProviderIdOnNode(element, thisNode);
}
if (ENTITY_VIRTUAL_GROUP.equals(entityType)) {
setEntityIdOnNode(element, thisNode, ClinicalDocumentDecoder.VG_ID);
setEntityIdOnNode(element, thisNode, VG_ID);
}
}

Expand All @@ -119,7 +77,7 @@ private void setEntityIdOnNode(Element element, Node thisNode) {
thisNode.putValue(PCF_ENTITY_ID, id.getValue(), false);
setOnNode(element, getXpath(PCF_ENTITY_ID), consumer, Filters.attribute(), false);
} else {
setEntityIdOnNode(element, thisNode, ClinicalDocumentDecoder.APM_ENTITY_ID);
setEntityIdOnNode(element, thisNode, APM_ENTITY_ID);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static gov.cms.qpp.conversion.model.Constants.MEASURE_POPULATION;
import static gov.cms.qpp.conversion.model.Constants.MEASURE_TYPE;

/**
* Decoder for CMS V2 Measure Data eCQM
*/
Expand All @@ -23,9 +26,6 @@ public class MeasureDataDecoder extends QrdaDecoder {
static final Set<String> MEASURES = Stream.of("IPP", "IPOP", "DENEX", "DENOM", "DENEXCEP", "NUMER", "NUMEX")
.collect(Collectors.toSet());

public static final String MEASURE_TYPE = "type";
public static final String MEASURE_POPULATION = "populationId";

public MeasureDataDecoder(Context context) {
super(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@

import java.util.function.Consumer;

import static gov.cms.qpp.conversion.model.Constants.*;

/**
* Decodes the Performance Rate Proportion Measure from the Measure Section
*/
@Decoder(TemplateId.PERFORMANCE_RATE_PROPORTION_MEASURE)
public class PerformanceRateProportionMeasureDecoder extends QrdaDecoder {

public static final String PERFORMANCE_RATE = "rate";
public static final String NULL_PERFORMANCE_RATE = "nullRate";
public static final String PERFORMANCE_RATE_ID = "performanceRateUuid";

public PerformanceRateProportionMeasureDecoder(Context context) {
super(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

import java.util.function.Consumer;

import static gov.cms.qpp.conversion.model.Constants.MEASURE_ID;

/**
* Decoder to parse an PI Measure Performed Reference and Results.
*/
@Decoder(TemplateId.PI_MEASURE_PERFORMED_REFERENCE_AND_RESULTS)
public class PiMeasurePerformedRnRDecoder extends QrdaDecoder {

public static final String MEASURE_ID = "measureId";

public PiMeasurePerformedRnRDecoder(Context context) {
super(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

import java.util.function.Consumer;

import static gov.cms.qpp.conversion.model.Constants.MEASURE_ID;

/**
* Decoder to parse PI Numerator Denominator Type Measure reference and results.
*/
@Decoder(TemplateId.PI_NUMERATOR_DENOMINATOR)
public class PiNumeratorDenominatorDecoder extends QrdaDecoder {

public static final String MEASURE_ID = "measureId";

public PiNumeratorDenominatorDecoder(Context context) {
super(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@
import java.util.Set;
import java.util.stream.Collectors;

import static gov.cms.qpp.conversion.model.Constants.*;

/**
* The engine for parsing XML into QPP format.
*/
public class QrdaDecoderEngine extends XmlDecoderEngine {

private static final Logger DEV_LOG = LoggerFactory.getLogger(QrdaDecoderEngine.class);
private static final String TEMPLATE_ID = "templateId";
private static final String NOT_VALID_QRDA_III_FORMAT = "The file is not a QRDA-III XML document";
private static final String ROOT_STRING = "root";
private static final String EXTENSION_STRING = "extension";

protected final Context context;
private final Registry<QrdaDecoder> decoders;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
import java.util.Locale;
import java.util.stream.Collectors;

import static gov.cms.qpp.conversion.model.Constants.MEASURE_ID;

/**
* Decoder to read XML Data for an Quality Measure Identifier (eCQM).
*/
@Decoder(TemplateId.MEASURE_REFERENCE_RESULTS_CMS_V5)
public class QualityMeasureIdDecoder extends QrdaDecoder {

public static final String MEASURE_ID = "measureId";

public QualityMeasureIdDecoder(Context context) {
super(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
import gov.cms.qpp.conversion.model.Decoder;
import gov.cms.qpp.conversion.model.TemplateId;

import static gov.cms.qpp.conversion.model.Constants.QUALITY_SECTION;

/**
* Decoder to read XML Data for an Quality Section (eCQM).
*/
@Decoder(TemplateId.MEASURE_SECTION_V5)
public class QualitySectionDecoder extends SkeletalSectionDecoder {

protected static final String QUALITY_SECTION = "quality";
public static final String CATEGORY_SECTION_V5 = "clinicalDocumentV5";

public QualitySectionDecoder(Context context) {
super(context, QUALITY_SECTION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@

import java.util.function.Consumer;

import static gov.cms.qpp.conversion.model.Constants.*;

/**
* Decoder to parse Reporting Parameters Act - CMS (V2).
*/
@Decoder(TemplateId.REPORTING_PARAMETERS_ACT)
public class ReportingParametersActDecoder extends QrdaDecoder {

public static final String PERFORMANCE_START = "performanceStart";
public static final String PERFORMANCE_END = "performanceEnd";
public static final String PERFORMANCE_YEAR = "performanceYear";
private static final int YEAR_LAST_INDEX = 4;

public ReportingParametersActDecoder(Context context) {
super(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import org.jdom2.Element;
import org.jdom2.filter.Filters;

import static gov.cms.qpp.conversion.model.Constants.CATEGORY_SECTION_V5;
import static gov.cms.qpp.conversion.model.Constants.QUALITY_SECTION;

/**
* {@link QrdaDecoder} that adds a {@link String} key/value pair to the {@link Node}
*/
Expand Down Expand Up @@ -39,16 +42,16 @@ public SkeletalKeyValueDecoder(Context context, String key, String value) {
@Override
protected DecodeResult decode(Element element, Node thisNode) {
thisNode.putValue(key, value);
if (QualitySectionDecoder.QUALITY_SECTION.equalsIgnoreCase(value)){
if (QUALITY_SECTION.equalsIgnoreCase(value)){
setCategorySectionOnNode(element, thisNode);
}
return DecodeResult.TREE_CONTINUE;
}

private void setCategorySectionOnNode(Element element, Node thisNode) {
Consumer<? super Attribute> consumer = p ->
thisNode.putValue(QualitySectionDecoder.CATEGORY_SECTION_V5, p.getValue());
setOnNode(element, getXpath(QualitySectionDecoder.CATEGORY_SECTION_V5),
thisNode.putValue(CATEGORY_SECTION_V5, p.getValue());
setOnNode(element, getXpath(CATEGORY_SECTION_V5),
consumer, Filters.attribute(), true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

import gov.cms.qpp.conversion.Context;

import static gov.cms.qpp.conversion.model.Constants.CATEGORY;

/**
* {@link SkeletalSectionDecoder} that uses the key {@code category}
*/
public abstract class SkeletalSectionDecoder extends SkeletalKeyValueDecoder {

/**
* {@code category} the key used by the {@link SkeletalSectionDecoder}
*/
public static final String CATEGORY = "category";

/**
* @param context
* @param category the value for the {@code category} key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
import org.jdom2.Element;
import org.jdom2.filter.Filters;

import static gov.cms.qpp.conversion.model.Constants.*;

/**
* {@link QrdaDecoder} abstraction for decoding supplemental data
*/
public abstract class SkeletalSupplementalDataDecoder extends QrdaDecoder {

public static final String SUPPLEMENTAL_DATA_CODE = "code";
public static final String SUPPLEMENTAL_DATA_KEY = "supplementalData";
public static final String SUPPLEMENTAL_DATA_PAYER_CODE = "payerCode";

private final SupplementalType type;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gov.cms.qpp.conversion.decode;


import gov.cms.qpp.conversion.model.Constants;
import org.jdom2.Attribute;
import org.jdom2.Element;
import org.jdom2.filter.Filters;
Expand All @@ -18,7 +19,7 @@
@Decoder(TemplateId.REPORTING_STRATUM_CMS)
public class StratifierDecoder extends QrdaDecoder {

public static final String STRATIFIER_ID = "populationId";
public static final String STRATIFIER_ID = Constants.MEASURE_POPULATION;

public StratifierDecoder(Context context) {
super(context);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package gov.cms.qpp.conversion.encode;

import gov.cms.qpp.conversion.Context;
import gov.cms.qpp.conversion.decode.AggregateCountDecoder;
import gov.cms.qpp.conversion.model.Encoder;
import gov.cms.qpp.conversion.model.Node;
import gov.cms.qpp.conversion.model.TemplateId;

import static gov.cms.qpp.conversion.model.Constants.VALUE;
import static gov.cms.qpp.conversion.model.Constants.AGGREGATE_COUNT;

/**
* Encoder to serialize an Aggregate Count value type.
*
Expand All @@ -27,6 +29,6 @@ public AggregateCountEncoder(Context context) {
@Override
protected void internalEncode(JsonWrapper wrapper, Node node) {
// simply writes the value in the Node
wrapper.putInteger(VALUE, node.getValue(AggregateCountDecoder.AGGREGATE_COUNT));
wrapper.putInteger(VALUE, node.getValue(AGGREGATE_COUNT));
}
}
Loading

0 comments on commit 6c753d1

Please sign in to comment.