# UCP 'Read-only Alert' AQLs This set of AQLs is designed to fund critical parts of the UCP dataset which need ot be displayed clearly 'read-only' in other contexts, perhaps alongside the manually entred Alerts on the Alerts form, or in the patient banner or custom summary views. Care setting adjustments Communication aids ### 1. Has a Safeguarding concern Show an read-only alert if the patient has a Safeguarding `Concern Status` of: `SNOMED-CT | 1010196001 | Safeguarding concern` #### AQL ```sql SELECT w/data[at0001]/items[at0002]/value/value AS Safeguarding_status FROM EHR e [ehrId/value = :ehrId] CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.report.v1] CONTAINS EVALUATION w[openEHR-EHR-EVALUATION.safeguarding_concern_uk.v0] WHERE c/name/value='OL - Safeguarding' AND w/data[at0001]/items[at0002]/value/defining_code/code_string = '1010196001' AND w/data[at0001]/items[at0002]/value/defining_code/terminologyId = 'SNOMED-CT' ``` If a match is found, it returns.... ```JSON [ { "compositionId": "79ce9194-0907-4224-9240-3a8f35892742::11ed4f4e-6a7f-4849-a03c-2c41333a15ec::1", "safeguardingStatusDateTime": "2024-02-20T13:32:47.887Z", "safeguardingStatusText": "Safeguarding concern" } ] ``` ## 2. Has a Critical Diagnosis Show an read-only alert if the patient has a `Primary diagnosis` or `Other significant diagnosis` of: `CMC-Diagnosis |D57 | Sickle cell disease` `CMC-Diagnosis |F101| Alcohol use disorder` `CMC-Diagnosis |F111| Opoid abuse` `CMC-Diagnosis |F112| Opoid dependence` Note this can be readily expanded to cover other Diagnoses #### AQL ```SQL SELECT c/uid/value as compositionId, w/data[at0001]/items[at0002]/value/value AS diagnosisText, w/data[at0001]/items[at0003]/value/value AS diagnosisDate FROM EHR e [ehrId/value = :ehrId] CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.problem_list.v2] CONTAINS EVALUATION w[openEHR-EHR-EVALUATION.problem_diagnosis.v1] WHERE c/name/value='Urgent care Problem list' AND w/data/items[at0002]/value/defining_code/code_string matches {'D57','F101','F111', 'F112'} AND w/data/items[at0002]/value/defining_code/terminology_id = 'CMC-Diagnosis' ``` If a match is found, it returns.... ```JSON [ { "compositionId": "db572c37-5962-43ce-8de9-89ba79b50cea::11ed4f4e-6a7f-4849-a03c-2c41333a15ec::1", "diagnosisText": "Sickle cell disease", "diagnosisDate": "2024-02-20T13:57:22.045Z" } ] ``` ### 2. Has a Reasonable Adjustments Flag Show an read-only alert if the patient has a `Reasonable Adjustments Flag Status` of: `SNOMED-CT | 1108111000000107 | Requires reasonable adjustment for health and care access (Equality Act 2010)` #### AQL ```sql SELECT c/uid/value as compositionId, c/context/start_time/value as dateReasonableAdjFlagupdated, m/data[at0001]/items[at0004]/value/value AS ReasonableAdjStatusText FROM EHR e [ehrId/value = :ehrId] CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.report.v1] CONTAINS EVALUATION m[openEHR-EHR-EVALUATION.reasonable_adjustment.v0] WHERE m/data[at0001]/items[at0004]/value/defining_code/code_string = '1108111000000107' AND m/data[at0001]/items[at0004]/value/defining_code/terminology_id = 'SNOMED-CT' ``` If a match is found, it returns.... ```JSON [ { "compositionId": "1b2fe496-4590-4146-89c2-65f7b0a6d9b3::11ed4f4e-6a7f-4849-a03c-2c41333a15ec::1", "dateReasonableAdjFlagupdated": "2024-02-20T14:33:28.565Z", "ReasonableAdjStatusText": "Requires reasonable adjustment for health and care access (Equality Act 2010)" } ] ``` ### 3. Has addtional Communication Needs or has communicaiton Aids Show an read-only alert if the patient has Additional communication needs or aids #### AQL ```sql SELECT 'Has additional communication needs/ aids' AS additional_communication_support FROM EHR e [ehr_id/value = :ehrId] CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.anticipatory_care_information.v0] CONTAINS cap[openEHR-EHR-EVALUATION.communication_capability-uk.v0] CONTAINS CLUSTER x[openEHR-EHR-CLUSTER.additional_communication_support.v1] WHERE c/archetype_details/template_id/value = 'OL - About me' AND (EXISTS x) or (EXISTS cap/data[at0001]/items[at0022]) ``` If a match is found, it returns.... ```JSON [ { "additional_communication_support": "Has additional communication needs" } ] ``` ### 4. Has Equipment that needs transferred Show a read-only alert if the patient has Home Equipment that needs transferred. THe response is grouped according to Equipment category and reports only those items that are both present and that may require to be transferred or tansported with the patient. Note that some devices are grouped under a single category. #### AQL ```sql SELECT c/uid/value as compositionId, d/data[at0001]/events[at0002]/data[at0003]/items[at0034]/value/value AS deviceCategory, d/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0043]/value/value as needsTransfer, squash(d/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value) AS deviceName FROM EHR e[ehr_id/value = :ehr_id] CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.equipment_summary.v1] CONTAINS (OBSERVATION d[openEHR-EHR-OBSERVATION.equipment_screening_ol.v1] and OBSERVATION s[openEHR-EHR-OBSERVATION.equipment_screening_ol.v1]) WHERE c/archetype_details/template_id/value='OL - Urgent care equipment summary' AND d/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/defining_code/code_string = 'at0023' AND d/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0043]/value/defining_code/code_string = 'at0044' ``` Response if match found: ```json { "compositionId": "d2fcf729-603f-4809-96ae-d7d1ea51c5ed::11ed4f4e-6a7f-4849-a03c-2c41333a15ec::1", "deviceCategory": "Personal assistive equipment", "needsTransfer": "Some equipment should normally be transferred", "deviceName": [ "Dentures", "Spectacles", "Hearing aid" ] }, { "compositionId": "d2fcf729-603f-4809-96ae-d7d1ea51c5ed::11ed4f4e-6a7f-4849-a03c-2c41333a15ec::1", "deviceCategory": null, "needsTransfer": "Some equipment should normally be transferred", "deviceName": [ "Intermittent", "Stoma", "Naso-gastric tube" ] }, { "compositionId": "d2fcf729-603f-4809-96ae-d7d1ea51c5ed::11ed4f4e-6a7f-4849-a03c-2c41333a15ec::1", "deviceCategory": "Respiratory support equipment", "needsTransfer": "Some equipment should normally be transferred", "deviceName": [ "Breathing support machine", "Home oxygen", "Ambulatory oxygen", "CPAP", "Tracheostomy", "Emergency tracheotomy kit" ] } ] ] ``` ### 5. Has an ADRT Show a read-only alert if the patient has an ADRT. #### AQL ```sql SELECT u/data[at0001]/items[at0004]/value/value AS advance_decision_to_refuse_exists FROM EHR e [ehr_id/value = :ehrId] CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.anticipatory_care_information.v0] CONTAINS EVALUATION u[openEHR-EHR-EVALUATION.advance_care_directive.v1] WHERE c/archetype_details/template_id/value = 'OL - Advance directives' AND u/data[at0001]/items[at0004]/value/defining_code/code_string = 'Y' AND u/data[at0001]/items[at0004]/value/defining_code/terminology_id = 'CMC-ADRTExists' ``` Response if match found: ```json [ { "advance_decision_to_refuse_exists": "Yes" } ] ``` ### 6. Has Key-safe Details Show a read-only alert if the patient has Keysafe Details recorded in Living arrangements. #### AQL ```sql SELECT d/uid/value as compositionId, u/items[at0014,'Key safe details']/value/value AS Alert_Key_Safe, g/items[at0011,'Street']/value AS Street, g/items[at0014]/value AS Postal_code, FROM EHR e[ehr_id/value = :ehrId] CONTAINS COMPOSITION d[openEHR-EHR-COMPOSITION.anticipatory_care_information.v0] CONTAINS EVALUATION n[openEHR-EHR-EVALUATION.housing_summary.v1] CONTAINS CLUSTER u[openEHR-EHR-CLUSTER.housing_record.v1] CONTAINS (CLUSTER g[openEHR-EHR-CLUSTER.address_cc.v0]) WHERE d/archetype_details/template_id/value = 'OL - Living arrangements' AND EXISTS u/items[at0014,'Key safe details']/value/value ``` #### Response Response if match found: ```json { } ``` ### 7. Requires Care-setting adjustments Show a read-only alert if the patient requires Care-settings adsjustments or has an NHS Reasonable adjustments flag. #### AQL ```sql SELECT a/data[at0001]/items[at0002]/value/value AS requiresCareSettingAdjustments FROM EHR e[ehr_id/value = :ehr_id] CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.anticipatory_care_information.v0] CONTAINS EVALUATION a[openEHR-EHR-EVALUATION.care_setting_adjustments.v1] WHERE a/data[at0001]/items[at0002]/value/defining_code/code_string MATCHES {'at0012', 'at0003'} AND c/archetype_details/template_id = 'OL - Disabilities' ``` Response if match found: ```json { [ { "requiresCareSettingAdjustments": "Adjustments recommended - does not have Reasonable Adjustment Flag" } ] }