From 7424e63e39ea85c540321587c5a88c4bc4ea0231 Mon Sep 17 00:00:00 2001 From: Michaela Ziegler Date: Fri, 22 Mar 2024 08:45:35 +0100 Subject: [PATCH] add dosage sequence constraints #263 --- input/fsh/invariants/ch-dosage-1.fsh | 4 -- input/fsh/invariants/ch-dosage-2.fsh | 4 -- input/fsh/invariants/ch-dosage-3.fsh | 4 -- input/fsh/invariants/ch-dosage-4.fsh | 4 -- input/fsh/invariants/ch-dosage.fsh | 49 +++++++++++++++++++ .../fsh/profiles/CHEMEDMedicationDispense.fsh | 1 + .../fsh/profiles/CHEMEDMedicationRequest.fsh | 1 + .../profiles/CHEMEDMedicationStatement.fsh | 1 + input/pagecontent/changelog.md | 1 + 9 files changed, 53 insertions(+), 16 deletions(-) delete mode 100644 input/fsh/invariants/ch-dosage-1.fsh delete mode 100644 input/fsh/invariants/ch-dosage-2.fsh delete mode 100644 input/fsh/invariants/ch-dosage-3.fsh delete mode 100644 input/fsh/invariants/ch-dosage-4.fsh create mode 100644 input/fsh/invariants/ch-dosage.fsh diff --git a/input/fsh/invariants/ch-dosage-1.fsh b/input/fsh/invariants/ch-dosage-1.fsh deleted file mode 100644 index cede9210..00000000 --- a/input/fsh/invariants/ch-dosage-1.fsh +++ /dev/null @@ -1,4 +0,0 @@ -Invariant: ch-dosage-1 -Description: "No sequence number (for one dosage element) or sequence number = 1 (for more than one dosage element)" -Severity: #error -Expression: "$this.count() = 0 or $this = 1" \ No newline at end of file diff --git a/input/fsh/invariants/ch-dosage-2.fsh b/input/fsh/invariants/ch-dosage-2.fsh deleted file mode 100644 index 518ac4da..00000000 --- a/input/fsh/invariants/ch-dosage-2.fsh +++ /dev/null @@ -1,4 +0,0 @@ -Invariant: ch-dosage-2 -Description: "The sequence number must be greater than 1" -Severity: #error -Expression: "$this > 1" \ No newline at end of file diff --git a/input/fsh/invariants/ch-dosage-3.fsh b/input/fsh/invariants/ch-dosage-3.fsh deleted file mode 100644 index 461110b0..00000000 --- a/input/fsh/invariants/ch-dosage-3.fsh +++ /dev/null @@ -1,4 +0,0 @@ -Invariant: ch-dosage-3 -Description: "Patient instruction/free text dosage instruction, timing or as needed has to be specified" -Severity: #error -Expression: "patientInstruction.exists() or timing.exists() or asNeeded.exists()" \ No newline at end of file diff --git a/input/fsh/invariants/ch-dosage-4.fsh b/input/fsh/invariants/ch-dosage-4.fsh deleted file mode 100644 index eae658e6..00000000 --- a/input/fsh/invariants/ch-dosage-4.fsh +++ /dev/null @@ -1,4 +0,0 @@ -Invariant: ch-dosage-4 -Description: "For split dosage timing event and dose/rate are required" -Severity: #error -Expression: "sequence.exists() implies (timing.repeat.when.exists() and doseAndRate.dose.exists())" \ No newline at end of file diff --git a/input/fsh/invariants/ch-dosage.fsh b/input/fsh/invariants/ch-dosage.fsh new file mode 100644 index 00000000..b13d3cb9 --- /dev/null +++ b/input/fsh/invariants/ch-dosage.fsh @@ -0,0 +1,49 @@ +// Base - Dosage.sequence +Invariant: ch-dosage-1 +Description: "No sequence number (for one dosage element) or sequence number = 1 (for more than one dosage element)" +Severity: #error +Expression: "$this.count() = 0 or $this = 1" + +// Split - Dosage.sequence +Invariant: ch-dosage-2 +Description: "The sequence number must be greater than 1" +Severity: #error +Expression: "$this > 1" + +// MedicationRequest +Invariant: ch-dosage-3 +Description: "Patient instruction/free text dosage instruction, timing or as needed has to be specified" +Severity: #error +Expression: "patientInstruction.exists() or timing.exists() or asNeeded.exists()" + +// Dosage +Invariant: ch-dosage-4 +Description: "For split dosage timing event and dose/rate are required" +Severity: #error +Expression: "sequence.exists() implies (timing.repeat.when.exists() and doseAndRate.dose.exists())" + +// MedicationStatement +Invariant: ch-dosage-medstat +Description: "If one dosage element is present, it should not have a sequence number. + If more than one dosage element is present, the base entry has the sequence number 1." +Severity: #error +Expression: "(dosage.count() > 1 implies dosage.where($this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage') and sequence = 1).exists()) + and (dosage.count() = 1 implies dosage.single().sequence.exists().not())" + +// MedicationDispense +Invariant: ch-dosage-meddis +Description: "If one dosage element is present, it should not have a sequence number. + If more than one dosage element is present, the base entry has the sequence number 1." +Severity: #error +Expression: "(dosageInstruction.count() > 1 implies dosageInstruction.where($this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage') and sequence = 1).exists()) + and (dosageInstruction.count() = 1 implies dosageInstruction.single().sequence.exists().not())" + +// MedicationRequest +Invariant: ch-dosage-medreq +Description: "If one dosage element is present, it should not have a sequence number. + If more than one dosage element is present, the base entry has the sequence number 1." +Severity: #error +Expression: "(dosageInstruction.count() > 1 implies dosageInstruction.where($this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-medicationrequest') and sequence = 1).exists()) + and (dosageInstruction.count() = 1 implies dosageInstruction.single().sequence.exists().not())" + + diff --git a/input/fsh/profiles/CHEMEDMedicationDispense.fsh b/input/fsh/profiles/CHEMEDMedicationDispense.fsh index 3f524d51..0168e95a 100644 --- a/input/fsh/profiles/CHEMEDMedicationDispense.fsh +++ b/input/fsh/profiles/CHEMEDMedicationDispense.fsh @@ -4,6 +4,7 @@ Id: ch-emed-medicationdispense Title: "CH EMED MedicationDispense (DIS)" Description: "Definition of the medication dispense for the medication dispense document" * . ^short = "CH EMED MedicationDispense (DIS)" +* obeys ch-dosage-meddis * contained 1.. * extension ^slicing.discriminator.type = #value * extension ^slicing.discriminator.path = "url" diff --git a/input/fsh/profiles/CHEMEDMedicationRequest.fsh b/input/fsh/profiles/CHEMEDMedicationRequest.fsh index 210ca7a0..00b41334 100644 --- a/input/fsh/profiles/CHEMEDMedicationRequest.fsh +++ b/input/fsh/profiles/CHEMEDMedicationRequest.fsh @@ -4,6 +4,7 @@ Id: ch-emed-medicationrequest Title: "CH EMED MedicationRequest (PRE)" Description: "Definition of the medication request for the medication prescription document" * . ^short = "CH EMED MedicationRequest (PRE)" +* obeys ch-dosage-medreq * contained 1.. * extension ^slicing.discriminator.type = #value * extension ^slicing.discriminator.path = "url" diff --git a/input/fsh/profiles/CHEMEDMedicationStatement.fsh b/input/fsh/profiles/CHEMEDMedicationStatement.fsh index c1bc7a0e..48294289 100644 --- a/input/fsh/profiles/CHEMEDMedicationStatement.fsh +++ b/input/fsh/profiles/CHEMEDMedicationStatement.fsh @@ -4,6 +4,7 @@ Id: ch-emed-medicationstatement Title: "CH EMED MedicationStatement" Description: "Definition of the medication statement for the medication treatment plan document (and as basis medication statement)" * . ^short = "CH EMED MedicationStatement (MTP and basis)" +* obeys ch-dosage-medstat * contained 1.. /* CH Core * extension ^slicing.discriminator.type = #value diff --git a/input/pagecontent/changelog.md b/input/pagecontent/changelog.md index 8a7fb3ff..ce953535 100644 --- a/input/pagecontent/changelog.md +++ b/input/pagecontent/changelog.md @@ -12,6 +12,7 @@ All significant changes to this FHIR implementation guide will be documented on * Fix links from internal (CH EMED) to external (CH Term) artifacts * [#258](https://github.com/hl7ch/ch-emed/issues/258): CH Core base profiles as parent * [#252](https://github.com/hl7ch/ch-emed/issues/252): SCT code 246205007 'Quantity (attribute)' instead of UCUM human annotation {Piece} 'Stk.' +* [#263](https://github.com/hl7ch/ch-emed/issues/263): Add additional constraints beside ch-dosage-1 to check, if the sequence number is present in split dosage elements ### STU 4 Sequence - v4.0.1 (2023-12-28)