I want to allow a Patient with no Gender, but write a warning to the log.
For this, I define a StructureDefinition with a snapshot of a “Patient.Gender” element, with a constraint with severity “warning”.
This does not work, as my validator still returns an error message with severity: “error”.
On the other hand if I try to put a “fatal” constraint - ALL my errors disappear, and my resource is suddenly valid, with no errors/log.
Using FHIR Release 3 (STU)
Here is my structure:
{
"id": "Patient.gender",
"path": "Patient.gender",
"short": "male | female | other | unknown",
"definition": "Administrative Gender.",
"comment": "The gender may not match the biological sex as determined by genetics...",
"requirements": "Needed for identification of the individual, in combination with (at least) name and birth date...",
"min": 0,
"max": "1",
"constraint": [
{
"key": "gen-1",
"severity": "warning",
"human": "Something something"
}
],
"type": [
{
"code": "code"
}
],
"isSummary": true,
"binding": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
"valueString": "AdministrativeGender"
},
{
"url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding",
"valueBoolean": true
}
],
"strength": "required",
"description": "The gender of a person used for administrative purposes.",
"valueSetReference": {
"reference": "http://hl7.org/fhir/ValueSet/administrative-gender"
}
},
"mapping": [
{
"identity": "v2",
"map": "PID-8"
},
{
"identity": "rim",
"map": "player[classCode=PSN|ANM and determinerCode=INSTANCE]/administrativeGender"
},
{
"identity": "cda",
"map": ".patient.administrativeGenderCode"
}
]
},
And my validator:
// Use DefaultProfileValidationSupport since derived profiles generally
// rely on built-in profiles also being available
DefaultProfileValidationSupport defaultSupport = new DefaultProfileValidationSupport();
// Create a chain that includes both the pre-populated and default. We put
// the pre-populated (custom) support module first so that it takes precedence
FhirInstanceValidator instanceValidator = new FhirInstanceValidator();
ValidationSupportChain support = new ValidationSupportChain(
new VCValidationSupport(fhirContext), defaultSupport);
instanceValidator.setValidationSupport(support);
instanceValidator.setNoTerminologyChecks(true);
validator.registerValidatorModule(instanceValidator);
What am I missing here?