1 package ca.uhn.fhir.jpa.provider.dstu3;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import ca.uhn.fhir.jpa.provider.BaseTerminologyUploaderProvider;
24 import ca.uhn.fhir.rest.annotation.Operation;
25 import ca.uhn.fhir.rest.annotation.OperationParam;
26 import ca.uhn.fhir.rest.api.server.RequestDetails;
27 import ca.uhn.fhir.rest.param.StringParam;
28 import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
29 import org.hl7.fhir.convertors.VersionConvertor_30_40;
30 import org.hl7.fhir.dstu3.model.Attachment;
31 import org.hl7.fhir.dstu3.model.IntegerType;
32 import org.hl7.fhir.dstu3.model.Parameters;
33 import org.hl7.fhir.dstu3.model.StringType;
34 import org.hl7.fhir.exceptions.FHIRException;
35
36 import javax.servlet.http.HttpServletRequest;
37 import java.util.ArrayList;
38 import java.util.List;
39
40 public class TerminologyUploaderProviderDstu3 extends BaseTerminologyUploaderProvider {
41
42 @Operation(name = UPLOAD_EXTERNAL_CODE_SYSTEM, idempotent = false, returnParameters = {
43 @OperationParam(name = "conceptCount", type = IntegerType.class, min = 1)
44 })
45 public Parameters uploadExternalCodeSystem(
46 HttpServletRequest theServletRequest,
47 @OperationParam(name = "url", min = 1) StringParam theCodeSystemUrl,
48 @OperationParam(name = "localfile", min = 1, max = OperationParam.MAX_UNLIMITED) List<StringType> theLocalFile,
49 @OperationParam(name = "package", min = 0, max = OperationParam.MAX_UNLIMITED) List<Attachment> thePackage,
50 RequestDetails theRequestDetails
51 ) {
52 try {
53 List<org.hl7.fhir.r4.model.StringType> localFile = null;
54 if (theLocalFile != null) {
55 localFile = new ArrayList<>();
56 for (StringType next : theLocalFile) {
57 localFile.add(VersionConvertor_30_40.convertString(next));
58 }
59 }
60 List<org.hl7.fhir.r4.model.Attachment> pkg = null;
61 if (thePackage!=null){
62 pkg = new ArrayList<>();
63 for (Attachment next : thePackage) {
64 pkg.add(VersionConvertor_30_40.convertAttachment(next));
65 }
66 }
67 org.hl7.fhir.r4.model.Parameters retValR4 = handleUploadExternalCodeSystem(theServletRequest, theCodeSystemUrl, localFile, pkg, theRequestDetails);
68 return VersionConvertor_30_40.convertParameters(retValR4);
69 } catch (FHIRException e) {
70 throw new InternalErrorException(e);
71 }
72 }
73 }