-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve mapping between XDS XON and FHIR Organization
Fixes #165
- Loading branch information
Showing
6 changed files
with
128 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/test/java/ch/bfh/ti/i4mi/mag/mhd/BaseQueryResponseConverterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package ch.bfh.ti.i4mi.mag.mhd; | ||
|
||
import ch.bfh.ti.i4mi.mag.Config; | ||
import ch.bfh.ti.i4mi.mag.mhd.iti67.Iti67ResponseConverter; | ||
import org.junit.jupiter.api.Test; | ||
import org.openehealth.ipf.commons.ihe.xds.core.metadata.Hl7v2Based; | ||
import org.openehealth.ipf.commons.ihe.xds.core.metadata.Organization; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* Tests for {@link BaseQueryResponseConverter}. | ||
* | ||
* @author Quentin Ligier | ||
**/ | ||
class BaseQueryResponseConverterTest { | ||
|
||
@Test | ||
void testTransformOrganization() { | ||
final var converter = new Iti67ResponseConverter(new Config()); | ||
|
||
var fhirOrg = converter.transform(Hl7v2Based.parse("Test^^^^^^^^^1234", Organization.class)); | ||
assertEquals("Test", fhirOrg.getName()); | ||
assertEquals(1, fhirOrg.getIdentifier().size()); | ||
assertEquals("1234", fhirOrg.getIdentifierFirstRep().getValue()); | ||
assertFalse(fhirOrg.getIdentifierFirstRep().hasSystem()); | ||
|
||
fhirOrg = converter.transform(Hl7v2Based.parse("Test^^^^^&1.2.3&ISO^^^^1234", Organization.class)); | ||
assertEquals("Test", fhirOrg.getName()); | ||
assertEquals(1, fhirOrg.getIdentifier().size()); | ||
assertEquals("1234", fhirOrg.getIdentifierFirstRep().getValue()); | ||
assertEquals("urn:oid:1.2.3", fhirOrg.getIdentifierFirstRep().getSystem()); | ||
|
||
fhirOrg = converter.transform(Hl7v2Based.parse("Test^^^^^^^^^1.2.3", Organization.class)); | ||
assertEquals("Test", fhirOrg.getName()); | ||
assertEquals(1, fhirOrg.getIdentifier().size()); | ||
assertEquals("urn:oid:1.2.3", fhirOrg.getIdentifierFirstRep().getValue()); | ||
assertEquals("urn:ietf:rfc:3986", fhirOrg.getIdentifierFirstRep().getSystem()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/test/java/ch/bfh/ti/i4mi/mag/mhd/iti65/Iti65RequestConverterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package ch.bfh.ti.i4mi.mag.mhd.iti65; | ||
|
||
import org.hl7.fhir.r4.model.Organization; | ||
import org.junit.jupiter.api.Test; | ||
import org.openehealth.ipf.commons.ihe.xds.core.metadata.Hl7v2Based; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* Tests for {@link Iti65RequestConverter}. | ||
* | ||
* @author Quentin Ligier | ||
**/ | ||
class Iti65RequestConverterTest { | ||
|
||
@Test | ||
void testTransformOrganization() { | ||
final var iti65RequestConverter = new Iti65RequestConverter(); | ||
|
||
final var org = new Organization(); | ||
org.setName("Test"); | ||
org.addIdentifier().setValue("1234"); | ||
|
||
var xon = iti65RequestConverter.transform(org); | ||
assertEquals("Test^^^^^^^^^1234", Hl7v2Based.render(xon)); | ||
|
||
org.getIdentifierFirstRep().setSystem("urn:oid:1.2.3"); | ||
xon = iti65RequestConverter.transform(org); | ||
assertEquals("Test^^^^^&1.2.3&ISO^^^^1234", Hl7v2Based.render(xon)); | ||
|
||
org.getIdentifierFirstRep().setValue("urn:oid:1.2.3").setSystem("urn:ietf:rfc:3986"); | ||
xon = iti65RequestConverter.transform(org); | ||
assertEquals("Test^^^^^^^^^1.2.3", Hl7v2Based.render(xon)); | ||
} | ||
} |