diff --git a/docs/changelog.md b/docs/changelog.md index b4a5930..db805ea 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,7 +1,9 @@ ## Unreleased - Fixed an NPE in the assertion route -- capability statment validation issues [177](https://github.com/i4mi/MobileAccessGateway/issues/177) +- capability statement validation issues [#177](https://github.com/i4mi/MobileAccessGateway/issues/177) +- Add CH PIXm ITI-83 constraints for sourceIdentifier and targetSystem [#170](https://github.com/i4mi/MobileAccessGateway/issues/170) + ## 2024/05/15 v070 - support for multiple IDP's [128](https://github.com/i4mi/MobileAccessGateway/issues/128) diff --git a/src/main/java/ch/bfh/ti/i4mi/mag/pmir/iti83/Iti83RequestConverter.java b/src/main/java/ch/bfh/ti/i4mi/mag/pmir/iti83/Iti83RequestConverter.java index 25e7a46..6a82e93 100644 --- a/src/main/java/ch/bfh/ti/i4mi/mag/pmir/iti83/Iti83RequestConverter.java +++ b/src/main/java/ch/bfh/ti/i4mi/mag/pmir/iti83/Iti83RequestConverter.java @@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired; import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException; +import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ch.bfh.ti.i4mi.mag.BaseRequestConverter; import ch.bfh.ti.i4mi.mag.Config; import lombok.extern.slf4j.Slf4j; @@ -88,15 +89,33 @@ public String iti83ToIti45Converter(Parameters parameters) throws JAXBException // https://fhir.ch/ig/ch-epr-fhir/iti-83.html#message-semantics-1 if (sourceIdentifier == null) { log.error("sourceIdentifier is missing"); - throw new ForbiddenOperationException("sourceIdentifier is missing", getTargetDomainNotRecognized()); + throw new InvalidRequestException("sourceIdentifier is missing", getTargetDomainNotRecognized()); } - if (targetSystemList == null || (targetSystemList.size() != 2)) { + + if (sourceIdentifier != null && (sourceIdentifier.getSystem() == null || sourceIdentifier.getValue() == null)) { + log.error("sourceIdentifier system or value is missing"); + throw new InvalidRequestException("sourceIdentifier is missing", getTargetDomainNotRecognized()); + } + + // FIXME https://gazelle.ihe.net/jira/servicedesk/customer/portal/8/EHS-820 + if (targetSystemList == null || (targetSystemList.size() == 0)) { +// if (targetSystemList == null || (targetSystemList.size() != 2)) { log.error("targetSystem need to be 2..2"); throw new ForbiddenOperationException("targetSystem need to be 2..2", getTargetDomainNotRecognized()); } + // FIXME https://gazelle.ihe.net/jira/servicedesk/customer/portal/8/EHS-820 UriType uri1 = (UriType) targetSystemList.get(0).getValue(); - UriType uri2 = (UriType) targetSystemList.get(1).getValue(); - if (!((uri1.equals("urn:oid:"+config.OID_EPRSPID) && uri2.equals("urn:oid:"+config.getOidMpiPid()) || (uri1.equals("urn:oid:"+config.getOidMpiPid()) && uri2.equals("urn:oid:"+config.OID_EPRSPID))))) { + if (uri1.getValue().equals(config.OID_EPRSPID)) { + uri1.setValue("urn:oid:"+config.OID_EPRSPID); + } + UriType uri2 = null; + if (targetSystemList.size()>1) { + uri2 = (UriType) targetSystemList.get(1).getValue(); + if (uri2.getValue().equals(config.OID_EPRSPID)) { + uri2.setValue("urn:oid:"+config.OID_EPRSPID); + } + } + if (!((uri1.equals("urn:oid:"+config.OID_EPRSPID) && (uri2==null || uri2.equals("urn:oid:"+config.getOidMpiPid())) || (uri1.equals("urn:oid:"+config.getOidMpiPid()) && (uri2==null || uri2.equals("urn:oid:"+config.OID_EPRSPID)))))) { log.error("targetSystem is not restricted to the Assigning authority of the community and the EPR-SPID"); throw new ForbiddenOperationException("targetSystem is not restricted to the Assigning authority of the community and the EPR-SPID,", getTargetDomainNotRecognized()); }