Skip to content
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

Code Validator and Reference Validator enhancements #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,628 changes: 1,458 additions & 170 deletions configuration/ccdaReferenceValidatorConfig.xml

Large diffs are not rendered by default.

47 changes: 37 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
<modelVersion>4.0.0</modelVersion>

<groupId>org.sitenv</groupId>
<artifactId>referenceccdavalidator</artifactId>
<version>1.0.18</version>
<packaging>war</packaging>
<artifactId>cerner-referenceccdavalidator</artifactId>
<version>1.0.18-SNAPSHOT</version>
<!--
<packaging>war</packaging>
-->
<name>Reference CCDA Validator</name>

<properties>
<!-- Generic properties -->
<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.10</code.validator.version>
<content.validator.version>1.0.10</content.validator.version>
<code.validator.version>1.0.10-SNAPSHOT</code.validator.version>
<content.validator.version>1.0.10-SNAPSHOT</content.validator.version>
<!-- MDHT properties -->
<mdht.models.version>3.0.0.20170622</mdht.models.version>
<mdht.plugins.version>3.0.0.201706220503</mdht.plugins.version>
Expand All @@ -22,7 +24,7 @@
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
<enabled>true</enabled>
</snapshots>
<id>mdht-libs</id>
<name>libs-release</name>
Expand All @@ -31,12 +33,12 @@
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
</snapshots>
<id>mdht-plugins</id>
<name>plugins-release</name>
<url>http://devsoap.sitenv.org:8081/artifactory/plugins-release-local</url>
</repository>
</repositories>
</repository>
</repositories>

<dependencies>
<!-- START MDHT DEPENDENCIES - from devsoap.sitenv.org:8081 artifactory -->
Expand Down Expand Up @@ -128,7 +130,7 @@
<!-- START VOCAB DEPENDENCIES -->
<dependency>
<groupId>org.sitenv.vocabulary</groupId>
<artifactId>codevalidator-api</artifactId>
<artifactId>cerner-codevalidator-api</artifactId>
<version>${code.validator.version}</version>
</dependency>
<!-- END VOCAB DEPENDENCIES -->
Expand Down Expand Up @@ -312,6 +314,17 @@
<allowSnapshots>true</allowSnapshots>
</configuration>
</plugin>
<!-- START : Need to exclude ApplicationInitializer from building since Cerner specific Custom initializer is used in a separate project -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<excludes>
<exclude>org/sitenv/referenceccda/configuration/ApplicationInitializer.java</exclude>
</excludes>
</configuration>
</plugin>
<!-- END : -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
Expand Down Expand Up @@ -408,6 +421,7 @@
<!-- This profile will build a zip file of the war and all of the necessary artifacts to deploy the validator. -->
<id>distribution</id>
<build>
<finalName>cerner-referencevalidator-${version}</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
Expand Down Expand Up @@ -436,6 +450,19 @@
<packagingExcludes>**/context.xml</packagingExcludes>
</configuration>
</plugin>

<!-- Need to exclude since Cerner Custom initializer is being used-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<excludes>
<exclude>org/sitenv/referenceccda/configuration/ApplicationInitializer.java</exclude>
</excludes>
</configuration>
</plugin>
<!-- Need to exclude since Cerner Custom initializer is being used-->

</plugins>
</build>
</profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@
<directory>configuration</directory>
<includes>
<include>ccdaReferenceValidatorConfig.xml</include>
<include>referenceccda-orientdb-server-profiles.xml</include>
<include>referenceccda-orientdb-server-config.xml</include>
</includes>
<outputDirectory>VocabularyConfiguration</outputDirectory>
</fileSet>
<fileSet>
<directory>E:\Brian\Development\Environment\VocabularyConfiguration\scenarios</directory>
<outputDirectory>VocabularyConfiguration\scenarios</outputDirectory>
</fileSet>
<fileSet>
<directory>E:\Brian\Development\Environment\VocabularyConfiguration\Vocabulary</directory>
<outputDirectory>VocabularyConfiguration\Vocabulary</outputDirectory>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.sitenv.referenceccda.configuration;

import javax.servlet.ServletContext;

import org.sitenv.contentvalidator.configuration.ContentValidatorApiConfiguration;
import org.sitenv.vocabularies.configuration.CodeValidatorApiConfiguration;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

import javax.servlet.ServletContext;

public class ApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package org.sitenv.referenceccda.controllers;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.sitenv.referenceccda.dto.ValidationResultsDto;
import org.sitenv.referenceccda.services.ReferenceCCDAValidationService;
import org.sitenv.referenceccda.services.VocabularyService;
import org.sitenv.referenceccda.validators.schema.CCDATypes;
import org.sitenv.referenceccda.validators.schema.OCLLoader;
import org.sitenv.vocabularies.validation.entities.Code;
import org.sitenv.vocabularies.validation.entities.VsacValueSet;
import org.sitenv.vocabularies.validation.services.VocabularyValidationService;
Expand All @@ -14,12 +20,10 @@
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@RestController
public class ReferenceCCDAValidationController {

@Autowired
ReferenceCCDAValidationService referenceCcdaValidationService;
@Autowired
Expand All @@ -33,8 +37,12 @@ public class ReferenceCCDAValidationController {
public ValidationResultsDto doValidation(
@RequestParam(value = "validationObjective", required = true) String validationObjective,
@RequestParam(value = "referenceFileName", required = true) String referenceFileName,
@RequestParam(value = "ccdaFile", required = true) MultipartFile ccdaFile) {
return referenceCcdaValidationService.validateCCDA(validationObjective, referenceFileName, ccdaFile);
@RequestParam(value = "ccdaFile", required = true) MultipartFile ccdaFile,
@RequestParam(value = "severityLevel", required = false, defaultValue = "info") String severityLevel) {
if (severityLevel==null || severityLevel.equals("")) {
severityLevel="info";
}
return referenceCcdaValidationService.validateCCDA(validationObjective, referenceFileName, ccdaFile, severityLevel);
}

@RequestMapping(value = "/getvaluesetsbyoids", method = RequestMethod.GET)
Expand Down Expand Up @@ -73,4 +81,40 @@ public Map<String, Map<String, List<String>>> getMapOfSenderAndRecieverValidatio
return vocabularyService.getMapOfSenderAndRecieverValidationObjectivesWithReferenceFiles();
}

/*
* Following Method is added to support CCDA validation on file reference.
* ccdaReferenceFileName parameter will the file reference path to the CCDA file cache.
* The file cache must be shared and accessible to the service.
*/
//------------------------- INTERNAL CODE CHANGE START --------------------------

/*
* Following method is another flavor to validate a CDA document by file.
* Additional parameter severityLevel is passed to filter the results based on the severity.
*/
@RequestMapping(value = "/validateDocumentByFile", headers = "content-type=multipart/*", method = RequestMethod.POST)
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(value = "severityLevel", required = true, defaultValue = "Error") String severityLevel,
@RequestParam(value = "performMDHTValidation", required = false, defaultValue = "true") boolean performMDHTValidation,
@RequestParam(value = "performVocabularyValidation", required = false, defaultValue = "true") boolean performVocabularyValidation,
@RequestParam(value = "performContentValidation", required = false, defaultValue = "false") boolean performContentValidation,
@RequestParam(value = "defaultR21ValidationObjective", required = false, defaultValue = CCDATypes.NON_SPECIFIC_CCDAR2) String defaultR21ValidationObjective,
@RequestParam(value = "defaultR11ValidationObjective", required = false, defaultValue = CCDATypes.NON_SPECIFIC_CCDAR2) String defaultR11ValidationObjective
) {

return referenceCcdaValidationService.validateCCDA(validationObjective, referenceFileName, ccdaFile,severityLevel.toUpperCase(),
performMDHTValidation, performVocabularyValidation, performContentValidation, defaultR21ValidationObjective, defaultR11ValidationObjective);
}

@RequestMapping(value = "/initOCL", method = RequestMethod.GET)
public Map<String,String> doIniOCL() {

return OCLLoader.loadocl();
}

//------------------------- INTERNAL CODE CHANGE END --------------------------

}
21 changes: 20 additions & 1 deletion src/main/java/org/sitenv/referenceccda/dto/ResultMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public ResultMetaData(String type, int count) {
this.type = type;
this.count = count;
}

public String getType() {
return type;
}
Expand All @@ -25,6 +25,25 @@ public void setCount(int count) {
this.count = count;
}

// ------------------------- INTERNAL CODE CHANGE START
private String severity;

public ResultMetaData(String type, int count, String severity) {
this(type, count);
this.severity = severity;
}


public String getSeverity() {
return severity;
}

public void setSeverity(String severity) {
this.severity = severity;
}

// ------------------------- INTERNAL CODE CHANGE END

@Override
public int hashCode() {
final int prime = 31;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.sitenv.referenceccda.dto;

import org.sitenv.referenceccda.validators.RefCCDAValidationResult;

import java.util.List;

import org.sitenv.referenceccda.validators.RefCCDAValidationResult;

public class ValidationResultsDto {
private ValidationResultsMetaData resultsMetaData;
private List<RefCCDAValidationResult> ccdaValidationResults;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package org.sitenv.referenceccda.dto;

import org.sitenv.referenceccda.validators.enums.ValidationResultType;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.commons.lang3.StringUtils;
import org.sitenv.referenceccda.validators.enums.ValidationResultType;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

public class ValidationResultsMetaData {
private String ccdaDocumentType;
Expand All @@ -17,7 +20,7 @@ public class ValidationResultsMetaData {
private String ccdaFileContents;
private final Map<String, AtomicInteger> errorCounts = new LinkedHashMap<String, AtomicInteger>();
private List<ResultMetaData> resultMetaData;

public ValidationResultsMetaData() {
for (ValidationResultType resultType : ValidationResultType.values()) {
errorCounts.put(resultType.getTypePrettyName(), new AtomicInteger(0));
Expand Down Expand Up @@ -48,14 +51,58 @@ public void setServiceErrorMessage(String serviceErrorMessage) {
this.serviceErrorMessage = serviceErrorMessage;
}

// ------------------------- INTERNAL CODE CHANGE START
private static final String INFO = "INFO";
private static final String WARNING = "WARNING";
private static final String ERROR = "ERROR";
private boolean isValid;
private String cdaSchemaValidationErrorMessage;

@JsonProperty("isValid")
public boolean isValid() {
return isValid;
}

public void setValid(boolean isValid) {
this.isValid = isValid;
}

@JsonProperty("resultMetaData")
public List<ResultMetaData> getCustomResultMetaData() {
resultMetaData = new ArrayList<ResultMetaData>();
for (Map.Entry<String, AtomicInteger> entry : errorCounts.entrySet()) {
resultMetaData.add(new ResultMetaData(entry.getKey(), entry.getValue().intValue(), getSeverityType(entry.getKey())));
}
return resultMetaData;
}


private String getSeverityType(String key) {
String severityType = (StringUtils.containsIgnoreCase(key, ERROR)) ? ERROR
: (StringUtils.containsIgnoreCase(key, WARNING)) ? WARNING : INFO;

return severityType;
}

public String getCdaSchemaValidationErrorMessage() {
return cdaSchemaValidationErrorMessage;
}

public void setCdaSchemaValidationErrorMessage(
String cdaSchemaValidationErrorMessage) {
this.cdaSchemaValidationErrorMessage = cdaSchemaValidationErrorMessage;
}

@JsonIgnore
// ------------------------- INTERNAL CODE CHANGE END
public List<ResultMetaData> getResultMetaData() {
resultMetaData = new ArrayList<ResultMetaData>();
for (Map.Entry<String, AtomicInteger> entry : errorCounts.entrySet()) {
resultMetaData.add(new ResultMetaData(entry.getKey(), entry.getValue().intValue()));
}
return resultMetaData;
}

public String getCcdaFileName() {
return ccdaFileName;
}
Expand All @@ -71,12 +118,12 @@ public String getCcdaFileContents() {
public void setCcdaFileContents(String ccdaFileContents) {
this.ccdaFileContents = ccdaFileContents;
}

public void addCount(ValidationResultType resultType) {
if (errorCounts.containsKey(resultType.getTypePrettyName())) {
errorCounts.get(resultType.getTypePrettyName()).addAndGet(1);
} else {
errorCounts.put(resultType.getTypePrettyName(), new AtomicInteger(1));
}
}

}
Loading