Example #1
0
        public static Conformance AddSingleResourceComponent(this Conformance conformance, String resourcetype, Boolean readhistory, Boolean updatecreate, Conformance.ResourceVersionPolicy versioning, ResourceReference profile = null)
        {
            var resource = new Conformance.ConformanceRestResourceComponent();

            resource.Type         = resourcetype;
            resource.Profile      = profile;
            resource.ReadHistory  = readhistory;
            resource.UpdateCreate = updatecreate;
            resource.Versioning   = versioning;
            conformance.Server().Resource.Add(resource);
            return(conformance);
        }
Example #2
0
        public static Conformance Build()
        {
            Stream       s              = typeof(ConformanceBuilder).Assembly.GetManifestResourceStream("Spark.Service.Service.Conformance.xml");
            StreamReader sr             = new StreamReader(s);
            string       conformanceXml = sr.ReadToEnd();


            var conformance = (Conformance)FhirParser.ParseResourceFromXml(conformanceXml);

            conformance.Software.Version = ReadVersionFromAssembly();
            conformance.Software.Name    = ReadProductNameFromAssembly();
            conformance.FhirVersion      = ModelInfo.Version;
            conformance.Date             = Date.Today().Value;

            Conformance.ConformanceRestComponent serverComponent = conformance.Rest[0];

            // Replace anything that was there before...
            serverComponent.Resource = new List <Conformance.ConformanceRestResourceComponent>();

            // todo: An alternative is needed for the missing operation types below:
            var allOperations = new List <Conformance.ConformanceRestResourceOperationComponent>()
            {
                new Conformance.ConformanceRestResourceOperationComponent {
                    Code =
                        Conformance.RestfulOperationType.Create
                },
                new Conformance.ConformanceRestResourceOperationComponent {
                    Code =
                        Conformance.RestfulOperationType.Delete
                },
                new Conformance.ConformanceRestResourceOperationComponent {
                    Code =
                        Conformance.RestfulOperationType.HistoryInstance
                },

                /*
                 * new Conformance.ConformanceRestResourceOperationComponent { Code =
                 *  Conformance.RestfulOperationType.HistorySystem },
                 */
                new Conformance.ConformanceRestResourceOperationComponent {
                    Code =
                        Conformance.RestfulOperationType.HistoryType
                },
                new Conformance.ConformanceRestResourceOperationComponent {
                    Code =
                        Conformance.RestfulOperationType.Read
                },

                new Conformance.ConformanceRestResourceOperationComponent {
                    Code =
                        Conformance.RestfulOperationType.SearchType
                },

                /*
                 *  new Conformance.ConformanceRestResourceOperationComponent { Code =
                 *  Conformance.RestfulOperationType.Transaction },
                 */
                new Conformance.ConformanceRestResourceOperationComponent {
                    Code =
                        Conformance.RestfulOperationType.Update
                },
                new Conformance.ConformanceRestResourceOperationComponent {
                    Code =
                        Conformance.RestfulOperationType.Validate
                },
                new Conformance.ConformanceRestResourceOperationComponent {
                    Code =
                        Conformance.RestfulOperationType.Vread
                },
            };

            foreach (var resourceName in ModelInfo.SupportedResources)
            {
                var supportedResource = new Conformance.ConformanceRestResourceComponent();
                supportedResource.Type        = resourceName;
                supportedResource.ReadHistory = true;
                supportedResource.Operation   = allOperations;

                // Add supported _includes for this resource
                supportedResource.SearchInclude = ModelInfo.SearchParameters
                                                  .Where(sp => sp.Resource == resourceName)
                                                  .Where(sp => sp.Type == Conformance.SearchParamType.Reference)
                                                  .Select(sp => sp.Name);

                supportedResource.SearchParam = new List <Conformance.ConformanceRestResourceSearchParamComponent>();

                // todo: search params. error: "The name "Search" does not exist in the current context
                var parameters = ModelInfo.SearchParameters.Where(sp => sp.Resource == resourceName)
                                 .Select(sp => new Conformance.ConformanceRestResourceSearchParamComponent
                {
                    Name          = sp.Name,
                    Source        = new Uri("http://hl7.org/fhir/" + resourceName.ToLower() + "/search#" + sp.Name),
                    Type          = sp.Type,
                    Documentation = sp.Description,
                    Xpath         = sp.Path != null ? String.Join(",", sp.Path) : null
                });

                supportedResource.SearchParam.AddRange(parameters);

                serverComponent.Resource.Add(supportedResource);
            }

            // todo: This constant has become internal. Please undo. We need it.

            // Update: new location: XHtml.XHTMLNS / XHtml
            // XNamespace ns = Hl7.Fhir.Support.Util.XHTMLNS;
            XNamespace ns = "http://www.w3.org/1999/xhtml";

            var summary = new XElement(ns + "div");

            foreach (string resourceName in ModelInfo.SupportedResources)
            {
                summary.Add(new XElement(ns + "p",
                                         String.Format("The server supports all operations on the {0} resource, including history",
                                                       resourceName)));
            }

            conformance.Text.Div = summary.ToString();
            return(conformance);
        }
Example #3
0
        public Conformance.ConformanceRestResourceComponent Metadata()
        {
            var patientConformance = new Conformance.ConformanceRestResourceComponent
            {
                Type        = PATIENT,
                ReadHistory = false,
                Operation   = new List <Conformance.ConformanceRestResourceOperationComponent>
                {
                    new Conformance.ConformanceRestResourceOperationComponent
                    {
                        Code = Conformance.RestfulOperationType.Create
                    },
                    new Conformance.ConformanceRestResourceOperationComponent
                    {
                        Code = Conformance.RestfulOperationType.Read
                    },
                    new Conformance.ConformanceRestResourceOperationComponent
                    {
                        Code = Conformance.RestfulOperationType.Update
                    },
                    new Conformance.ConformanceRestResourceOperationComponent
                    {
                        Code = Conformance.RestfulOperationType.Delete
                    },
                    new Conformance.ConformanceRestResourceOperationComponent
                    {
                        Code = Conformance.RestfulOperationType.SearchType
                    }
                }
            };

            #region CRUD operation support

            #endregion

            #region search operation support

            #endregion

            #region version related operation support
            #if false
            patientConformance.Operation.Add(new Conformance.ConformanceRestResourceOperationComponent()
            {
                Code = Conformance.RestfulOperationType.HistoryInstance
            });
            patientConformance.Operation.Add(new Conformance.ConformanceRestResourceOperationComponent()
            {
                Code = Conformance.RestfulOperationType.HistoryType
            });
            patientConformance.Operation.Add(new Conformance.ConformanceRestResourceOperationComponent()
            {
                Code = Conformance.RestfulOperationType.Vread
            });
            #endif
            #endregion

            #region validation operation support
            #if false
            patientConformance.Operation.Add(new Conformance.ConformanceRestResourceOperationComponent()
            {
                Code = Conformance.RestfulOperationType.Validate
            });
            #endif
            #endregion

            return(patientConformance);
        }
Example #4
0
        public static Conformance.ResourceInteractionComponent AddSingleResourceInteraction(Conformance.ConformanceRestResourceComponent resourcecomp, Conformance.TypeRestfulInteraction type)
        {
            var interaction = new Conformance.ResourceInteractionComponent();

            interaction.Code = type;
            return(interaction);
        }
Example #5
0
 public static Conformance.ConformanceRestResourceComponent AddAllResourceInteractions(Conformance.ConformanceRestResourceComponent resourcecomp)
 {
     foreach (Conformance.TypeRestfulInteraction type in Enum.GetValues(typeof(Conformance.TypeRestfulInteraction)))
     {
         var interaction = AddSingleResourceInteraction(resourcecomp, type);
         resourcecomp.Interaction.Add(interaction);
     }
     return(resourcecomp);
 }
Example #6
0
        public static Conformance.ConformanceRestResourceComponent AddCoreSearchParamsResource(Conformance.ConformanceRestResourceComponent resourcecomp)
        {
            var parameters = ModelInfo.SearchParameters.Where(sp => sp.Resource == resourcecomp.Type)
                             .Select(sp => new Conformance.ConformanceRestResourceSearchParamComponent
            {
                Name          = sp.Name,
                Type          = sp.Type,
                Documentation = sp.Description,
            });

            resourcecomp.SearchParam.AddRange(parameters);
            return(resourcecomp);
        }