-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
384 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,9 @@ | |
}, | ||
"cSpell.words": [ | ||
"DEQM", | ||
"Eicrs", | ||
"Gson", | ||
"mgsc", | ||
"numer", | ||
"reindex" | ||
], | ||
|
2 changes: 1 addition & 1 deletion
2
core/src/main/java/org/opencds/cqf/ruler/utility/CanonicalParts.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
plugin/cr/src/test/java/org/opencds/cqf/ruler/cr/CqlBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.opencds.cqf.ruler.cr; | ||
|
||
public class CqlBuilder { | ||
|
||
private final StringBuilder stringBuilder; | ||
|
||
private CqlBuilder(String fhirVersion) { | ||
this.stringBuilder = new StringBuilder(); | ||
this.stringBuilder.append(cql(fhirVersion)); | ||
} | ||
|
||
public static CqlBuilder newCql(String fhirVersion) { | ||
return new CqlBuilder(fhirVersion); | ||
} | ||
|
||
public CqlBuilder addExpression(String name, String expression) { | ||
this.stringBuilder.append("\n"); | ||
this.stringBuilder.append(cqlExpression(name, expression)); | ||
return this; | ||
} | ||
|
||
public CqlBuilder addSdeRace() { | ||
addExpression(sdeRace(), sdeRaceExpression()); | ||
return this; | ||
} | ||
|
||
public String build() { | ||
return this.stringBuilder.toString(); | ||
} | ||
|
||
private String cql(String fhirVersion) { | ||
return libraryHeader(fhirVersion) + measurementPeriod() + patientContext(); | ||
} | ||
|
||
private String libraryHeader(String fhirVersion) { | ||
return String.format( | ||
"library Test version '1.0.0'\n\nusing FHIR version '%1$s'\ninclude FHIRHelpers version '%1$s'\n\n", | ||
fhirVersion); | ||
} | ||
|
||
private String measurementPeriod() { | ||
return "parameter \"Measurement Period\" Interval<Date> default Interval[@2019-01-01, @2019-12-31]\n\n"; | ||
} | ||
|
||
private String patientContext() { | ||
return "context Patient\n"; | ||
} | ||
|
||
private String sdeRace() { | ||
return "SDE Race"; | ||
} | ||
|
||
private String sdeRaceExpression() { | ||
return " (flatten (\n" + | ||
" Patient.extension Extension\n" + | ||
" where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race'\n" + | ||
" return Extension.extension\n" + | ||
" )) E\n" + | ||
" where E.url = 'ombCategory'\n" + | ||
" or E.url = 'detailed'\n" + | ||
" return E.value as Coding\n\n"; | ||
} | ||
|
||
private String cqlExpression(String name, String expression) { | ||
return "define \"" + name + "\":\n" + expression; | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
plugin/cr/src/test/java/org/opencds/cqf/ruler/cr/r4/Libraries.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.opencds.cqf.ruler.cr.r4; | ||
|
||
import org.hl7.fhir.r4.model.Library; | ||
|
||
public class Libraries { | ||
|
||
public static Library library(String cql) { | ||
Library library = new Library(); | ||
library.setId("library-Test"); | ||
library.setName("Test"); | ||
library.setVersion("1.0.0"); | ||
library.setUrl("http://test.com/fhir/Library/Test"); | ||
library.getType().getCodingFirstRep().setCode("logic-library"); | ||
library.getContentFirstRep().setContentType("text/cql").setData(cql.getBytes()); | ||
return library; | ||
} | ||
} |
Oops, something went wrong.