コード例 #1
0
        private String describeCardinality(Profile.ElementDefinitionComponent definition, Profile.ElementDefinitionComponent fallback, UnusedTracker tracker)
        {
            var min = definition.Min;
            var max = definition.Max;

            if (min == null && fallback != null)
            {
                min = fallback.Min;
            }
            if (max == null && fallback != null)
            {
                max = fallback.Max;
            }

            tracker.used = max == null || !(max == "0");

            if (min == null && max == null)
            {
                return(null);
            }
            else
            {
                return(min == null ? "" : min.ToString() + ".." + (max == null ? "" : max));
            }
        }
コード例 #2
0
 private void generateElementInner(Profile profile, Profile.ElementDefinitionComponent d)
 {
     tableRowMarkdown("Definition", d.Formal, profile);
     tableRow("Control", "conformance-rules.html#conformance", d.DescribeCardinality() + summariseConditions(d.Condition));
     tableRowNE("Binding", "terminologies.html", describeBinding(d));
     if (d.NameReference != null)
     {
         tableRow("Type", null, "See " + d.NameReference);
     }
     else
     {
         tableRowNE("Type", "datatypes.html", describeTypes(profile, d.Type));
     }
     tableRow("Is Modifier", "conformance-rules.html#ismodifier", displayBoolean(d.IsModifier));
     tableRow("Must Support", "conformance-rules.html#mustSupport", displayBoolean(d.MustSupport));
     tableRowMarkdown("Requirements", d.Requirements, profile);
     tableRow("Aliases", null, d.Synonym != null ? String.Join(", ", d.Synonym) : null);
     tableRowMarkdown("Comments", d.Comments, profile);
     tableRow("Max Length", null, d.MaxLength == null ? null : d.MaxLength.ToString());
     tableRow("Fixed Value", null, d.Value != null ? d.Value.ForDisplay() : null);
     tableRow("Example", null, d.Example != null ? d.Example.ForDisplay() : null);
     tableRowNE("Invariants", null, describeInvariants(d.Constraint));
     tableRow("LOINC Code", null, getMapping(profile, d, LOINC_MAPPING));
     tableRow("SNOMED-CT Code", null, getMapping(profile, d, SNOMED_MAPPING));
 }
コード例 #3
0
        private void HarvestCardinality(Profile.ElementDefinitionComponent source, Element target)
        {
            Cardinality cardinality = new Cardinality();

            cardinality.Min    = source.Min.ToString();
            cardinality.Max    = source.Max;
            target.Cardinality = cardinality;
        }
コード例 #4
0
 private String describeBinding(Profile.ElementDefinitionComponent d)
 {
     if (d.Binding == null)
     {
         return(null);
     }
     else
     {
         return(d.Binding.ForHtml(_pkp));
     }
 }
コード例 #5
0
 public static string DescribeCardinality(this Profile.ElementDefinitionComponent defn)
 {
     if (defn.Max == null || defn.Max == "-1")
     {
         return(defn.Min.ToString() + "..*");
     }
     else
     {
         return(defn.Min.ToString() + ".." + defn.Max);
     }
 }
コード例 #6
0
 private void HarvestElementDefinition(Profile.ElementDefinitionComponent source, Element target)
 {
     if (source != null)
     {
         HarvestBinding(source, target);
         HarvestTypeRefs(source, target);
         HarvestElementRef(source, target);
         HarvestCardinality(source, target);
         HarvestConstraints(source, target);
         HarvestFixedValue(source, target);
     }
 }
コード例 #7
0
        private void HarvestTypeRefs(Profile.ElementDefinitionComponent source, Element target)
        {
            if (source.Type == null)
            {
                return;
            }

            foreach (var type in source.Type)
            {
                target.TypeRefs.Add(HarvestTypeRef(type));
            }
        }
コード例 #8
0
        private void HarvestConstraints(Profile.ElementDefinitionComponent source, Element target)
        {
            if (source.Constraint == null)
            {
                return;
            }

            foreach (Profile.ElementDefinitionConstraintComponent c in source.Constraint)
            {
                Constraint constraint = new Constraint();
                constraint.Name          = c.Name ?? c.Key;
                constraint.XPath         = c.Xpath;
                constraint.HumanReadable = c.Human;
                target.Constraints.Add(constraint);
            }
        }
コード例 #9
0
        private void HarvestBinding(Profile.ElementDefinitionComponent source, Element target)
        {
            if (source.Binding != null)
            {
                var reference = source.Binding.Reference;

                if (reference is ResourceReference)
                {
                    // todo: dit deel is nog niet getest.
                    target.BindingUri = (reference as ResourceReference).Url.ToString();
                }
                else if (reference is FhirUri)
                {
                    target.BindingUri = (reference as FhirUri).Value;
                }
            }
        }
コード例 #10
0
        private String getMapping(Profile profile, Profile.ElementDefinitionComponent d, String uri)
        {
            if (profile.Mapping == null)
            {
                return(null);
            }
            if (d.Mapping == null)
            {
                return(null);
            }

            String id = profile.Mapping.Where(map => map.Uri == uri).Select(map => map.Identity).FirstOrDefault();

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

            return(d.Mapping.Where(map => map.Identity == id).Select(map => map.Map).FirstOrDefault());
        }
コード例 #11
0
        public static bool InRange(this Profile.ElementDefinitionComponent defn, int count)
        {
            int min = Convert.ToInt32(defn.Min);

            if (count < min)
            {
                return(false);
            }

            if (defn.Max == "*")
            {
                return(true);
            }

            int max = Convert.ToInt32(defn.Max);

            if (count > max)
            {
                return(false);
            }

            return(true);
        }
コード例 #12
0
 private void HarvestFixedValue(Profile.ElementDefinitionComponent source, Element target)
 {
     target.FixedValue = (source.Value != null)
         ? source.Value.ToString()
         : null;
 }
コード例 #13
0
        private Cell generateDescription(HierarchicalTableGenerator gen, Row row, Profile.ElementComponent element, Profile.ElementDefinitionComponent fallback, bool used, String baseURL, String profileUrl, Profile profile)
        {
            Cell c = new Cell();

            row.getCells().Add(c);

            if (used)
            {
                if (element.Definition != null && element.Definition.Short != null)
                {
                    if (c.getPieces().Any())
                    {
                        c.addPiece(new Piece("br"));
                    }
                    c.addPiece(new Piece(null, element.Definition.Short, null));
                }
                else if (fallback != null && fallback.Short != null)
                {
                    if (c.getPieces().Any())
                    {
                        c.addPiece(new Piece("br"));
                    }
                    c.addPiece(new Piece(null, fallback.Short, null));
                }

                if (profileUrl != null)
                {
                    if (c.getPieces().Any())
                    {
                        c.addPiece(new Piece("br"));
                    }
                    String fullUrl   = profileUrl.StartsWith("#") ? baseURL + profileUrl : profileUrl;
                    String reference = _pkp.getLinkForExtension(profile, profileUrl);
                    c.getPieces().Add(new Piece(null, "URL: ", null).addStyle("font-weight:bold"));
                    c.getPieces().Add(new Piece(reference, fullUrl, null));
                }

                if (element.Slicing != null)
                {
                    if (c.getPieces().Any())
                    {
                        c.addPiece(new Piece("br"));
                    }
                    c.getPieces().Add(new Piece(null, "Slice: ", null).addStyle("font-weight:bold"));
                    c.getPieces().Add(new Piece(null, describeSlice(element.Slicing), null));
                }

                if (element.Definition != null)
                {
                    if (element.Definition.Binding != null)
                    {
                        if (c.getPieces().Any())
                        {
                            c.addPiece(new Piece("br"));
                        }
                        String reference = _pkp.resolveBinding(element.Definition.Binding);
                        c.getPieces().Add(new Piece(null, "Binding: ", null).addStyle("font-weight:bold"));
                        c.getPieces().Add(new Piece(reference, element.Definition.Binding.Name, null));
                    }

                    if (element.Definition.Constraint != null)
                    {
                        foreach (Profile.ElementDefinitionConstraintComponent inv in element.Definition.Constraint)
                        {
                            if (c.getPieces().Any())
                            {
                                c.addPiece(new Piece("br"));
                            }
                            c.getPieces().Add(new Piece(null, "Inv-" + inv.Key + ": ", null).addStyle("font-weight:bold"));
                            c.getPieces().Add(new Piece(null, inv.Human, null));
                        }
                    }

                    if (element.Definition.Value != null)
                    {
                        if (c.getPieces().Any())
                        {
                            c.addPiece(new Piece("br"));
                        }
                        c.getPieces().Add(new Piece(null, "Fixed Value: ", null).addStyle("font-weight:bold"));
                        c.getPieces().Add(new Piece(null, element.Definition.Value.RenderValue(), null));
                    }

                    // ?? example from definition
                }
            }

            return(c);
        }
コード例 #14
0
        private void genTypes(HierarchicalTableGenerator gen, Row r, Profile.ElementDefinitionComponent elementDefn, String profileBaseFileName, Profile profile)
        {
            Cell c = new Cell();

            r.getCells().Add(c);

            if (elementDefn.Type == null)
            {
                return;
            }

            bool first = true;

            foreach (Profile.TypeRefComponent t in elementDefn.Type)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    c.addPiece(new Piece(null, ", ", null));
                }

                if (t.Code == "ResourceReference" || (t.Code == "Resource" && t.Profile != null))
                {
                    if (t.Profile.StartsWith("http://hl7.org/fhir/Profile/"))
                    {
                        String rn = t.Profile.Substring(28);
                        c.addPiece(new Piece(_pkp.getLinkFor(rn), rn, null));
                    }
                    else if (t.Profile.StartsWith("#"))
                    {
                        c.addPiece(new Piece(profileBaseFileName + "." + t.Profile.Substring(1).ToLower() + ".html", t.Profile, null));
                    }
                    else
                    {
                        c.addPiece(new Piece(t.Profile, t.Profile, null));
                    }
                }
                else if (t.Profile != null)
                { // a profiled type
                    String reference = _pkp.getLinkForProfile(profile, t.Profile);
                    if (reference != null)
                    {
                        String[] parts = reference.Split('|');      //TODO: Not too sure, was: String[] parts = ref.split("\\|"); in Java
                        c.addPiece(new Piece(parts[0], parts[1], t.Code));
                    }
                    else
                    {
                        c.addPiece(new Piece(reference, t.Code, null));
                    }
                }
                else if (_pkp.hasLinkFor(t.Code))
                {
                    c.addPiece(new Piece(_pkp.getLinkFor(t.Code), t.Code, null));
                }
                else
                {
                    c.addPiece(new Piece(null, t.Code, null));
                }
            }
        }
コード例 #15
0
        private void genTypes(HierarchicalTableGenerator gen, Row r, Profile.ElementDefinitionComponent elementDefn, Profile profile)
        {
            Cell c = new Cell();

            r.getCells().Add(c);

            if (elementDefn.Type == null)
            {
                return;
            }

            bool first = true;

            foreach (Profile.TypeRefComponent t in elementDefn.Type)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    c.addPiece(new Piece(null, ", ", null));
                }

                if (t.Code == "ResourceReference" || (t.Code == "Resource" && t.Profile != null))
                {
                    var reference = _pkp.GetLinkForProfileReference(profile, t.Profile);
                    var label     = _pkp.GetLabelForProfileReference(profile, t.Profile);

                    if (t.Profile.StartsWith("http://hl7.org/fhir/Profile/"))
                    {
                        String rn = t.Profile.Substring(28);
                        c.addPiece(new Piece(_pkp.GetLinkForTypeDocu(rn), rn, null));
                    }
                    else if (t.Profile.StartsWith("#"))
                    {
                        c.addPiece(new Piece(_pkp.GetLinkForLocalStructure(profile, t.Profile.Substring(1)), t.Profile, null));
                    }
                    else
                    {
                        c.addPiece(new Piece(t.Profile, t.Profile, null));
                    }
                }
                else if (t.Profile != null)
                { // a profiled type
                    var reference = _pkp.GetLinkForProfileReference(profile, t.Profile);
                    var label     = _pkp.GetLabelForProfileReference(profile, t.Profile);

                    if (reference != null)
                    {
                        String[] parts = reference.Split('|');      //TODO: Not too sure, was: String[] parts = ref.split("\\|"); in Java
                        c.addPiece(new Piece(reference, label, t.Code));
                    }
                    else
                    {
                        c.addPiece(new Piece(reference, t.Code, null));
                    }
                }
                else if (_pkp.HasLinkForTypeDocu(t.Code))
                {
                    c.addPiece(new Piece(_pkp.GetLinkForTypeDocu(t.Code), t.Code, null));
                }
                else
                {
                    c.addPiece(new Piece(null, t.Code, null));
                }
            }
        }
コード例 #16
0
        private void mergeElementDefnAttributes(Profile.ElementDefinitionComponent snap, Profile.ElementDefinitionComponent diff)
        {
            if (diff.ShortElement != null)
            {
                snap.ShortElement = (FhirString)diff.ShortElement.DeepCopy();
            }
            if (diff.FormalElement != null)
            {
                snap.FormalElement = (FhirString)diff.FormalElement.DeepCopy();
            }
            if (diff.CommentsElement != null)
            {
                snap.CommentsElement = (FhirString)diff.CommentsElement.DeepCopy();
            }
            if (diff.RequirementsElement != null)
            {
                snap.RequirementsElement = (FhirString)diff.RequirementsElement.DeepCopy();
            }

            if (diff.SynonymElement != null)
            {
                if (snap.SynonymElement == null)
                {
                    snap.SynonymElement = new List <FhirString>();
                }

                // Add new synonyms to the snap, and replace existing ones
                foreach (var dsyn in diff.SynonymElement)
                {
                    snap.SynonymElement.Remove(snap.SynonymElement.FirstOrDefault(ssyn => ssyn.Value == dsyn.Value));
                    snap.SynonymElement.Add((FhirString)dsyn.DeepCopy());
                }
                // Original code from Java leaves snapshot untouched when encountering an existing synonym,but
                // this means differential can not override e.g. extensions in such synonyms.
                //var newSynonyms = from dsyn in diff.SynonymElement
                //                  where !snap.SynonymElement.Any(ssyn => ssyn.Value == dsyn.Value)
                //                  select (FhirString)dsyn.DeepCopy();
                //snap.SynonymElement.AddRange(newSynonyms);
            }

            if (diff.MinElement != null)
            {
                snap.MinElement = (Integer)diff.MinElement.DeepCopy();
            }
            if (diff.MaxElement != null)
            {
                snap.MaxElement = (FhirString)diff.MaxElement.DeepCopy();
            }

            // ElementDefinition.nameReference cannot be overridden by a derived profile

            if (diff.Fixed != null)
            {
                snap.Fixed = (Element)diff.Fixed.DeepCopy();
            }
            if (diff.Pattern != null)
            {
                snap.Pattern = (Element)diff.Pattern.DeepCopy();
            }
            if (diff.Example != null)
            {
                snap.Example = (Element)diff.Example.DeepCopy();
            }
            if (diff.MaxLengthElement != null)
            {
                snap.MaxLengthElement = (Integer)diff.MaxLengthElement.DeepCopy();
            }

            // todo: [GG] what to do about conditions?  [EK] Since me made ElementDefinition.Constrain cumulative, these need to be cumulative too?
            if (diff.ConditionElement != null && diff.ConditionElement.Any())
            {
                if (snap.ConditionElement == null)
                {
                    snap.ConditionElement = new List <Id>();
                }
                snap.ConditionElement.AddRange(diff.ConditionElement.DeepCopy());
            }

            if (diff.MustSupportElement != null)
            {
                snap.MustSupportElement = (FhirBoolean)diff.MustSupportElement.DeepCopy();
            }

            // ElementDefinition.isModifier cannot be overridden by a derived profle
            if (diff.IsSummaryElement != null)
            {
                snap.IsSummaryElement = (FhirBoolean)diff.IsSummaryElement.DeepCopy();
            }

            if (diff.Binding != null)
            {
                snap.Binding = (Profile.ElementDefinitionBindingComponent)diff.Binding.DeepCopy();
            }

            // todo: [GG] is this actually right?  [EK] I think it is, at least this is what Forge expects as well
            if (diff.Type != null && diff.Type.Any())
            {
                snap.Type = new List <Profile.TypeRefComponent>(diff.Type.DeepCopy());
            }

            // todo: [GG] mappings are cumulative - or does one replace another?
            if (diff.Mapping != null && diff.Mapping.Any())
            {
                if (snap.Mapping == null)
                {
                    snap.Mapping = new List <Profile.ElementDefinitionMappingComponent>();
                }
                snap.Mapping.AddRange(diff.Mapping.DeepCopy());
            }

            // todo: constraints are cumulative - or does one replace another?
            if (diff.Constraint != null && diff.Constraint.Any())
            {
                if (snap.Constraint == null)
                {
                    snap.Constraint = new List <Profile.ElementDefinitionConstraintComponent>();
                }
                snap.Constraint.AddRange(diff.Constraint.DeepCopy());
            }
        }
コード例 #17
0
 private void HarvestElementRef(Profile.ElementDefinitionComponent source, Element target)
 {
     target.ElementRefPath = source.NameReference;
 }
コード例 #18
0
 public static bool IsRepeating(this Profile.ElementDefinitionComponent defn)
 {
     return(defn.Max != "1" && defn.Max != "0");
 }
コード例 #19
0
 public static string DescribeTypeCode(this Profile.ElementDefinitionComponent defn)
 {
     return(String.Join(" | ", defn.Type.Select(tr => tr.Code)));
 }
コード例 #20
0
 public static string CardinalityAsString(this Profile.ElementDefinitionComponent defn)
 {
     return(defn.Min + ".." + defn.Max);
 }