Document cda = DocumentHelper.parseText(cdaString);
final CdaSettings cdaSettings = new CdaSettings(cda, "cda1", null);
log.debug("Doing query on Cda - Initializing CdaEngine");
final CdaEngine engine = CdaEngine.getInstance();
final QueryOptions queryOptions = new QueryOptions();
queryOptions.setDataAccessId("1");
queryOptions.setOutputType("json");
log.info("Doing query");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintStream printstream = new PrintStream(outputStream);
engine.doQuery(printstream, cdaSettings, queryOptions);
byte[] doc = outputStream.toByteArray();
return Response.ok(doc, MediaType.APPLICATION_JSON).header(
"content-length",doc.length).build();