src/main/java/ch/bfh/ti/i4mi/mag/mhd/iti65/Iti65ResponseConverter.java
/**
	 * convert ITI-41 response to ITI-65 response 
	 */
convert ITI-41 response to ITI-65 response
convert ITI - 41 response to ITI - 65 response
@Override
	public Object translateToFhir(Response input, Map<String, Object> parameters) {
		if (input.getStatus().equals(Status.SUCCESS)) {
			Bundle responseBundle = new Bundle();		
			Bundle requestBundle = (Bundle) parameters.get(Utils.KEPT_BODY);
			responseBundle.getMeta().addProfile("http://profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.ProvideDocumentBundleResponse");
			for (Bundle.BundleEntryComponent requestEntry : requestBundle.getEntry()) {
	            Bundle.BundleEntryResponseComponent response = new Bundle.BundleEntryResponseComponent()
	                    .setStatus("201 Created")
	                    .setLastModified(new Date());
	            if (requestEntry.getResource() instanceof Binary) {
	              String uniqueId = (String) requestEntry.getResource().getUserData("masterIdentifier");
	              response.setLocation(config.getUriMagXdsRetrieve() + "?uniqueId=" + uniqueId
                     + "&repositoryUniqueId=" + config.getRepositoryUniqueId());	            
	            } else if (requestEntry.getResource() instanceof ListResource) {
	            	String id = config.getSchemeMapper().getScheme(((ListResource) requestEntry.getResource()).getId());
	            	response.setLocation("List/"+id);
	            } else if (requestEntry.getResource() instanceof DocumentReference) {
	            	String id = config.getSchemeMapper().getScheme(((DocumentReference) requestEntry.getResource()).getId());
	            	response.setLocation("DocumentReference/"+id);	              
	            }
	            responseBundle.addEntry()
	                    .setResponse(response);
	        }
			return responseBundle;
		} else {	
			processError(input);
			return null;
		}
	}
@ Override public Object translateToFhir ( Response input , Map < String , Object > parameters ) { if ( input . getStatus ( ) . equals ( Status . SUCCESS ) ) { Bundle responseBundle = new Bundle ( ) ; Bundle requestBundle = ( Bundle ) parameters . get ( Utils . KEPT_BODY ) ; responseBundle . getMeta ( ) . addProfile ( "http://profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.ProvideDocumentBundleResponse" ) ; for ( Bundle . BundleEntryComponent requestEntry : requestBundle . getEntry ( ) ) { Bundle . BundleEntryResponseComponent response = new Bundle . BundleEntryResponseComponent ( ) . setStatus ( "201 Created" ) . setLastModified ( new Date ( ) ) ; if ( requestEntry . getResource ( ) instanceof Binary ) { String uniqueId = ( String ) requestEntry . getResource ( ) . getUserData ( "masterIdentifier" ) ; response . setLocation ( config . getUriMagXdsRetrieve ( ) + "?uniqueId=" + uniqueId + "&repositoryUniqueId=" + config . getRepositoryUniqueId ( ) ) ; } else if ( requestEntry . getResource ( ) instanceof ListResource ) { String id = config . getSchemeMapper ( ) . getScheme ( ( ( ListResource ) requestEntry . getResource ( ) ) . getId ( ) ) ; response . setLocation ( "List/" + id ) ; } else if ( requestEntry . getResource ( ) instanceof DocumentReference ) { String id = config . getSchemeMapper ( ) . getScheme ( ( ( DocumentReference ) requestEntry . getResource ( ) ) . getId ( ) ) ; response . setLocation ( "DocumentReference/" + id ) ; } responseBundle . addEntry ( ) . setResponse ( response ) ; } return responseBundle ; } else { processError ( input ) ; return null ; } }
convert ITI-41 response to ITI-65 response
convert ITI - 41 response to ITI - 65 response