|
| 1 | + |
| 2 | +/* |
| 3 | + * Library: IMMZD5DTMeaslesCI (–) |
| 4 | + * Rule: undefined |
| 5 | + * Decision Table: Trigger |
| 6 | + * Trigger: IMMZ.D5.DT.Measles contraindications |
| 7 | + */ |
| 8 | +library IMMZD5DTMeaslesCI |
| 9 | + |
| 10 | +using FHIR version '4.0.1' |
| 11 | +include FHIRHelpers version '4.0.1' |
| 12 | + |
| 13 | +include IMMZCommon called Common |
| 14 | +include IMMZConcepts called Concepts |
| 15 | + |
| 16 | +include IMMZElements called Elements |
| 17 | + |
| 18 | +include IMMZEncounterElements called IE |
| 19 | +include IMMZD5DTMeaslesEncounterElements called Encounter |
| 20 | + |
| 21 | +parameter Today default Today() |
| 22 | + |
| 23 | +context Patient |
| 24 | + |
| 25 | +/* |
| 26 | +@internal: Draft Medication Request for MCV dose |
| 27 | +*/ |
| 28 | +define "Draft Medication Request for MCV dose": |
| 29 | + [MedicationRequest: Concepts."MCV Vaccine"] MR where MR.status = 'draft' and MR.intent = 'proposal' |
| 30 | + sort by date from (authoredOn as FHIR.dateTime) desc |
| 31 | + |
| 32 | +/* |
| 33 | +@dynamicValue: Draft Medication Request ID for MCV dose |
| 34 | +*/ |
| 35 | +define "Draft Medication Request ID for MCV dose": |
| 36 | + First("Draft Medication Request for MCV dose").id |
| 37 | + |
| 38 | +/* |
| 39 | +@dynamicValue: Guidance |
| 40 | +*/ |
| 41 | +define "Guidance": |
| 42 | + case |
| 43 | + when "Measles vaccination contraindicated" then "Measles vaccination contraindicated Guidance" |
| 44 | + when "Measles vaccination could be contraindicated. Clinical judgement required. Create a clinical note" then "Measles vaccination could be contraindicated. Clinical judgement required. Create a clinical note Guidance" |
| 45 | + when "Clinical judgement required. Create a clinical note" then "Clinical judgement required. Create a clinical note Guidance" |
| 46 | + else '' |
| 47 | + end |
| 48 | + |
| 49 | +define "Has Guidance": |
| 50 | + "Guidance" is not null and "Guidance" != '' |
| 51 | + |
| 52 | +/* |
| 53 | +@output: Measles vaccination contraindicated Case 1 |
| 54 | +@pseudocode: "Immunization recommendation status" = "Contraindicated" |
| 55 | +*/ |
| 56 | +define "Measles vaccination contraindicated Case 1": |
| 57 | + Encounter."The client is pregnant" |
| 58 | + |
| 59 | +/* |
| 60 | +@output: Measles vaccination contraindicated Case 2 |
| 61 | +@pseudocode: "Immunization recommendation status" = "Contraindicated" |
| 62 | +*/ |
| 63 | +define "Measles vaccination contraindicated Case 2": |
| 64 | + Encounter."The client is severely immunosuppressed" |
| 65 | + |
| 66 | +/* |
| 67 | +@output: Measles vaccination contraindicated |
| 68 | +@pseudocode: "Immunization recommendation status" = "Contraindicated" |
| 69 | +*/ |
| 70 | +define "Measles vaccination contraindicated": |
| 71 | + "Measles vaccination contraindicated Case 1" |
| 72 | + or "Measles vaccination contraindicated Case 2" |
| 73 | + |
| 74 | +/* |
| 75 | +@output: Measles vaccination contraindicated Guidance |
| 76 | +@guidance: Do not vaccinate client with measles as measles vaccination is contraindicated for pregnant client. |
| 77 | +@guidance: Do not vaccinate client with measles as measles vaccination is contraindicated for severely immunosuppressed client. |
| 78 | +*/ |
| 79 | +define "Measles vaccination contraindicated Guidance": |
| 80 | + case |
| 81 | + when "Measles vaccination contraindicated Case 1" then 'Do not vaccinate client with measles as measles vaccination is contraindicated for pregnant client.' |
| 82 | + when "Measles vaccination contraindicated Case 2" then 'Do not vaccinate client with measles as measles vaccination is contraindicated for severely immunosuppressed client.' |
| 83 | + else '' |
| 84 | + end |
| 85 | + |
| 86 | +/* |
| 87 | +@output: Measles vaccination could be contraindicated. Clinical judgement required. Create a clinical note |
| 88 | +@pseudocode: "Immunization recommendation status" = "Further evaluation needed" |
| 89 | +*/ |
| 90 | +define "Measles vaccination could be contraindicated. Clinical judgement required. Create a clinical note": |
| 91 | + Encounter."The client has history of anaphylactic reactions" |
| 92 | + |
| 93 | +/* |
| 94 | +@output: Measles vaccination could be contraindicated. Clinical judgement required. Create a clinical note Guidance |
| 95 | +@guidance: Do not vaccinate client with measles if client has history of anaphylactic reaction to any component of the vaccine (e.g. neomycin or gelatin). |
| 96 | +*/ |
| 97 | +define "Measles vaccination could be contraindicated. Clinical judgement required. Create a clinical note Guidance": |
| 98 | + 'Do not vaccinate client with measles if client has history of anaphylactic reaction to any component of the vaccine (e.g. neomycin or gelatin).' |
| 99 | + |
| 100 | +/* |
| 101 | +@output: Clinical judgement required. Create a clinical note Case 1 |
| 102 | +@pseudocode: "Immunization recommendation status" = "Further evaluation needed" |
| 103 | +*/ |
| 104 | +define "Clinical judgement required. Create a clinical note Case 1": |
| 105 | + Encounter."The client has history of severe allergic reactions" |
| 106 | + |
| 107 | +/* |
| 108 | +@output: Clinical judgement required. Create a clinical note Case 2 |
| 109 | +@pseudocode: "Immunization recommendation status" = "Further evaluation needed" |
| 110 | +*/ |
| 111 | +define "Clinical judgement required. Create a clinical note Case 2": |
| 112 | + Encounter."The client has a symptomatic HIV infection" |
| 113 | + |
| 114 | +/* |
| 115 | +@output: Clinical judgement required. Create a clinical note |
| 116 | +@pseudocode: "Immunization recommendation status" = "Further evaluation needed" |
| 117 | +*/ |
| 118 | +define "Clinical judgement required. Create a clinical note": |
| 119 | + "Clinical judgement required. Create a clinical note Case 1" |
| 120 | + or "Clinical judgement required. Create a clinical note Case 2" |
| 121 | + |
| 122 | +/* |
| 123 | +@output: Clinical judgement required. Create a clinical note Guidance |
| 124 | +@guidance: Do not vaccinate client with measles if client has history of severe allergic reactions to any component of the vaccine (e.g. neomycin or gelatin). |
| 125 | +@guidance: Client has symptomatic HIV infection. Measles vaccination may be considered if the client is not severely immunosuppressed according to conventional definitions, consider risks of vaccination and make a clinical judgement. |
| 126 | +*/ |
| 127 | +define "Clinical judgement required. Create a clinical note Guidance": |
| 128 | + case |
| 129 | + when "Clinical judgement required. Create a clinical note Case 1" then 'Do not vaccinate client with measles if client has history of severe allergic reactions to any component of the vaccine (e.g. neomycin or gelatin).' |
| 130 | + when "Clinical judgement required. Create a clinical note Case 2" then 'Client has symptomatic HIV infection. Measles vaccination may be considered if the client is not severely immunosuppressed according to conventional definitions, consider risks of vaccination and make a clinical judgement.' |
| 131 | + else '' |
| 132 | + end |
| 133 | + |
| 134 | + |
| 135 | +/* |
| 136 | +@test: Test expected results based on example patients |
| 137 | +*/ |
| 138 | +define "Test Validation": |
| 139 | + case |
| 140 | + when Patient.id = '56.CI162' then "Measles vaccination contraindicated Case 1" and "Guidance" = 'Do not vaccinate client with measles as measles vaccination is contraindicated for pregnant client.' |
| 141 | + when Patient.id = '57.CI166' then "Measles vaccination could be contraindicated. Clinical judgement required. Create a clinical note" and "Guidance" = 'Do not vaccinate client with measles if client has history of anaphylactic reaction to any component of the vaccine (e.g. neomycin or gelatin).' |
| 142 | + when Patient.id = '58.CI167' then "Clinical judgement required. Create a clinical note Case 1" and "Guidance" = 'Do not vaccinate client with measles if client has history of severe allergic reactions to any component of the vaccine (e.g. neomycin or gelatin).' |
| 143 | + when Patient.id = '59.CI165' then "Measles vaccination contraindicated Case 2" and "Guidance" = 'Do not vaccinate client with measles as measles vaccination is contraindicated for severely immunosuppressed client.' |
| 144 | + when Patient.id = '60.CI168' then "Clinical judgement required. Create a clinical note Case 2" and "Guidance" = 'Client has symptomatic HIV infection. Measles vaccination may be considered if the client is not severely immunosuppressed according to conventional definitions, consider risks of vaccination and make a clinical judgement.' |
| 145 | + else 'No test case set' |
| 146 | + end |
0 commit comments