Ejemplo n.º 1
0
        void DefineBinding(ElementDefinition elementDefinition)
        {
            if (CSMisc.BindingClassName(elementDefinition,
                                        out String bindingClassName,
                                        out ElementDefinition.ElementDefinitionBindingComponent binding) == false)
            {
                return;
            }

            String fieldName     = $"{elementDefinition.Path.LastPathPart().ToMachineName()}";
            String methodName    = $"Set{elementDefinition.Path.LastPathPart().ToMachineName()}";
            String fhirFieldName = $"{elementDefinition.Path.LastPathPart().ToMachineName()}";

            switch (fhirFieldName)
            {
            case "ValueX":
                fhirFieldName = "Value";
                break;
            }
            String thisClass = CSMisc.ClassName(this.fragBase);

            this.fragBase.ClassMethods
            .SummaryOpen()
            .Summary($"Set {elementDefinition.ElementId} to one of the predefined items")
            .SummaryClose()
            .AppendCode($"public void {methodName}({bindingClassName} code)")
            .OpenBrace()
            .IfElse(elementDefinition.Base.Max == "1",
                    code1 => code1.AppendCode($"this.Resource.{fhirFieldName} = ({elementDefinition.Type[0].Code}) code;"),
                    code1 => code1.AppendCode($"this.Resource.{fhirFieldName}.Add(({elementDefinition.Type[0].Code}) code);")
                    )
            .CloseBrace()
            ;
        }
Ejemplo n.º 2
0
        public override void Build()
        {
            const String fcn = "Build";

            this.CSBuilder.ConversionInfo(this.GetType().Name,
                                          fcn,
                                          $"Building {this.fragBase.StructDef.Url.LastUriPart()}");

            base.Build();

            //{
            //    if (this.fragBase.SnapNodes.TryGetElementNode("Extension.extension", out ElementTreeNode extensionNode) == false)
            //        throw new Exception($"Extension.extension node is missing");
            //    BuildItemExtension bmv = new BuildItemExtension(this, this.fragBase.CodeBlocks);
            //    bmv.Build(CSMisc.ClassName(this.fragBase), extensionNode);
            //}
            {
                BuildMembers.BuildMemberExtension bm = new BuildMembers.BuildMemberExtension(this,
                                                                                             this.fragBase.CodeBlocks,
                                                                                             this.fragBase.SnapNodes.DefaultSlice,
                                                                                             CSMisc.ClassName(this.fragBase));
                bm.Build();
            }
        }
Ejemplo n.º 3
0
 public static String LocalClassNameSpace(String name) => $"BreastRadLib.{CSMisc.ClassName(name)}Local;";
Ejemplo n.º 4
0
 public static String LocalClassNameSpace(SDInfo fi) => $"BreastRadLib.{CSMisc.ClassName(fi)}Local;";
Ejemplo n.º 5
0
        void SaveAll()
        {
            this.resourceFactoryEditor.Save();
            this.fc.Mark(this.resourceFactoryEditor.SavePath);
            foreach (SDInfo fi in this.SDFragments.Values)
            {
                this.Save(fi.InterfaceEditor, Path.Combine(this.OutputDir, "Generated", "Interfaces", $"{CSMisc.InterfaceName(fi)}.cs"));
                if (fi.ClassEditor != null)
                {
                    if (
                        (fi.IsFragment() == true) ||
                        (fi.StructDef.BaseDefinition == Global.ExtensionUrl)
                        )
                    {
                        this.Save(fi.ClassEditor, Path.Combine(this.OutputDir, "Generated", "Class", $"{CSMisc.ClassName(fi)}.txt"));
                    }
                    else
                    {
                        this.Save(fi.ClassEditor, Path.Combine(this.OutputDir, "Generated", "Class", $"{CSMisc.ClassName(fi)}.cs"));
                    }
                }
                if (fi.SubClassEditor != null)
                {
                    this.Save(fi.SubClassEditor, Path.Combine(this.OutputDir, "Generated", "Class", $"{CSMisc.ClassName(fi)}Local.cs"));
                }
            }

            foreach (CSInfo ci in this.CodeSystems.Values)
            {
                this.Save(ci.ClassCode, Path.Combine(this.OutputDir, "Generated", "CodeSystems", $"{CSMisc.CodeSystemName(ci)}.cs"));
            }

            foreach (VSInfo vi in this.ValueSets.Values)
            {
                this.Save(vi.ClassCode, Path.Combine(this.OutputDir, "Generated", "ValueSets", $"{CSMisc.ValueSetName(vi)}.cs"));
            }
        }
Ejemplo n.º 6
0
        void BuildFragment(SDInfo fi)
        {
            const String fcn = "BuildFragment";

            String fhirType = fi.BaseDefinitionName;

            this.ConversionInfo(this.GetType().Name,
                                fcn,
                                $"Processing fragment {fi.StructDef.Name}");

            if (String.Compare(CSMisc.ClassName(fi), this.BreakOnClass, StringComparison.OrdinalIgnoreCase) == 0)
            {
                Debugger.Break();
            }

            if (
                (fi.IsFragment() == false) &&
                (fi.StructDef.BaseDefinition != Global.ExtensionUrl)
                )
            {
                String url = fi.StructDef.Url.Trim().ToLower();
                this.resourceFactoryProfileBlock
                .AppendCode($"case \"{url}\":")
                .AppendCode($"    return new {CSMisc.ClassName(fi)}(doc, ({fhirType}) resource);")
                ;
            }

            this.DefineInterfaces(fi);
            DefineBase csDef = null;

            switch (fi.StructDef.BaseDefinition)
            {
            case Global.ExtensionUrl:
                csDef = new DefineExtension(this, fi);
                break;

            case Global.ResourceUrl:
                break;

            case Global.ObservationUrl:
                csDef = new DefineObservation(this, fi);
                break;

            case Global.DiagnosticReportUrl:
                csDef = new DefineDiagnosticReport(this, fi);
                break;

            case Global.CompositionUrl:
                csDef = new DefineComposition(this, fi);
                break;

            case Global.ServiceRequestUrl:
                csDef = new DefineServiceRequest(this, fi);
                break;

            default:
                this.ConversionError(this.GetType().Name,
                                     fcn,
                                     $"No builder defined for class {fi.StructDef.BaseDefinition}");
                break;
            }

            if (csDef != null)
            {
                csDef.Clear();
                csDef.DefBase();
                csDef.Build();
            }
        }