How to Query using REST API

Hi i am new to orthanc. I have tried writing query using REST API but i couldn't. Can anyone help me writing Small query to retrieve based on Patient Name in any REST client.

Hi. I've actually coded the query/retrieve into both PHP and Javascript for my front end/launcher but am still tweaking the code/design before I upload it. I'd be happy to upload the code snippet, but I'm not around until tomorrow. If you can wait and still interested, I will upload the code snippet within the next 36 hours.

Haha, found free time while waiting for hairdresser! :slight_smile:

This is the Javascript code snippet for querying Orthanc. Note that you'll need to use the ServeFolders plugin or run Orthanc using reverse proxy because of cross domain restrictions.

var query = {};
query.Level = "STUDY"; //alternately "SERIES"
query.Query = {};
query.Query.PatientName = patientName;
query.Query.PatientID = patientID;
query.Query.StudyDate = studyDate; //e.g. 20150705
query.Query.ModalitiesInStudy = modality; //e.g. CT, MRI
query.Query.SpecificCharacterSet = "ISO_IR 192";
query.Query.AccessionNumber = "*";
query.Query.StudyDescription = "*";
query.Query.PatientBirthDate = "";
query.Query.PatientSex = "*";

var data = JSON.stringify(query);

var XHR = new XMLHttpRequest();
XHR.open("POST", "http://orthanc:8042/modalities/pacs/query", true); //e.g. "pacs" defined in config.json under dicom modalities
XHR.setRequestHeader("Content-type", "application/json");
XHR.responseType = "text";
XHR.onload = function (e) {
   alert ('this.response'); //response from Orthanc in the form of queryID. Do a GET call to orthanc/query/queryID
   };
XHR.send(data);

Regards,
Emsy

thank you, I was so helpful

but i am getting 'Access-Control-Allow-Origin' error in jquery call. how to resolve this?

I haven't reached the level of using jquery yet... :wink:

Sounds like a cross domain issue. Are you using the ServeFolders plugin or using Orthanc through a reverse proxy?

ServeFolders
https://code.google.com/p/orthanc/source/browse/?name=default#hg%2FPlugins%2FSamples%2FServeFolders

Reverse proxy https://code.google.com/p/orthanc/wiki/FAQ#How_can_I_run_Orthanc_behind_Apache?