View Javadoc
1   package ca.uhn.fhir.jpa.provider.r4;
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 org.hl7.fhir.r4.model.*;
30  
31  import javax.servlet.http.HttpServletRequest;
32  import java.util.List;
33  
34  public class BaseJpaResourceProviderCodeSystemR4 extends JpaResourceProviderR4<CodeSystem> {
35  
36  	@SuppressWarnings("unchecked")
37  	@Operation(name = JpaConstants.OPERATION_LOOKUP, idempotent = true, returnParameters= {
38  		@OperationParam(name="name", type=StringType.class, min=1),
39  		@OperationParam(name="version", type=StringType.class, min=0),
40  		@OperationParam(name="display", type=StringType.class, min=1),
41  		@OperationParam(name="abstract", type=BooleanType.class, min=1),
42  	})
43  	public Parameters lookup(
44  			HttpServletRequest theServletRequest,
45  			@OperationParam(name="code", min=0, max=1) CodeType theCode, 
46  			@OperationParam(name="system", min=0, max=1) UriType theSystem,
47  			@OperationParam(name="coding", min=0, max=1) Coding theCoding,
48  			@OperationParam(name = "property", min = 0, max = OperationParam.MAX_UNLIMITED) List<CodeType> theProperties,
49  			RequestDetails theRequestDetails
50  			) {
51  
52  		startRequest(theServletRequest);
53  		try {
54  			IFhirResourceDaoCodeSystem<CodeSystem, Coding, CodeableConcept> dao = (IFhirResourceDaoCodeSystem<CodeSystem, Coding, CodeableConcept>) getDao();
55  			LookupCodeResult result = dao.lookupCode(theCode, theSystem, theCoding, theRequestDetails);
56  			result.throwNotFoundIfAppropriate();
57  			return result.toParameters(theProperties);
58  		} finally {
59  			endRequest(theServletRequest);
60  		}
61  	}
62  	
63  }