private async Task <SearchParameter> CreateSearchParam(string searchParamName, string searchParamCode)
        {
            var searchParam = new SearchParameter()
            {
                Url  = $"http://hl7.org/fhir/SearchParameter/Patient-{searchParamName}",
                Type = SearchParamType.String,
                Base = new List <ResourceType?>()
                {
                    ResourceType.Patient
                },
                Expression = "Patient.name",
                Name       = searchParamName,
                Code       = searchParamCode,
            };

            _searchParameterDefinitionManager.AddNewSearchParameters(new List <ITypedElement> {
                searchParam.ToTypedElement()
            });

            // Add the search parameter to the datastore
            await _searchParameterStatusManager.UpdateSearchParameterStatusAsync(new List <string> {
                searchParam.Url.ToString()
            }, SearchParameterStatus.Supported);

            return(searchParam);
        }
示例#2
0
        public async Task <(bool success, string message)> UpdateSearchParameterStatus(IReadOnlyCollection <string> searchParameterUris, CancellationToken cancellationToken)
        {
            try
            {
                await _searchParameterStatusManager.UpdateSearchParameterStatusAsync(searchParameterUris, SearchParameterStatus.Enabled);
            }
            catch (SearchParameterNotSupportedException spx)
            {
                var errorMessage = spx.Issues.FirstOrDefault()?.Diagnostics ?? Core.Resources.SearchParameterUnknownNotSupported;
                return(false, string.Format(Core.Resources.SearchParameterNoLongerSupported, errorMessage));
            }

            return(true, null);
        }