-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Add Operation evaluate-measure
- Loading branch information
1 parent
1046317
commit a81fb4c
Showing
55 changed files
with
2,265 additions
and
627 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Usage: ./evaluate-measure.sh -f <query>.cql <server-base> | ||
|
||
# Takes a CQL file, creates a Library resource from it, references that from a | ||
# Measure resource and calls $evaluate-measure on it. | ||
|
||
library() { | ||
cat <<END | ||
{ | ||
"resourceType": "Library", | ||
"content": [ | ||
{ | ||
"contentType": "text/cql" | ||
} | ||
] | ||
} | ||
END | ||
} | ||
|
||
measure() { | ||
cat <<END | ||
{ | ||
"resourceType": "Measure", | ||
"status": "active", | ||
"subjectCodeableConcept": { | ||
"coding": [ | ||
{ | ||
"system": "http://hl7.org/fhir/resource-types", | ||
"code": "Patient" | ||
} | ||
] | ||
}, | ||
"scoring": { | ||
"coding": [ | ||
{ | ||
"system": "http://terminology.hl7.org/CodeSystem/measure-scoring", | ||
"code": "cohort" | ||
} | ||
] | ||
}, | ||
"group": [ | ||
{ | ||
"population": [ | ||
{ | ||
"code": { | ||
"coding": [ | ||
{ | ||
"system": "http://terminology.hl7.org/CodeSystem/measure-population", | ||
"code": "initial-population" | ||
} | ||
] | ||
}, | ||
"criteria": { | ||
"language": "text/cql", | ||
"expression": "InInitialPopulation" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
END | ||
} | ||
|
||
create-library() { | ||
library | jq -cM ".url = \"urn:uuid:$1\" | .content[0].data = \"$2\"" | ||
} | ||
|
||
create-measure() { | ||
measure | jq -cM ".url = \"urn:uuid:$1\" | .library[0] = \"urn:uuid:$2\"" | ||
} | ||
|
||
post() { | ||
curl -sH "Content-Type: application/fhir+json" -d @- "${BASE}/$1" | ||
} | ||
|
||
evaluate-measure() { | ||
time curl -s "${BASE}/Measure/$1/\$evaluate-measure?periodStart=2000&periodEnd=2019" | ||
} | ||
|
||
usage() | ||
{ | ||
echo "Usage: $0 [ -f QUERY_FILE ] BASE" | ||
exit 2 | ||
} | ||
|
||
unset FILE BASE | ||
|
||
while getopts 'f:' c | ||
do | ||
case ${c} in | ||
f) FILE=$OPTARG ;; | ||
esac | ||
done | ||
|
||
shift $((OPTIND-1)) | ||
BASE=$1 | ||
|
||
[[ -z "$FILE" ]] && usage | ||
[[ -z "$BASE" ]] && usage | ||
|
||
DATA=$(cat ${FILE} | base64 | tr -d '\n') | ||
LIBRARY_URI=$(uuidgen | tr '[:upper:]' '[:lower:]') | ||
MEASURE_URI=$(uuidgen | tr '[:upper:]' '[:lower:]') | ||
|
||
create-library ${LIBRARY_URI} ${DATA} | post "Library" > /dev/null | ||
|
||
MEASURE_ID=$(create-measure ${MEASURE_URI} ${LIBRARY_URI} | post "Measure" | jq -r .id) | ||
|
||
COUNT=$(evaluate-measure ${MEASURE_ID} | jq ".group[0].population[0].count") | ||
|
||
echo "Count: ${COUNT}" |
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
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
Oops, something went wrong.