Commit a9c7f316 authored by R.W.Majeed's avatar R.W.Majeed
Browse files

fixed location header to conform to FHIR specs

parent 86172058
...@@ -3,7 +3,6 @@ package org.aktin.cda.etl.fhir; ...@@ -3,7 +3,6 @@ package org.aktin.cda.etl.fhir;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
...@@ -136,6 +135,7 @@ public class Binary implements ExternalInterface{ ...@@ -136,6 +135,7 @@ public class Binary implements ExternalInterface{
String templateId = null; String templateId = null;
boolean isValid = false; boolean isValid = false;
boolean importSuccessful = false; boolean importSuccessful = false;
URI location = null;
Document cda=null; Document cda=null;
try { try {
cda = parser.buildDOM(doc); cda = parser.buildDOM(doc);
...@@ -153,20 +153,18 @@ public class Binary implements ExternalInterface{ ...@@ -153,20 +153,18 @@ public class Binary implements ExternalInterface{
// otherwise return HTTP_BAD_REQUEST // otherwise return HTTP_BAD_REQUEST
// process document // process document
CDAStatus stat = processor.createOrUpdate(cda, documentId, templateId); CDAStatus stat = processor.createOrUpdate(cda, documentId, templateId);
// check whether document was created or updated, return 201 or 200 // check whether document was created or updated, return 201 or 200
if( stat.getStatus() == Status.Created ){ if( stat.getStatus() == Status.Created ){
try { // create location conforming to FHIR specification
URI location = new URI("Binary/?_id="+stat.getDocumentId()); location = URI.create("Binary/"+stat.getDocumentId()+"/_history/0");
response = Response.created(location); response = Response.created(location);
} catch (URISyntaxException e) {
log.log(Level.WARNING, "Unable to build URI for created resource", e);
response = Response.ok();
}
hallihallo2.addCreated(); hallihallo2.addCreated();
importSuccessful = true; importSuccessful = true;
}else if( stat.getStatus() == Status.Updated ){ }else if( stat.getStatus() == Status.Updated ){
response = Response.ok(); response = Response.ok();
location = URI.create("Binary/"+stat.getDocumentId());
// Location header not allowed for status 200
hallihallo2.addUpdated(); hallihallo2.addUpdated();
importSuccessful = true; importSuccessful = true;
}else{ }else{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment