001package ca.uhn.fhir.jpa.searchparam.extractor;
002
003
004/*
005 * #%L
006 * HAPI FHIR Search Parameters
007 * %%
008 * Copyright (C) 2014 - 2022 Smile CDR, Inc.
009 * %%
010 * Licensed under the Apache License, Version 2.0 (the "License");
011 * you may not use this file except in compliance with the License.
012 * You may obtain a copy of the License at
013 *
014 *      http://www.apache.org/licenses/LICENSE-2.0
015 *
016 * Unless required by applicable law or agreed to in writing, software
017 * distributed under the License is distributed on an "AS IS" BASIS,
018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019 * See the License for the specific language governing permissions and
020 * limitations under the License.
021 * #L%
022 */
023
024import ca.uhn.fhir.context.RuntimeSearchParam;
025import ca.uhn.fhir.jpa.model.entity.BaseResourceIndexedSearchParam;
026import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamDate;
027import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamNumber;
028import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamQuantity;
029import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamQuantityNormalized;
030import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString;
031import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamToken;
032import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamUri;
033import org.hl7.fhir.instance.model.api.IBase;
034import org.hl7.fhir.instance.model.api.IBaseResource;
035
036import java.util.ArrayList;
037import java.util.Collections;
038import java.util.Date;
039import java.util.HashSet;
040import java.util.List;
041
042public interface ISearchParamExtractor {
043
044//      SearchParamSet<ResourceIndexedSearchParamCoords> extractSearchParamCoords(IBaseResource theResource);
045
046        SearchParamSet<ResourceIndexedSearchParamDate> extractSearchParamDates(IBaseResource theResource);
047
048        SearchParamSet<ResourceIndexedSearchParamNumber> extractSearchParamNumber(IBaseResource theResource);
049
050        SearchParamSet<ResourceIndexedSearchParamQuantity> extractSearchParamQuantity(IBaseResource theResource);
051
052        SearchParamSet<ResourceIndexedSearchParamQuantityNormalized> extractSearchParamQuantityNormalized(IBaseResource theResource);
053
054        SearchParamSet<ResourceIndexedSearchParamString> extractSearchParamStrings(IBaseResource theResource);
055
056        SearchParamSet<BaseResourceIndexedSearchParam> extractSearchParamTokens(IBaseResource theResource);
057
058        SearchParamSet<BaseResourceIndexedSearchParam> extractSearchParamTokens(IBaseResource theResource, RuntimeSearchParam theSearchParam);
059
060        SearchParamSet<BaseResourceIndexedSearchParam> extractSearchParamSpecial(IBaseResource theResource);
061
062        SearchParamSet<ResourceIndexedSearchParamUri> extractSearchParamUri(IBaseResource theResource);
063
064        SearchParamSet<PathAndRef> extractResourceLinks(IBaseResource theResource, boolean theWantLocalReferences);
065
066        String[] split(String theExpression);
067
068        List<String> extractParamValuesAsStrings(RuntimeSearchParam theActiveSearchParam, IBaseResource theResource);
069
070        List<IBase> extractValues(String thePaths, IBaseResource theResource);
071
072        String toRootTypeName(IBase nextObject);
073
074        String toTypeName(IBase nextObject);
075
076        PathAndRef extractReferenceLinkFromResource(IBase theValue, String thePath);
077
078        Date extractDateFromResource(IBase theValue, String thePath);
079
080        ResourceIndexedSearchParamToken createSearchParamForCoding(String theResourceType, RuntimeSearchParam theSearchParam, IBase theValue);
081
082        String getDisplayTextForCoding(IBase theValue);
083
084        BaseSearchParamExtractor.IValueExtractor getPathValueExtractor(IBaseResource theResource, String theSinglePath);
085
086        List<IBase> getCodingsFromCodeableConcept(IBase theValue);
087
088        String getDisplayTextFromCodeableConcept(IBase theValue);
089
090        class SearchParamSet<T> extends HashSet<T> {
091
092                private List<String> myWarnings;
093
094                public void addWarning(String theWarning) {
095                        if (myWarnings == null) {
096                                myWarnings = new ArrayList<>();
097                        }
098                        myWarnings.add(theWarning);
099                }
100
101                List<String> getWarnings() {
102                        if (myWarnings == null) {
103                                return Collections.emptyList();
104                        }
105                        return myWarnings;
106                }
107
108        }
109
110
111}