public void BreastAbnormality() { String zipPath = Path.Combine("TestFiles", "BreastRadiology.zip"); using (ZipArchive archive = ZipFile.OpenRead(zipPath)) { FhirJsonParser fjp = new FhirJsonParser(); foreach (ZipArchiveEntry entry in archive.Entries) { if (entry.FullName.EndsWith(".json", StringComparison.OrdinalIgnoreCase)) { StructureDefinition profile; using (StreamReader streamReader = new StreamReader(entry.Open())) { String jsonText = streamReader.ReadToEndAsync().WaitResult(); profile = fjp.Parse <StructureDefinition>(jsonText); } SliceGenerator sliceGen = new SliceGenerator(SliceGenerator.OutputLanguageType.CSharp, OutputNameSpace, GenDir); //sliceGen.SaveFlag = false; sliceGen.AddProfile(profile); bool success = sliceGen.Process(); StringBuilder sb = new StringBuilder(); sliceGen.FormatMessages(sb); Trace.WriteLine(sb.ToString()); Assert.True(success == true); } } } }
void ProcessFile(String filePath) { if (File.Exists(filePath) == false) { throw new Exception($"File {this.inputFile} does not exist"); } SliceGenerator p = new SliceGenerator(this.outputLanguage, this.nameSpace, this.outputDir); p.AddProfile(filePath); bool success = p.Process(); if (success == false) { throw new Exception($"SliceGenerator returned failure"); } }
public void SlicedNested() { SliceGenerator sliceGen = new SliceGenerator(SliceGenerator.OutputLanguageType.CSharp, OutputNameSpace, GenDir); StructureDefinition profile = CreateObservation("SlicedNested"); { ElementDefinition e = profile.Differential.Element.GetOrCreateElement("Observation.component"); e.Slicing = new ElementDefinition.SlicingComponent { ElementId = "ObservationComponentSlice", Ordered = false, Rules = ElementDefinition.SlicingRules.Open }; e.Slicing.Discriminator.Add(new ElementDefinition.DiscriminatorComponent { Type = ElementDefinition.DiscriminatorType.Value, Path = "code" }); } { ElementDefinition e = new ElementDefinition { ElementId = "Observation.component:Slice1", Path = "Observation.component", SliceName = "Slice1" }; profile.Differential.Element.Add(e); } { ElementDefinition e = new ElementDefinition { Path = "Observation.component.code", ElementId = "Observation.component:Slice1.code", Fixed = new CodeableConcept("system", "Slice3aCode") }; profile.Differential.Element.Add(e); } { ElementDefinition e = new ElementDefinition { Path = "Observation.component.code.coding", ElementId = "Observation.component:Slice1.code.coding", }; profile.Differential.Element.Add(e); e.Slicing = new ElementDefinition.SlicingComponent { ElementId = "ObservationComponentSlice1", Ordered = false, Rules = ElementDefinition.SlicingRules.Open }; e.Slicing.Discriminator.Add(new ElementDefinition.DiscriminatorComponent { Type = ElementDefinition.DiscriminatorType.Value, Path = "code" }); } { ElementDefinition e = new ElementDefinition { Path = "Observation.component.code.coding.code", ElementId = "Observation.component:Slice1.code.coding.code", Fixed = new Code("Slice3aCode") }; profile.Differential.Element.Add(e); } SnapshotCreator.Create(profile); String outputPath = $@"\Temp\SlicedNested.json"; profile.SaveJson(outputPath); //FhirValidator f = new FhirValidator(); //{ // bool success = f.Validate("4.0.0", outputPath); // StringBuilder sb = new StringBuilder(); // f.FormatMessages(sb); // Trace.WriteLine(sb.ToString()); // Assert.True(success == true); //} sliceGen.AddProfile(profile); { bool success = sliceGen.Process(); StringBuilder sb = new StringBuilder(); sliceGen.FormatMessages(sb); Trace.WriteLine(sb.ToString()); Assert.True(success == true); } }