src/main/java/ch/bfh/ti/i4mi/mag/pmir/iti93/Iti93ResponseConverter.java
/**
	 * translate ITI-44 response to ITI-93 response
	 */
translate ITI-44 response to ITI-93 response
translate ITI - 44 response to ITI - 93 response
public Bundle translateToFhir(byte[] input, Map<String, Object> parameters)  {
		try {
			System.out.println(new String(input));
			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");
		}
	}
public Bundle translateToFhir ( byte [ ] input , Map < String , Object > parameters ) { try { System . out . println ( new String ( input ) ) ; 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" ) ; } }
translate ITI-44 response to ITI-93 response
translate ITI - 44 response to ITI - 93 response
// FIX for xmlns:xmlns