Ejemplo n.º 1
0
        public void ResolveByCanonicalFromZip()
        {
            var extDefn = source.ResolveByCanonicalUri("http://hl7.org/fhir/StructureDefinition/data-absent-reason");
            Assert.IsNotNull(extDefn);
            Assert.IsInstanceOfType(extDefn, typeof(StructureDefinition));

            extDefn = source.ResolveByCanonicalUri("http://hl7.org/fhir/StructureDefinition/Patient");
            Assert.IsNotNull(extDefn);
            Assert.IsInstanceOfType(extDefn, typeof(StructureDefinition));

            extDefn = source.ResolveByCanonicalUri("http://hl7.org/fhir/StructureDefinition/Patient");
            Assert.IsNotNull(extDefn);
            Assert.IsInstanceOfType(extDefn, typeof(StructureDefinition));
        }
Ejemplo n.º 2
0
            public Resource ResolveByCanonicalUri(string uri)
            {
                if (_customSds.TryGetValue(uri, out var customSd))
                {
                    return(customSd);
                }

                return(_coreResolver.ResolveByCanonicalUri(uri));
            }
Ejemplo n.º 3
0
        public void ResolveByCanonicalFromZip()
        {
            var extDefn = source.ResolveByCanonicalUri("http://hl7.org/fhir/StructureDefinition/data-absent-reason");

            Assert.IsNotNull(extDefn);
            Assert.IsInstanceOfType(extDefn, typeof(StructureDefinition));

            extDefn = source.ResolveByCanonicalUri("http://hl7.org/fhir/StructureDefinition/Patient");
            Assert.IsNotNull(extDefn);
            Assert.IsInstanceOfType(extDefn, typeof(StructureDefinition));

            extDefn = source.ResolveByCanonicalUri("http://hl7.org/fhir/StructureDefinition/Patient");
            Assert.IsNotNull(extDefn);
            Assert.IsInstanceOfType(extDefn, typeof(StructureDefinition));

            var dirSource = new DirectorySource(@"TestData\validation");

            extDefn = dirSource.ResolveByCanonicalUri("http://example.com/StructureDefinition/patient-telecom-reslice-ek|1.0");

            Assert.ThrowsException <ArgumentException>(() => dirSource.ResolveByCanonicalUri("http://example.com/StructureDefinition/patient-telecom-reslice-ek|1.0|"));
        }
Ejemplo n.º 4
0
        public void ExpansionOfDefine()
        {
            var issueTypeVs = _resolver.ResolveByCanonicalUri("http://hl7.org/fhir/ValueSet/issue-type").DeepCopy() as ValueSet;

            Assert.False(issueTypeVs.HasExpansion);

            // Wipe the version so we don't have to update our tests all the time
            issueTypeVs.CodeSystem.Version = null;

            var expander = new ValueSetExpander();

            expander.Expand(issueTypeVs);

            Assert.True(issueTypeVs.HasExpansion);
            var id = issueTypeVs.Expansion.Identifier;

            Assert.NotNull(id);
            Assert.False(issueTypeVs.Expansion.Parameter.Any(c => c.Name == "version"));

            Assert.True(issueTypeVs.CodeInExpansion("security", "http://hl7.org/fhir/issue-type"));
            Assert.True(issueTypeVs.CodeInExpansion("expired", "http://hl7.org/fhir/issue-type"));
            Assert.Equal(29, issueTypeVs.ExpansionSize());
            Assert.Equal(issueTypeVs.ExpansionSize(), issueTypeVs.Expansion.Total);

            var trans = issueTypeVs.FindInExpansion("transient", "http://hl7.org/fhir/issue-type");

            Assert.NotNull(trans);
            Assert.NotNull(trans.FindCode("exception"));

            // Now, make this a versioned system
            issueTypeVs.CodeSystem.Version = "3.14";
            expander.Expand(issueTypeVs);
            Assert.NotEqual(id, issueTypeVs.Expansion.Identifier);
            Assert.Equal(29, issueTypeVs.ExpansionSize());

            var versionParam = issueTypeVs.Expansion.Parameter.Single(c => c.Name == "version");

            Assert.Equal("http://hl7.org/fhir/ValueSet/issue-type?version=3.14", ((FhirUri)versionParam.Value).Value);
        }
Ejemplo n.º 5
0
        public static StructureDefinition FindStructureDefinition(this IResourceResolver resolver, string uri, bool requireSnapshot = false)
        {
            var sd = resolver.ResolveByCanonicalUri(uri) as StructureDefinition;

            if (sd == null)
            {
                return(null);
            }

            if (sd.Snapshot == null && requireSnapshot)
            {
                return(null);
            }

            return(sd);
        }
Ejemplo n.º 6
0
        public static StructureDefinition FindExtensionDefinition(this IResourceResolver resolver, string uri, bool requireSnapshot = false)
        {
            var sd = resolver.ResolveByCanonicalUri(uri) as StructureDefinition;

            if (sd == null)
            {
                return(null);
            }

            if (!sd.IsExtension)
            {
                throw Error.Argument(nameof(uri), "Given uri exists as a StructureDefinition, but is not an extension");
            }

            if (sd.Snapshot == null && requireSnapshot)
            {
                return(null);
            }

            return(sd);
        }
            public Resource ResolveByCanonicalUri(string uri)
            {
                var result = _resolver.ResolveByCanonicalUri(uri);

                return(clearSnapshot(result));
            }
Ejemplo n.º 8
0
 /// <summary>
 /// Tries to locate a valueset using a combined algorithm: first, the uri is used to find a valueset by system.
 /// If that fails, the valueset is searched for by canonical url. Failing that, the function tries to locate the
 /// valueset by resource url.
 /// </summary>
 /// <param name="source"></param>
 /// <param name="uri"></param>
 /// <returns></returns>
 public static ValueSet FindValueSet(this IResourceResolver source, string uri)
 {
     return(source.ResolveByCanonicalUri(uri) as ValueSet);
 }