Exemplo n.º 1
0
        /// <summary>
        /// Create a value set of all the codes in the passed code system.
        /// </summary>
        ValueSet CreateValueSet(String name,
                                String title,
                                String mapName,
                                String description,
                                String groupPath,
                                CodeSystem cs = null)
        {
            ValueSet vs = new ValueSet
            {
                Id          = name,
                Url         = $"http://hl7.org/fhir/us/breast-radiology/ValueSet/{name}",
                Name        = name,
                Title       = title,
                Description = new Markdown(description)
            };

            vs.AddFragRef(this.HeaderFragment);

            // store groupPath as an extension. This is an unregistered extension that will be removed before
            // processing is complete.
            vs.Extension.Add(new Extension
            {
                Url   = Global.GroupExtensionUrl,
                Value = new FhirString(groupPath)
            });

            this.resources.Add(Path.Combine(this.resourceDir, $"ValueSet-{name}.json"), vs);
            Debug.Assert(mapName.Contains("Tumor Satellite") == false);
            vs.AddExtension(Global.ResourceMapNameUrl, new FhirString(mapName));

            if (cs == null)
            {
                return(vs);
            }

            ValueSet.ConceptSetComponent vsComp = new ValueSet.ConceptSetComponent
            {
                System = cs.Url
            };

            vs.Compose = new ValueSet.ComposeComponent();
            vs.Compose.Include.Add(vsComp);

            foreach (var code in cs.Concept)
            {
                vsComp.Concept.Add(new ValueSet.ConceptReferenceComponent
                {
                    Code    = code.Code,
                    Display = code.Display
                });
            }

            return(vs);
        }