示例#1
0
        public void QuantityElement()
        {
            var assertion = new ProfileAssertion("Patient.name[0]", resolve);

            assertion.SetInstanceType(FHIRDefinedType.Quantity);
            assertion.SetDeclaredType(FHIRDefinedType.Age);

            Assert.True(assertion.Validate().Success);
            Assert.Single(assertion.MinimalProfiles, assertion.DeclaredType);

            assertion.SetInstanceType(FHIRDefinedType.Identifier);
            var report = assertion.Validate();

            Assert.False(report.Success);
            Assert.Contains("is incompatible with that of the instance", report.ToString());
        }
示例#2
0
        public void ProfiledElement()
        {
            var assertion = new ProfileAssertion("Patient.identifier[0]", resolve);

            assertion.SetDeclaredType("http://validationtest.org/fhir/StructureDefinition/IdentifierWithBSN");
            Assert.True(assertion.Validate().Success);

            assertion.SetInstanceType(FHIRDefinedType.Identifier);
            Assert.True(assertion.Validate().Success);
            Assert.Single(assertion.MinimalProfiles, assertion.DeclaredType);

            assertion.SetInstanceType(FHIRDefinedType.HumanName);
            var report = assertion.Validate();

            Assert.False(report.Success);
            Assert.Contains("is incompatible with that of the instance", report.ToString());
        }
示例#3
0
        public void ContainedResource()
        {
            var assertion = new ProfileAssertion("Bundle.entry.resource[0]", resolve);

            assertion.SetDeclaredType(FHIRDefinedType.Resource);
            Assert.True(assertion.Validate().Success);

            assertion.SetInstanceType(FHIRDefinedType.Patient);
            Assert.True(assertion.Validate().Success);

            assertion.SetDeclaredType(FHIRDefinedType.DomainResource);
            Assert.True(assertion.Validate().Success);

            Assert.Single(assertion.MinimalProfiles, assertion.InstanceType);

            assertion.SetInstanceType(FHIRDefinedType.Binary);
            var report = assertion.Validate();

            Assert.False(report.Success);
            Assert.Contains("is incompatible with that of the instance", report.ToString());
        }
示例#4
0
        public void ResourceWithStatedProfiles()
        {
            var assertion = new ProfileAssertion("Observation", resolve);

            assertion.SetDeclaredType(FHIRDefinedType.Observation);

            Assert.True(assertion.Validate().Success);

            assertion.AddStatedProfile(ModelInfo.CanonicalUriForFhirCoreType(FHIRDefinedType.Observation));
            assertion.AddStatedProfile("http://validationtest.org/fhir/StructureDefinition/WeightHeightObservation");
            assertion.AddStatedProfile("http://hl7.org/fhir/StructureDefinition/devicemetricobservation");

            var report = assertion.Validate();

            Assert.True(report.Success);
            Assert.Equal(2, assertion.MinimalProfiles.Count());
            Assert.Equal(assertion.MinimalProfiles, assertion.StatedProfiles.Skip(1));

            assertion.SetDeclaredType(FHIRDefinedType.Procedure);
            report = assertion.Validate();

            Assert.False(report.Success);
            Assert.Contains("is incompatible with the declared type", report.ToString());
        }
示例#5
0
        public OperationOutcome Process()
        {
            var outcome = new OperationOutcome();

            // Start preprocessing by resolving the references to the profiles (if any)
            var resolveOutcome = _profiles.Resolve();

            outcome.Add(resolveOutcome);

            if (resolveOutcome.Success)
            {
                // Then, validate consistency of the profile assertions
                var validationOutcome = _profiles.Validate();
                outcome.Add(validationOutcome);

                if (validationOutcome.Success)
                {
                    if (_profiles.MinimalProfiles.Any())
                    {
                        // Then, generate snapshots for all sds that we have found
                        var genSnapshotOutcome = GenerateSnapshots(_profiles.MinimalProfiles, _snapshotGenerator, _path);
                        outcome.Add(genSnapshotOutcome);

                        if (genSnapshotOutcome.Success)
                        {
                            // Finally, return navigators to the definitions
                            Result = CreateNavigators(_profiles.MinimalProfiles);
                        }
                    }
                    else
                    {
                        outcome.AddIssue("There are no profile and type assertions at this point in the instance, so validation cannot succeed",
                                         Issue.PROFILE_NO_PROFILE_TO_VALIDATE_AGAINST, _path);
                    }
                }
            }

            return(outcome);
        }