示例#1
0
        private static OperationOutcome ValidateMatch(this Validator validator, Match match, IElementNavigator parent)
        {
            var outcome = new OperationOutcome();

            var definition = match.Definition.Current;

            if (definition.Min == null)
            {
                validator.Trace(outcome, $"Element definition does not specify a 'min' value, which is required. Cardinality has not been validated",
                                Issue.PROFILE_ELEMENTDEF_CARDINALITY_MISSING, parent);
            }
            else if (definition.Max == null)
            {
                validator.Trace(outcome, $"Element definition does not specify a 'max' value, which is required. Cardinality has not been validated",
                                Issue.PROFILE_ELEMENTDEF_CARDINALITY_MISSING, parent);
            }

            var cardinality = Cardinality.FromElementDefinition(definition);

            var bucket = BucketFactory.CreateRoot(match.Definition, validator);

            foreach (var element in match.InstanceElements)
            {
                var success = bucket.Add(element);

                // For the "root" slice group (=the original core element that was sliced, not resliced)
                // any element that does not match is an error
                // Since the ChildNameMatcher currently does the matching, this will never go wrong
            }

            outcome.Add(bucket.Validate(validator, parent));

            return(outcome);
        }
        private static OperationOutcome ValidateMatch(this Validator validator, Match match, ScopedNode parent)
        {
            var outcome = new OperationOutcome();

            var definition = match.Definition.Current;

            if (definition.Min == null)
            {
                validator.Trace(outcome, $"Element definition does not specify a 'min' value, which is required. Cardinality has not been validated",
                                Issue.PROFILE_ELEMENTDEF_CARDINALITY_MISSING, parent);
            }
            else if (definition.Max == null)
            {
                validator.Trace(outcome, $"Element definition does not specify a 'max' value, which is required. Cardinality has not been validated",
                                Issue.PROFILE_ELEMENTDEF_CARDINALITY_MISSING, parent);
            }

            var cardinality = Cardinality.FromElementDefinition(definition);

            IBucket bucket;

            try
            {
                bucket = BucketFactory.CreateRoot(match.Definition, validator);
            }
            catch (NotImplementedException ni)
            {
                // Will throw if a non-supported slice type is encountered
                validator.Trace(outcome, ni.Message, Issue.UNSUPPORTED_SLICING_NOT_SUPPORTED, parent);
                return(outcome);
            }

            foreach (var element in match.InstanceElements)
            {
                var success = bucket.Add(element);

                // For the "root" slice group (=the original core element that was sliced, not resliced)
                // any element that does not match is an error
                // Since the ChildNameMatcher currently does the matching, this will never go wrong
            }

            outcome.Add(bucket.Validate(validator, parent));

            return(outcome);
        }
        private IBucket createSliceDefs()
        {
            var sd = _resolver.FindStructureDefinition("http://example.com/StructureDefinition/patient-telecom-reslice-ek");

            Assert.NotNull(sd);
            var snapgen = new SnapshotGenerator(_resolver);

            snapgen.Update(sd);

            // sd.Snapshot.Element.Where(e => e.Path.EndsWith(".telecom")).Select(e=>e.Path + " : " + e.Name ?? "").ToArray()

            var nav     = new ElementDefinitionNavigator(sd);
            var success = nav.JumpToFirst("Patient.telecom");

            Assert.True(success);
            //var xml = FhirSerializer.SerializeResourceToXml(sd);
            //File.WriteAllText(@"c:\temp\sdout.xml", xml);

            return(BucketFactory.CreateRoot(nav, _validator));
        }