Skip to content

Commit

Permalink
#170 add configurable CH PIXm ITI-83 constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
oliveregger authored and qligier committed Nov 5, 2024
1 parent ec2eee5 commit eac57e4
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 22 deletions.
7 changes: 6 additions & 1 deletion example-config/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mag:
baseurl: http://localhost
# adjust here the baseurl to the external url which should be exposed
baseurl: http://localhost:9090
client-ssl:
enabled: true
# certificate from https://ehealthsuisse.ihe-europe.net/gss/certificate/view.seam?id=386
Expand Down Expand Up @@ -61,6 +62,10 @@ mag:
audit-repository-port: 3202
audit-repostiory-transport: TLS

ch-epr-fhir:
ch-pixm-constraints: true
epr-spid-as-patientid: true

# certificate from https://ehealthsuisse.ihe-europe.net/gss/certificate/view.seam?id=386
server:
max-http-header-size: 10000
Expand Down
18 changes: 9 additions & 9 deletions example-config/test.http
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
### PIXm Query with ERPSPID
GET http://localhost:9090/fhir/Patient/$ihe-pix?sourceIdentifier=urn:oid:2.16.756.5.30.1.127.3.10.3|761337610411265304 HTTP/1.1
### Responding Gateway configured
GET http://localhost:9090/fhir/metadata HTTP/1.1
Accept: application/fhir+json

### PIXm Query with ERPSPID
GET http://localhost:9090/fhir/Patient/$ihe-pix?sourceIdentifier=urn:oid:1.3.6.1.4.1.12559.11.25.1.19|PAM8776579876 HTTP/1.1
###
GET https://localhost:9091/fhir/metadata HTTP/1.1
Accept: application/fhir+json


### PDQm with identifier
GET http://localhost:9090/fhir/Patient?identifier=urn:oid:2.16.756.5.30.1.127.3.10.3|761337610411265304 HTTP/1.1
### PIXm Query general (returns 403 when ch-pixm-constraints: true)
GET http://localhost:9090/fhir/Patient/$ihe-pix?sourceIdentifier=urn:oid:1.3.6.1.4.1.12559.11.25.1.19|CHFACILITY900012 HTTP/1.1
Accept: application/fhir+json

### PDQm with identifier
GET http://localhost:9090/fhir/Patient?identifier=urn:oid:1.3.6.1.4.1.12559.11.25.1.19|PAM8776579876 HTTP/1.1
### PIXm Query according to CH PIXm constraints (see https://fhir.ch/ig/ch-epr-fhir/iti-83.html#message-semantics-1)
GET http://localhost:9090/fhir/Patient/$ihe-pix?sourceIdentifier=urn:oid:1.3.6.1.4.1.12559.11.25.1.19|CHFACILITY900012&targetSystem=urn:oid:2.16.756.5.30.1.127.3.10.3&targetSystem=urn:oid:1.3.6.1.4.1.12559.11.20.1 HTTP/1.1
Accept: application/fhir+json



### registered also 1.3.6.1.4.1.12559.11.25.1.19 in our repository

### certifactes used are from # certificate from https://ehealthsuisse.ihe-europe.net/gss/certificate/view.seam?id=386
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/ch/bfh/ti/i4mi/mag/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;
import org.hl7.fhir.instance.model.api.IBaseConformance;
import org.openehealth.ipf.commons.audit.AuditContext;
import org.openehealth.ipf.commons.audit.DefaultAuditContext;
import org.openehealth.ipf.commons.audit.protocol.TCPSyslogSender;
Expand All @@ -51,8 +50,6 @@
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.filter.CorsFilter;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.server.provider.ServerCapabilityStatementProvider;
import ch.bfh.ti.i4mi.mag.mhd.SchemeMapper;
import ch.bfh.ti.i4mi.mag.pmir.PatientReferenceCreator;
import lombok.Data;
Expand Down Expand Up @@ -192,6 +189,12 @@ public class Config {
@Value("${mag.pix.oids.local-patient-id-aa:}")
private String localPatientIDAssigningAuthority;

@Value("${mag.ch-epr-fhir.ch-pixm-constraints:false}")
private boolean chPixmConstraints;

@Value("${mag.ch-epr-fhir.epr-spid-as-patientid:false}")
private boolean chEprspidAsPatientId;


/**
* baseurl of gateway
Expand Down Expand Up @@ -434,4 +437,5 @@ public String getStsEndpoint(final @Value("${mag.iua.ap.url}") String assertionE
(clientSsl ? "&sslContextParameters=#sslContext" : ""),
assertionEndpointUrl, wsdl);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ public Narrative transformToNarrative(LocalizedString in) {
* @return
*/
public Reference transformPatient(Identifiable patient) {
String baseUrl = config.getUriPatientEndpoint();
String system = patient.getAssigningAuthority().getUniversalId();
String value = patient.getId();
return patientReferenceCreator.createPatientReference(system, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
import org.openehealth.ipf.commons.ihe.xds.core.metadata.AssigningAuthority;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import ch.bfh.ti.i4mi.mag.Config;
import ch.bfh.ti.i4mi.mag.MobileAccessGateway;
import ch.bfh.ti.i4mi.mag.mhd.SchemeMapper;
import lombok.extern.slf4j.Slf4j;

Expand Down Expand Up @@ -59,6 +57,9 @@ public Reference createPatientReference(String system, String value) {
}

public String createPatientId(String system, String value) {
if (system.equals(config.getOID_EPRSPID()) && config.isChEprspidAsPatientId()) {
return value;
}
return system+"-"+value;
}

Expand All @@ -80,6 +81,10 @@ public Identifiable resolvePatientId(String fullId) {
} else {
log.error("expected oid as a system for resolving Patient in: "+fullId);
}
} else {
if (config.isChEprspidAsPatientId()) {
return new Identifiable(fullId, new AssigningAuthority(schemeMapper.getScheme(config.getOID_EPRSPID())));
}
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
import javax.xml.bind.JAXBException;

import org.hl7.fhir.r4.model.Identifier;
import org.hl7.fhir.r4.model.OperationOutcome;
import org.hl7.fhir.r4.model.OperationOutcome.IssueType;
import org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent;
import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.r4.model.Type;
import org.hl7.fhir.r4.model.UriType;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp;
import org.springframework.beans.factory.annotation.Autowired;

import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException;
import ch.bfh.ti.i4mi.mag.BaseRequestConverter;
import ch.bfh.ti.i4mi.mag.Config;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -66,11 +69,39 @@ public class Iti83RequestConverter extends BaseRequestConverter {

@Autowired
private Config config;


public OperationOutcome getTargetDomainNotRecognized() {
OperationOutcome outcome = new OperationOutcome();
OperationOutcomeIssueComponent issue = outcome.addIssue();
issue.setSeverity(OperationOutcome.IssueSeverity.ERROR);
issue.setCode(IssueType.CODEINVALID);
issue.setDiagnostics("targetSystem not found");
return outcome;
}

public String iti83ToIti45Converter(Parameters parameters) throws JAXBException {
List<Parameters.ParametersParameterComponent> targetSystemList = parameters.getParameters("targetSystem");
Identifier sourceIdentifier = (Identifier) parameters.getParameter("sourceIdentifier").getValue();

if (config.isChPixmConstraints()) {
// 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());
}
if (targetSystemList == null || (targetSystemList.size() != 2)) {
log.error("targetSystem need to be 2..2");
throw new ForbiddenOperationException("targetSystem need to be 2..2", getTargetDomainNotRecognized());
}
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))))) {
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());
}
}

PRPAIN201309UV02Type resultMsg = new PRPAIN201309UV02Type();
resultMsg.setITSVersion("XML_1.0");
// String UUID.randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,15 @@ public Parameters translateToFhir(byte[] input, Map<String, Object> parameters)
response.addParameter().setName("targetIdentifier").setValue((new Identifier()).setSystem("urn:oid:"+root).setValue(extension));
noDuplicates.add(root);
}
if (!targetIdAdded && root.equals(config.getOidMpiPid())) {
if (!targetIdAdded && root.equals(config.getOidMpiPid()) && !config.isChEprspidAsPatientId()) {
response.addParameter().setName("targetId").setValue(patientRefCreator.createPatientReference(root, extension));
targetIdAdded = true;
}
}


if (!targetIdAdded && root.equals(config.OID_EPRSPID) && config.isChEprspidAsPatientId()) {
response.addParameter().setName("targetId").setValue(patientRefCreator.createPatientReference(root, extension));
targetIdAdded = true;
}
}
}

return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Iti83RouteBuilder extends RouteBuilder {

@Autowired
Iti83ResponseConverter converter;

public Iti83RouteBuilder(final Config config) {
super();
this.config = config;
Expand Down

0 comments on commit eac57e4

Please sign in to comment.