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); } }
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); } }