public static CapabilityStatement AddSummaryForAllResources(this CapabilityStatement conformance)
 {
     foreach (var resource in conformance.Rest.FirstOrDefault().Resource.ToList())
     {
         var p = new CapabilityStatement.SearchParamComponent();
         p.Name          = "_summary";
         p.Type          = SearchParamType.String;
         p.Documentation = "Summary for resource";
         resource.SearchParam.Add(p);
     }
     return(conformance);
 }
Exemplo n.º 2
0
        public static CapabilityStatement AddSummaryForAllResources(this CapabilityStatement capabilityStatement)
        {
            foreach (var resource in capabilityStatement.Rest.FirstOrDefault().Resource.ToList())
            {
                var p = new CapabilityStatement.SearchParamComponent
                {
                    Name          = "_summary",
                    Type          = SearchParamType.String,
                    Documentation = new Markdown("Summary for resource")
                };
                resource.SearchParam.Add(p);
            }

            return(capabilityStatement);
        }
Exemplo n.º 3
0
        public IResourceServiceOutcome GetServersConformanceResource(IRequestMeta RequestMeta)
        {
            if (RequestMeta == null)
            {
                throw new NullReferenceException("RequestMeta can not be null.");
            }
            if (RequestMeta.SearchParameterGeneric == null)
            {
                throw new NullReferenceException("SearchParameterGeneric can not be null.");
            }

            IResourceServiceOutcome         ServiceOperationOutcome        = IResourceServiceOutcomeFactory.CreateResourceServiceOutcome();
            ISearchParameterService         SearchService                  = ISearchParameterServiceFactory.CreateSearchParameterService();
            ISearchParametersServiceOutcome SearchParametersServiceOutcome = SearchService.ProcessBaseSearchParameters(RequestMeta.SearchParameterGeneric);

            if (SearchParametersServiceOutcome.FhirOperationOutcome != null)
            {
                ServiceOperationOutcome.ResourceResult = SearchParametersServiceOutcome.FhirOperationOutcome;
                ServiceOperationOutcome.HttpStatusCode = SearchParametersServiceOutcome.HttpStatusCode;
                ServiceOperationOutcome.FormatMimeType = SearchParametersServiceOutcome.SearchParameters.Format;
                return(ServiceOperationOutcome);
            }

            var    Conformance            = new CapabilityStatement();
            var    ApplicationReleaseDate = new DateTimeOffset(2017, 10, 17, 6, 00, 00, new TimeSpan(8, 0, 0));
            string ServerName             = "Pyro Server";
            string Https = "https://";

            Conformance.Id               = "metadata";
            Conformance.Url              = $"{Https}{IPrimaryServiceRootCache.GetPrimaryRootUrlFromDatabase().Url}/metadata";
            Conformance.Version          = $"V{IGlobalProperties.ApplicationVersionInfo}";
            Conformance.Meta             = new Meta();
            Conformance.Meta.LastUpdated = ApplicationReleaseDate;
            Conformance.Name             = ServerName;
            Conformance.Status           = PublicationStatus.Active;
            Conformance.Experimental     = true;
            Conformance.Date             = (new FhirDateTime(ApplicationReleaseDate)).Value;
            Conformance.Publisher        = "PyroHealth.net";
            var AngusContactDetail = Common.PyroHealthInformation.PyroHealthContactDetailAngusMillar.GetContactDetail();

            Conformance.Contact = new List <ContactDetail>()
            {
                AngusContactDetail
            };

            Conformance.Description = new Markdown("Conformance statement for the " + ServerName);

            var Australia = new CodeableConcept("urn:iso:std:iso:3166", "AU", "Australia");

            Conformance.Jurisdiction = new List <CodeableConcept>()
            {
                Australia
            };

            Conformance.Purpose = new Markdown("FHIR Server reference implementation");

            Conformance.Copyright = new Markdown("Copyright: PyroHealth.net");
            Conformance.Kind      = CapabilityStatement.CapabilityStatementKind.Instance;

            Conformance.Software             = new CapabilityStatement.SoftwareComponent();
            Conformance.Software.Name        = ServerName;
            Conformance.Software.Version     = IGlobalProperties.ApplicationVersionInfo; //To align with FHIR version only use number no prefix of 'V'
            Conformance.Software.ReleaseDate = (new FhirDateTime(ApplicationReleaseDate)).Value;

            Conformance.Implementation             = new CapabilityStatement.ImplementationComponent();
            Conformance.Implementation.Description = $"{ServerName} is an implementation of a FHIR server supporting V{Hl7.Fhir.Model.ModelInfo.Version} of the specification. This instance is a publicly available testing server and its resource may be cleared at any time.";
            Conformance.Implementation.Url         = $"{Https}{IPrimaryServiceRootCache.GetPrimaryRootUrlFromDatabase().Url}";

            Conformance.FhirVersion   = Hl7.Fhir.Model.ModelInfo.Version; //Must be formated as just the number '3.0.1' as touchstone does not like the V3.0.1
            Conformance.AcceptUnknown = CapabilityStatement.UnknownContentCode.Extensions;

            var ContentFormatList = new List <string>();

            foreach (var mediaType in Hl7.Fhir.Rest.ContentType.XML_CONTENT_HEADERS)
            {
                ContentFormatList.Add(mediaType);
            }
            foreach (var mediaType in Hl7.Fhir.Rest.ContentType.JSON_CONTENT_HEADERS)
            {
                ContentFormatList.Add(mediaType);
            }
            Conformance.Format = ContentFormatList;

            Conformance.Rest = new List <CapabilityStatement.RestComponent>();
            var RestComponent = new CapabilityStatement.RestComponent();

            Conformance.Rest.Add(RestComponent);
            RestComponent.Mode                 = CapabilityStatement.RestfulCapabilityMode.Server;
            RestComponent.Documentation        = $"STU{Hl7.Fhir.Model.ModelInfo.Version.Split('.')[0]} V{Hl7.Fhir.Model.ModelInfo.Version} FHIR Server";
            RestComponent.Security             = new CapabilityStatement.SecurityComponent();
            RestComponent.Security.Description = "No Security has been implemented, server if publicly open";

            RestComponent.Interaction = new List <CapabilityStatement.SystemInteractionComponent>();
            var SystemInteractionComponent = new CapabilityStatement.SystemInteractionComponent();

            RestComponent.Interaction.Add(SystemInteractionComponent);
            SystemInteractionComponent.Code          = CapabilityStatement.SystemRestfulInteraction.Transaction;
            SystemInteractionComponent.Documentation = "Batch Transaction supports all request methods (Delete, POST, PUT, GET) including conditional create/update/delete. Operatons are not supported within Transaction bundles.";

            var CompartmentList = IServiceCompartmentRepository.GetAllServiceCompartments();

            if (CompartmentList != null && CompartmentList.Count > 0)
            {
                var CompartmentUrlList = new List <string>();
                CompartmentList.ForEach(x => CompartmentUrlList.Add(x.Url));
                RestComponent.Compartment = CompartmentUrlList;
            }

            RestComponent.Resource = new List <CapabilityStatement.ResourceComponent>();

            List <DtoServiceSearchParameterHeavy> DtoServiceSearchParameterHeavyList = IServiceSearchParameterService.GetServiceSearchParametersHeavy(false);

            var ResourceTypeList = Enum.GetValues(typeof(ResourceType));

            foreach (ResourceType ResourceType in ResourceTypeList)
            {
                string       CurrentResourceString = ResourceType.GetLiteral();
                FHIRAllTypes?FhirType          = Hl7.Fhir.Model.ModelInfo.FhirTypeNameToFhirType(CurrentResourceString);
                var          ResourceComponent = new CapabilityStatement.ResourceComponent();
                RestComponent.Resource.Add(ResourceComponent);
                ResourceComponent.Type        = ResourceType;
                ResourceComponent.Interaction = new List <CapabilityStatement.ResourceInteractionComponent>()
                {
                    new CapabilityStatement.ResourceInteractionComponent()
                    {
                        Code = CapabilityStatement.TypeRestfulInteraction.Create
                    },
                    new CapabilityStatement.ResourceInteractionComponent()
                    {
                        Code = CapabilityStatement.TypeRestfulInteraction.Delete
                    },
                    new CapabilityStatement.ResourceInteractionComponent()
                    {
                        Code = CapabilityStatement.TypeRestfulInteraction.Read
                    },
                    new CapabilityStatement.ResourceInteractionComponent()
                    {
                        Code = CapabilityStatement.TypeRestfulInteraction.Update
                    },
                    new CapabilityStatement.ResourceInteractionComponent()
                    {
                        Code = CapabilityStatement.TypeRestfulInteraction.Vread
                    },
                    new CapabilityStatement.ResourceInteractionComponent()
                    {
                        Code = CapabilityStatement.TypeRestfulInteraction.SearchType
                    },
                    new CapabilityStatement.ResourceInteractionComponent()
                    {
                        Code = CapabilityStatement.TypeRestfulInteraction.HistoryInstance
                    },
                    new CapabilityStatement.ResourceInteractionComponent()
                    {
                        Code = CapabilityStatement.TypeRestfulInteraction.HistoryType
                    }
                    //new Conformance.ResourceInteractionComponent() { Code = Conformance.TypeRestfulInteraction.HistoryType},
                };
                ResourceComponent.Versioning        = CapabilityStatement.ResourceVersionPolicy.Versioned;
                ResourceComponent.ReadHistory       = true;
                ResourceComponent.UpdateCreate      = true;
                ResourceComponent.ConditionalCreate = true;
                ResourceComponent.ConditionalRead   = CapabilityStatement.ConditionalReadStatus.FullSupport;
                ResourceComponent.ConditionalUpdate = true;
                ResourceComponent.ConditionalDelete = CapabilityStatement.ConditionalDeleteStatus.Multiple;


                var ReferenceHandlingPolicyList = new List <CapabilityStatement.ReferenceHandlingPolicy?>();
                ReferenceHandlingPolicyList.Add(CapabilityStatement.ReferenceHandlingPolicy.Literal);
                ReferenceHandlingPolicyList.Add(CapabilityStatement.ReferenceHandlingPolicy.Local);
                ResourceComponent.ReferencePolicy = ReferenceHandlingPolicyList;

                List <DtoServiceSearchParameterHeavy> DtoServiceSearchParameterHeavyForResourceList = DtoServiceSearchParameterHeavyList.Where(x => x.Resource == CurrentResourceString || x.Resource == FHIRAllTypes.Resource.GetLiteral()).ToList();

                //List<ServiceSearchParameterHeavy> DtoServiceSearchParameterHeavyForResourceList = ICommonServices.GetServiceSearchParametersHeavyForResource(FhirType.Value.GetLiteral());
                //DtoServiceSearchParameterHeavyForResourceList.AddRange(ICommonServices.GetServiceSearchParametersHeavyForResource(FHIRAllTypes.Resource.GetLiteral()));
                ResourceComponent.SearchParam = new List <CapabilityStatement.SearchParamComponent>();
                List <string> IncludesList    = null;
                List <string> RevIncludesList = null;
                foreach (var SupportedSearchParam in DtoServiceSearchParameterHeavyForResourceList)
                {
                    if (SupportedSearchParam.IsIndexed && SupportedSearchParam.Status == PublicationStatus.Active)
                    {
                        //Include (RevIncludes are below)
                        if (SupportedSearchParam.Type == SearchParamType.Reference)
                        {
                            if (IncludesList == null)
                            {
                                IncludesList = new List <string>();
                            }
                            if (SupportedSearchParam.TargetResourceTypeList.Count > 1)
                            {
                                foreach (var Target in SupportedSearchParam.TargetResourceTypeList)
                                {
                                    IncludesList.Add($"{SupportedSearchParam.Resource}:{SupportedSearchParam.Name}:{Target.ResourceType.GetLiteral()}");
                                }
                            }
                            else
                            {
                                IncludesList.Add($"{SupportedSearchParam.Resource}:{SupportedSearchParam.Name}");
                            }
                        }

                        CapabilityStatement.SearchParamComponent SearchParamComponent = new CapabilityStatement.SearchParamComponent();
                        ResourceComponent.SearchParam.Add(SearchParamComponent);

                        SearchParamComponent.Name       = SupportedSearchParam.Name;
                        SearchParamComponent.Type       = SupportedSearchParam.Type;
                        SearchParamComponent.Definition = SupportedSearchParam.Url;
                        if (!string.IsNullOrWhiteSpace(SupportedSearchParam.Description))
                        {
                            SearchParamComponent.Documentation = SupportedSearchParam.Description;
                        }
                    }
                }
                ResourceComponent.SearchInclude = IncludesList;

                //RevIncludes
                var RevIncludeSearchParameterList = DtoServiceSearchParameterHeavyList.Where(x => x.Type == SearchParamType.Reference && x.TargetResourceTypeList.Any(c => c.ResourceType == ResourceType));
                foreach (var Rev in RevIncludeSearchParameterList)
                {
                    if (RevIncludesList == null)
                    {
                        RevIncludesList = new List <string>();
                    }
                    if (Rev.TargetResourceTypeList.Count > 1)
                    {
                        RevIncludesList.Add($"{Rev.Resource}:{Rev.Name}:{CurrentResourceString}");
                    }
                    else
                    {
                        RevIncludesList.Add($"{Rev.Resource}:{Rev.Name}");
                    }
                }

                ResourceComponent.SearchRevInclude = RevIncludesList;
            }
            ConstructConformanceResourceNarrative(Conformance);

            IDatabaseOperationOutcome DatabaseOperationOutcome = IDatabaseOperationOutcomeFactory.CreateDatabaseOperationOutcome();

            ServiceOperationOutcome.FhirResourceId        = Conformance.Id;
            ServiceOperationOutcome.ResourceVersionNumber = Conformance.Version;
            ServiceOperationOutcome.LastModified          = Conformance.Meta.LastUpdated;
            ServiceOperationOutcome.OperationType         = Common.Enum.RestEnum.CrudOperationType.Read;
            ServiceOperationOutcome.IsDeleted             = false;
            ServiceOperationOutcome.RequestUri            = null;
            ServiceOperationOutcome.ResourceResult        = Conformance;
            ServiceOperationOutcome.FormatMimeType        = SearchParametersServiceOutcome.SearchParameters.Format;
            ServiceOperationOutcome.HttpStatusCode        = System.Net.HttpStatusCode.OK;
            return(ServiceOperationOutcome);
        }
Exemplo n.º 4
0
        public static Resource GetStatement(NameValueCollection queryParam)
        {
            string modeVal = Utilities.GetQueryValue("mode", queryParam);

            if (modeVal.ToLower() == "terminology")
            {
                return(TerminologyCapability.GetStatement(false));
            }

            CapabilityStatement capabilityStatement = new CapabilityStatement
            {
                Url         = TERMINZ_CANONICAL,
                Id          = "capability-fhir-server-patients-first",
                Description = new Markdown(TERMINZ_DESCRIPTION),
                Name        = "Patients First Terminology Server (Terminz)",
                Publisher   = "Patients First Ltd",
                Date        = "2019-05-08",
                Version     = "4.0.0",
                FhirVersion = FHIRVersion.N4_0_0,
                //Language = "en-NZ",  // review with next version of library - this needs to be a coded element!
                Status = PublicationStatus.Draft,
                //capabilityStatement.AcceptUnknown = CapabilityStatement.UnknownContentCode.Both;
                Experimental = true,
                Format       = new string[] { "json", "xml" },
                Software     = new CapabilityStatement.SoftwareComponent {
                    Name = "Health Intelligence Platform", Version = "6.9.6.0", ReleaseDate = "2019-05-08"
                },
                Kind           = CapabilityStatementKind.Instance,
                Implementation = new CapabilityStatement.ImplementationComponent {
                    Description = TERMINZ_DESCRIPTION, Url = TERMINZ_CANONICAL
                }
            };

            ContactDetail cd = new ContactDetail {
                Name = "Peter Jordan"
            };
            ContactPoint cp = new ContactPoint {
                System = ContactPoint.ContactPointSystem.Email, Value = "*****@*****.**"
            };

            cd.Telecom.Add(cp);
            capabilityStatement.Contact.Add(cd);

            // Add Extensions for supported Code Systems
            capabilityStatement.AddExtension(HL7_FHIR_CANONICAL + "/StructureDefinition/capabilitystatement-supported-system", new FhirUri("http://snomed.info/sct"));
            capabilityStatement.AddExtension(HL7_FHIR_CANONICAL + "/StructureDefinition/capabilitystatement-supported-system", new FhirUri("http://loinc.org"));
            capabilityStatement.AddExtension(HL7_FHIR_CANONICAL + "/StructureDefinition/capabilitystatement-supported-system", new FhirUri("http://nzmt.org.nz"));

            // create server object

            var server = new CapabilityStatement.RestComponent
            {
                Mode          = CapabilityStatement.RestfulCapabilityMode.Server,
                Documentation = new Markdown("RESTful Terminology Server")
            };

            server.Interaction.Add(new CapabilityStatement.SystemInteractionComponent
            {
                Code          = CapabilityStatement.SystemRestfulInteraction.Batch,
                Documentation = new Markdown("Supported for validate-code and translate operations.")
            });

            // Add CORS security
            server.Security = new CapabilityStatement.SecurityComponent {
                Cors = true
            };

            // create resource objects and add them to server object....

            // Capability Statement - only if /CapabilityStatement is supported where multiple CS exist

            // TerminologyCapabilities

            var resourceTerminologyCapabilities = new CapabilityStatement.ResourceComponent
            {
                Type         = ResourceType.TerminologyCapabilities,
                ReadHistory  = false,
                UpdateCreate = false,
                Versioning   = CapabilityStatement.ResourceVersionPolicy.NoVersion
            };

            // add interactions
            var confReadcs = new CapabilityStatement.ResourceInteractionComponent
            {
                Code          = CapabilityStatement.TypeRestfulInteraction.Read,
                Documentation = new Markdown("Read allows clients to get the logical definition of the Terminology Capability Statement")
            };

            resourceTerminologyCapabilities.Interaction.Add(confReadcs);

            // Operation Definition

            var resourceOperationDefinition = new CapabilityStatement.ResourceComponent
            {
                Type         = ResourceType.OperationDefinition,
                ReadHistory  = false,
                UpdateCreate = false,
                Versioning   = CapabilityStatement.ResourceVersionPolicy.NoVersion
            };

            // add interactions
            var confReadOd = new CapabilityStatement.ResourceInteractionComponent
            {
                Code          = CapabilityStatement.TypeRestfulInteraction.Read,
                Documentation = new Markdown("Read allows clients to get the logical definition of the Operation Definition")
            };

            resourceOperationDefinition.Interaction.Add(confReadOd);

            var confSearchOd = new CapabilityStatement.ResourceInteractionComponent
            {
                Code          = CapabilityStatement.TypeRestfulInteraction.SearchType,
                Documentation = new Markdown("Search allows clients to find Operation Definitions on the server")
            };

            resourceOperationDefinition.Interaction.Add(confSearchOd);

            // add search parameters

            var spOd0 = new CapabilityStatement.SearchParamComponent {
                Name = "identifier", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/OperationDefinition-identifier"
            };

            resourceOperationDefinition.SearchParam.Add(spOd0);

            var spOd1 = new CapabilityStatement.SearchParamComponent {
                Name = "url", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/OperationDefinition-url"
            };

            resourceOperationDefinition.SearchParam.Add(spOd1);

            // CodeSystem

            var resourceCodeSystem = new CapabilityStatement.ResourceComponent
            {
                Type         = ResourceType.CodeSystem,
                ReadHistory  = false,
                UpdateCreate = false,
                Versioning   = CapabilityStatement.ResourceVersionPolicy.NoVersion
            };

            // add interactions
            var confRead0 = new CapabilityStatement.ResourceInteractionComponent
            {
                Code          = CapabilityStatement.TypeRestfulInteraction.Read,
                Documentation = new Markdown("Read allows clients to get the logical definitions of Code Systems")
            };

            resourceCodeSystem.Interaction.Add(confRead0);

            var confSearch0 = new CapabilityStatement.ResourceInteractionComponent
            {
                Code          = CapabilityStatement.TypeRestfulInteraction.SearchType,
                Documentation = new Markdown("Search allows clients to find Code Systems on the server")
            };

            resourceCodeSystem.Interaction.Add(confSearch0);

            // add search parameters
            var sp1 = new CapabilityStatement.SearchParamComponent {
                Name = "code", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/CodeSystem-code"
            };

            resourceCodeSystem.SearchParam.Add(sp1);

            var sp2 = new CapabilityStatement.SearchParamComponent {
                Name = "date", Type = SearchParamType.Date, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/CodeSystem-date"
            };
            //resourceCodeSystem.SearchParam.Add(sp2);

            var sp3 = new CapabilityStatement.SearchParamComponent {
                Name = "name", Type = SearchParamType.String, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/CodeSystem-name"
            };
            //resourceCodeSystem.SearchParam.Add(sp3);

            var sp4 = new CapabilityStatement.SearchParamComponent {
                Name = "reference", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/CodeSystem-reference"
            };
            //resourceCodeSystem.SearchParam.Add(sp4);

            var sp5 = new CapabilityStatement.SearchParamComponent {
                Name = "status", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/CodeSystem-status"
            };
            //resourceCodeSystem.SearchParam.Add(sp5);

            var sp6 = new CapabilityStatement.SearchParamComponent {
                Name = "system", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/CodeSystem-system"
            };

            resourceCodeSystem.SearchParam.Add(sp6);

            var sp7 = new CapabilityStatement.SearchParamComponent {
                Name = "url", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/CodeSystem-url"
            };

            resourceCodeSystem.SearchParam.Add(sp7);

            var sp8 = new CapabilityStatement.SearchParamComponent {
                Name = "version", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/CodeSystem-version"
            };

            resourceCodeSystem.SearchParam.Add(sp8);

            var sp9 = new CapabilityStatement.SearchParamComponent {
                Name = "identifier", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/CodeSystem-identifier"
            };

            resourceCodeSystem.SearchParam.Add(sp9);

            var sp1a = new CapabilityStatement.SearchParamComponent {
                Name = "content-mode", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/CodeSystem-content-mode"
            };

            resourceCodeSystem.SearchParam.Add(sp1a);

            var sp1b = new CapabilityStatement.SearchParamComponent {
                Name = "supplements", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/CodeSystem-supplements"
            };

            resourceCodeSystem.SearchParam.Add(sp1b);

            // ValueSet

            var resourceValueSet = new CapabilityStatement.ResourceComponent
            {
                Type         = ResourceType.ValueSet,
                ReadHistory  = false,
                UpdateCreate = false,
                Versioning   = CapabilityStatement.ResourceVersionPolicy.NoVersion
            };

            // add interactions
            var confRead = new CapabilityStatement.ResourceInteractionComponent
            {
                Code          = CapabilityStatement.TypeRestfulInteraction.Read,
                Documentation = new Markdown("Read allows clients to get the logical definitions of Value Sets")
            };

            resourceValueSet.Interaction.Add(confRead);

            var confSearch = new CapabilityStatement.ResourceInteractionComponent
            {
                Code          = CapabilityStatement.TypeRestfulInteraction.SearchType,
                Documentation = new Markdown("Search allows clients to find Value Sets on the server")
            };

            resourceValueSet.Interaction.Add(confSearch);

            // add search parameters
            var sp11 = new CapabilityStatement.SearchParamComponent
            {
                Name = "code", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ValueSet-code"
            };

            resourceValueSet.SearchParam.Add(sp11);

            var sp12 = new CapabilityStatement.SearchParamComponent
            {
                Name = "date", Type = SearchParamType.Date, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ValueSet-date"
            };
            //resourceValueSet.SearchParam.Add(sp12);

            var sp13 = new CapabilityStatement.SearchParamComponent
            {
                Name = "name", Type = SearchParamType.String, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ValueSet-name"
            };
            //resourceValueSet.SearchParam.Add(sp13);

            var sp14 = new CapabilityStatement.SearchParamComponent
            {
                Name = "reference", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ValueSet-reference"
            };
            //resourceValueSet.SearchParam.Add(sp14);

            var sp15 = new CapabilityStatement.SearchParamComponent
            {
                Name = "status", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ValueSet-status"
            };
            //resourceValueSet.SearchParam.Add(sp15);

            var sp16 = new CapabilityStatement.SearchParamComponent
            {
                Name = "system", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ValueSet-system"
            };

            resourceValueSet.SearchParam.Add(sp16);

            var sp17 = new CapabilityStatement.SearchParamComponent
            {
                Name = "url", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ValueSet-url"
            };

            resourceValueSet.SearchParam.Add(sp17);

            var sp18 = new CapabilityStatement.SearchParamComponent
            {
                Name = "version", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ValueSet-version"
            };

            resourceValueSet.SearchParam.Add(sp18);

            var sp19 = new CapabilityStatement.SearchParamComponent
            {
                Name = "identifier", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ValueSet-identifier"
            };

            resourceValueSet.SearchParam.Add(sp19);

            // ConceptMap

            var resourceConceptMap = new CapabilityStatement.ResourceComponent
            {
                Type         = ResourceType.ConceptMap,
                ReadHistory  = false,
                UpdateCreate = false,
                Versioning   = CapabilityStatement.ResourceVersionPolicy.NoVersion
            };

            // add interactions
            var confRead2 = new CapabilityStatement.ResourceInteractionComponent
            {
                Code          = CapabilityStatement.TypeRestfulInteraction.Read,
                Documentation = new Markdown("Read allows clients to get the logical definitions of Concept Maps")
            };

            resourceConceptMap.Interaction.Add(confRead2);

            var confSearch2 = new CapabilityStatement.ResourceInteractionComponent
            {
                Code          = CapabilityStatement.TypeRestfulInteraction.SearchType,
                Documentation = new Markdown("Search allows clients to find Concept Maps on the server")
            };

            resourceConceptMap.Interaction.Add(confSearch2);

            // add search parameters

            var sp21 = new CapabilityStatement.SearchParamComponent
            {
                Name = "date", Type = SearchParamType.Date, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ConceptMap-date"
            };
            //resourceConceptMap.SearchParam.Add(sp21);

            var sp22 = new CapabilityStatement.SearchParamComponent
            {
                Name = "name", Type = SearchParamType.String, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ConceptMap-name"
            };
            //resourceConceptMap.SearchParam.Add(sp22);

            var sp23 = new CapabilityStatement.SearchParamComponent
            {
                Name = "status", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ConceptMap-status"
            };
            //resourceConceptMap.SearchParam.Add(sp23);

            var sp24 = new CapabilityStatement.SearchParamComponent
            {
                Name = "source", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ConceptMap-source"
            };

            resourceConceptMap.SearchParam.Add(sp24);

            var sp25 = new CapabilityStatement.SearchParamComponent
            {
                Name = "target", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ConceptMap-target"
            };

            resourceConceptMap.SearchParam.Add(sp25);

            var sp26 = new CapabilityStatement.SearchParamComponent
            {
                Name = "url", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ConceptMap-url"
            };

            resourceConceptMap.SearchParam.Add(sp26);

            var sp27 = new CapabilityStatement.SearchParamComponent
            {
                Name = "version", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ConceptMap-version"
            };

            resourceConceptMap.SearchParam.Add(sp27);

            var sp28 = new CapabilityStatement.SearchParamComponent
            {
                Name = "identifier", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/ConceptMap-identifier"
            };

            resourceConceptMap.SearchParam.Add(sp28);

            // Naming System

            var resourceNamingSystem = new CapabilityStatement.ResourceComponent
            {
                Type         = ResourceType.NamingSystem,
                ReadHistory  = false,
                UpdateCreate = false,
                Versioning   = CapabilityStatement.ResourceVersionPolicy.NoVersion
            };

            // add interactions
            var confReadNs = new CapabilityStatement.ResourceInteractionComponent
            {
                Code          = CapabilityStatement.TypeRestfulInteraction.Read,
                Documentation = new Markdown("Read allows clients to get the logical definitions of Naming Systems")
            };

            resourceNamingSystem.Interaction.Add(confReadNs);

            var confSearchNs = new CapabilityStatement.ResourceInteractionComponent
            {
                Code          = CapabilityStatement.TypeRestfulInteraction.SearchType,
                Documentation = new Markdown("Search allows clients to find Naming Systems on the server")
            };

            resourceNamingSystem.Interaction.Add(confSearchNs);

            // add search parameters

            var spNs = new CapabilityStatement.SearchParamComponent
            {
                Name = "identifier", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/NamingSystem-identifier"
            };

            resourceNamingSystem.SearchParam.Add(spNs);

            var spNs2 = new CapabilityStatement.SearchParamComponent
            {
                Name = "url", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/NamingSystem-url"
            };

            resourceNamingSystem.SearchParam.Add(spNs2);

            var spNs3 = new CapabilityStatement.SearchParamComponent
            {
                Name = "value", Type = SearchParamType.String, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/NamingSystem-value"
            };

            resourceNamingSystem.SearchParam.Add(spNs3);

            var spNs4 = new CapabilityStatement.SearchParamComponent
            {
                Name = "kind", Type = SearchParamType.String, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/NamingSystem-kind"
            };

            resourceNamingSystem.SearchParam.Add(spNs4);

            // Location

            var resourceLocation = new CapabilityStatement.ResourceComponent
            {
                Type         = ResourceType.Location,
                UpdateCreate = false,
                Versioning   = CapabilityStatement.ResourceVersionPolicy.NoVersion
            };

            // add interactions
            //var confRead3 = new CapabilityStatement.ResourceInteractionComponent();
            //confRead3.Code = CapabilityStatement.TypeRestfulInteraction.Read;
            //confRead3.Documentation = "Read allows clients to get the logical definitions of the locations";
            //resourceLocation.Interaction.Add(confRead3);

            var confSearch3 = new CapabilityStatement.ResourceInteractionComponent
            {
                Code          = CapabilityStatement.TypeRestfulInteraction.SearchType,
                Documentation = new Markdown("Search allows clients to find Locations (NZ Healthcare Facilities) on the server")
            };

            resourceLocation.Interaction.Add(confSearch3);

            // add search parameters

            var sp31 = new CapabilityStatement.SearchParamComponent
            {
                Name = "address", Type = SearchParamType.Date, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/Location-address"
            };

            resourceLocation.SearchParam.Add(sp31);

            var sp32 = new CapabilityStatement.SearchParamComponent
            {
                Name = "address-city", Type = SearchParamType.String, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/Location-address-city"
            };

            resourceLocation.SearchParam.Add(sp32);

            var sp33 = new CapabilityStatement.SearchParamComponent
            {
                Name = "address-postalcode", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/Location-address-postalcode"
            };

            resourceLocation.SearchParam.Add(sp33);

            var sp34 = new CapabilityStatement.SearchParamComponent
            {
                Name = "identifier", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/Location-identifier"
            };

            resourceLocation.SearchParam.Add(sp34);

            var sp35 = new CapabilityStatement.SearchParamComponent
            {
                Name = "name", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/Location-name"
            };

            resourceLocation.SearchParam.Add(sp35);

            var sp36 = new CapabilityStatement.SearchParamComponent
            {
                Name = "type", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/Location-type"
            };

            resourceLocation.SearchParam.Add(sp36);

            // Organization

            var resourceOrganization = new CapabilityStatement.ResourceComponent
            {
                Type         = ResourceType.Organization,
                ReadHistory  = false,
                UpdateCreate = false,
                Versioning   = CapabilityStatement.ResourceVersionPolicy.NoVersion
            };

            // add interactions
            //var confRead4 = new CapabilityStatement.ResourceInteractionComponent();
            //confRead4.Code = CapabilityStatement.TypeRestfulInteraction.Read;
            //confRead4.Documentation = "Read allows clients to get the logical definitions of the locations";
            //resourceOrganization.Interaction.Add(confRead4);

            var confSearch4 = new CapabilityStatement.ResourceInteractionComponent
            {
                Code          = CapabilityStatement.TypeRestfulInteraction.SearchType,
                Documentation = new Markdown("Search allows clients to find Organizations on the server")
            };

            resourceOrganization.Interaction.Add(confSearch4);

            // add search parameters

            var sp41 = new CapabilityStatement.SearchParamComponent
            {
                Name = "address", Type = SearchParamType.Date, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/Organization-address"
            };

            resourceOrganization.SearchParam.Add(sp41);

            var sp42 = new CapabilityStatement.SearchParamComponent
            {
                Name = "address-city", Type = SearchParamType.String, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/Organization-address-city"
            };

            resourceOrganization.SearchParam.Add(sp42);

            var sp43 = new CapabilityStatement.SearchParamComponent
            {
                Name = "address-postalcode", Type = SearchParamType.Token, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/Organization-address-postalcode"
            };

            resourceOrganization.SearchParam.Add(sp43);

            var sp44 = new CapabilityStatement.SearchParamComponent
            {
                Name = "identifier", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/Organization-identifier"
            };

            resourceOrganization.SearchParam.Add(sp44);

            var sp45 = new CapabilityStatement.SearchParamComponent
            {
                Name = "name", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/Organization-name"
            };

            resourceOrganization.SearchParam.Add(sp45);

            var sp46 = new CapabilityStatement.SearchParamComponent
            {
                Name = "type", Type = SearchParamType.Uri, Definition = HL7_FHIR_CANONICAL + "/SearchParameter/Organization-type"
            };

            resourceOrganization.SearchParam.Add(sp46);

            // add resources to server object

            //server.Resource.Add(resourceCapabilityStatement);

            server.Resource.Add(resourceTerminologyCapabilities);
            server.Resource.Add(resourceOperationDefinition);
            server.Resource.Add(resourceCodeSystem);
            server.Resource.Add(resourceValueSet);
            server.Resource.Add(resourceConceptMap);
            server.Resource.Add(resourceNamingSystem);
            server.Resource.Add(resourceLocation);
            server.Resource.Add(resourceOrganization);

            // add operations to server object

            var opCom1 = new CapabilityStatement.OperationComponent {
                Name = "lookup", Definition = TERMINZ_CANONICAL + "/OperationDefinition/CodeSystem-lookup"
            };

            server.Operation.Add(opCom1);

            var opCom1a = new CapabilityStatement.OperationComponent {
                Name = "validate-code", Definition = TERMINZ_CANONICAL + "/OperationDefinition/CodeSystem-validate-code"
            };

            //opCom5.FhirCommentsElement.Add(new FhirString("Supported in batch request"));
            server.Operation.Add(opCom1a);

            var opCom2 = new CapabilityStatement.OperationComponent {
                Name = "subsumes", Definition = TERMINZ_CANONICAL + "/OperationDefinition/CodeSystem-subsumes"
            };

            server.Operation.Add(opCom2);

            var opCom3 = new CapabilityStatement.OperationComponent {
                Name = "find-matches", Definition = HL7_FHIR_CANONICAL + "/OperationDefinition/CodeSystem-find-matches"
            };

            server.Operation.Add(opCom3);

            var opCom4 = new CapabilityStatement.OperationComponent {
                Name = "expand", Definition = TERMINZ_CANONICAL + "/OperationDefinition/ValueSet-expand"
            };

            server.Operation.Add(opCom4);

            var opCom5 = new CapabilityStatement.OperationComponent {
                Name = "validate-code", Definition = TERMINZ_CANONICAL + "/OperationDefinition/ValueSet-validate-code"
            };

            //opCom5.FhirCommentsElement.Add(new FhirString("Supported in batch request"));
            server.Operation.Add(opCom5);

            var opCom6 = new CapabilityStatement.OperationComponent {
                Name = "translate", Definition = TERMINZ_CANONICAL + "/OperationDefinition/ConceptMap-translate"
            };

            //opCom6.FhirCommentsElement.Add(new FhirString("Supported in batch request"));
            server.Operation.Add(opCom6);

            var opCom7 = new CapabilityStatement.OperationComponent {
                Name = "closure", Definition = HL7_FHIR_CANONICAL + "/OperationDefinition/ConceptMap-closure"
            };

            server.Operation.Add(opCom7);

            var opCom8 = new CapabilityStatement.OperationComponent {
                Name = "preferred-id", Definition = HL7_FHIR_CANONICAL + "/OperationDefinition/NamingSystem-preferred-id"
            };

            server.Operation.Add(opCom8);

            var opCom9 = new CapabilityStatement.OperationComponent {
                Name = "versions", Definition = HL7_FHIR_CANONICAL + "/OperationDefinition/CapabilityStatement-versions"
            };

            server.Operation.Add(opCom9);

            // add server to capability statement object
            capabilityStatement.Rest.Add(server);

            // create text
            AddNarrative(capabilityStatement, server);

            return(capabilityStatement);
        }