Пример #1
0
        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);
                    }
                }
            }
        }
Пример #2
0
        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");
            }
        }
Пример #3
0
 public GenerateItem(SliceGenerator gen,
                     String nameSpace,
                     String className,
                     String profileType,
                     Type fhirType,
                     OutputLanguageType outputLanguage,
                     ElementDefinitionNode profileElements)
 {
     this.gen             = gen;
     this.nameSpace       = nameSpace;
     this.className       = className;
     this.fhirType        = fhirType;
     this.outputLanguage  = outputLanguage;
     this.profileElements = profileElements;
     this.profileType     = profileType;
 }
Пример #4
0
        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);
            }
        }
Пример #5
0
 public CSCodeFormatter(SliceGenerator gen)
 {
     this.Gen  = gen;
     this.code = new CodeEditor();
 }
Пример #6
0
 public GenerateFhirPathSearch(SliceGenerator gen)
 {
     this.gen = gen;
 }