Skip to content

Commit

Permalink
Generate valid XON when the FHIR Organization identifier has no system
Browse files Browse the repository at this point in the history
Fixes #165
  • Loading branch information
qligier committed Jul 30, 2024
1 parent 610d886 commit 7c8187b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Unreleased

- Fixed an NPE in the assertion route
- Generate valid XON when the FHIR Organization identifier has no system [165](https://github.com/i4mi/MobileAccessGateway/issues/165)

## 2024/05/15 v070
- support for multiple IDP's [128](https://github.com/i4mi/MobileAccessGateway/issues/128)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1000,17 +1000,21 @@ public Telecom transform(ContactPoint contactPoint) {
}

/**
* FHIR Organization -> XDS Organization
* FHIR Organization -> IPF Organization (XDS XON)
* @param org
* @return
*/
public org.openehealth.ipf.commons.ihe.xds.core.metadata.Organization transform(Organization org) {
org.openehealth.ipf.commons.ihe.xds.core.metadata.Organization result = new org.openehealth.ipf.commons.ihe.xds.core.metadata.Organization();
final var result = new org.openehealth.ipf.commons.ihe.xds.core.metadata.Organization();
result.setOrganizationName(org.getName());
Identifier identifier = org.getIdentifierFirstRep();
final Identifier identifier = org.getIdentifierFirstRep();
if (identifier != null) {
result.setIdNumber(identifier.getValue());
result.setAssigningAuthority(new AssigningAuthority(noPrefix(identifier.getSystem())));
if (identifier.hasValue()) {
result.setIdNumber(identifier.getValue());
}
if (identifier.hasSystem()) {
result.setAssigningAuthority(new AssigningAuthority(noPrefix(identifier.getSystem())));
}
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ch.bfh.ti.i4mi.mag.mhd.iti65;

import ca.uhn.hl7v2.HL7Exception;
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.*;

/**
* MobileAccessGateway
*
* @author Quentin Ligier
**/
class Iti65RequestConverterTest {

@Test
void testTransformOrganization() {
Iti65RequestConverter 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));
}
}

0 comments on commit 7c8187b

Please sign in to comment.