Skip to content

Commit

Permalink
fulfill a TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
unixoid authored and qligier committed Jul 11, 2024
1 parent 7815178 commit c6ea4cd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.HashMap;
import java.util.UUID;

import ch.bfh.ti.i4mi.mag.Config;
import ch.bfh.ti.i4mi.mag.MagConstants;
import org.apache.camel.Body;
import org.hl7.fhir.r4.model.*;
Expand All @@ -30,6 +31,8 @@

import ch.bfh.ti.i4mi.mag.mhd.iti65.Iti65RequestConverter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
* ITI-67 DocumentReference Update request converter
Expand All @@ -38,8 +41,16 @@
*
*/
@Slf4j
@Component
public class Iti67RequestUpdateConverter extends Iti65RequestConverter {

private final Config config;

@Autowired
public Iti67RequestUpdateConverter(Config config) {
this.config = config;
}

/**
* ITI-67 Response to ITI-57 request converter
*
Expand All @@ -56,8 +67,7 @@ public SubmitObjectsRequest convertDocumentReferenceToDocumentEntry(@Body Docume
if (source != null && source.getValue() instanceof Identifier) {
submissionSet.setSourceId(noPrefix(((Identifier) source.getValue()).getValue()));
} else {
// todo: use Config.getDocumentSourceId
submissionSet.setSourceId("2.16.756.5.30.1.190.0.0.12.2.101.32");
submissionSet.setSourceId(noPrefix(config.getDocumentSourceId()));
}

Extension designationType =
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/ch/bfh/ti/i4mi/mag/mhd/iti67/Iti67RouteBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@

import org.apache.camel.builder.PredicateBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.hl7.fhir.r4.model.DocumentReference;
import org.openehealth.ipf.commons.ihe.fhir.Constants;
import org.openehealth.ipf.commons.ihe.xds.core.responses.QueryResponse;
import org.openehealth.ipf.commons.ihe.xds.core.responses.Response;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rs.RegistryRequestType;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.lcm.SubmitObjectsRequest;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

Expand All @@ -42,11 +43,13 @@
class Iti67RouteBuilder extends RouteBuilder {

private final Config config;
private final Iti67RequestUpdateConverter iti67RequestUpdateConverter;

public Iti67RouteBuilder(final Config config) {
public Iti67RouteBuilder(final Config config, Iti67RequestUpdateConverter iti67RequestUpdateConverter) {
super();
log.debug("Iti67RouteBuilder initialized");
this.config = config;
this.iti67RequestUpdateConverter = iti67RequestUpdateConverter;
}

@Override
Expand Down Expand Up @@ -92,8 +95,11 @@ public void configure() throws Exception {
.process(translateToFhir(new Iti67ResponseConverter(config) , QueryResponse.class))
.endChoice()
.when(PredicateBuilder.and(header("FhirHttpUri").isNotNull(),header("FhirHttpMethod").isEqualTo("PUT")))
.bean(Iti67RequestUpdateConverter.class)
.convertBodyTo(RegistryRequestType.class)
.process(exchange -> {
DocumentReference documentReference = exchange.getIn().getMandatoryBody(DocumentReference.class);
SubmitObjectsRequest submitObjectsRequest = iti67RequestUpdateConverter.convertDocumentReferenceToDocumentEntry(documentReference);
exchange.getMessage().setBody(submitObjectsRequest);
})
.to(endpoint57)
.process(translateToFhir(new Iti67FromIti57ResponseConverter(config), Response.class))
.endChoice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void beforeAll() {
PatientReferenceCreator patientReferenceCreator = new PatientReferenceCreator();
patientReferenceCreator.setConfig(config);
patientReferenceCreator.setSchemeMapper(schemeMapper);
iti67RequestUpdateConverter = new Iti67RequestUpdateConverter();
iti67RequestUpdateConverter = new Iti67RequestUpdateConverter(config);
iti67RequestUpdateConverter.setConfig(config);
iti67RequestUpdateConverter.setSchemeMapper(schemeMapper);
iti67RequestUpdateConverter.setPatientRefCreator(patientReferenceCreator);
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/update-request-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"coding": [
{
"system": "https://profiles.ihe.net/ITI/MHD/CodeSystem/DocumentIdentifierTypes",
"code": "logicalId"
"code": "logicalID"
}
]
}
Expand Down

0 comments on commit c6ea4cd

Please sign in to comment.