Mercurial > hg > orthanc-dicomweb
view Samples/JavaScript/orthanc.js @ 3:8e7bc8bf874d
sample JavaScript for QIDO-RS, support of encodings
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 14 Mar 2015 12:12:20 +0100 |
parents | |
children | a373f73e30b8 |
line wrap: on
line source
/** * Orthanc - A Lightweight, RESTful DICOM Store * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics * Department, University Hospital of Liege, Belgium * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ function GetTag(answer, tag) { if (!(tag in answer) || !("Value" in answer[tag]) || answer[tag].length == 0) { return ''; } else { return answer[tag]["Value"][0]; } } $(document).ready(function() { $('#qido-series').submit(function() { var data = {}; $('input[name]', this).each(function() { data[$(this).attr('name')] = $(this).val(); }); $.ajax({ headers: { 'Accept' : 'application/json' }, data: data, cache: true, // If set to false, the "_" GET argument is added, resulting in a bad QIDO-RS request dataType: 'json', url: '../qido-rs/series', success: function(answer) { $('#qido-series-results').empty(); for (var i = 0; i < answer.length; i++) { var patientId = GetTag(answer[i], '00100020'); var patientName = GetTag(answer[i], '00100010'); var studyDescription = GetTag(answer[i], '00081030'); var seriesDescription = GetTag(answer[i], '0008103E'); $('#qido-series-results').append( '<li>' + patientId + ' - ' + patientName + ' - ' + studyDescription + ' - ' + seriesDescription + '</li>'); } }, error: function() { alert('Cannot process this query'); } }); // Prevent default action return false; }); });