-
Notifications
You must be signed in to change notification settings - Fork 10
Implement ITI-119 → ITI-47 mapping #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
80 changes: 80 additions & 0 deletions
80
src/main/java/ch/bfh/ti/i4mi/mag/pmir/iti119/Iti119RequestConverter.java
This file contains hidden or 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,80 @@ | ||||||||||||||||||||||||||
| package ch.bfh.ti.i4mi.mag.pmir.iti119; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import ch.bfh.ti.i4mi.mag.Config; | ||||||||||||||||||||||||||
| import ch.bfh.ti.i4mi.mag.pmir.iti78.Iti78RequestConverter; | ||||||||||||||||||||||||||
| import net.ihe.gazelle.hl7v3.datatypes.II; | ||||||||||||||||||||||||||
| import net.ihe.gazelle.hl7v3.datatypes.IVLTS; | ||||||||||||||||||||||||||
| import net.ihe.gazelle.hl7v3.prpain201305UV02.PRPAIN201305UV02Type; | ||||||||||||||||||||||||||
| import net.ihe.gazelle.hl7v3.prpamt201306UV02.PRPAMT201306UV02LivingSubjectId; | ||||||||||||||||||||||||||
| import org.apache.camel.Body; | ||||||||||||||||||||||||||
| import org.hl7.fhir.r4.model.Parameters; | ||||||||||||||||||||||||||
| import org.hl7.fhir.r4.model.Patient; | ||||||||||||||||||||||||||
| import org.hl7.fhir.r4.model.StringType; | ||||||||||||||||||||||||||
| import org.openehealth.ipf.commons.ihe.fhir.iti119.PdqmMatchInputPatient; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import javax.xml.bind.JAXBException; | ||||||||||||||||||||||||||
| import java.util.Optional; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| public class Iti119RequestConverter extends Iti78RequestConverter { | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| public Iti119RequestConverter(final Config config) { | ||||||||||||||||||||||||||
| this.config = config; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| public PRPAIN201305UV02Type convert(@Body final Parameters parameters) throws JAXBException { | ||||||||||||||||||||||||||
| // Extract the Patient resource from the Parameters | ||||||||||||||||||||||||||
| final var patient = Optional.ofNullable(parameters.getParameter("resource")) | ||||||||||||||||||||||||||
| .map(Parameters.ParametersParameterComponent::getResource) | ||||||||||||||||||||||||||
| .filter(Patient.class::isInstance) | ||||||||||||||||||||||||||
| .map(Patient.class::cast) | ||||||||||||||||||||||||||
| .orElseThrow(() -> new IllegalArgumentException("Parameters must contain a Patient resource")); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Create an ITI-47 request | ||||||||||||||||||||||||||
| final PRPAIN201305UV02Type request = initiateIti47Request(config.getPixMySenderOid(), | ||||||||||||||||||||||||||
| config.getPixReceiverOid()); | ||||||||||||||||||||||||||
| final var parameterList = request.getControlActProcess().getQueryByParameter().getParameterList(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Map the search parameters from the Patient resource to the request | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // 1. Identifiers | ||||||||||||||||||||||||||
| for (final var identifier : patient.getIdentifier()) { | ||||||||||||||||||||||||||
| final var id = new PRPAMT201306UV02LivingSubjectId(); | ||||||||||||||||||||||||||
| id.addValue(new II(identifier.getSystem(), identifier.getValue())); | ||||||||||||||||||||||||||
| id.setSemanticsText(ST("LivingSubject.id")); | ||||||||||||||||||||||||||
| parameterList.addLivingSubjectId(id); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // 2. Name & Birth name | ||||||||||||||||||||||||||
| for (final var name : patient.getName()) { | ||||||||||||||||||||||||||
| parameterList.addLivingSubjectName(createLivingSubjectName(transform(name))); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // 3. Gender | ||||||||||||||||||||||||||
| if (patient.hasGender()) { | ||||||||||||||||||||||||||
| parameterList.addLivingSubjectAdministrativeGender(createAdministrativeGender(patient.getGender().toCode())); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // 4. Birth date | ||||||||||||||||||||||||||
| if (patient.hasBirthDate()) { | ||||||||||||||||||||||||||
| final var birthDate = new IVLTS(); | ||||||||||||||||||||||||||
| birthDate.setValue(patient.getBirthDateElement().getValueAsString().replace("-","")); | ||||||||||||||||||||||||||
| parameterList.addLivingSubjectBirthTime(createBirthTime(birthDate)); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // 5. Address | ||||||||||||||||||||||||||
| for (final var address : patient.getAddress()) { | ||||||||||||||||||||||||||
| parameterList.addPatientAddress(createAddress(transform(address))); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // 6. Maiden name (not required) | ||||||||||||||||||||||||||
| if (patient.hasExtension(PdqmMatchInputPatient.MOTHERS_MAIDEN_NAME_EXT)) { | ||||||||||||||||||||||||||
| final var ext = patient.getExtensionByUrl(PdqmMatchInputPatient.MOTHERS_MAIDEN_NAME_EXT); | ||||||||||||||||||||||||||
| if (ext.getValue() instanceof StringType) { | ||||||||||||||||||||||||||
| final var value = (StringType) ext.getValue(); | ||||||||||||||||||||||||||
| parameterList.addMothersMaidenName(createMothersMaidenName(value.getValue())); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| parameterList.addMothersMaidenName(createMothersMaidenName(value.getValue())); | |
| if (ext.getValue() instanceof HumanName) { | |
| final var humanName = (HumanName) ext.getValue(); | |
| // Use the display name if available, otherwise concatenate given and family | |
| String maidenName = humanName.getText(); | |
| if (maidenName == null || maidenName.isEmpty()) { | |
| maidenName = String.join(" ", humanName.getGiven().stream().map(g -> g.getValue()).toArray(String[]::new)); | |
| if (humanName.hasFamily()) { | |
| maidenName = maidenName.isEmpty() ? humanName.getFamily() : maidenName + " " + humanName.getFamily(); | |
| } | |
| } | |
| parameterList.addMothersMaidenName(createMothersMaidenName(maidenName)); |
8 changes: 8 additions & 0 deletions
8
src/main/java/ch/bfh/ti/i4mi/mag/pmir/iti119/Iti119ResponseConverter.java
This file contains hidden or 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,8 @@ | ||
| package ch.bfh.ti.i4mi.mag.pmir.iti119; | ||
|
|
||
| import ch.bfh.ti.i4mi.mag.pmir.iti78.Iti78ResponseConverter; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| public class Iti119ResponseConverter extends Iti78ResponseConverter { | ||
| } |
65 changes: 65 additions & 0 deletions
65
src/main/java/ch/bfh/ti/i4mi/mag/pmir/iti119/Iti119RouteBuilder.java
This file contains hidden or 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,65 @@ | ||
| package ch.bfh.ti.i4mi.mag.pmir.iti119; | ||
|
|
||
| import ch.bfh.ti.i4mi.mag.Config; | ||
| import ch.bfh.ti.i4mi.mag.common.RequestHeadersForwarder; | ||
| import ch.bfh.ti.i4mi.mag.common.TraceparentHandler; | ||
| import ch.bfh.ti.i4mi.mag.mhd.BaseResponseConverter; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.apache.camel.builder.RouteBuilder; | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import javax.xml.ws.soap.SOAPFaultException; | ||
|
|
||
| import static org.openehealth.ipf.platform.camel.ihe.fhir.core.FhirCamelTranslators.translateToFhir; | ||
|
|
||
| /** | ||
| * IHE PDQm: ITI-119 Patient Demographics Match | ||
| */ | ||
| @Slf4j | ||
| @Component | ||
| @ConditionalOnProperty("mag.pix.iti-47.url") | ||
| public class Iti119RouteBuilder extends RouteBuilder { | ||
|
|
||
| private final Config config; | ||
| private final Iti119ResponseConverter responseConverter; | ||
|
|
||
| public Iti119RouteBuilder(final Config config, | ||
| final Iti119ResponseConverter responseConverter) { | ||
| super(); | ||
| this.config = config; | ||
| this.responseConverter = responseConverter; | ||
| log.debug("Iti119RouteBuilder initialized"); | ||
| } | ||
|
|
||
| @Override | ||
| public void configure() throws Exception { | ||
| log.debug("Iti119RouteBuilder configure"); | ||
|
|
||
| final String xds47Endpoint = String.format( | ||
| "pdqv3-iti47://%s?secure=%s", this.config.getIti47HostUrl(), this.config.isPixHttps() ? "true" : "false" | ||
| ) + | ||
| //"&sslContextParameters=#pixContext" + | ||
| "&audit=true" + | ||
| "&auditContext=#myAuditContext" + | ||
| "&inInterceptors=#soapResponseLogger" + | ||
| "&inFaultInterceptors=#soapResponseLogger"+ | ||
| "&outInterceptors=#soapRequestLogger" + | ||
| "&outFaultInterceptors=#soapRequestLogger"; | ||
|
|
||
| from("pdqm-iti119:translation?audit=true&auditContext=#myAuditContext").routeId("pdqm-adapter") | ||
| // pass back errors to the endpoint | ||
| .errorHandler(noErrorHandler()) | ||
| .process(RequestHeadersForwarder.checkAuthorization(config.isChPdqmConstraints())) | ||
| .process(RequestHeadersForwarder.forward()) | ||
| .bean(Iti119RequestConverter.class, "convert") | ||
| .doTry() | ||
| .to(xds47Endpoint) | ||
| .process(TraceparentHandler.updateHeaderForFhir()) | ||
| .process(translateToFhir(responseConverter , byte[].class)) | ||
| .doCatch(SOAPFaultException.class) | ||
| .setBody(simple("${exception}")) | ||
| .bean(BaseResponseConverter.class, "errorFromException") | ||
| .end(); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The date formatting logic using simple string replacement is fragile and may not handle all date formats correctly. Consider using a proper date formatter or the existing transform methods for consistent date handling.