Sample RuleSet
See the sample RuleSet instance below (as Simplifier cannot render examples for custom ResourceTypes):
{
"resourceType": "RuleSet",
"url": "https://sap.com/healthcare/fhir/RuleSet/createListOfPatients",
"version": "1.0.0",
"name": "Create List Of Patients",
"status": {
"system": "http://hl7.org/fhir/resource-status",
"code": "active",
"display": "active-en"
},
"inReference": [
{
"name": "sd-patient",
"type": "Patient",
"url": "http://hl7.org/fhir/StructureDefinition/Patient"
},
{
"name": "sd-list",
"type": "List",
"url": "http://hl7.org/fhir/StructureDefinition/List"
},
{
"name": "sd-consent",
"type": "Consent",
"url": "http://hl7.org/fhir/StructureDefinition/Consent"
},
{
"name": "sd-condition",
"type": "Condition",
"url": "http://hl7.org/fhir/StructureDefinition/Condition"
},
{
"name": "sd-procedure",
"type": "Procedure",
"url": "http://hl7.org/fhir/StructureDefinition/Procedure"
},
{
"name": "sd-codesystem",
"type": "CodeSystem",
"url": "http://hl7.org/fhir/StructureDefinition/CodeSystem"
}
],
"outReference": [
{
"name": "sd-list",
"type": "List",
"url": "http://hl7.org/fhir/StructureDefinition/List"
}
],
"rule": [
{
"name": "Create-List-Of-Patients",
"salience": 0,
"content": "{\"when\":[{\"context\":\"sd-codesystem\",\"contextType\":\"variable\",\"variable\":\"codesInclude\",\"constraint\":{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-codesystem\",\"contextType\":\"type\",\"path\":\"url\"},\"right\":{\"type\":\"string\",\"value\":\"http://sap.com/healthcare/hdsf/CodeSystem/patConditionIncludedCodes\"},\"operator\":\"==\"}},{\"context\":\"sd-codesystem\",\"contextType\":\"variable\",\"variable\":\"codesExclude\",\"constraint\":{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-codesystem\",\"contextType\":\"type\",\"path\":\"url\"},\"right\":{\"type\":\"string\",\"value\":\"http://sap.com/healthcare/hdsf/CodeSystem/patConditionExcludedCodes\"},\"operator\":\"==\"}},{\"context\":\"sd-patient\",\"contextType\":\"variable\",\"variable\":\"p\",\"constraint\":{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-patient\",\"contextType\":\"type\",\"variable\":\"p\",\"path\":\"birthDate\"},\"right\":{\"type\":\"date\",\"value\":\"2002-03-01\"},\"operator\":\"<\"}},{\"context\":\"sd-procedure\",\"contextType\":\"variable\",\"variable\":\"proc\",\"constraint\":{\"type\":\"composite\",\"all\":[{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-procedure\",\"contextType\":\"type\",\"variable\":\"proc\",\"path\":\"code.coding.where(system='http://snomed.info/sct').code.first()\"},\"right\":{\"type\":\"string\",\"value\":\"307280005\"},\"operator\":\"hasToken\"},{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-procedure\",\"contextType\":\"type\",\"variable\":\"proc\",\"path\":\"performedDateTime\"},\"right\":{\"type\":\"datetime\",\"value\":\"2018-01-01\"},\"operator\":\">=\"},{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-procedure\",\"contextType\":\"type\",\"variable\":\"proc\",\"path\":\"performedDateTime\"},\"right\":{\"type\":\"datetime\",\"value\":\"2020-12-31\"},\"operator\":\"<=\"},{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-procedure\",\"contextType\":\"type\",\"path\":\"status\"},\"right\":{\"type\":\"string\",\"value\":\"completed\"},\"operator\":\"hasToken\"},{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-procedure\",\"contextType\":\"type\",\"path\":\"subject.type\"},\"right\":{\"type\":\"string\",\"value\":\"Patient\"},\"operator\":\"==\"},{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-procedure\",\"contextType\":\"type\",\"path\":\"subject.identifier\"},\"right\":{\"type\":\"path\",\"context\":\"sd-patient\",\"contextType\":\"variable\",\"variable\":\"p\",\"path\":\"identifier\"},\"operator\":\"in\"}]}},{\"context\":\"sd-condition\",\"contextType\":\"variable\",\"variable\":\"cond\",\"constraint\":{\"type\":\"composite\",\"all\":[{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-condition\",\"contextType\":\"type\",\"path\":\"subject.type\"},\"right\":{\"type\":\"string\",\"value\":\"Patient\"},\"operator\":\"==\"},{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-condition\",\"contextType\":\"type\",\"path\":\"subject.identifier\"},\"right\":{\"type\":\"path\",\"context\":\"sd-patient\",\"contextType\":\"variable\",\"variable\":\"p\",\"path\":\"identifier\"},\"operator\":\"in\"},{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-condition\",\"contextType\":\"type\",\"path\":\"code.coding.where(system='http://hl7.org/fhir/sid/icd-10').code.first()\"},\"right\":{\"type\":\"path\",\"context\":\"sd-codesystem\",\"contextType\":\"variable\",\"variable\":\"codesInclude\",\"path\":\"concept.code\"},\"operator\":\"in\"},{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-condition\",\"contextType\":\"type\",\"path\":\"code.coding.where(system='http://hl7.org/fhir/sid/icd-10').code.first()\"},\"right\":{\"type\":\"path\",\"context\":\"sd-codesystem\",\"contextType\":\"variable\",\"variable\":\"codesExclude\",\"path\":\"concept.code\"},\"operator\":\"!in\"},{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-condition\",\"contextType\":\"type\",\"path\":\"verificationStatus.coding.where(system='http://terminology.hl7.org/CodeSystem/condition-ver-status').code.first()\"},\"right\":{\"type\":\"string\",\"value\":\"confirmed\"},\"operator\":\"hasToken\"}]}},{\"context\":\"sd-consent\",\"contextType\":\"variable\",\"variable\":\"cons\",\"constraint\":{\"type\":\"composite\",\"all\":[{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-consent\",\"contextType\":\"type\",\"variable\":\"cons\",\"path\":\"scope.coding.where(system='http://terminology.hl7.org/CodeSystem/consentscope').code.first()\"},\"right\":{\"type\":\"string\",\"value\":\"research\"},\"operator\":\"hasToken\"},{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-consent\",\"contextType\":\"type\",\"variable\":\"cons\",\"path\":\"category[0].coding.where(system='http://terminology.hl7.org/CodeSystem/consentcategorycodes').code.first()\"},\"right\":{\"type\":\"string\",\"value\":\"research\"},\"operator\":\"hasToken\"},{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-consent\",\"contextType\":\"type\",\"path\":\"status\"},\"right\":{\"type\":\"string\",\"value\":\"active\"},\"operator\":\"hasToken\"},{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-consent\",\"contextType\":\"type\",\"path\":\"patient.type\"},\"right\":{\"type\":\"string\",\"value\":\"Patient\"},\"operator\":\"==\"},{\"type\":\"binary\",\"left\":{\"type\":\"path\",\"context\":\"sd-consent\",\"contextType\":\"type\",\"path\":\"patient.identifier\"},\"right\":{\"type\":\"path\",\"context\":\"sd-patient\",\"contextType\":\"variable\",\"variable\":\"p\",\"path\":\"identifier\"},\"operator\":\"in\"}]}},{\"context\":\"sd-list\",\"contextType\":\"variable\",\"variable\":\"list\",\"constraint\":{\"type\":\"composite\",\"any\":[{\"type\":\"binary\",\"operator\":\"==\",\"left\":{\"context\":\"sd-list\",\"contextType\":\"type\",\"variable\":\"list\",\"type\":\"path\",\"path\":\"entry.exists()\"},\"right\":{\"type\":\"boolean\",\"value\":false}},{\"type\":\"binary\",\"operator\":\"!in\",\"left\":{\"type\":\"string\",\"value\":\"Patient/%pid\",\"parameters\":[{\"type\":\"parameter\",\"name\":\"pid\",\"value\":{\"type\":\"path\",\"context\":\"sd-patient\",\"contextType\":\"variable\",\"variable\":\"p\",\"path\":\"id\"}}]},\"right\":{\"context\":\"sd-list\",\"contextType\":\"type\",\"type\":\"path\",\"path\":\"entry.item.reference\"}}]}}],\"then\":[{\"type\":\"constructor\",\"context\":\"sd-list\",\"contextType\":\"variable\",\"variable\":\"entry\",\"source\":{\"context\":\"sd-list\",\"contextType\":\"variable\",\"variable\":\"list\",\"path\":\"entry\"}},{\"type\":\"assignment\",\"context\":\"sd-list\",\"contextType\":\"type\",\"variable\":\"entry\",\"assignment\":[{\"path\":\"item\",\"type\":\"reference\",\"value\":{\"type\":\"resource\",\"context\":\"sd-patient\",\"contextType\":\"variable\",\"variable\":\"p\"}}]},{\"type\":\"cud\",\"context\":\"sd-list\",\"contextType\":\"type\",\"variable\":\"list\",\"interaction\":\"update\",\"target\":\"Universe\"}]}"
}
]
}
We apologize that we currently do not offer any editor for our rules. That is the reason why we provide you with the ready-to-use ruleSet instances.
A rule editor would visualize the rule in a more readable way similar to the visualization below where you can better see the WHEN, THEN clauses included in the rule set above:
{
"when": [
{
"context": "sd-codesystem",
"contextType": "variable",
"variable": "codesInclude",
"constraint": {
"type": "binary",
"left": {
"type": "path",
"context": "sd-codesystem",
"contextType": "type",
"path": "url"
},
"right": {
"type": "string",
"value": "http://sap.com/healthcare/hdsf/CodeSystem/patConditionIncludedCodes"
},
"operator": "=="
}
},
{
"context": "sd-codesystem",
"contextType": "variable",
"variable": "codesExclude",
"constraint": {
"type": "binary",
"left": {
"type": "path",
"context": "sd-codesystem",
"contextType": "type",
"path": "url"
},
"right": {
"type": "string",
"value": "http://sap.com/healthcare/hdsf/CodeSystem/patConditionExcludedCodes"
},
"operator": "=="
}
},
{
"context": "sd-patient",
"contextType": "variable",
"variable": "p",
"constraint": {
"type": "binary",
"left": {
"type": "path",
"context": "sd-patient",
"contextType": "type",
"variable": "p",
"path": "birthDate"
},
"right": {
"type": "date",
"value": "2002-03-01"
},
"operator": "<"
}
},
{
"context": "sd-procedure",
"contextType": "variable",
"variable": "proc",
"constraint": {
"type": "composite",
"all": [
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-procedure",
"contextType": "type",
"variable": "proc",
"path": "code.coding.where(system='http://snomed.info/sct').code.first()"
},
"right": {
"type": "string",
"value": "307280005"
},
"operator": "hasToken"
},
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-procedure",
"contextType": "type",
"variable": "proc",
"path": "performedDateTime"
},
"right": {
"type": "datetime",
"value": "2018-01-01"
},
"operator": ">="
},
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-procedure",
"contextType": "type",
"variable": "proc",
"path": "performedDateTime"
},
"right": {
"type": "datetime",
"value": "2020-12-31"
},
"operator": "<="
},
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-procedure",
"contextType": "type",
"path": "status"
},
"right": {
"type": "string",
"value": "completed"
},
"operator": "hasToken"
},
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-procedure",
"contextType": "type",
"path": "subject.type"
},
"right": {
"type": "string",
"value": "Patient"
},
"operator": "=="
},
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-procedure",
"contextType": "type",
"path": "subject.identifier"
},
"right": {
"type": "path",
"context": "sd-patient",
"contextType": "variable",
"variable": "p",
"path": "identifier"
},
"operator": "in"
}
]
}
},
{
"context": "sd-condition",
"contextType": "variable",
"variable": "cond",
"constraint": {
"type": "composite",
"all": [
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-condition",
"contextType": "type",
"path": "subject.type"
},
"right": {
"type": "string",
"value": "Patient"
},
"operator": "=="
},
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-condition",
"contextType": "type",
"path": "subject.identifier"
},
"right": {
"type": "path",
"context": "sd-patient",
"contextType": "variable",
"variable": "p",
"path": "identifier"
},
"operator": "in"
},
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-condition",
"contextType": "type",
"path": "code.coding.where(system='http://hl7.org/fhir/sid/icd-10').code.first()"
},
"right": {
"type": "path",
"context": "sd-codesystem",
"contextType": "variable",
"variable": "codesInclude",
"path": "concept.code"
},
"operator": "in"
},
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-condition",
"contextType": "type",
"path": "code.coding.where(system='http://hl7.org/fhir/sid/icd-10').code.first()"
},
"right": {
"type": "path",
"context": "sd-codesystem",
"contextType": "variable",
"variable": "codesExclude",
"path": "concept.code"
},
"operator": "!in"
},
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-condition",
"contextType": "type",
"path": "verificationStatus.coding.where(system='http://terminology.hl7.org/CodeSystem/condition-ver-status').code.first()"
},
"right": {
"type": "string",
"value": "confirmed"
},
"operator": "hasToken"
}
]
}
},
{
"context": "sd-consent",
"contextType": "variable",
"variable": "cons",
"constraint": {
"type": "composite",
"all": [
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-consent",
"contextType": "type",
"variable": "cons",
"path": "scope.coding.where(system='http://terminology.hl7.org/CodeSystem/consentscope').code.first()"
},
"right": {
"type": "string",
"value": "research"
},
"operator": "hasToken"
},
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-consent",
"contextType": "type",
"variable": "cons",
"path": "category[0].coding.where(system='http://terminology.hl7.org/CodeSystem/consentcategorycodes').code.first()"
},
"right": {
"type": "string",
"value": "research"
},
"operator": "hasToken"
},
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-consent",
"contextType": "type",
"path": "status"
},
"right": {
"type": "string",
"value": "active"
},
"operator": "hasToken"
},
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-consent",
"contextType": "type",
"path": "patient.type"
},
"right": {
"type": "string",
"value": "Patient"
},
"operator": "=="
},
{
"type": "binary",
"left": {
"type": "path",
"context": "sd-consent",
"contextType": "type",
"path": "patient.identifier"
},
"right": {
"type": "path",
"context": "sd-patient",
"contextType": "variable",
"variable": "p",
"path": "identifier"
},
"operator": "in"
}
]
}
},
{
"context": "sd-list",
"contextType": "variable",
"variable": "list",
"constraint": {
"type": "composite",
"any": [
{
"type": "binary",
"operator": "==",
"left": {
"context": "sd-list",
"contextType": "type",
"variable": "list",
"type": "path",
"path": "entry.exists()"
},
"right": {
"type": "boolean",
"value": false
}
},
{
"type": "binary",
"operator": "!in",
"left": {
"type": "string",
"value": "Patient/%pid",
"parameters": [
{
"type": "parameter",
"name": "pid",
"value": {
"type": "path",
"context": "sd-patient",
"contextType": "variable",
"variable": "p",
"path": "id"
}
}
]
},
"right": {
"context": "sd-list",
"contextType": "type",
"type": "path",
"path": "entry.item.reference"
}
}
]
}
}
],
"then": [
{
"type": "constructor",
"context": "sd-list",
"contextType": "variable",
"variable": "entry",
"source": {
"context": "sd-list",
"contextType": "variable",
"variable": "list",
"path": "entry"
}
},
{
"type": "assignment",
"context": "sd-list",
"contextType": "type",
"variable": "entry",
"assignment": [
{
"path": "item",
"type": "reference",
"value": {
"type": "resource",
"context": "sd-patient",
"contextType": "variable",
"variable": "p"
}
}
]
},
{
"type": "cud",
"context": "sd-list",
"contextType": "type",
"variable": "list",
"interaction": "update",
"target": "Universe"
}
]
}