Exemple #1
0
        protected Schema.Catalog _catalog;         // main catalog where all referenced objects can be found

        protected virtual void Describe()
        {
            _catalog = _process.Catalog;
            Schema.Object objectValue = null;
            if (Parser.IsValidQualifiedIdentifier(_seed.Query))
            {
                objectValue = Compiler.ResolveCatalogIdentifier(_program.Plan, _seed.Query, false);
            }

            if (objectValue != null)
            {
                _elaborableTableVarName = objectValue.Name;
                _elaborableCatalog      = _process.Catalog;
            }
            else
            {
                IServerExpressionPlan plan = ((IServerProcess)_process).PrepareExpression(String.Format(@"select {0}{1}", _seed.Query, _seed.Query.IndexOf(Keywords.Capabilities) > 0 || !_seed.Elaborate ? "" : String.Format(" {0} {{ elaborable }}", Keywords.Capabilities)), null);
                try
                {
                    _elaborableTableVarName = plan.TableVar.Name;
                    _elaborableCatalog      = plan.Catalog;
                }
                finally
                {
                    ((IServerProcess)_process).UnprepareExpression(plan);
                }
            }
        }
Exemple #2
0
        public override Schema.Catalog GetDeviceCatalog(ServerProcess process, Schema.Catalog serverCatalog, Schema.TableVar tableVar)
        {
            Schema.Catalog catalog = base.GetDeviceCatalog(process, serverCatalog, tableVar);

            using (Plan plan = new Plan(process))
            {
                // Need to support reverse lookup to determine the scalar type for a given native type

                Type[] types = typeof(Base).Assembly.GetTypes();

                foreach (Type type in types)
                {
                    // create a table var for each DomainResource descendent
                    if (type.IsSubclassOf(typeof(DomainResource)))
                    {
                        if (!type.IsGenericTypeDefinition)
                        {
                            string tableName = Schema.Object.Qualify(ToFHIRTableName(type.Name), plan.CurrentLibrary.Name);
                            if (tableVar == null || Schema.Object.NamesEqual(tableName, tableVar.Name))
                            {
                                Schema.BaseTableVar localTableVar = new Schema.BaseTableVar(tableName, null);
                                localTableVar.Owner    = plan.User;
                                localTableVar.Library  = plan.CurrentLibrary;
                                localTableVar.Device   = this;
                                localTableVar.MetaData = new MetaData();

                                // with a FHIR.ResourceType tag
                                localTableVar.MetaData.Tags.Add(new Tag("FHIR.ResourceType", type.Name));
                                localTableVar.AddDependency(this);
                                localTableVar.DataType = new Schema.TableType();

                                var d4TypeName = Schema.Object.Qualify(GenerateTypesNode.GetD4TypeName(type.FullName), "FHIR.Core");
                                var d4Type     = Compiler.ResolveCatalogIdentifier(plan, d4TypeName, false) as Schema.ScalarType;
                                if (d4Type != null)
                                {
                                    AddColumnsForType(localTableVar, d4Type);

                                    localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["Id"] }));

                                    catalog.Add(localTableVar);
                                }
                            }
                        }
                    }
                }

                return(catalog);
            }
        }
Exemple #3
0
        public override Schema.Catalog GetDeviceCatalog(ServerProcess process, Schema.Catalog serverCatalog, Schema.TableVar tableVar)
        {
            Schema.Catalog catalog = base.GetDeviceCatalog(process, serverCatalog, tableVar);

            using (Plan plan = new Plan(process))
            {
                // Need to support reverse lookup to determine the scalar type for a given native type

                Type[] types = typeof(Authority).Assembly.GetTypes();

                foreach (Type type in types)
                {
                    // create a table var for each class
                    if (type.IsClass && type.GetField("id") != null)
                    {
                        if (!type.IsGenericTypeDefinition)
                        {
                            string tableName = Schema.Object.Qualify(ToPHINVADSTableName(type.Name), plan.CurrentLibrary.Name);
                            if (tableVar == null || Schema.Object.NamesEqual(tableName, tableVar.Name))
                            {
                                Schema.BaseTableVar localTableVar = new Schema.BaseTableVar(tableName, null);
                                localTableVar.Owner    = plan.User;
                                localTableVar.Library  = plan.CurrentLibrary;
                                localTableVar.Device   = this;
                                localTableVar.MetaData = new MetaData();

                                // with a FHIR.ResourceType tag
                                localTableVar.MetaData.Tags.Add(new Tag("PHINVADS.ResourceType", type.Name));
                                localTableVar.AddDependency(this);
                                localTableVar.DataType = new Schema.TableType();

                                var d4TypeName = Schema.Object.Qualify(GenerateTypesNode.GetD4TypeName(type.FullName), "PHINVADS.Core");
                                var d4Type     = Compiler.ResolveCatalogIdentifier(plan, d4TypeName, false) as Schema.ScalarType;
                                if (d4Type != null)
                                {
                                    AddColumnsForType(localTableVar, d4Type);

                                    localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["id"] }));

                                    switch (type.Name)
                                    {
                                    case "CodeSystem":
                                        localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["oid"] }));
                                        localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["codeSystemCode"] }));
                                        localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["hl70396Identifier"] }));
                                        break;

                                    case "CodeSystemConcept": localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["codeSystemOid"], localTableVar.Columns["conceptCode"] })); break;

                                    case "ValueSet":
                                        localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["oid"] }));
                                        localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["code"] }));
                                        break;

                                    case "ValueSetConcept":
                                        localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["codeSystemOid"], localTableVar.Columns["conceptCode"] }));
                                        localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["valueSetVersionId"], localTableVar.Columns["conceptCode"] }));
                                        break;

                                    case "ValueSetVersion":
                                        localTableVar.Keys.Add(new Schema.Key(new Schema.TableVarColumn[] { localTableVar.Columns["valueSetOid"], localTableVar.Columns["versionNumber"] }));
                                        break;
                                    }

                                    catalog.Add(localTableVar);
                                }
                            }
                        }
                    }
                }

                return(catalog);
            }
        }