Search in sources :

Example 1 with MessageSourceComponent

use of org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent in project integration-adaptor-111 by nhsconnect.

the class MessageHeaderServiceTest method shouldCreateMessageHeader.

@Test
public void shouldCreateMessageHeader() {
    ItkReportHeader itkReportHeader = new ItkReportHeader();
    itkReportHeader.setSpecKey(SPECIFICATION_KEY);
    itkReportHeader.setSpecVal(SPECIFICATION_VALUE);
    itkReportHeader.setAddressList(Arrays.asList(ADDRESS));
    MessageHeader messageHeader = messageHeaderService.createMessageHeader(itkReportHeader, MESSAGEID, EFFECTIVE_TIME);
    assertThat(messageHeader.getId()).isEqualTo(MESSAGEID);
    Coding event = messageHeader.getEvent();
    assertThat(event.getSystem()).isEqualTo(MessageHeaderEvent.SYSTEM);
    assertThat(event.getCode()).isEqualTo(DISCHARGE_DETAILS.getCode());
    assertThat(event.getDisplay()).isEqualTo(DISCHARGE_DETAILS.getDisplay());
    MessageSourceComponent source = messageHeader.getSource();
    assertThat(source.getName()).isEqualTo(MESSAGE_SOURCE_NAME);
    assertThat(source.getEndpoint()).isEqualTo(ENDPOINT);
    assertThat(messageHeader.getReason().getCodingFirstRep().getSystem()).isEqualTo(SPECIFICATION_KEY);
    assertThat(messageHeader.getReason().getCodingFirstRep().getCode()).isEqualTo(SPECIFICATION_VALUE);
    assertThat(messageHeader.getDestinationFirstRep().getEndpoint()).isEqualTo(ADDRESS);
    assertThat(messageHeader.getTimestampElement()).isEqualToComparingFieldByField(DateUtil.parseToInstantType(EFFECTIVE_TIME));
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) ItkReportHeader(uk.nhs.adaptors.oneoneone.cda.report.controller.utils.ItkReportHeader) MessageSourceComponent(org.hl7.fhir.dstu3.model.MessageHeader.MessageSourceComponent) MessageHeader(org.hl7.fhir.dstu3.model.MessageHeader) Test(org.junit.jupiter.api.Test)

Example 2 with MessageSourceComponent

use of org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent in project integration-adaptor-111 by nhsconnect.

the class MessageHeaderService method getSource.

private MessageSourceComponent getSource() {
    MessageSourceComponent source = new MessageSourceComponent();
    source.setName(MESSAGE_SOURCE_NAME);
    source.setEndpoint(soapProperties.getSendTo());
    return source;
}
Also used : MessageSourceComponent(org.hl7.fhir.dstu3.model.MessageHeader.MessageSourceComponent)

Example 3 with MessageSourceComponent

use of org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent in project MobileAccessGateway by i4mi.

the class Iti93ResponseConverter method translateToFhir.

/**
 * translate ITI-44 response to ITI-93 response
 */
public Bundle translateToFhir(byte[] input, Map<String, Object> parameters) {
    try {
        // FIX for xmlns:xmlns
        String content = new String(input);
        content = content.replace("xmlns:xmlns", "xmlns:xxxxx");
        MCCIIN000002UV01Type msg = HL7V3Transformer.unmarshallMessage(MCCIIN000002UV01Type.class, new ByteArrayInputStream(content.getBytes()));
        Bundle responseBundle = new Bundle().setType(Bundle.BundleType.MESSAGE);
        Bundle requestBundle = (Bundle) parameters.get(Utils.KEPT_BODY);
        MessageHeader header = (MessageHeader) requestBundle.getEntryFirstRep().getResource();
        MessageSourceComponent source = new MessageSourceComponent();
        source.setEndpoint(config.getBaseurl());
        header.setSource(source);
        MessageHeaderResponseComponent response = new MessageHeaderResponseComponent();
        response.setCode(ResponseType.OK);
        for (net.ihe.gazelle.hl7v3.mccimt000200UV01.MCCIMT000200UV01Acknowledgement akk : msg.getAcknowledgement()) {
            CS code = akk.getTypeCode();
            if (!code.getCode().equals("AA") && !code.getCode().equals("CA")) {
                response.setCode(ResponseType.FATALERROR);
                OperationOutcome outcome = new OperationOutcome();
                response.setDetails((Reference) new Reference().setResource(outcome));
                for (MCCIMT000200UV01AcknowledgementDetail detail : akk.getAcknowledgementDetail()) {
                    OperationOutcomeIssueComponent issue = outcome.addIssue();
                    issue.setDetails(new CodeableConcept().setText(toText(detail.getText())).addCoding(transform(detail.getCode())));
                }
            }
        }
        response.setIdentifier(header.getId());
        header.setId((String) null);
        header.setResponse(response);
        header.setFocus(null);
        BundleEntryComponent cmp = responseBundle.addEntry();
        cmp.setResource(header);
        return responseBundle;
    } catch (JAXBException e) {
        throw new InvalidRequestException("failed parsing response");
    }
}
Also used : MCCIMT000200UV01AcknowledgementDetail(net.ihe.gazelle.hl7v3.mccimt000200UV01.MCCIMT000200UV01AcknowledgementDetail) OperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent) Bundle(org.hl7.fhir.r4.model.Bundle) Reference(org.hl7.fhir.r4.model.Reference) JAXBException(javax.xml.bind.JAXBException) MessageSourceComponent(org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent) MessageHeaderResponseComponent(org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent) MCCIIN000002UV01Type(net.ihe.gazelle.hl7v3.mcciin000002UV01.MCCIIN000002UV01Type) CS(net.ihe.gazelle.hl7v3.datatypes.CS) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) ByteArrayInputStream(java.io.ByteArrayInputStream) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) MessageHeader(org.hl7.fhir.r4.model.MessageHeader) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Aggregations

MessageSourceComponent (org.hl7.fhir.dstu3.model.MessageHeader.MessageSourceComponent)2 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 JAXBException (javax.xml.bind.JAXBException)1 CS (net.ihe.gazelle.hl7v3.datatypes.CS)1 MCCIIN000002UV01Type (net.ihe.gazelle.hl7v3.mcciin000002UV01.MCCIIN000002UV01Type)1 MCCIMT000200UV01AcknowledgementDetail (net.ihe.gazelle.hl7v3.mccimt000200UV01.MCCIMT000200UV01AcknowledgementDetail)1 Coding (org.hl7.fhir.dstu3.model.Coding)1 MessageHeader (org.hl7.fhir.dstu3.model.MessageHeader)1 Bundle (org.hl7.fhir.r4.model.Bundle)1 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)1 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 MessageHeader (org.hl7.fhir.r4.model.MessageHeader)1 MessageHeaderResponseComponent (org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent)1 MessageSourceComponent (org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent)1 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)1 OperationOutcomeIssueComponent (org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent)1 Reference (org.hl7.fhir.r4.model.Reference)1 Test (org.junit.jupiter.api.Test)1 ItkReportHeader (uk.nhs.adaptors.oneoneone.cda.report.controller.utils.ItkReportHeader)1