Skip to content

Commit

Permalink
add dosage sequence constraints #263
Browse files Browse the repository at this point in the history
  • Loading branch information
ziegm committed Mar 22, 2024
1 parent 341aa59 commit 7424e63
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 16 deletions.
4 changes: 0 additions & 4 deletions input/fsh/invariants/ch-dosage-1.fsh

This file was deleted.

4 changes: 0 additions & 4 deletions input/fsh/invariants/ch-dosage-2.fsh

This file was deleted.

4 changes: 0 additions & 4 deletions input/fsh/invariants/ch-dosage-3.fsh

This file was deleted.

4 changes: 0 additions & 4 deletions input/fsh/invariants/ch-dosage-4.fsh

This file was deleted.

49 changes: 49 additions & 0 deletions 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())"


1 change: 1 addition & 0 deletions input/fsh/profiles/CHEMEDMedicationDispense.fsh
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions input/fsh/profiles/CHEMEDMedicationRequest.fsh
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions input/fsh/profiles/CHEMEDMedicationStatement.fsh
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions input/pagecontent/changelog.md
Expand Up @@ -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)

Expand Down

0 comments on commit 7424e63

Please sign in to comment.