Stream: dotnet
Topic: Profile Validation Confusing Behavior
Muhammad Abubakar Ikram (Aug 22 2019 at 17:03):
I have four custom StructureDefinitions in my DirectorySource
1. PkPatient.StructureDefinition.xml (has extension PkCnic.StructureDefinition.xml with cardinality 1..1 )
2. PkCnic.StructureDefinition.xml
3. UsPatient.StructureDefinition.xml (has extension UsSsn.StructureDefinition.xml with cardinality 1..1 )
4. UsSsn.StructureDefinition.xml
ISSUE:
1. PkPatient profile is in the meta of patient resource
2. PkCnic extension is in the patient resource
3. But the validation result of the patient resource is with UsPatient profile is "OVERALL SUCCESS"
4. Why this is giving me success result? while validating with UsPatient profile? I have never added UsSsn extention in the patient resource
5. It shouldn't give a validation error?
here is my code
Patient patient = new Patient(); patient.Meta = new Meta { Profile = new List<string> { "http://example.org/fhir/StructureDefinition/PkPatient" } }; patient.Id = "1"; patient.Gender = AdministrativeGender.Male; patient.Active = true; HumanName hn = new HumanName(); hn.Family = "Jhon"; hn.Given = new List<string> { "Doe" }; patient.Name.Add(hn); patient.AddExtension("http://example.org/fhir/StructureDefinition/PkCnic", new FhirString("123456789")); ZipSource zipSource = new ZipSource("<path>\\specification.zip"); DirectorySource directorySource = new DirectorySource("<path>"); // FOLDER CONTAINS CUSTOM STRUCTURE DEFINITIONS Validator validator = new Validator(new ValidationSettings { ResourceResolver = new MultiResolver(zipSource, directorySource) }); OperationOutcome operationOutcome = validator.Validate(patient, "http://example.org/fhir/StructureDefinition/UsPatient");
Michel Rutten (Aug 23 2019 at 09:06):
@Ewout Kramer ?
Muhammad Abubakar Ikram (Sep 04 2019 at 14:44):
Any update?
Richard Kavanagh (Sep 04 2019 at 16:52):
So my understanding is as follows:
-
Extensions are by default permitted anywhere within a profile even if not explicitly added. When validation occurs as long as the profile for any extensions used can be located then the validation will happen.
-
By explicitly adding an extension to the profile, you can choose to make extensions mandatory etc and it is probably good practice but if they are optional you don't need to do so.
Slightly different question but this may help https://chat.fhir.org/#narrow/stream/179175-argonaut/topic/Extensions.20.26.20Profiles
Muhammad Abubakar Ikram (Sep 10 2019 at 19:53):
@Richard Kavanagh I understand that extensions are permitted without the inclusion of profile in the meta.
What I am curious about is, that I am getting validation success against the profile whose mandatory extension (1..1) is not included in the resource!
Why validation success if the extension is specified mandatory in the profile but not included in the resource?
Michel Rutten (Sep 12 2019 at 11:16):
Sounds like you found a bug. Could you submit an issue to:
https://github.com/FirelyTeam/fhir-net-api/issues/
Please attach the profile & extension if possible, so we can reproduce the issue.
Muhammad Abubakar Ikram (Sep 12 2019 at 11:21):
@Richard Kavanagh
@Michel Rutten
UPDATE:
I got the expected result.
This is how I got the expected result.
I was just constraining the cardinality inside the extension structureDefinition and in the patient structureDefinition for the extension.
I also had to check the "Must Support" attribute for the value[x] of the extension inside the custom patient profile.
now it is giving me error of cardinality that there must be (1..1 something.........) this is what I was expecting.
if for making an extension mandatory we must have to check the "Must Support" for the value[x] then this is not bug.
If only setting the cardinality is the requirement for making mandatory extension then it is bug.
Now please review the situation.
Michel Rutten (Sep 12 2019 at 11:23):
MustSupport is separate from cardinality, one constraint should not affect validation of the other.
Michel Rutten (Sep 12 2019 at 11:23):
Still sounds like a bug
Muhammad Abubakar Ikram (Sep 12 2019 at 11:25):
@Michel Rutten alright I will post the issue.
yes for sure I'll attach the profiles so you can reproduce the issue.
I was just playing around the FHIR profiling. So these are just testing profiles.
Muhammad Abubakar Ikram (Sep 12 2019 at 12:01):
@Michel Rutten here is the issue
https://github.com/FirelyTeam/fhir-net-api/issues/1109
Richard Kavanagh (Sep 12 2019 at 14:31):
Well, I've had a play with the code supplied and I'm stumped....
Ewout Kramer (Sep 12 2019 at 16:52):
thanks @Muhammad Abubakar for the clear bug description you created.
Muhammad Abubakar Ikram (Sep 12 2019 at 17:27):
Welcome, I would be happy if some little contribution from my side can help us all.
Last updated: Apr 12 2022 at 19:14 UTC