Skip to content

Commit

Permalink
Support Delete Study to DICOMcloud server. Issue #8
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaid-Safadi committed Feb 20, 2017
1 parent 8a017d2 commit 1366e1f
Show file tree
Hide file tree
Showing 19 changed files with 439 additions and 1,300 deletions.
46 changes: 46 additions & 0 deletions DICOMwebJS.Proxies/Proxies/DelowRsProxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
class DelowRsProxy
{
public _baseUrl: string = "";

constructor(baseUrl: string = null) {
this._baseUrl = baseUrl;
}

public get BaseUrl() {
if (this._baseUrl === null) {
return DICOMwebJS.ServerConfiguration.getDelowRsUrl();
}
else
{
return this._baseUrl;
}
}

public set BaseUrl(value: string) {
this._baseUrl = value;
}

public deleteStudy(studyUID: string): JQueryPromise<any> {
var url = this.BaseUrl + "/studies/" + studyUID + "/"; //last part "/" is needed for proper routing
let settings: JQueryAjaxSettings = {
url: url,
type: "DELETE"
}

if (DICOMwebJS.ServerConfiguration.IncludeAuthorizationHeader) {
settings.headers = { "Authorization": DICOMwebJS.ServerConfiguration.SecurityToken };
}

var deffered = $.Deferred();

$.ajax(settings).then(
(data) => {
return deffered.resolve(data);
},
(jqxhr, textStatus, error) => {
return deffered.reject(Error(error));
});

return deffered.promise();
}
}
23 changes: 18 additions & 5 deletions DICOMwebJS.Proxies/Proxies/QidoRsProxy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
class QidoRsProxy
{
public BaseUrl: string = "";
constructor(baseUrl: string)
{
this.BaseUrl = baseUrl;
}
public _baseUrl: string = "";

constructor(baseUrl: string = null) {
this._baseUrl = baseUrl;
}

public get BaseUrl() {
if (this._baseUrl === null) {
return DICOMwebJS.ServerConfiguration.getQidoUrl();
}
else {
return this._baseUrl;
}
}

public set BaseUrl(value: string) {
this._baseUrl = value;
}

//findPatients(query: PatientParams, options: QueryOptions) {
// //there is no qido patient
Expand Down
5 changes: 5 additions & 0 deletions DICOMwebJS.Proxies/Proxies/ServerConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
export var WadoRsPart : string = "wadors";
export var StowPart: string = "stowrs";
export var QidoPart: string = "qidors";
export var DelowRsPart: string = "delowrs";

export var IncludeAuthorizationHeader: boolean = false;
export var SecurityToken: string = "";
Expand All @@ -24,5 +25,9 @@
export function getQidoUrl(): string {
return DICOMwebJS.ServerConfiguration.BaseServerUrl + DICOMwebJS.ServerConfiguration.QidoPart;
}

export function getDelowRsUrl(): string {
return DICOMwebJS.ServerConfiguration.BaseServerUrl + DICOMwebJS.ServerConfiguration.DelowRsPart;
}
}
}
20 changes: 17 additions & 3 deletions DICOMwebJS.Proxies/Proxies/StowRsProxy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
class StowRsProxy {
public BaseUrl: string = "";
constructor(baseUrl: string) {
this.BaseUrl = baseUrl;
public _baseUrl: string = "";

constructor(baseUrl: string = null) {
this._baseUrl = baseUrl;
}

public get BaseUrl() {
if (this._baseUrl === null) {
return DICOMwebJS.ServerConfiguration.getStowUrl();
}
else {
return this._baseUrl;
}
}

public set BaseUrl(value: string) {
this._baseUrl = value;
}

private _returnJson: boolean = true;
Expand Down
22 changes: 14 additions & 8 deletions DICOMwebJS.Proxies/Proxies/WadoRsProxy.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@

class WadoRsProxy{
private _baseUrl: string;
public _baseUrl: string = "";

constructor(baseUrl: string = null) {
this._baseUrl = baseUrl;
}

public get BaseUrl() {
return this._baseUrl;
if (this._baseUrl === null) {
return DICOMwebJS.ServerConfiguration.getWadoRsUrl();
}
else {
return this._baseUrl;
}
}

public set BaseUrl(value: string) {
this._baseUrl = value;
}

public constructor(baseUrl: string) {
this._baseUrl = baseUrl;
}

public getStudy
(
studyInstanceUid: string,
Expand Down Expand Up @@ -138,7 +144,7 @@ class WadoRsProxy{
): JQueryPromise<{}>
{
var deffered = $.Deferred();
var url = this._baseUrl + urlRsPart;
var url = this.BaseUrl + urlRsPart;
var xhr = new XMLHttpRequest();
var acceptHeader = MimeTypes.getMultiPartAcceptHeader( acceptDataType ) ;

Expand Down Expand Up @@ -191,7 +197,7 @@ class WadoRsProxy{
): JQueryPromise<{}>
{
var deffered = $.Deferred();
var url = this._baseUrl + urlRsPart;
var url = this.BaseUrl + urlRsPart;
var xhr = new XMLHttpRequest();


Expand Down
13 changes: 9 additions & 4 deletions DICOMwebJS.Proxies/Proxies/WadoUriProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@
{
private _xhr: XMLHttpRequest;
private static _QueryParamsFormatted: string = "?RequestType=wado&studyUID={0}&seriesUID={1}&objectUID={2}"
private _baseUrl: string;
public _baseUrl: string = "";

constructor(baseUrl: string)
{
constructor(baseUrl: string = null) {
this._baseUrl = baseUrl;
}

public get BaseUrl() {
return this._baseUrl;
if (this._baseUrl === null) {
return DICOMwebJS.ServerConfiguration.getWadoUriUrl();
}
else {
return this._baseUrl;
}
}

public set BaseUrl(value: string)
{
this._baseUrl = value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
declare class DelowRsProxy {
_baseUrl: string;
constructor(baseUrl?: string);
BaseUrl: string;
deleteStudy(studyUID: string): JQueryPromise<any>;
}
declare module DICOMwebJS {
module ServerConfiguration {
var BaseServerUrl: string;
var WadoUriPart: string;
var WadoRsPart: string;
var StowPart: string;
var QidoPart: string;
var DelowRsPart: string;
var IncludeAuthorizationHeader: boolean;
var SecurityToken: string;
function getWadoUriUrl(): string;
function getWadoRsUrl(): string;
function getStowUrl(): string;
function getQidoUrl(): string;
function getDelowRsUrl(): string;
}
}
declare class MimeTypes {
Expand All @@ -25,8 +33,9 @@ declare class MimeTypes {
static getMultiPartAcceptHeader(mimeType: string): string;
}
declare class QidoRsProxy {
_baseUrl: string;
constructor(baseUrl?: string);
BaseUrl: string;
constructor(baseUrl: string);
findStudies(query: queryParams): void;
findSeries(query: queryParams): void;
findInstances(query: queryParams): void;
Expand Down Expand Up @@ -73,8 +82,9 @@ declare class InstanceParams extends SeriesParams {
InstanceNumber: string;
}
declare class StowRsProxy {
_baseUrl: string;
constructor(baseUrl?: string);
BaseUrl: string;
constructor(baseUrl: string);
private _returnJson;
returnJson: boolean;
StoreInstance(fileBuffer: ArrayBuffer, successCallback: (xhr: XMLHttpRequest) => void, failureCallback: (error: Event) => void): void;
Expand All @@ -83,8 +93,8 @@ declare class StowRsProxy {
declare class WadoUriProxy {
private _xhr;
private static _QueryParamsFormatted;
private _baseUrl;
constructor(baseUrl: string);
_baseUrl: string;
constructor(baseUrl?: string);
BaseUrl: string;
getDicomInstance(instanceData: CommonDicomInstanceParams, anonymize: boolean, imageParams: WadoImageParams, successCallback: (buffer: any) => void, failureCallback: (error: ErrorEvent) => void): void;
getJpegImage(instanceData: CommonDicomInstanceParams, imageParams: WadoImageParams, successCallback: (buffer: any) => void, failureCallback: (error: ErrorEvent) => void): void;
Expand All @@ -102,9 +112,9 @@ declare class WadoImageParams {
transferSyntax: string;
}
declare class WadoRsProxy {
private _baseUrl;
_baseUrl: string;
constructor(baseUrl?: string);
BaseUrl: string;
constructor(baseUrl: string);
getStudy(studyInstanceUid: string, mediaType: string, transferSyntax?: string): JQueryPromise<{}>;
getSeries(studyInstanceUid: string, seriesInstanceUid: string, mediaType: string, transferSyntax?: string): JQueryPromise<{}>;
getObjectInstance(studyInstanceUid: string, seriesInstanceUid: string, sopInstanceUID: string, mediaType: string, transferSyntax?: string): JQueryPromise<{}>;
Expand Down
12 changes: 5 additions & 7 deletions Demo/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ class app {
}

var model = new QueryModel();
var rsProxy = new WadoRsProxy(DICOMwebJS.ServerConfiguration.getWadoRsUrl());
var uriProxy = new WadoUriProxy(DICOMwebJS.ServerConfiguration.getWadoUriUrl());
var qidoProxy = new QidoRsProxy(DICOMwebJS.ServerConfiguration.getQidoUrl());
var rsProxy = new WadoRsProxy();
var uriProxy = new WadoUriProxy();
var qidoProxy = new QidoRsProxy();
var rsService = new RetrieveService(rsProxy);
var delowProxy = new DelowRsProxy();
var queryView = new QueryView(document.getElementById("#content"), model, rsService );
var queryController = new QueryController(queryView, model, qidoProxy, rsService, uriProxy);
var queryController = new QueryController(queryView, model, qidoProxy, rsService, uriProxy, delowProxy);
var element = $('#dicomImage').get(0);
var viewer = new WadoViewer(element, uriProxy);

Expand Down Expand Up @@ -60,9 +61,6 @@ class app {

$("#serverList").change(function () {
DICOMwebJS.ServerConfiguration.BaseServerUrl = $("#serverList").val();
rsProxy.BaseUrl = DICOMwebJS.ServerConfiguration.getWadoRsUrl();
uriProxy.BaseUrl = DICOMwebJS.ServerConfiguration.getWadoUriUrl();
qidoProxy.BaseUrl = DICOMwebJS.ServerConfiguration.getQidoUrl();
});
}

Expand Down
12 changes: 12 additions & 0 deletions Demo/Controllers/DemoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Security.Claims;
using System.Web;
using System.Web.Mvc;
using Demo.Models ;
Expand All @@ -14,6 +15,12 @@ public class DemoController : Controller
// GET: Demo
public ActionResult Index()
{

if( Authorize() && !HttpContext.User.Identity.IsAuthenticated)
{
return new HttpUnauthorizedResult ( ) ;
}

var serverUrl = ConfigurationManager.AppSettings["app:serverUrl"];


Expand All @@ -37,6 +44,11 @@ public ActionResult Index()
} ).ToArray ( ) ) ) ;
}

private bool Authorize ( )
{
return string.Compare (HttpContext.Request.QueryString["auth"], bool.TrueString, true) == 0 ;
}

[Route("_StudyItem")]
[Route("dicomwebjs/_StudyItem")]
public ActionResult _StudyItem()
Expand Down
Loading

0 comments on commit 1366e1f

Please sign in to comment.