firely-net-sdk icon indicating copy to clipboard operation
firely-net-sdk copied to clipboard

Profile validation (on id/regex) not working

Open andygemis opened this issue 3 years ago • 3 comments

Currently porting some code from .net framework 4.8 STU3 (using package Hl7.Fhir.STU3 v0.94.0) to .net core 3.1 using package Hl7.Fhir.R4 v 3.4.0

Under STU3 - works :-


      var patient = new Patient();
			patient.Id = string.Empty.PadLeft(90, '!');

			var validator = new Validator(new ValidationSettings()
			{
				ResourceResolver = new ZipSource(@"Packages\Hl7.Fhir.Specification.STU3.0.94.0\contentFiles\any\any\specification.zip"),
			});

var validationResut =validator.Validate(new PocoNavigator(patient));

STU3 Patient INPUT {"resourceType":"Patient","id":"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"}

STU3 OperationOutcome/validation result {"resourceType":"OperationOutcome","issue":[{"severity":"error","code":"invalid","details":{"coding":[{"system":"http://hl7.org/fhir/dotnet-api-operation-outcome","code":"1006"}],"text":"Primitive value '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' does not match regex '[A-Za-z0-9\\-\\.]{1,64}'"},"location":["Patient.id[0]"]}]}

Under R4

var patient = new Patient();
            patient.Id = string.Empty.PadLeft(90, '!');


            var validator = new Validator(new ValidationSettings()
            {
                ResourceResolver = new ZipSource(@"/workspaces/tst/bin/Debug/netcoreapp3.1/specification.zip"),
                ResolveExternalReferences = false
            });

            var validationResut = validator.Validate(patient.ToTypedElement());

R4 Patient INPUT "{"resourceType":"Patient","id":"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"}"

R4 OperationOutcome/validation result "{"resourceType":"OperationOutcome"}"

Ie the regex/length isn''t been caught,

But other tests for missing manditory elements are being trapped - seems to be regex based?

andygemis avatar Jul 29 '21 17:07 andygemis

I think this is a duplicate of #1773, correct?

ewoutkramer avatar Jul 30 '21 08:07 ewoutkramer

I think so.

"id" doesn't seem to have changed between STU3 "id" -> https://www.hl7.org/fhir/STU3/datatypes.html#id -> Regex: [A-Za-z0-9-.]{1,64} and R4 "id" -> http://hl7.org/fhir/R4/datatypes.html#id -> Regex: [A-Za-z0-9-.]{1,64}

At least, not according to the HTML/documentation pages.

This regex validation did previously work with STU3/older version of your library.

I'm not sure where the Structuredefinition.profile.json fits in - ie is the actual R4 FHIR source data wrong (which is why the regex rule isn't being run)?

andygemis avatar Jul 30 '21 10:07 andygemis

I suspect a connection between the two. We'll keep them both open until we have a better understanding of the issue.

ewoutkramer avatar Jul 30 '21 12:07 ewoutkramer