Search in sources :

Example 1 with DvCodedText

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());
}
Also used : DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) Coding(org.hl7.fhir.r4.model.Coding) Test(org.junit.jupiter.api.Test)

Example 2 with DvCodedText

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());
}
Also used : DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) Coding(org.hl7.fhir.r4.model.Coding) Test(org.junit.jupiter.api.Test)

Example 3 with DvCodedText

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));
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) TerminologyServiceException(org.ehrbase.fhirbridge.service.TerminologyServiceException)

Example 4 with DvCodedText

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);
}
Also used : FhirTerminologyServerR4AdaptorImpl(org.ehrbase.service.FhirTerminologyServerR4AdaptorImpl) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) HttpClient(org.apache.http.client.HttpClient) SSLContext(javax.net.ssl.SSLContext) FhirTsProps(org.ehrbase.service.FhirTsProps) IOException(java.io.IOException) GeneralSecurityException(java.security.GeneralSecurityException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with DvCodedText

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);
}
Also used : FhirTerminologyServerR4AdaptorImpl(org.ehrbase.service.FhirTerminologyServerR4AdaptorImpl) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) FhirTsProps(org.ehrbase.service.FhirTsProps) IOException(java.io.IOException) GeneralSecurityException(java.security.GeneralSecurityException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)74 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)56 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)50 Test (org.junit.jupiter.api.Test)25 DvText (com.nedap.archie.rm.datavalues.DvText)17 Test (org.junit.Test)15 Composition (com.nedap.archie.rm.composition.Composition)9 ArrayList (java.util.ArrayList)9 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)8 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)8 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)7 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)7 List (java.util.List)7 AbstractRMObjectValidatorTest (org.ehrbase.validation.webtemplate.AbstractRMObjectValidatorTest)7 IOException (java.io.IOException)6 PersistedPartyProxy (org.ehrbase.dao.access.jooq.party.PersistedPartyProxy)6 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)6 FlatPathDto (org.ehrbase.webtemplate.path.flat.FlatPathDto)6 EventContext (com.nedap.archie.rm.composition.EventContext)4 DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)4