use of com.nedap.archie.rm.datavalues.DvCodedText in project fhir-bridge by ehrbase.
the class DvCodedTextParserIT method testConvert.
@Test
void testConvert() {
Coding coding = new Coding("http://hl7.org/fhir/address-type", "both", null);
Optional<DvCodedText> dvCodedText = parser.parseFHIRCoding(coding);
Assertions.assertTrue(dvCodedText.isPresent());
Assertions.assertEquals(coding.getSystem(), dvCodedText.get().getDefiningCode().getTerminologyId().getValue());
Assertions.assertEquals(coding.getCode(), dvCodedText.get().getDefiningCode().getCodeString());
Assertions.assertEquals("Postal & Physical", dvCodedText.get().getValue());
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project fhir-bridge by ehrbase.
the class DvCodedTextParserTest method testConvert.
@Test
void testConvert() {
Coding coding = new Coding("http://snomed.info/sct", "408475000", "Diabetic medicine");
Optional<DvCodedText> dvCodedText = DvCodedTextParser.getInstance().parseFHIRCoding(coding);
Assertions.assertTrue(dvCodedText.isPresent());
Assertions.assertEquals(coding.getSystem(), dvCodedText.get().getDefiningCode().getTerminologyId().getValue());
Assertions.assertEquals(coding.getCode(), dvCodedText.get().getDefiningCode().getCodeString());
Assertions.assertEquals(coding.getDisplay(), dvCodedText.get().getValue());
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project fhir-bridge by ehrbase.
the class DvCodedTextParser method parseFHIRCoding.
public Optional<DvCodedText> parseFHIRCoding(Coding coding) {
if (coding == null) {
return Optional.empty();
}
if (!coding.hasSystem() || !coding.hasCode()) {
throw new ConversionException("Coding must have a system and a code");
}
String display;
if (coding.hasDisplay()) {
display = coding.getDisplay();
} else {
try {
display = getDisplay(coding.getSystem(), coding.getCode()).orElseThrow(() -> new ConversionException("Coding must have a display or TerminologyService must not be null"));
} catch (TerminologyServiceException e) {
throw new ConversionException("Cannot convert coding. Reason: " + e.getMessage(), e);
}
}
CodePhrase codePhrase = new CodePhrase(new TerminologyId(coding.getSystem()), coding.getCode());
return Optional.of(new DvCodedText(display, codePhrase));
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project ehrbase by ehrbase.
the class FhirTerminologyServerR4AdaptorImplTest method expandValueSetUsingSsl.
@Ignore("Requires SSL configuration")
@Test
public void expandValueSetUsingSsl() throws GeneralSecurityException, IOException {
SSLContext sslContext = SSLContextBuilder.create().loadKeyMaterial(ResourceUtils.getFile("test-keystore.jks"), "test".toCharArray(), "test".toCharArray()).loadTrustMaterial(ResourceUtils.getFile("test-truststore.jks"), "test".toCharArray(), TrustAllStrategy.INSTANCE).build();
HttpClient httpClient = HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build();
FhirTsProps props = new FhirTsProps();
props.setCodePath("$[\"expansion\"][\"contains\"][*][\"code\"]");
props.setDisplayPath("$[\"expansion\"][\"contains\"][*][\"display\"]");
props.setSystemPath("$[\"expansion\"][\"contains\"][*][\"system\"]");
props.setTsUrl("https://terminology-highmed.medic.medfak.uni-koeln.de/fhir/");
try {
tsserver = new FhirTerminologyServerR4AdaptorImpl(httpClient, props);
} catch (Exception e) {
e.printStackTrace();
}
List<DvCodedText> result = tsserver.expandWithParameters("https://www.netzwerk-universitaetsmedizin.de/fhir/ValueSet/frailty-score", "expand");
result.forEach((e) -> System.out.println(e.getValue()));
// 1: Very Severely Frail
assertThat(result.get(0).getDefiningCode().getCodeString()).isEqualTo("8");
assertThat(result.get(0).getValue()).isEqualTo("Very Severely Frail");
// 2: Severely Frail
assertThat(result.get(1).getDefiningCode().getCodeString()).isEqualTo("7");
assertThat(result.get(1).getValue()).isEqualTo("Severely Frail");
// 3: Terminally Ill
assertThat(result.get(2).getDefiningCode().getCodeString()).isEqualTo("9");
assertThat(result.get(2).getValue()).isEqualTo("Terminally Ill");
// 4: Vulnerable
assertThat(result.get(3).getDefiningCode().getCodeString()).isEqualTo("4");
assertThat(result.get(3).getValue()).isEqualTo("Vulnerable");
assertThat(result.size()).isEqualTo(9);
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project ehrbase by ehrbase.
the class FhirTerminologyServerR4AdaptorImplTest method shouldRetrieveValueSet.
@Ignore("This test runs against ontoserver sample inteance. It is deactivated until we have a test FHIR terminology server and the architecture allows to run Spring integration tests.")
@Test
public void shouldRetrieveValueSet() {
FhirTsProps props = new FhirTsProps();
props.setCodePath("$[\"expansion\"][\"contains\"][*][\"code\"]");
props.setDisplayPath("$[\"expansion\"][\"contains\"][*][\"display\"]");
props.setSystemPath("$[\"expansion\"][\"contains\"][*][\"system\"]");
props.setTsUrl("https://r4.ontoserver.csiro.au/fhir/");
try {
tsserver = new FhirTerminologyServerR4AdaptorImpl(HttpClients.createDefault(), props);
} catch (Exception e) {
e.printStackTrace();
}
List<DvCodedText> result = tsserver.expandWithParameters("http://hl7.org/fhir/ValueSet/surface", "expand");
result.forEach((e) -> System.out.println(e.getValue()));
// 1: Buccal
assertThat(result.get(0).getDefiningCode().getCodeString()).isEqualTo("B");
assertThat(result.get(0).getValue()).isEqualTo("Buccal");
// 2: Distal
assertThat(result.get(1).getDefiningCode().getCodeString()).isEqualTo("D");
assertThat(result.get(1).getValue()).isEqualTo("Distal");
// 3: Distoclusal
assertThat(result.get(2).getDefiningCode().getCodeString()).isEqualTo("DO");
assertThat(result.get(2).getValue()).isEqualTo("Distoclusal");
// 4: Distoincisal
assertThat(result.get(3).getDefiningCode().getCodeString()).isEqualTo("DI");
assertThat(result.get(3).getValue()).isEqualTo("Distoincisal");
assertThat(result.size()).isEqualTo(11);
}
Aggregations