1

I am defining a profile in DetectedIssue resource and want to make mitigation field as required when the status field of this resource = final. Can someone help me how to do that? Here is the profile definition of my DetectedIssue resource.

Profile: SystemPatientDetectedIssue
Parent: DetectedIssue
Id: patient-detectedissue
Title: "Patient Alert DetectedIssue"
Description: "Profile of DetectedIssue for capturing patient alerts"

* status from SystemDetectedIssueStatusValueSet (required)
* code 1..1
* code from SystemDetectedIssueCodeValueSet (required)
* patient 1..1
* identifiedDateTime 1..1
* detail 1..1
* author 1..1
* author.identifier 1..1
* author.identifier.type from SystemIdentifierValueSet (required)

// Mitigation required when marking the issue as "final".
// How to Make the mitigation field required when setting the issue as final?
* mitigation 0..1
* mitigation.action.coding from SystemDetectedIssueMitigationActionValueSet
* mitigation.action.text 1..1
* mitigation.date 1..1
* mitigation.author 1..1

And here is the valueset definition (SystemDetectedIssueStatusValueSet) for status attribute above:

Alias: OBSERVATION_STATUS = http://hl7.org/fhir/observation-status

ValueSet: SystemDetectedIssueStatusValueSet
Id: system-detected-issue-status-value-set
Title: "System DetectedIssue status ValueSet"
* ^url = https://terminology.system.com/ValueSet/detectedissue-status
* include OBSERVATION_STATUS#registered
* include OBSERVATION_STATUS#cancelled
* include OBSERVATION_STATUS#final
nirojshrestha019
  • 2,068
  • 1
  • 10
  • 14

1 Answers1

2

Any constraints that depend on relationships between elements (like status and mitigation) can only be constrained using an invariant. Invariants are set on ElementDefinition.constraint in FHIR, but FSH has a special mechanism for invariants documented here. The most difficult thing about invariants is that they use another language, called FHIRPath, to express the constraint. You should look at the core FHIRPath documentation as well as the FHIR-specific FHIRPath documentation.

For your specific example, you would first define your invariant as a separate item. The special FHIRPath expression is in the Expression field:

Invariant:   final-mitigation
Description: "If DetectedIssue.status is final, then DetectedIssue.mitigation must be present"
Expression:  "status = 'final' implies mitigation.exists()"
Severity:    #error

Then, since it talks about two elements, relative to the root of the resource, you add a top-level obeys rule to your profile that brings in the invariant you just created:

* obeys final-mitigation

In the future, you'll probably have the best luck asking these questions in the #shorthand stream of chat.fhir.org, where there is a whole community of people that can help.

Chris M
  • 183
  • 2
  • 8