Skip to content

Commit

Permalink
Add severityLevel to API, support MDHT results, add tests, update UI
Browse files Browse the repository at this point in the history
-SITE-3008
ETT GG/Github Issues Ref Val: "Configure Validator to Exclude Warnings &
Info"
  • Loading branch information
drbgfc committed Jun 19, 2019
1 parent b2dce3c commit 2903f55
Show file tree
Hide file tree
Showing 7 changed files with 1,329 additions and 939 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<java.version>1.7</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<code.validator.version>1.0.20</code.validator.version>
<code.validator.version>1.0.21-SNAPSHOT</code.validator.version>
<content.validator.version>1.0.19</content.validator.version>
<!-- MDHT properties -->
<mdht.models.version>3.0.8.20180531</mdht.models.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.sitenv.referenceccda.services.ReferenceCCDAValidationService;
import org.sitenv.referenceccda.services.VocabularyService;
import org.sitenv.vocabularies.constants.VocabularyConstants;
import org.sitenv.vocabularies.constants.VocabularyConstants.SeverityLevel;
import org.sitenv.vocabularies.validation.entities.Code;
import org.sitenv.vocabularies.validation.entities.VsacValueSet;
import org.sitenv.vocabularies.validation.services.VocabularyValidationService;
Expand Down Expand Up @@ -35,9 +36,15 @@ public ValidationResultsDto doValidation(
@RequestParam(value = "validationObjective", required = true) String validationObjective,
@RequestParam(value = "referenceFileName", required = true) String referenceFileName,
@RequestParam(value = "ccdaFile", required = true) MultipartFile ccdaFile,
@RequestParam(defaultValue = VocabularyConstants.Config.DEFAULT, required = false) String vocabularyConfig) {
@RequestParam(defaultValue = VocabularyConstants.Config.DEFAULT, required = false) String vocabularyConfig,
@RequestParam(defaultValue = "info", required = false) String severityLevel) {
if (severityLevel == null || severityLevel.equals("")) {
severityLevel = "info";
}
SeverityLevel severityLevelEnum = SeverityLevel.valueOf(severityLevel.toUpperCase());

return referenceCcdaValidationService.validateCCDA(validationObjective, referenceFileName, ccdaFile,
vocabularyConfig);
vocabularyConfig, severityLevelEnum);
}

@RequestMapping(value = "/getvaluesetsbyoids", method = RequestMethod.GET)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.sitenv.referenceccda.validators.schema.ValidationObjectives;
import org.sitenv.referenceccda.validators.vocabulary.VocabularyCCDAValidator;
import org.sitenv.vocabularies.constants.VocabularyConstants;
import org.sitenv.vocabularies.constants.VocabularyConstants.SeverityLevel;
import org.sitenv.vocabularies.validation.dto.GlobalCodeValidatorResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -52,21 +53,26 @@ public ReferenceCCDAValidationService(ReferenceCCDAValidator referenceCCDAValida
}

public ValidationResultsDto validateCCDA(String validationObjective, String referenceFileName, MultipartFile ccdaFile) {
return validateCCDAImplementation(validationObjective, referenceFileName, ccdaFile, VocabularyConstants.Config.DEFAULT);
return validateCCDAImplementation(validationObjective, referenceFileName, ccdaFile, VocabularyConstants.Config.DEFAULT, SeverityLevel.INFO);
}

public ValidationResultsDto validateCCDA(String validationObjective, String referenceFileName, MultipartFile ccdaFile,
String vocabularyConfig) {
return validateCCDAImplementation(validationObjective, referenceFileName, ccdaFile, vocabularyConfig);
return validateCCDAImplementation(validationObjective, referenceFileName, ccdaFile, vocabularyConfig, SeverityLevel.INFO);
}

public ValidationResultsDto validateCCDA(String validationObjective, String referenceFileName, MultipartFile ccdaFile,
String vocabularyConfig, SeverityLevel severityLevel) {
return validateCCDAImplementation(validationObjective, referenceFileName, ccdaFile, vocabularyConfig, severityLevel);
}

private ValidationResultsDto validateCCDAImplementation(String validationObjective, String referenceFileName,
MultipartFile ccdaFile, String vocabularyConfig) {
MultipartFile ccdaFile, String vocabularyConfig, SeverityLevel severityLevel) {
ValidationResultsDto resultsDto = new ValidationResultsDto();
ValidationResultsMetaData resultsMetaData = new ValidationResultsMetaData();
List<RefCCDAValidationResult> validatorResults = new ArrayList<>();
try {
validatorResults = runValidators(validationObjective, referenceFileName, ccdaFile, vocabularyConfig);
validatorResults = runValidators(validationObjective, referenceFileName, ccdaFile, vocabularyConfig, severityLevel);
resultsMetaData = buildValidationMedata(validatorResults, validationObjective);
resultsMetaData.setCcdaFileName(ccdaFile.getOriginalFilename());
resultsMetaData.setCcdaFileContents(new String(ccdaFile.getBytes()));
Expand Down Expand Up @@ -103,7 +109,7 @@ private static void processValidateCCDAException(ValidationResultsMetaData resul
}

private List<RefCCDAValidationResult> runValidators(String validationObjective, String referenceFileName,
MultipartFile ccdaFile, String vocabularyConfig)
MultipartFile ccdaFile, String vocabularyConfig, SeverityLevel severityLevel)
throws SAXException, Exception {
List<RefCCDAValidationResult> validatorResults = new ArrayList<>();
InputStream ccdaFileInputStream = null;
Expand All @@ -117,7 +123,7 @@ private List<RefCCDAValidationResult> runValidators(String validationObjective,
}
String ccdaFileContents = IOUtils.toString(bomInputStream, "UTF-8");

List<RefCCDAValidationResult> mdhtResults = doMDHTValidation(validationObjective, referenceFileName, ccdaFileContents);
List<RefCCDAValidationResult> mdhtResults = doMDHTValidation(validationObjective, referenceFileName, ccdaFileContents, severityLevel);
if(mdhtResults != null && !mdhtResults.isEmpty()) {
logger.info("Adding MDHT results");
validatorResults.addAll(mdhtResults);
Expand Down Expand Up @@ -183,9 +189,10 @@ private boolean objectiveAllowsContentValidation(String validationObjective) {
ValidationObjectives.ALL_UNIQUE_CONTENT_ONLY);
}

private List<RefCCDAValidationResult> doMDHTValidation(String validationObjective, String referenceFileName, String ccdaFileContents) throws SAXException, Exception {
private List<RefCCDAValidationResult> doMDHTValidation(String validationObjective, String referenceFileName,
String ccdaFileContents, SeverityLevel severityLevel) throws SAXException, Exception {
logger.info("Attempting MDHT validation...");
return referenceCCDAValidator.validateFile(validationObjective, referenceFileName, ccdaFileContents);
return referenceCCDAValidator.validateFile(validationObjective, referenceFileName, ccdaFileContents, severityLevel);
}

private ArrayList<RefCCDAValidationResult> doVocabularyValidation(String validationObjective,
Expand Down
Loading

0 comments on commit 2903f55

Please sign in to comment.