001package ca.uhn.fhir.jpa.api.dao;
002
003import ca.uhn.fhir.context.FhirContext;
004import ca.uhn.fhir.context.support.IValidationSupport;
005import ca.uhn.fhir.rest.api.server.RequestDetails;
006import ca.uhn.fhir.util.ParametersUtil;
007import org.hl7.fhir.instance.model.api.IBaseParameters;
008import org.hl7.fhir.instance.model.api.IBaseResource;
009import org.hl7.fhir.instance.model.api.IIdType;
010import org.hl7.fhir.instance.model.api.IPrimitiveType;
011import org.hl7.fhir.r4.model.codesystems.ConceptSubsumptionOutcome;
012
013import javax.annotation.Nonnull;
014import java.util.List;
015
016/*
017 * #%L
018 * HAPI FHIR JPA API
019 * %%
020 * Copyright (C) 2014 - 2021 Smile CDR, Inc.
021 * %%
022 * Licensed under the Apache License, Version 2.0 (the "License");
023 * you may not use this file except in compliance with the License.
024 * You may obtain a copy of the License at
025 *
026 *      http://www.apache.org/licenses/LICENSE-2.0
027 *
028 * Unless required by applicable law or agreed to in writing, software
029 * distributed under the License is distributed on an "AS IS" BASIS,
030 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
031 * See the License for the specific language governing permissions and
032 * limitations under the License.
033 * #L%
034 */
035
036public interface IFhirResourceDaoCodeSystem<T extends IBaseResource, CD, CC> extends IFhirResourceDao<T> {
037
038        List<IIdType> findCodeSystemIdsContainingSystemAndCode(String theCode, String theSystem, RequestDetails theRequest);
039
040        @Nonnull
041        IValidationSupport.LookupCodeResult lookupCode(IPrimitiveType<String> theCode, IPrimitiveType<String> theSystem, CD theCoding, RequestDetails theRequestDetails);
042
043        @Nonnull
044        IValidationSupport.LookupCodeResult lookupCode(IPrimitiveType<String> theCode, IPrimitiveType<String> theSystem, CD theCoding, IPrimitiveType<String> theDisplayLanguage, RequestDetails theRequestDetails);
045
046        SubsumesResult subsumes(IPrimitiveType<String> theCodeA, IPrimitiveType<String> theCodeB, IPrimitiveType<String> theSystem, CD theCodingA, CD theCodingB, RequestDetails theRequestDetails);
047
048        IValidationSupport.CodeValidationResult validateCode(IIdType theCodeSystemId, IPrimitiveType<String> theCodeSystemUrl, IPrimitiveType<String> theVersion, IPrimitiveType<String> theCode, IPrimitiveType<String> theDisplay, CD theCoding, CC theCodeableConcept, RequestDetails theRequestDetails);
049
050        class SubsumesResult {
051
052                private final ConceptSubsumptionOutcome myOutcome;
053
054                public SubsumesResult(ConceptSubsumptionOutcome theOutcome) {
055                        myOutcome = theOutcome;
056                }
057
058                public ConceptSubsumptionOutcome getOutcome() {
059                        return myOutcome;
060                }
061
062                @SuppressWarnings("unchecked")
063                public IBaseParameters toParameters(FhirContext theFhirContext) {
064                        IBaseParameters retVal = ParametersUtil.newInstance(theFhirContext);
065
066                        IPrimitiveType<String> outcomeValue = (IPrimitiveType<String>) theFhirContext.getElementDefinition("code").newInstance();
067                        outcomeValue.setValueAsString(getOutcome().toCode());
068                        ParametersUtil.addParameterToParameters(theFhirContext, retVal, "outcome", outcomeValue);
069
070                        return retVal;
071                }
072        }
073
074
075}