|
1 | 1 | package ca.uhn.fhir.jpa.starter.common; |
2 | 2 |
|
3 | | -import ca.uhn.fhir.context.FhirContext; |
4 | | -import ca.uhn.fhir.context.support.ConceptValidationOptions; |
5 | | -import ca.uhn.fhir.context.support.IValidationSupport; |
6 | | -import ca.uhn.fhir.context.support.ValidationSupportContext; |
7 | 3 | import ca.uhn.fhir.jpa.config.r4.JpaR4Config; |
8 | | -import ca.uhn.fhir.jpa.starter.AppProperties; |
9 | 4 | import ca.uhn.fhir.jpa.starter.annotations.OnR4Condition; |
10 | | -import ca.uhn.fhir.jpa.starter.common.validation.OnRemoteTerminologyPresent; |
11 | 5 | import ca.uhn.fhir.jpa.starter.cr.StarterCrR4Config; |
12 | 6 | import ca.uhn.fhir.jpa.starter.ips.StarterIpsConfig; |
13 | | -import org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport; |
14 | | -import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain; |
15 | | -import org.springframework.context.annotation.Bean; |
16 | 7 | import org.springframework.context.annotation.Conditional; |
17 | 8 | import org.springframework.context.annotation.Configuration; |
18 | 9 | import org.springframework.context.annotation.Import; |
|
26 | 17 | ElasticsearchConfig.class, |
27 | 18 | StarterIpsConfig.class |
28 | 19 | }) |
29 | | -public class FhirServerConfigR4 { |
30 | | - |
31 | | - @Bean(name = "myHybridRemoteValidationSupportChain") |
32 | | - @Conditional({OnR4Condition.class, OnRemoteTerminologyPresent.class}) |
33 | | - public IValidationSupport addRemoteValidation( |
34 | | - ValidationSupportChain theValidationSupport, FhirContext theFhirContext, AppProperties theAppProperties) { |
35 | | - var values = theAppProperties.getRemoteTerminologyServicesMap().values(); |
36 | | - |
37 | | - // If the remote terminology service is "*" and is the only one then forward all requests to the remote |
38 | | - // terminology service |
39 | | - if (values.size() == 1 && "*".equalsIgnoreCase(values.iterator().next().getSystem())) { |
40 | | - var remoteSystem = values.iterator().next(); |
41 | | - theValidationSupport.addValidationSupport( |
42 | | - 0, new RemoteTerminologyServiceValidationSupport(theFhirContext, remoteSystem.getUrl())); |
43 | | - return theValidationSupport; |
44 | | - |
45 | | - // If there are multiple remote terminology services, then add each one to the validation chain |
46 | | - } else { |
47 | | - values.forEach((remoteSystem) -> theValidationSupport.addValidationSupport( |
48 | | - 0, new RemoteTerminologyServiceValidationSupport(theFhirContext, remoteSystem.getUrl()) { |
49 | | - @Override |
50 | | - public boolean isCodeSystemSupported( |
51 | | - ValidationSupportContext theValidationSupportContext, String theSystem) { |
52 | | - return remoteSystem.getSystem().equalsIgnoreCase(theSystem); |
53 | | - } |
54 | | - |
55 | | - @Override |
56 | | - public CodeValidationResult validateCode( |
57 | | - ValidationSupportContext theValidationSupportContext, |
58 | | - ConceptValidationOptions theOptions, |
59 | | - String theCodeSystem, |
60 | | - String theCode, |
61 | | - String theDisplay, |
62 | | - String theValueSetUrl) { |
63 | | - if (remoteSystem.getSystem().equalsIgnoreCase(theCodeSystem)) { |
64 | | - return super.validateCode( |
65 | | - theValidationSupportContext, |
66 | | - theOptions, |
67 | | - theCodeSystem, |
68 | | - theCode, |
69 | | - theDisplay, |
70 | | - theValueSetUrl); |
71 | | - } |
72 | | - return null; |
73 | | - } |
74 | | - })); |
75 | | - } |
76 | | - return theValidationSupport; |
77 | | - } |
78 | | -} |
| 20 | +public class FhirServerConfigR4 {} |
0 commit comments