jasonwa.ng
01/11/2024, 6:15 AM{
"resourceType": "Encounter",
"status": "active",
"class": {
"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
"code": "medical-visit",
"display": "Medical Visit"
},
"meta": {
"profile": [
"https://example.com/fhir/StructureDefinition/custom-encounter"
]
}
}
The above is a sample JSON but illustrates that this encounter should at least return a validation error generated by the custom profile.
My custom profile is stored in Medplum. It has a snapshot as well. Why is this error occurring?rahul1
01/11/2024, 8:59 AMrahul1
01/11/2024, 9:01 AMexample.com
jasonwa.ng
01/11/2024, 6:19 PMjasonwa.ng
01/11/2024, 6:20 PMStructureDefinition
I addedrahul1
01/12/2024, 8:15 AMStructureDefinition
- Create a new StructureDefinition
from JSON, using the contents of the file attached
- Save
- navigate to Encounter
- Create a new Encounter
using the JSON below
- Try to save
I end up seeing the error in the attached screenshot
json
{
"resourceType": "Encounter",
"status": "active",
"class": {
"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
"code": "HH",
"display": "Home Health"
},
"meta": {
"profile": [
"https://foomedical.org/fhir/StructureDefinition/abc-visit-encounter"
],
"versionId": "77361ee9-e125-4cff-a440-426509805c09",
"lastUpdated": "2024-01-11T08:57:26.559Z",
"author": {
"reference": "Practitioner/996a2c29-5aaa-4810-bd6f-5f2935e90239",
"display": "Rahul Agarwal"
},
"project": "70721083-1dde-413a-bd2a-419771a8718e",
"compartment": [
{
"reference": "Project/70721083-1dde-413a-bd2a-419771a8718e"
}
]
},
"id": "04a1c6f9-3459-4b6f-9359-d5f011c5fedb"
}
jasonwa.ng
01/16/2024, 6:54 AMrahul1
01/16/2024, 4:25 PMno snapshot defined
error ?jasonwa.ng
01/16/2024, 7:07 PMrahul1
01/16/2024, 7:09 PMjasonwa.ng
01/16/2024, 7:23 PMrahul1
01/17/2024, 5:35 AMrahul1
01/17/2024, 5:40 AMapp.medplum.com/StructureDefinition
2. Click "new"
3. Paste json of the StructureDefinition (See attached)
4. Click Ok
5. Navigate to app.medplum.com/Encounter
6. Click "new"
7. Paste the attached JSON for the encoutner
8. Click "Ok"jasonwa.ng
01/17/2024, 9:16 PMjasonwa.ng
01/18/2024, 11:55 PMjasonwa.ng
01/18/2024, 11:56 PMjasonwa.ng
01/18/2024, 11:57 PMjasonwa.ng
01/19/2024, 7:18 AMStructureDefinition
is that even after removing the constraint from the StructureDefinition, the error continues to pop up saying that the constraint that was removed is not satisfiedrahul1
01/19/2024, 4:23 PMrahul1
01/19/2024, 4:24 PMrahul1
01/19/2024, 4:46 PMEncounters
, but rather more of a "type". In this case, I would recommend that you actually constrain Encounter.category
2. Rather than a FHIRpath constraint
, the "more appropriate" way to encode this would be via "slicing'. Some resources here:
https://build.fhir.org/profiling.html#slicing
https://kodjin.com/blog/how-to-slice-an-fhir-resource/
Example: https://hl7.org/fhir/us/core/STU5.0.1/StructureDefinition-us-core-body-temperature.htmljasonwa.ng
01/23/2024, 12:59 AMjasonwa.ng
01/23/2024, 1:00 AMProfile
instead of just slicing. Would love any opinions if this is the wrong approach!rahul1
01/24/2024, 8:27 AMrahul1
01/24/2024, 8:28 AMrahul1
01/24/2024, 8:28 AMrahul1
01/24/2024, 8:29 AMrahul1
01/24/2024, 8:30 AMcategory
and code
fields to fixed values, using slicingjasonwa.ng
01/24/2024, 6:10 PMjasonwa.ng
01/24/2024, 6:11 PMrahul1
01/24/2024, 7:27 PMrahul1
01/24/2024, 7:34 PMjasonwa.ng
01/25/2024, 12:28 AMjasonwa.ng
01/25/2024, 12:29 AMjasonwa.ng
01/25/2024, 12:29 AMjasonwa.ng
01/25/2024, 12:32 AMrahul1
01/25/2024, 8:49 PMjasonwa.ng
01/25/2024, 8:55 PMrahul1
01/25/2024, 10:18 PMjasonwa.ng
01/27/2024, 12:45 AMjasonwa.ng
01/31/2024, 9:16 PMjasonwa.ng
01/31/2024, 9:17 PMStructureDefinition
constraint on `Encounter.identifier`:
{
"id": "Encounter.identifier",
"path": "Encounter.identifier",
"min": 1,
"max": "*",
"type": [
{
"code": "Identifier"
}
],
"constraint": [
{
"key": "encounter-has-number-identifier",
"severity": "error",
"human": "Encounter must have an identifier that denotes which visit number it is.",
"expression": "identifier.where(system = 'https://terminology.blah.org/CodeSystem/encounter-number' and value.matches('[0-9]+')).exists()",
"xpath": "f:identifier[f:system/@value='https://terminology.blah.org/CodeSystem/encounter-number' and f:value/@value cast as xs:integer]"
}
]
},
jasonwa.ng
01/31/2024, 9:19 PM{
"resourceType": "Encounter",
"identifier": [
{
"system": "https://terminology.blah.org/CodeSystem/encounter-number",
"value": "5"
}
],
...
]
rahul1
02/05/2024, 10:40 PMEncounter.identifier
is referring to identifier
.
When you attach a constraint at a path, the context for the constraint expression is already that variable. So in this case, your constraint is looking for identifier.identifier.where(...)
The solution that I was able to make work was to move this constraint to the Encounter
element definition