...
Another important use-case is when querying demographic data of actors that matches certain relationship condition. En example would be “Retrieve all Patient’s data (uid, name, age, gender) that are belonging to a specific Care Group X (relation type = 'patientOf').
Code Block | ||
---|---|---|
| ||
SELECT p/uid/value, pid/items[at0010]/value AS full_name, d/items[at0001]/value AS bday, d/items[at0031]/value AS gender FROM (PERSON p [openEHR-DEMOGRAPHIC-PERSON.person.v2] CONTAINS PARTY_IDENTITY pid [openEHR-DEMOGRAPHIC-PARTY_IDENTITY.person_name.v2] AND CONTAINS ITEM_TREE d [openEHR-DEMOGRAPHIC-ITEM_TREE.person_details.v2]) AND (CONTAINS GROUP g [openEHR-DEMOGRAPHIC-GROUP.group.v2] CONTAINS PARTY_IDENTITY gid [openEHR-DEMOGRAPHIC-PARTY_IDENTITY.group_name.v2]) AND (CONTAINS ROLE r [openEHR-DEMOGRAPHIC-ROLE.role.v2]) WHERE gid/items[at0010]/value = "Care Group X" AND IS_RELATED(p, g, 'patientOf') AND p/roles[1]/id = r/uid AND r/name/value = 'Patient' |
...