Skip to content

Commit

Permalink
Merge pull request #235 from cqframework/spelling-and-warning-fixes
Browse files Browse the repository at this point in the history
Fixes for various spelling issues and warnings
  • Loading branch information
Adam Stevenson authored May 26, 2021
2 parents 347aca5 + 5008c14 commit 198c0a8
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 94 deletions.
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
"java.configuration.updateBuildConfiguration": "automatic",
"cSpell.words": [
"Careand",
"pagecontent",
"plandefinition"
]
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.opencds.cqf.tooling.library.r4;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.opencds.cqf.tooling.utilities.*;
import org.opencds.cqf.tooling.utilities.IOUtils.Encoding;

import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;

Expand All @@ -32,7 +31,6 @@ public static String getId(String baseId) {
public static List<String> refreshIgMeasureContent(BaseProcessor parentContext, Encoding outputEncoding, Boolean versioned, FhirContext fhirContext, String measureToRefreshPath) {

System.out.println("Refreshing measures...");
ArrayList<String> refreshedMeasureNames = new ArrayList<String>();

MeasureProcessor measureProcessor;
switch (fhirContext.getVersion().getVersion()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.opencds.cqf.tooling.measure.r4;

import ca.uhn.fhir.context.FhirContext;
import org.hl7.fhir.convertors.VersionConvertor_40_50;
import org.hl7.fhir.r4.formats.FormatUtilities;
import org.opencds.cqf.tooling.common.r4.CqfmSoftwareSystemHelper;
Expand All @@ -9,7 +8,6 @@
import org.opencds.cqf.tooling.utilities.IOUtils;

import java.io.File;
import java.io.IOException;
import java.util.*;

public class R4MeasureProcessor extends MeasureProcessor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void refreshMeasureFromFile(File f) {

public Measure refreshMeasure(Measure measure) {
cqfmHelper.ensureCQFToolingExtensionAndDevice(measure, this.getFhirContext());
R4MeasureProcessor refresher = new R4MeasureProcessor();
// R4MeasureProcessor refresher = new R4MeasureProcessor();
//refresher.refreshMeasure(measure, );
return measure;
}
Expand Down
42 changes: 16 additions & 26 deletions src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,29 @@
import java.io.File;
import java.io.FilenameFilter;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;

import org.cqframework.cql.cql2elm.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.cqframework.cql.cql2elm.CqlTranslator;
import org.cqframework.cql.cql2elm.CqlTranslatorException;
import org.cqframework.cql.cql2elm.CqlTranslatorOptions;
import org.cqframework.cql.cql2elm.DefaultLibrarySourceProvider;
import org.cqframework.cql.cql2elm.DefaultModelInfoProvider;
import org.cqframework.cql.cql2elm.FhirLibrarySourceProvider;
import org.cqframework.cql.cql2elm.LibraryManager;
import org.cqframework.cql.cql2elm.ModelManager;
import org.cqframework.cql.cql2elm.NamespaceInfo;
import org.cqframework.cql.cql2elm.NamespaceManager;
import org.cqframework.cql.cql2elm.model.TranslatedLibrary;
import org.cqframework.cql.elm.tracking.TrackBack;
import org.fhir.ucum.UcumService;
import org.hl7.cql.model.IntervalType;
import org.hl7.cql.model.ListType;
import org.hl7.cql.model.NamedType;
import org.hl7.elm.r1.AccessModifier;
import org.hl7.elm.r1.Code;
import org.hl7.elm.r1.CodeDef;
import org.hl7.elm.r1.CodeRef;
import org.hl7.elm.r1.CodeSystemDef;
import org.hl7.elm.r1.CodeSystemRef;
import org.hl7.elm.r1.Concept;
import org.hl7.elm.r1.ConceptDef;
import org.hl7.elm.r1.ConceptRef;
import org.hl7.elm.r1.Expression;
import org.hl7.elm.r1.ExpressionDef;
import org.hl7.elm.r1.FunctionDef;
import org.hl7.elm.r1.IncludeDef;
import org.hl7.elm.r1.ParameterDef;
import org.hl7.elm.r1.Retrieve;
import org.hl7.elm.r1.UsingDef;
import org.hl7.elm.r1.ValueSetDef;
import org.hl7.elm.r1.ValueSetRef;
import org.hl7.elm.r1.VersionedIdentifier;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.IWorkerContext.ILoggingService;
import org.hl7.fhir.r5.model.DataRequirement;
import org.hl7.fhir.r5.model.Enumerations;
import org.hl7.fhir.r5.model.ParameterDefinition;
import org.hl7.fhir.r5.model.RelatedArtifact;
import org.hl7.fhir.utilities.npm.NpmPackage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import org.apache.commons.io.FilenameUtils;
import org.hl7.fhir.utilities.Utilities;
import org.opencds.cqf.tooling.library.LibraryProcessor;
import org.opencds.cqf.tooling.measure.MeasureProcessor;
import org.opencds.cqf.tooling.parameter.RefreshIGParameters;
import org.opencds.cqf.tooling.utilities.IGUtils;
Expand Down Expand Up @@ -56,7 +55,7 @@ public void publishIG(RefreshIGParameters params) {
//ScaffoldProcessor.scaffold(ScaffoldParameters);

//Use case 2 while developing in Atom refresh content and run tests for either entire IG or targeted Artifact
//refreshcontent
//refreshContent
LogUtils.info("IGProcessor.publishIG - refreshIG");
refreshIG(params);
//validate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ else if (context.getTypeResolver().isDateType(comparisonType)) {
}
// Determine operation and appropriate range
// If right is interval-valued
// If the operation is equal, equivalent, sameas, in, or included in, the date range is the comparand
// If the operation is equal, equivalent, same as, in, or included in, the date range is the comparand
Expression comparand = conditionRequirement.getComparand().getExpression();
if (context.getTypeResolver().isIntervalType(comparisonType)) {
switch (conditionRequirement.getElement().getClass().getSimpleName()) {
Expand Down Expand Up @@ -317,7 +317,7 @@ private void applyJoinRequirementTo(ElmJoinRequirement joinRequirement, Retrieve
}

// Search from the model info should be used to inform the selection, but will in general resolve to multiple choices
// May be a choice better left to the capabilitystatement-informed planning phase anyway
// May be a choice better left to the capabilityStatement-informed planning phase anyway
}

// In the absence of search information, either of these formulations is correct, favor primary query sources over withs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.opencds.cqf.tooling.visitor;

import org.hl7.elm.r1.Element;
import org.hl7.elm.r1.Expression;
import org.hl7.elm.r1.Property;
import org.hl7.elm.r1.VersionedIdentifier;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.opencds.cqf.tooling.visitor;

import org.hl7.elm.r1.AliasedQuerySource;
import org.hl7.elm.r1.Property;
import org.hl7.elm.r1.Retrieve;
import org.hl7.elm.r1.VersionedIdentifier;

Expand Down
17 changes: 12 additions & 5 deletions src/main/java/org/opencds/cqf/tooling/visitor/ElmRequirements.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package org.opencds.cqf.tooling.visitor;

import org.hl7.elm.r1.*;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.toList;
import org.hl7.elm.r1.CodeDef;
import org.hl7.elm.r1.CodeSystemDef;
import org.hl7.elm.r1.ConceptDef;
import org.hl7.elm.r1.Element;
import org.hl7.elm.r1.ExpressionDef;
import org.hl7.elm.r1.FunctionDef;
import org.hl7.elm.r1.IncludeDef;
import org.hl7.elm.r1.ParameterDef;
import org.hl7.elm.r1.Retrieve;
import org.hl7.elm.r1.UsingDef;
import org.hl7.elm.r1.ValueSetDef;
import org.hl7.elm.r1.VersionedIdentifier;

public class ElmRequirements extends ElmRequirement {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import org.cqframework.cql.elm.visiting.ElmBaseLibraryVisitor;
import org.hl7.elm.r1.*;

import javax.xml.namespace.QName;

public class ElmRequirementsVisitor extends ElmBaseLibraryVisitor <ElmRequirement, ElmRequirementsContext>{

public ElmRequirementsVisitor() {
Expand Down Expand Up @@ -105,7 +103,7 @@ public ElmRequirement visitParameterRef(ParameterRef elm, ElmRequirementsContext
@Override
public ElmRequirement visitRetrieve(Retrieve elm, ElmRequirementsContext context) {
// TODO: childResult reporting?
ElmRequirement childResult = super.visitRetrieve(elm, context);
super.visitRetrieve(elm, context);
ElmDataRequirement result = new ElmDataRequirement(context.getCurrentLibraryIdentifier(), elm);
// If not in a query context, report the data requirement
// If in a query context, the requirement will be reported as an inferred requirement at the query boundary
Expand Down Expand Up @@ -324,7 +322,7 @@ public ElmRequirement visitChildren(BinaryExpression elm, ElmRequirementsContext
case "ProperIncludes":
case "ProperIncludedIn":
default: {
ElmRequirement childResult = super.visitChildren(elm, context);
super.visitChildren(elm, context);
return new ElmExpressionRequirement(context.getCurrentLibraryIdentifier(), elm);
}
}
Expand All @@ -337,13 +335,13 @@ public ElmRequirement visitBinaryExpression(BinaryExpression elm, ElmRequirement

@Override
public ElmRequirement visitTernaryExpression(TernaryExpression elm, ElmRequirementsContext context) {
ElmRequirement childResult = super.visitTernaryExpression(elm, context);
super.visitTernaryExpression(elm, context);
return new ElmExpressionRequirement(context.getCurrentLibraryIdentifier(), elm);
}

@Override
public ElmRequirement visitNaryExpression(NaryExpression elm, ElmRequirementsContext context) {
ElmRequirement childResult = super.visitNaryExpression(elm, context);
super.visitNaryExpression(elm, context);
return new ElmExpressionRequirement(context.getCurrentLibraryIdentifier(), elm);
}

Expand Down Expand Up @@ -659,7 +657,7 @@ public ElmRequirement visitCombine(Combine elm, ElmRequirementsContext context)

@Override
public ElmRequirement visitSplit(Split elm, ElmRequirementsContext context) {
// If the separtor is a literal, infer based only on the string to split argument
// If the separator is a literal, infer based only on the string to split argument
if (elm.getSeparator() instanceof Literal) {
return visitElement(elm.getStringToSplit(), context);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
package org.opencds.cqf.tooling.utilities;

import ca.uhn.fhir.context.FhirContext;
import org.cqframework.cql.cql2elm.*;
import org.cqframework.cql.cql2elm.model.TranslatedLibrary;
import org.fhir.ucum.UcumEssenceService;
import org.fhir.ucum.UcumException;
import org.fhir.ucum.UcumService;
import org.hl7.elm.r1.*;
import ca.uhn.fhir.parser.IParser;
import org.hl7.elm.r1.Library;
import org.hl7.fhir.r5.model.*;
import org.junit.Test;
import org.opencds.cqf.tooling.processor.DataRequirementsProcessor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.IOException;
Expand All @@ -20,8 +10,43 @@
import java.util.List;
import java.util.Set;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.cqframework.cql.cql2elm.CqlTranslator;
import org.cqframework.cql.cql2elm.CqlTranslatorOptions;
import org.cqframework.cql.cql2elm.DefaultLibrarySourceProvider;
import org.cqframework.cql.cql2elm.FhirLibrarySourceProvider;
import org.cqframework.cql.cql2elm.LibraryManager;
import org.cqframework.cql.cql2elm.ModelManager;
import org.cqframework.cql.cql2elm.NamespaceInfo;
import org.cqframework.cql.cql2elm.NamespaceManager;
import org.cqframework.cql.cql2elm.model.TranslatedLibrary;
import org.fhir.ucum.UcumEssenceService;
import org.fhir.ucum.UcumException;
import org.fhir.ucum.UcumService;
import org.hl7.elm.r1.AliasedQuerySource;
import org.hl7.elm.r1.CodeFilterElement;
import org.hl7.elm.r1.DateFilterElement;
import org.hl7.elm.r1.Exists;
import org.hl7.elm.r1.ExpressionDef;
import org.hl7.elm.r1.IncludeElement;
import org.hl7.elm.r1.LetClause;
import org.hl7.elm.r1.Literal;
import org.hl7.elm.r1.ParameterRef;
import org.hl7.elm.r1.Query;
import org.hl7.elm.r1.Retrieve;
import org.hl7.elm.r1.SingletonFrom;
import org.hl7.elm.r1.ValueSetRef;
import org.hl7.elm.r1.With;
import org.hl7.fhir.r5.model.Coding;
import org.hl7.fhir.r5.model.DataRequirement;
import org.hl7.fhir.r5.model.Enumerations;
import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.ParameterDefinition;
import org.hl7.fhir.r5.model.RelatedArtifact;
import org.junit.Test;
import org.opencds.cqf.tooling.processor.DataRequirementsProcessor;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.parser.IParser;

public class DataRequirementsProcessorTest {
private static ModelManager modelManager;
Expand Down Expand Up @@ -56,7 +81,7 @@ public void TestDataRequirementsProcessor() {
PreventiveCareandWellness-v0-0-001-FHIR-4-0-1.xml
*/
CqlTranslator translator = createTranslator("CompositeMeasures/cql/EXM124-9.0.000.cql", cqlTranslatorOptions);//"OpioidCDS/cql/OpioidCDSCommon.cql", cqlTranslatorOptions);
Library elmLibrary = translator.toELM();
translator.toELM();
assertTrue(translator.getErrors().isEmpty());
cacheLibrary(translator.getTranslatedLibrary());

Expand Down Expand Up @@ -89,7 +114,7 @@ public void TestDataRequirementsProcessorWithExpressions() {
// TODO - add expressions to expressions
expressions.add("Conditions Indicating End of Life or With Limited Life Expectancy");//Active Ambulatory Opioid Rx");
CqlTranslator translator = createTranslator("OpioidCDS/cql/OpioidCDSCommon.cql", cqlTranslatorOptions);
Library elmLibrary = translator.toELM();
translator.toELM();
assertTrue(translator.getErrors().isEmpty());
cacheLibrary(translator.getTranslatedLibrary());
DataRequirementsProcessor dqReqTrans = new DataRequirementsProcessor();
Expand Down Expand Up @@ -157,7 +182,7 @@ public void TestLibraryDataRequirements() {
try {
// CqlTranslator translator = createTranslator("/ecqm/resources/library-EXM506-2.2.000.json", cqlTranslatorOptions);
CqlTranslator translator = createTranslator("CompositeMeasures/cql/BCSComponent.cql", cqlTranslatorOptions);
Library elmLibrary = translator.toELM();
translator.toELM();
assertTrue(translator.getErrors().isEmpty());
cacheLibrary(translator.getTranslatedLibrary());
DataRequirementsProcessor dqReqTrans = new DataRequirementsProcessor();
Expand Down Expand Up @@ -225,7 +250,7 @@ private CqlTranslatorOptions getTranslatorOptions() {

private CqlTranslator setupDataRequirementsAnalysis(String fileName, CqlTranslatorOptions cqlTranslatorOptions) throws IOException {
CqlTranslator translator = createTranslator(fileName, cqlTranslatorOptions);
Library elmLibrary = translator.toELM();
translator.toELM();
assertTrue(translator.getErrors().isEmpty());
cacheLibrary(translator.getTranslatedLibrary());
return translator;
Expand Down Expand Up @@ -879,13 +904,9 @@ public static CqlTranslator createTranslator(NamespaceInfo namespaceInfo, String

public static CqlTranslator createTranslator(NamespaceInfo namespaceInfo, String testFileName, CqlTranslatorOptions options) throws IOException {
File translationTestFile = new File(DataRequirementsProcessorTest.class.getResource(testFileName).getFile());
if(null != translationTestFile) {
reset();
setup(translationTestFile.getParent());
CqlTranslator translator = CqlTranslator.fromFile(namespaceInfo, translationTestFile, getModelManager(), getLibraryManager(), getUcumService(), options);
return translator;

}
return null;
reset();
setup(translationTestFile.getParent());
CqlTranslator translator = CqlTranslator.fromFile(namespaceInfo, translationTestFile, getModelManager(), getLibraryManager(), getUcumService(), options);
return translator;
}
}
Loading

0 comments on commit 198c0a8

Please sign in to comment.