Esempio n. 1
0
        private bool ValidateSearchParameterSupported(DtoServiceSearchParameterLight oSupported, ISearchParameterBase oInboundSearchParameter, IList <UnspportedSearchParameter> UnspportedSearchParameterList)
        {
            UnspportedSearchParameter DtoUnspportedSearchParameter = null;

            if (!oInboundSearchParameter.IsValid)
            {
                DtoUnspportedSearchParameter = InitaliseUnspportedParamerter(oInboundSearchParameter, DtoUnspportedSearchParameter);
                DtoUnspportedSearchParameter.ReasonMessage = DtoUnspportedSearchParameter.ReasonMessage + oInboundSearchParameter.InvalidMessage + ", ";
            }

            if (oInboundSearchParameter.Modifier.HasValue)
            {
                IList <SearchParameter.SearchModifierCode> oSupportedModifierList = Common.Tools.SearchParameterTools.GetModifiersForSearchType(oInboundSearchParameter.Type);
                if (!oSupportedModifierList.Contains(oInboundSearchParameter.Modifier.Value))
                {
                    DtoUnspportedSearchParameter = InitaliseUnspportedParamerter(oInboundSearchParameter, DtoUnspportedSearchParameter);
                    DtoUnspportedSearchParameter.ReasonMessage = DtoUnspportedSearchParameter.ReasonMessage + $"The parameter's modifier: '{oInboundSearchParameter.Modifier.ToString()}' is not supported by this server for the resource type '{oInboundSearchParameter.Resource.ToString()}', the whole parameter was : '{DtoUnspportedSearchParameter.RawParameter}', ";
                }
                if (oInboundSearchParameter.Modifier == SearchParameter.SearchModifierCode.Type)
                {
                    if (!ServiceSearchParameterFactory.GetSearchParameterTargetResourceList(oInboundSearchParameter).Contains(oInboundSearchParameter.TypeModifierResource))
                    {
                        DtoUnspportedSearchParameter = InitaliseUnspportedParamerter(oInboundSearchParameter, DtoUnspportedSearchParameter);
                        DtoUnspportedSearchParameter.ReasonMessage = DtoUnspportedSearchParameter.ReasonMessage + $"The search parameter modifier was expected to be a Fhir resource type that is supported for this search parameter. The Resource given was: {oInboundSearchParameter.TypeModifierResource} which is not supported for the search parameter '{oInboundSearchParameter.Name}.', ";
                    }
                }
            }

            if (!oInboundSearchParameter.ValidatePrefixes(oSupported))
            {
                DtoUnspportedSearchParameter = InitaliseUnspportedParamerter(oInboundSearchParameter, DtoUnspportedSearchParameter);
                string PreFixListString = string.Empty;
                Common.Tools.SearchParameterTools.GetPrefixListForSearchType(oSupported.Type).ForEach(x => PreFixListString = PreFixListString + "," + x);
                if (PreFixListString == string.Empty)
                {
                    PreFixListString = "(none)";
                }
                else
                {
                    PreFixListString = $"({PreFixListString})";
                }
                DtoUnspportedSearchParameter.ReasonMessage = DtoUnspportedSearchParameter.ReasonMessage + $"The one or more of the search parameter prefixes are not supported by this server against resource type of :'{oInboundSearchParameter.Resource.ToString()}', the whole parameter given was : '{DtoUnspportedSearchParameter.RawParameter}'. The prefixes that are supported are: {PreFixListString}, ";
            }

            if (oInboundSearchParameter.TypeModifierResource != null)
            {
                if (!ServiceSearchParameterFactory.GetSearchParameterTargetResourceList(oInboundSearchParameter).Contains(oInboundSearchParameter.TypeModifierResource))
                {
                    DtoUnspportedSearchParameter = InitaliseUnspportedParamerter(oInboundSearchParameter, DtoUnspportedSearchParameter);
                    DtoUnspportedSearchParameter.ReasonMessage = DtoUnspportedSearchParameter.ReasonMessage + String.Format("Unsupported search, the Resource type given as the Modifier is not supported. Resource type: '{0}' in parameter '{1}'., ", oInboundSearchParameter.TypeModifierResource.ToString(), oInboundSearchParameter.RawValue);
                }
            }

            if (DtoUnspportedSearchParameter != null)
            {
                UnspportedSearchParameterList.Add(DtoUnspportedSearchParameter);
                return(false);
            }
            else
            {
                UnspportedSearchParameterList.Clear();
                return(true);
            }
        }