-
Notifications
You must be signed in to change notification settings - Fork 52
Examples
c-schuler edited this page Jun 26, 2022
·
6 revisions
Request
POST [base]/$cql
{
"resourceType": "Parameters",
"parameter": [
{
"name": "expression",
"valueString": "5 * 5"
}
]
}
Response
{
"resourceType": "Parameters",
"parameter": [
{
"name": "value",
"valueString": "25"
},
{
"name": "resultType",
"valueString": "Integer"
}
]
}
Load Resources
POST [base]
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"resource": {
"resourceType": "Patient",
"id": "SimplePatient",
"birthDate": "1995-01-01",
"gender": "female"
},
"request": {
"method": "PUT",
"url": "Patient/SimplePatient"
}
},
{
"resource": {
"resourceType": "Observation",
"id": "SimpleObservation",
"status": "final",
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "10524-7",
"display": "Microscopic observation [Identifier] in Cervix by Cyto stain"
}
]
},
"value": {
"coding": [
{
"system": "http://loinc.org",
"code": "10524-7",
"display": "Microscopic observation [Identifier] in Cervix by Cyto stain"
}
]
},
"subject": {
"reference": "Patient/SimplePatient",
"type": "Patient"
},
"effectiveDateTime": "2019-11-01T00:00:00"
},
"request": {
"method": "PUT",
"url": "Observation/SimpleObservation"
}
}
]
}
Request
POST [base]/$cql
{
"resourceType": "Parameters",
"parameter": [
{
"name": "subject",
"valueString": "Patient/SimplePatient"
},
{
"name": "expression",
"valueString": "[Observation] Obs where Obs.status = 'final'"
}
]
}
Response
{
"resourceType": "Parameters",
"parameter": [
{
"name": "value",
"valueString": "[]"
},
{
"name": "resultType",
"valueString": "List"
}
]
}
Load Resources
POST [base]
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"resource": {
"resourceType": "Patient",
"id": "SimplePatient",
"birthDate": "1995-01-01",
"gender": "female"
},
"request": {
"method": "PUT",
"url": "Patient/SimplePatient"
}
},
{
"resource": {
"resourceType": "Library",
"id": "SimpleLibrary",
"name": "SimpleLibrary",
"version": "0.0.1",
"status": "active",
"experimental": false,
"type": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/library-type",
"code": "logic-library"
}
]
},
"date": "2021-04-23T15:32:03+00:00",
"publisher": "National Committee for Quality Assurance",
"description": "Simple Library for Testing Simple Expressions",
"content": [
{
"contentType": "text/cql",
"data": "bGlicmFyeSBTaW1wbGVSNExpYnJhcnkKCnVzaW5nIEZISVIgdmVyc2lvbiAnNC4wLjEnCgppbmNsdWRlIEZISVJIZWxwZXJzIHZlcnNpb24gJzQuMC4xJyBjYWxsZWQgRkhJUkhlbHBlcnMKCmNvbnRleHQgUGF0aWVudAoKZGVmaW5lIHNpbXBsZUJvb2xlYW5FeHByZXNzaW9uOiB0cnVlCgpkZWZpbmUgb2JzZXJ2YXRpb25SZXRyaWV2ZTogW09ic2VydmF0aW9uXQoKZGVmaW5lIG9ic2VydmF0aW9uSGFzQ29kZTogbm90IElzTnVsbCgoW09ic2VydmF0aW9uXSkuY29kZSkKCmRlZmluZSAiSW5pdGlhbCBQb3B1bGF0aW9uIjogb2JzZXJ2YXRpb25IYXNDb2RlCgpkZWZpbmUgIkRlbm9taW5hdG9yIjogIkluaXRpYWwgUG9wdWxhdGlvbiIKCmRlZmluZSAiTnVtZXJhdG9yIjogIkRlbm9taW5hdG9yIgo="
}
]
},
"request": {
"method": "PUT",
"url": "Library/SimpleLibrary"
}
}
]
}
Request
POST [base]/$cql
{
"resourceType": "Parameters",
"parameter": [
{
"name": "subject",
"valueString": "Patient/SimplePatient"
},
{
"name": "library",
"resource": {
"resourceType": "Parameters",
"parameter": [
{
"name": "url",
"valueCanonical": "http://www.example.com/Library/SimpleR4Library"
},
{
"name": "name",
"valueString": "SimpleR4Library"
}
]
}
},
{
"name": "expression",
"valueString": "SimpleR4Library.\"simpleBooleanExpression\""
}
]
}
Response
{
"resourceType": "Parameters",
"parameter": [
{
"name": "value",
"valueString": "true"
},
{
"name": "resultType",
"valueString": "Boolean"
}
]
}
Request
POST [base]/$cql
{
"resourceType": "Parameters",
"parameter": [
{
"name": "parameters",
"resource": {
"resourceType": "Parameters",
"parameter": [
{
"name": "%inputDate",
"valueDate": "2019-11-01"
}
]
}
},
{
"name": "expression",
"valueString": "year from %inputDate"
}
]
}
Response
{
"resourceType": "Parameters",
"parameter": [
{
"name": "value",
"valueString": "2019"
},
{
"name": "resultType",
"valueString": "Integer"
}
]
}
CQL Source
library SimpleR4Library
using FHIR version '4.0.1'
include FHIRHelpers version '4.0.1' called FHIRHelpers
context Patient
define simpleBooleanExpression: true
define observationRetrieve: [Observation]
define observationHasCode: not IsNull(([Observation]).code)
define "Initial Population": observationHasCode
define "Denominator": "Initial Population"
define "Numerator": "Denominator"
Load Resources
POST [base]
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"resource": {
"resourceType": "Patient",
"id": "SimplePatient",
"birthDate": "1995-01-01",
"gender": "female"
},
"request": {
"method": "PUT",
"url": "Patient/SimplePatient"
}
},
{
"resource": {
"resourceType": "Observation",
"id": "SimpleObservation",
"status": "final",
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "10524-7",
"display": "Microscopic observation [Identifier] in Cervix by Cyto stain"
}
]
},
"value": {
"coding": [
{
"system": "http://loinc.org",
"code": "10524-7",
"display": "Microscopic observation [Identifier] in Cervix by Cyto stain"
}
]
},
"subject": {
"reference": "Patient/SimplePatient",
"type": "Patient"
},
"effectiveDateTime": "2019-11-01T00:00:00"
},
"request": {
"method": "PUT",
"url": "Observation/SimpleObservation"
}
},
{
"resource": {
"resourceType": "Library",
"id": "SimpleR4Library",
"name": "SimpleR4Library",
"status": "active",
"experimental": false,
"type": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/library-type",
"code": "logic-library"
}
]
},
"date": "2021-04-23T15:32:03+00:00",
"publisher": "National Committee for Quality Assurance",
"description": "Simple Library for Testing Simple Expressions",
"content": [
{
"contentType": "text/cql",
"data": "bGlicmFyeSBTaW1wbGVSNExpYnJhcnkKCnVzaW5nIEZISVIgdmVyc2lvbiAnNC4wLjEnCgppbmNsdWRlIEZISVJIZWxwZXJzIHZlcnNpb24gJzQuMC4xJyBjYWxsZWQgRkhJUkhlbHBlcnMKCmNvbnRleHQgUGF0aWVudAoKZGVmaW5lIHNpbXBsZUJvb2xlYW5FeHByZXNzaW9uOiB0cnVlCgpkZWZpbmUgb2JzZXJ2YXRpb25SZXRyaWV2ZTogW09ic2VydmF0aW9uXQoKZGVmaW5lIG9ic2VydmF0aW9uSGFzQ29kZTogbm90IElzTnVsbCgoW09ic2VydmF0aW9uXSkuY29kZSkKCmRlZmluZSAiSW5pdGlhbCBQb3B1bGF0aW9uIjogb2JzZXJ2YXRpb25IYXNDb2RlCgpkZWZpbmUgIkRlbm9taW5hdG9yIjogIkluaXRpYWwgUG9wdWxhdGlvbiIKCmRlZmluZSAiTnVtZXJhdG9yIjogIkRlbm9taW5hdG9yIgo="
}
]
},
"request": {
"method": "PUT",
"url": "Library/SimpleR4Library"
}
}
]
}
Request:
GET [base]/Library/SimpleR4Library/$evaluate?subject=Patient/SimplePatient
Response
{
"resourceType": "Bundle",
"type": "collection",
"entry": [
{
"fullUrl": "http://localhost:8080/fhirPatient",
"resource": {
"resourceType": "Parameters",
"id": "Patient",
"parameter": [
{
"name": "value",
"valueString": "null"
},
{
"name": "resultType",
"valueString": "Null"
}
]
}
},
{
"fullUrl": "http://localhost:8080/fhirsimpleBooleanExpression",
"resource": {
"resourceType": "Parameters",
"id": "simpleBooleanExpression",
"parameter": [
{
"name": "value",
"valueString": "true"
},
{
"name": "resultType",
"valueString": "Boolean"
}
]
}
},
{
"fullUrl": "http://localhost:8080/fhirobservationRetrieve",
"resource": {
"resourceType": "Parameters",
"id": "observationRetrieve",
"parameter": [
{
"name": "value",
"valueString": "[]"
},
{
"name": "resultType",
"valueString": "EmptyList"
}
]
}
},
{
"fullUrl": "http://localhost:8080/fhirobservationHasCode",
"resource": {
"resourceType": "Parameters",
"id": "observationHasCode",
"parameter": [
{
"name": "value",
"valueString": "true"
},
{
"name": "resultType",
"valueString": "Boolean"
}
]
}
},
{
"fullUrl": "http://localhost:8080/fhirInitial Population",
"resource": {
"resourceType": "Parameters",
"id": "Initial Population",
"parameter": [
{
"name": "value",
"valueString": "true"
},
{
"name": "resultType",
"valueString": "Boolean"
}
]
}
},
{
"fullUrl": "http://localhost:8080/fhirDenominator",
"resource": {
"resourceType": "Parameters",
"id": "Denominator",
"parameter": [
{
"name": "value",
"valueString": "true"
},
{
"name": "resultType",
"valueString": "Boolean"
}
]
}
},
{
"fullUrl": "http://localhost:8080/fhirNumerator",
"resource": {
"resourceType": "Parameters",
"id": "Numerator",
"parameter": [
{
"name": "value",
"valueString": "true"
},
{
"name": "resultType",
"valueString": "Boolean"
}
]
}
}
]
}