public void MergeCode() { try { // should work. PreFhirGenerator p = this.CreatePreFhir(); StructureDefinition pBase = this.CreateBaseProfile(); StructureDefinition frag = this.CreateFragment("Fragment", "http://www.test.com/frag1"); // use snapshot min and max in base check. { ElementDefinition e = new ElementDefinition { Path = "Observation.category", ElementId = "Observation.category" }; e.Code.Add(new Coding("s-base", "c-base")); pBase.AddSnapElement(e); } String fragRoot = frag.Differential.Element[0].Path; { ElementDefinition e = new ElementDefinition { Path = $"{fragRoot}.category", ElementId = $"{fragRoot}.category", }; e.Code.Add(new Coding("s-frag", "c-frag")); frag.AddDiffElement(e); } pBase.AddFragRef(frag); p.AddFragment(pBase); p.AddFragment(frag); Assert.True(p.Process() == true); StringBuilder sb = new StringBuilder(); p.FormatMessages(sb); Trace.WriteLine(sb.ToString()); Assert.True(p.HasErrors == false); Assert.True(pBase.Differential.Element.Count == 2); { ElementDefinition category = pBase.Differential.Element[1]; Assert.True(category.Path == "Observation.category"); Assert.True(category.Code.Count == 2); Assert.True(category.Code[0].System == "s-base"); Assert.True(category.Code[1].System == "s-frag"); } } catch { Assert.False(true); } }
public void Create() { try { StructureDefinition pBase = this.CreateBaseProfile(); Assert.True(pBase.BaseDefinition == "http://hl7.org/fhir/StructureDefinition/Observation"); Assert.True(pBase.Type == "Observation"); Assert.True(pBase.Kind == StructureDefinition.StructureDefinitionKind.Resource); Assert.True(pBase.Abstract == false); SnapshotCreator.Create(pBase); StructureDefinition frag = this.CreateFragment("Fragment", "http://www.test.com/frag1"); Assert.True(frag.FhirVersion == FhirVersion); Assert.True(frag.Kind == StructureDefinition.StructureDefinitionKind.Logical); Assert.True(frag.Abstract == true); PreFhirGenerator p = this.CreatePreFhir(); frag.FhirVersion = FHIRVersion.N0_01; frag.Version = ProfileVersion; frag.Date = this.date.ToString(); frag.Status = ProfileStatus; frag.Publisher = "Hl7-Clinical Interoperability Council"; frag.Contact = this.Contact(); pBase.AddFragRef(frag); p.AddFragment(pBase); p.AddFragment(frag); Assert.True(p.Process() == true); StringBuilder sb = new StringBuilder(); p.FormatMessages(sb); Trace.WriteLine(sb.ToString()); Assert.True(p.HasErrors == false); Assert.True(pBase.FhirVersion == FHIRVersion.N0_01); Assert.True(pBase.Version == ProfileVersion); Assert.True(pBase.Date == this.date.ToString()); Assert.True(pBase.Status == ProfileStatus); Assert.True(pBase.Publisher == "Hl7-Clinical Interoperability Council"); Assert.True(pBase.Contact.Matches(this.Contact())); } catch { Assert.False(true); } }
public void MergeTypes2() { try { PreFhirGenerator p = this.CreatePreFhir(); StructureDefinition pBase = this.CreateBaseProfile(); StructureDefinition frag = this.CreateFragment("Fragment", "http://www.test.com/frag1"); String fragRoot = frag.Differential.Element[0].Path; { ElementDefinition e = new ElementDefinition { Path = "Observation.value[x]", ElementId = "Observation.value[x]" }; e.Type.Add(new ElementDefinition.TypeRefComponent { Code = "integer" }); e.Type.Add(new ElementDefinition.TypeRefComponent { Code = "decimal" }); pBase.AddSnapElement(e); } { ElementDefinition e = new ElementDefinition { Path = $"{fragRoot}.value[x]", ElementId = $"{fragRoot}.value[x]", }; e.Type.Add(new ElementDefinition.TypeRefComponent { Code = "string" }); frag.AddDiffElement(e); } pBase.AddFragRef(frag); p.AddFragment(pBase); p.AddFragment(frag); Assert.True(p.Process() == false); } catch { Assert.False(true); } }
public void MergeTypes1() { try { // should work. PreFhirGenerator p = this.CreatePreFhir(); StructureDefinition pBase = this.CreateBaseProfile(); SnapshotCreator.Create(pBase); StructureDefinition frag = this.CreateFragment("Fragment", "http://www.test.com/frag1"); String fragRoot = frag.Differential.Element[0].Path; { ElementDefinition e = new ElementDefinition { Path = $"{fragRoot}.value[x]", ElementId = $"{fragRoot}.value[x]", Min = 1, Max = "1" }; e.Type.Add(new ElementDefinition.TypeRefComponent { Code = "string" }); frag.AddDiffElement(e); } pBase.AddFragRef(frag); p.AddFragment(pBase); p.AddFragment(frag); Assert.True(p.Process() == true); StringBuilder sb = new StringBuilder(); p.FormatMessages(sb); Trace.WriteLine(sb.ToString()); Assert.True(p.HasErrors == false); Assert.True(pBase.Differential.Element.Count == 2); Assert.True(pBase.Differential.Element[1].Min == 1); Assert.True(pBase.Differential.Element[1].Max == "1"); Assert.True(pBase.Differential.Element[1].Type.Count == 1); Assert.True(pBase.Differential.Element[1].Type[0].Code == "string"); } catch { Assert.False(true); } }
public void MergeCardinalities4() { try { // should work. PreFhirGenerator p = this.CreatePreFhir(); StructureDefinition pBase = this.CreateBaseProfile(); StructureDefinition frag = this.CreateFragment("Fragment", "http://www.test.com/frag1"); pBase.AddSnapElement(new ElementDefinition { Path = "Observation.partOf", ElementId = "Observation.partOf", Min = 0, Max = "*", }); String fragRoot = frag.Differential.Element[0].Path; frag.AddDiffElement(new ElementDefinition { Path = $"{fragRoot}.partOf", ElementId = $"{fragRoot}.partOf", Min = 1, Max = "2", }); pBase.AddFragRef(frag); p.AddFragment(pBase); p.AddFragment(frag); Assert.True(p.Process() == true); StringBuilder sb = new StringBuilder(); p.FormatMessages(sb); Trace.WriteLine(sb.ToString()); Assert.True(p.HasErrors == false); Assert.True(pBase.Differential.Element.Count == 2); Assert.True(pBase.Differential.Element[1].Min == 1); Assert.True(pBase.Differential.Element[1].Max == "2"); } catch { Assert.False(true); } }
public void MergeLabelErr() { try { // should work. PreFhirGenerator p = this.CreatePreFhir(); StructureDefinition pBase = this.CreateBaseProfile(); StructureDefinition frag = this.CreateFragment("Fragment", "http://www.test.com/frag1"); // use snapshot min and max in base check. pBase.AddSnapElement(new ElementDefinition { Path = "Observation.category", ElementId = "Observation.category", Label = "1234" }); String fragRoot = frag.Differential.Element[0].Path; { ElementDefinition e = new ElementDefinition { Path = $"{fragRoot}.category", ElementId = $"{fragRoot}.category", Label = "xxyyz" }; frag.AddDiffElement(e); } pBase.AddFragRef(frag); p.AddFragment(pBase); p.AddFragment(frag); Assert.True(p.Process() == false); } catch { Assert.False(true); } }
public void CheckBaseCompatability() { try { // Verify merge failes if different fhir versions. PreFhirGenerator p = this.CreatePreFhir(); StructureDefinition pBase = this.CreateBaseProfile(); StructureDefinition frag = this.CreateFragment("Fragment", "http://www.test.com/frag1"); frag.FhirVersion = FHIRVersion.N0_01; pBase.AddFragRef(frag); p.AddFragment(pBase); p.AddFragment(frag); Assert.True(p.Process() == true); StringBuilder sb = new StringBuilder(); p.FormatMessages(sb); Trace.WriteLine(sb.ToString()); Assert.True(p.HasErrors == false); } catch { Assert.False(true); } }
public void MergeSlicing() { try { // should work. PreFhirGenerator p = this.CreatePreFhir(); StructureDefinition pBase = this.CreateBaseProfile(); StructureDefinition frag = this.CreateFragment("Fragment", "http://www.test.com/frag1"); // use snapshot min and max in base check. pBase.AddSnapElement(new ElementDefinition { Path = "Observation.category", ElementId = "Observation.category" }); String fragRoot = frag.Differential.Element[0].Path; { ElementDefinition e = new ElementDefinition { Path = $"{fragRoot}.category", ElementId = $"{fragRoot}.category", Slicing = new ElementDefinition.SlicingComponent { Description = "Slicing description", Ordered = true, Rules = ElementDefinition.SlicingRules.OpenAtEnd } }; e.Slicing.Discriminator.Add(new ElementDefinition.DiscriminatorComponent { Type = ElementDefinition.DiscriminatorType.Value, Path = "coding" }); frag.AddDiffElement(e); } pBase.AddFragRef(frag); p.AddFragment(pBase); p.AddFragment(frag); Assert.True(p.Process() == true); StringBuilder sb = new StringBuilder(); p.FormatMessages(sb); Trace.WriteLine(sb.ToString()); Assert.True(p.HasErrors == false); Assert.True(pBase.Differential.Element.Count == 2); { ElementDefinition category = pBase.Differential.Element[1]; Assert.True(category.Path == "Observation.category"); Assert.True(category.Slicing != null); Assert.True(category.Slicing.Discriminator.Count == 1); Assert.True(category.Slicing.Discriminator[0].Type == ElementDefinition.DiscriminatorType.Value); Assert.True(category.Slicing.Discriminator[0].Path == "coding"); Assert.True(category.Slicing.Description == "Slicing description"); Assert.True(category.Slicing.Ordered == true); Assert.True(category.Slicing.Rules == ElementDefinition.SlicingRules.OpenAtEnd); } } catch { Assert.False(true); } }
public void MergeFrag1() { try { // should work. PreFhirGenerator p = this.CreatePreFhir(); StructureDefinition pBase = this.CreateBaseProfile(); { ElementDefinition e = new ElementDefinition { Path = $"Observation.category", ElementId = $"Observation.category", Min = 0, Max = "*" }; pBase.AddSnapElement(e); } { ElementDefinition e = new ElementDefinition { Path = $"Observation.effective[x]", ElementId = $"Observation.effective[x]", Min = 0, Max = "*" }; e.Type.Add(new ElementDefinition.TypeRefComponent { Code = "integer" }); e.Type.Add(new ElementDefinition.TypeRefComponent { Code = "dateTime" }); pBase.AddSnapElement(e); } { ElementDefinition e = new ElementDefinition { Path = "Observation.value[x]", ElementId = "Observation.value[x]" }; pBase.AddSnapElement(e); e.Type.Add(new ElementDefinition.TypeRefComponent { Code = "string" }); e.Type.Add(new ElementDefinition.TypeRefComponent { Code = "decimal" }); e.Type.Add(new ElementDefinition.TypeRefComponent { Code = "coding" }); } StructureDefinition frag1 = this.CreateFragment("Frag1", "http://www.test.com/frag1"); StructureDefinition frag2 = this.CreateFragment("Frag2", "http://www.test.com/frag2"); StructureDefinition frag3 = this.CreateFragment("Frag3", "http://www.test.com/frag3"); { ElementDefinition e = new ElementDefinition { Path = $"Frag1.value[x]", ElementId = $"Frag1.value[x]", }; e.Type.Add(new ElementDefinition.TypeRefComponent { Code = "string" }); frag1.AddDiffElement(e); } { ElementDefinition e = new ElementDefinition { Path = $"Frag2.effective[x]", ElementId = $"Frag2.effective[x]", Min = 1 }; e.Type.Add(new ElementDefinition.TypeRefComponent { Code = "dateTime" }); frag2.AddDiffElement(e); } { ElementDefinition e = new ElementDefinition { Path = $"Frag3.category", ElementId = $"Frag3.category", Min = 1, Max = "1" }; frag3.AddDiffElement(e); } pBase.AddFragRef(frag1); frag1.AddFragRef(frag2); frag2.AddFragRef(frag3); p.AddFragment(pBase); p.AddFragment(frag1); p.AddFragment(frag2); p.AddFragment(frag3); Assert.True(p.Process() == true); StringBuilder sb = new StringBuilder(); p.FormatMessages(sb); Trace.WriteLine(sb.ToString()); Assert.True(p.HasErrors == false); Assert.True(frag2.Differential.Element.Count == 3); Assert.True(frag1.Differential.Element.Count == 4); Assert.True(pBase.Differential.Element.Count == 4); Assert.True(pBase.Differential.Element[1].Path == "Observation.category"); Assert.True(pBase.Differential.Element[2].Path == "Observation.effective[x]"); Assert.True(pBase.Differential.Element[2].Type.Count == 1); Assert.True(pBase.Differential.Element[2].Type[0].Code == "dateTime"); Assert.True(pBase.Differential.Element[3].Path == "Observation.value[x]"); Assert.True(pBase.Differential.Element[3].Type.Count == 1); Assert.True(pBase.Differential.Element[3].Type[0].Code == "string"); } catch { Assert.False(true); } }