View Javadoc
1   package ca.uhn.fhir.jpa.provider.dstu3;
2   
3   /*
4    * #%L
5    * HAPI FHIR JPA Server
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import ca.uhn.fhir.jpa.dao.IFhirResourceDaoCodeSystem;
24  import ca.uhn.fhir.jpa.dao.IFhirResourceDaoCodeSystem.LookupCodeResult;
25  import ca.uhn.fhir.jpa.util.JpaConstants;
26  import ca.uhn.fhir.rest.annotation.Operation;
27  import ca.uhn.fhir.rest.annotation.OperationParam;
28  import ca.uhn.fhir.rest.api.server.RequestDetails;
29  import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
30  import org.hl7.fhir.convertors.VersionConvertor_30_40;
31  import org.hl7.fhir.dstu3.model.*;
32  import org.hl7.fhir.exceptions.FHIRException;
33  
34  import javax.servlet.http.HttpServletRequest;
35  import java.util.List;
36  
37  public class BaseJpaResourceProviderCodeSystemDstu3 extends JpaResourceProviderDstu3<CodeSystem> {
38  
39  	@SuppressWarnings("unchecked")
40  	@Operation(name = JpaConstants.OPERATION_LOOKUP, idempotent = true, returnParameters= {
41  		@OperationParam(name="name", type=StringType.class, min=1),
42  		@OperationParam(name="version", type=StringType.class, min=0),
43  		@OperationParam(name="display", type=StringType.class, min=1),
44  		@OperationParam(name="abstract", type=BooleanType.class, min=1),
45  	})
46  	public Parameters lookup(
47  			HttpServletRequest theServletRequest,
48  			@OperationParam(name="code", min=0, max=1) CodeType theCode, 
49  			@OperationParam(name="system", min=0, max=1) UriType theSystem,
50  			@OperationParam(name="coding", min=0, max=1) Coding theCoding,
51  			@OperationParam(name = "property", min = 0, max = OperationParam.MAX_UNLIMITED) List<CodeType> theProperties,
52  			RequestDetails theRequestDetails
53  			) {
54  
55  		startRequest(theServletRequest);
56  		try {
57  			IFhirResourceDaoCodeSystem<CodeSystem, Coding, CodeableConcept> dao = (IFhirResourceDaoCodeSystem<CodeSystem, Coding, CodeableConcept>) getDao();
58  			LookupCodeResult result = dao.lookupCode(theCode, theSystem, theCoding, theRequestDetails);
59  			result.throwNotFoundIfAppropriate();
60  			org.hl7.fhir.r4.model.Parameters parametersR4 = result.toParameters(theProperties);
61  			return VersionConvertor_30_40.convertParameters(parametersR4);
62  		} catch (FHIRException e) {
63  			throw new InternalErrorException(e);
64  		} finally {
65  			endRequest(theServletRequest);
66  		}
67  	}
68  	
69  }