Ejemplo n.º 1
0
        void ProcessFhirComplex(SDefInfo sDefInfo)
        {
            const String fcn = "ProcessFhirPrimitive";

            StructureDefinition sDef = sDefInfo.SDef;

            ClearSDef(sDef);

            this.ConversionInfo(this.GetType().Name, fcn, $"Processing Complex {sDef.Name} {sDefInfo.TFlag}");

            String          instanceName   = TypeName(sDef.Name);
            CodeEditor      instanceEditor = this.project.CreateEditor(Path.Combine(ComplexGenPath, $"{instanceName}.cs"));
            CodeBlockNested instanceBlock  = instanceEditor.Blocks.AppendBlock();

            instanceBlock
            .AppendCode("using System;")
            .AppendCode("using System.Diagnostics;")
            .AppendCode("using System.IO;")
            .AppendCode("using System.Linq;")
            .AppendCode("using Hl7.Fhir.Model;")
            .BlankLine()
            .AppendCode($"namespace {ComplexNameSpace}")
            .OpenBrace()
            .AppendCode("#region Json")
            .AppendLine("#if NEVER")
            .AppendLines("", sDef.ToFormatedJson().ToLines())
            .AppendLine("#endif")
            .AppendCode("#endregion")
            .SummaryOpen()
            .Summary($"Fhir complex '{sDef.Name}'")
            .SummaryClose()
            .DefineBlock(out CodeBlockNested classBlock)
            .CloseBrace()
            ;

            Int32 i = 0;

            DefineClass(classBlock,
                        sDef.Differential.Element.ToArray(),
                        ref i,
                        sDef.Differential.Element[0].Path,
                        instanceName,
                        ComplexBase,
                        out CodeBlockNested dummy);

            if (i != sDef.Differential.Element.Count)
            {
                throw new ConvertErrorException(this.GetType().Name, fcn, $"Internal error. Invalid element index");
            }
        }
Ejemplo n.º 2
0
        void ProcessFhirPrimitive(SDefInfo sDefInfo)
        {
            const String fcn = "ProcessFhirPrimitive";

            StructureDefinition sDef = sDefInfo.SDef;

            ClearSDef(sDef);

            this.ConversionInfo(this.GetType().Name, fcn, $"Processing Primitive {sDef.Name} {sDefInfo.TFlag}");
            String          instanceName   = PrimitiveName(sDef.Name);
            CodeEditor      instanceEditor = this.project.CreateEditor(Path.Combine(PrimitiveGenPath, $"{instanceName}.cs"));
            CodeBlockNested instanceBlock  = instanceEditor.Blocks.AppendBlock();

            instanceBlock
            .AppendCode("using System;")
            .AppendCode("using System.Diagnostics;")
            .AppendCode("using System.IO;")
            .AppendCode("using System.Linq;")
            .AppendCode("using Hl7.Fhir.Model;")
            .BlankLine()
            .AppendCode($"namespace {PrimitiveNameSpace}")
            .OpenBrace()
            .AppendCode("#region Json")
            .AppendLine("#if NEVER")
            .AppendLines("", sDef.ToFormatedJson().ToLines())
            .AppendLine("#endif")
            .AppendCode("#endregion")
            .SummaryOpen()
            .Summary($"Fhir primitive '{sDef.Name}'")
            .SummaryClose()
            .AppendCode($"public partial class {instanceName} : {PrimitiveBase}")
            .OpenBrace()
            .CloseBrace()
            .CloseBrace()
            ;
        }
Ejemplo n.º 3
0
        void ProcessFhirResource(SDefInfo sDefInfo)
        {
            const String fcn = "ProcessFhirResource";

            StructureDefinition sDef = sDefInfo.SDef;

            ClearSDef(sDef);

            this.ConversionInfo(this.GetType().Name, fcn, $"Processing Resource {sDef.Name} {sDefInfo.TFlag}");

            String          instanceName   = ResourceName(sDef.Name);
            CodeEditor      instanceEditor = this.project.CreateEditor(Path.Combine(ResourceGenPath, $"{instanceName}.cs"));
            CodeBlockNested instanceBlock  = instanceEditor.Blocks.AppendBlock();

            instanceBlock
            .AppendCode("using System;")
            .AppendCode("using System.Diagnostics;")
            .AppendCode("using System.IO;")
            .AppendCode("using System.Linq;")
            .AppendCode("using Hl7.Fhir.Model;")
            .BlankLine()
            .AppendCode($"namespace {ResourceNameSpace}")
            .OpenBrace()
            .AppendCode("#region Json")
            .AppendCode("#if NEVER")
            .AppendLines("", sDef.ToFormatedJson().ToLines())
            .AppendLine("#endif")
            .AppendCode("#endregion")
            .SummaryOpen()
            .Summary($"Fhir resource '{sDef.Name}'")
            .SummaryClose()
            .DefineBlock(out CodeBlockNested classBlock)
            .CloseBrace()
            ;

            String baseClass = ResourceBase;

            if (String.IsNullOrEmpty(sDef.BaseDefinition) == false)
            {
                String name = this.ResourceName(sDef.BaseDefinition.LastUriPart());
                baseClass = $"{ResourceNameSpace}.{name}";
            }
            Int32 i = 0;

            DefineClass(classBlock,
                        sDef.Differential.Element.ToArray(),
                        ref i,
                        sDef.Differential.Element[0].Path,
                        instanceName,
                        baseClass,
                        out CodeBlockNested constructorBlock);

            constructorBlock
            .AppendCode($"this.Name = \"{sDef.Name}\";")
            .AppendCode($"this.Uri = \"{sDef.Url}\";")
            ;

            if (i != sDef.Differential.Element.Count)
            {
                throw new ConvertErrorException(this.GetType().Name, fcn, $"Internal error. Invalid element index");
            }
        }