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