Skip to content

Commit

Permalink
Add support for totalConformanceErrorChecks
Browse files Browse the repository at this point in the history
  • Loading branch information
drbgfc committed Apr 22, 2020
1 parent 102965d commit 8f2d609
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 12 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
<mdht.models.version>3.0.8.20180531</mdht.models.version>
<mdht.plugins.version>3.0.0.201805310501</mdht.plugins.version>
<consentdirective.version>1.0.0.20170920</consentdirective.version>
<ds4pcontent.version>3.0.0.20170920</ds4pcontent.version>
<!--<ds4pcontent.version>3.0.0.20170920</ds4pcontent.version>-->
<ds4pcontent.version>3.0.0.20200422</ds4pcontent.version> <!-- Test Scorecard Update -->
</properties>

<repositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class ValidationResultsMetaData {
private int vocabularyValidationConfigurationsCount;
private int vocabularyValidationConfigurationsErrorCount;
private String severityLevel;
private long totalConformanceErrorChecks;

public ValidationResultsMetaData() {
for (ValidationResultType resultType : ValidationResultType.values()) {
Expand All @@ -48,12 +49,10 @@ public String getCcdaVersion() {
public String getObjectiveProvided() {
return objectiveProvided;
}


public void setObjectiveProvided(String objectiveProvided) {
this.objectiveProvided = objectiveProvided;
}


public boolean isServiceError() {
return serviceError;
Expand Down Expand Up @@ -126,4 +125,12 @@ public String getSeverityLevel() {
public void setSeverityLevel(String severityLevel) {
this.severityLevel = severityLevel;
}

public long getTotalConformanceErrorChecks() {
return totalConformanceErrorChecks;
}

public void setTotalConformanceErrorChecks(long totalConformanceErrorChecks) {
this.totalConformanceErrorChecks = totalConformanceErrorChecks;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,21 @@ private List<RefCCDAValidationResult> doContentValidation(String validationObjec
private ValidationResultsMetaData buildValidationMedata(List<RefCCDAValidationResult> validatorResults,
String validationObjective, SeverityLevel severityLevel) {
ValidationResultsMetaData resultsMetaData = new ValidationResultsMetaData();

for (RefCCDAValidationResult result : validatorResults) {
resultsMetaData.addCount(result.getType());
}
resultsMetaData.setObjectiveProvided(validationObjective);
resultsMetaData.setCcdaDocumentType(referenceCCDAValidator.getCcdaDocumentType());
resultsMetaData.setCcdaVersion(referenceCCDAValidator.getCcdaVersion().getVersion());
resultsMetaData.setTotalConformanceErrorChecks(referenceCCDAValidator.getTotalConformanceErrorChecks());
resultsMetaData.setSeverityLevel(severityLevel.name());
GlobalCodeValidatorResults globalCodeValidatorResults = vocabularyCCDAValidator.getGlobalCodeValidatorResults();
resultsMetaData.setVocabularyValidationConfigurationsCount(
globalCodeValidatorResults.getVocabularyValidationConfigurationsCount());
resultsMetaData.setVocabularyValidationConfigurationsErrorCount(
globalCodeValidatorResults.getVocabularyValidationConfigurationsErrorCount());
globalCodeValidatorResults.getVocabularyValidationConfigurationsErrorCount());

return resultsMetaData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ public class ReferenceCCDAValidator extends BaseCCDAValidator implements CCDAVal
private static Logger logger = Logger.getLogger(ReferenceCCDAValidator.class);

private static final String IG_ISSUE_ID = "a.consol", MU_ISSUE_ID = "a.mu2con", DS4P_ISSUE_ID = "ds4p";
private static final boolean CAPTURE_VALIDATION_STATISTICS = true;
private boolean isValidationObjectiveMu2Type = false;
private boolean isValidationObjectiveDS4PType = false;
private String ccdaDocumentType = CCDATypes.UNKNOWN_DOC_TYPE;
private CCDAVersion ccdaVersion = CCDAVersion.NOT_CCDA;
private long totalConformanceErrorChecks = -1L;

public boolean isValidationObjectiveMu2Type() {
return isValidationObjectiveMu2Type;
Expand All @@ -82,6 +84,10 @@ public String getCcdaDocumentType() {
public CCDAVersion getCcdaVersion() {
return ccdaVersion;
}

public long getTotalConformanceErrorChecks() {
return totalConformanceErrorChecks;
}

public ArrayList<RefCCDAValidationResult> validateFile(String validationObjective, String referenceFileName,
String ccdaFile) throws SAXException, Exception {
Expand All @@ -91,7 +97,7 @@ public ArrayList<RefCCDAValidationResult> validateFile(String validationObjectiv
public ArrayList<RefCCDAValidationResult> validateFile(String validationObjective, String referenceFileName,
String ccdaFile, SeverityLevel severityLevel) throws SAXException, Exception {
final XPathIndexer xpathIndexer = new XPathIndexer();
ValidationResult result = new ValidationResult();
ValidationResult result = new ValidationResult(CAPTURE_VALIDATION_STATISTICS);
InputStream in = null, in2 = null;
trackXPathsInXML(xpathIndexer, ccdaFile);
try {
Expand Down Expand Up @@ -124,7 +130,7 @@ private static void closeInputStreams(List<InputStream> inputStreams) {
}
}
}
}
}

private void validateDocumentByTypeUsingMDHTApi(InputStream in, InputStream in2, String validationObjective,
ValidationResult result) throws Exception {
Expand Down Expand Up @@ -196,7 +202,7 @@ private void validateDocumentByTypeUsingMDHTApi(InputStream in, InputStream in2,
+ ValidationObjectives.getObjectives() + " " + CCDATypes.getTypes());
}
ccdaDocumentType = determineCcdaDocumentType(clinicalDocument);
ccdaVersion = determineCcdaDocumentVersion(clinicalDocument);
ccdaVersion = determineCcdaDocumentVersion(clinicalDocument);
logger.info("ccdaVersion identified as: " + ccdaVersion.getVersion());
}

Expand Down Expand Up @@ -231,7 +237,7 @@ private CCDAVersion determineCcdaDocumentVersion(ClinicalDocument clinicalDocume
}
logger.info("returning version by determineCcdaDocumentVersion method end");
return version;
}
}

private String determineCcdaDocumentType(ClinicalDocument clinicalDocument) {
UsrhSubType usrhSubType = null;
Expand Down Expand Up @@ -330,6 +336,8 @@ private static boolean isValidationObjectiveCCDAType(String validationObjective)

private ArrayList<RefCCDAValidationResult> processValidationResults(final XPathIndexer xpathIndexer,
ValidationResult result, SeverityLevel severityLevel) {
totalConformanceErrorChecks = result.getValidationStatistics().shallCount;

ArrayList<RefCCDAValidationResult> results = new ArrayList<RefCCDAValidationResult>();
switch (severityLevel) {
case ERROR:
Expand All @@ -351,7 +359,7 @@ private ArrayList<RefCCDAValidationResult> processValidationResults(final XPathI
break;
}
return results;
}
}

private void addValidationResults(ArrayList<RefCCDAValidationResult> results, ValidationResultType currentValidationResultType,
List<Diagnostic> diagnosticsOfCurrentSeverity, final XPathIndexer xpathIndexer) {
Expand Down
22 changes: 19 additions & 3 deletions src/test/java/org/sitenv/referenceccda/test/tests/RefCCDATest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class RefCCDATest extends ReferenceValidationTester implements Validation

private static final boolean LOG_RESULTS_TO_CONSOLE = true;

private static final boolean SHOW_ERRORS_ONLY = false;
private static final boolean SHOW_ERRORS_ONLY = true;
private static final boolean LOG_LOG4J = true;
static {
if (LOG_LOG4J) {
Expand Down Expand Up @@ -471,7 +471,7 @@ public void tempResults_UTF8_BOM_EttGg_runReferenceCCDAValidation_Test() {
}

@Test
public void mDHTSeverityLevelTest() {
public void mdhtSeverityLevelTest() {
setupInitParameters(true);
injectDependencies();

Expand Down Expand Up @@ -622,6 +622,22 @@ public void vocabAndMdhtSeverityLevelWarningMultipleValidatorsPerExpressionTest(
public void vocabAndMdhtSeverityLevelInfoMultipleValidatorsPerExpressionTest() {
vocabAndMdhtSeverityLevelConfigTestImpl(SeverityLevel.INFO, false, "severityLevelLimitTestConfig");
}

@Test
public void mdhtValidationStatisticsShallChecksTest() {
setupInitParameters(true);
injectDependencies();

ValidationResultsDto results = runReferenceCCDAValidationServiceAndReturnResults(CCDATypes.NON_SPECIFIC_CCDAR2,
CCD_R21, new VocabularyCCDAValidator(getVocabularyValidationService()),
"ccdaReferenceValidatorConfigTest");

printResultsBasedOnFlags(results.getCcdaValidationResults());

long checks = results.getResultsMetaData().getTotalConformanceErrorChecks();
println("IG Checks: " + checks);
assertTrue("There should be a positive number of IG checks but there is " + checks + " instead.", checks > 0);
}

private static List<ConfiguredExpression> getGenericConfiguredExpressionsForTesting() {
final String validationMessage = "Will always fail";
Expand Down Expand Up @@ -897,7 +913,7 @@ private static ValidationResultsDto runReferenceCCDAValidationServiceAndReturnRe
severityLevel);
}
return referenceCcdaValidationService.validateCCDA(validationObjective, "", mockSample, vocabularyConfig);
}
}

private static void printResultsBasedOnFlags(List<RefCCDAValidationResult> results) {
if (SHOW_ERRORS_ONLY) {
Expand Down

0 comments on commit 8f2d609

Please sign in to comment.