Exemple #1
0
        /// <summary>
        /// Map FHIR parameter type
        /// </summary>
        private static SearchParamType MapFhirParameterType <TModelType>(QueryParameterRewriteType type, string definition)
        {
            switch (type)
            {
            case QueryParameterRewriteType.Concept:
            case QueryParameterRewriteType.Identifier:
            case QueryParameterRewriteType.Token:
                return(SearchParamType.Token);

            case QueryParameterRewriteType.Reference:
                return(SearchParamType.Reference);

            case QueryParameterRewriteType.Indicator:
                return(SearchParamType.Token);

            default:
                try
                {
                    switch (GetQueryType <TModelType>(definition).StripNullable().Name)
                    {
                    case "String":
                        return(SearchParamType.String);

                    case "Uri":
                        return(SearchParamType.Uri);

                    case "Int32":
                    case "Int64":
                    case "Int16":
                    case "Double":
                    case "Decimal":
                    case "Float":
                        return(SearchParamType.Number);

                    case "DateTime":
                    case "DateTimeOffset":
                        return(SearchParamType.Date);

                    default:
                        return(SearchParamType.Composite);
                    }
                }
                catch
                {
                    return(SearchParamType.String);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Add search parameters
        /// </summary>
        public static void AddSearchParam <TFhirResource>(String fhirQueryParameter, String hdsiQueryParmeter, QueryParameterRewriteType type)
        {
            var resourceType = typeof(TFhirResource).GetResourceType();
            var mapConfig    = s_map.Map.FirstOrDefault(o => resourceType.HasValue ? resourceType.Value == o.Resource : !o.ResourceSpecified);

            if (mapConfig == null)
            {
                mapConfig = new QueryParameterType()
                {
                    Resource = resourceType.Value, ResourceSpecified = resourceType.HasValue
                };
                s_map.Map.Add(mapConfig);
            }

            // parm config
            var parmConfig = mapConfig.Map.FirstOrDefault(o => o.FhirQuery == fhirQueryParameter);

            if (parmConfig == null)
            {
                parmConfig = new QueryParameterMapProperty()
                {
                    FhirQuery  = fhirQueryParameter,
                    ModelQuery = hdsiQueryParmeter,
                    FhirType   = type
                };
            }
            else
            {
                parmConfig.ModelQuery = hdsiQueryParmeter;
                parmConfig.FhirType   = type;
            }
            mapConfig.Map.Add(parmConfig);
        }