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