Skip to content

Instantly share code, notes, and snippets.

@catalinabustam
Created April 25, 2016 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catalinabustam/a0e6f3069773fe2f505f808064e40dc7 to your computer and use it in GitHub Desktop.
Save catalinabustam/a0e6f3069773fe2f505f808064e40dc7 to your computer and use it in GitHub Desktop.
class OsirixService
require 'xmlrpc/client'
XMLRPC::Config::ENABLE_NIL_PARSER = true # para que no den error cuando el metodo devuelve nil
# Ejemplo de uso:
# o = OsirixService.new('127.0.0.1','3334')
# o.display_study(PatientID: 'CC000001', StudyID: '1')
def initialize(ip, port)
@ip = ip
@port = port
@server = XMLRPC::Client.new( @ip, nil, @port)
end
def kill_osirix
# Method: KillOsiriX
@server.call("KillOsiriX")
end
def download_url(opts = {})
# Method: DownloadURL
# Parameters:
# URL: any URLs that return a file compatible with OsiriX, including .dcm, .zip, .osirixzip, ...
# Display: display the images at the end of the download? (Optional parameter : it requires a WADO URL, containing the studyUID parameter)
# Example: {URL: "http://127.0.0.1:3333/wado?requestType=WADO&studyUID=XXXXXXXXXXX&seriesUID=XXXXXXXXXXX&objectUID=XXXXXXXXXXX"}
# Response: {error: "0"}
@server.call("DownloadURL", opts)
end
def display_study(opts = {})
# Method: DisplayStudy
# Parameters:
# PatientID: 0010,0020
# StudyID: 0020,0010
# StudyInstanceUID: ESTA EN EL CODIGO DE OSIRIX PERO NO DOCUMENTADO!
# AccessionNumber: ESTA EN EL CODIGO DE OSIRIX PERO NO DOCUMENTADO!
# Example: {PatientID: "1100697", StudyID: "A10043712203"}
# Response: {error: "0", elements: array of elements corresponding to the request}
# def display_study(patient_id, study_id, study_uid, accession_number)
# @server.call("DisplayStudy", {PatientID: patient_id, StudyID: study_id, StudyInstanceUID: study_uid, AccessionNumber: accession_number})
# end
@server.call("DisplayStudy", opts)
end
def display_series(opts = {})
# Method: DisplaySeries
# Parameters:
# PatientID: 0010,0020
# SeriesInstanceUID: 0020,000e
# Example: {PatientID: "1100697", SeriesInstanceUID: "1.3.12.2.1107.5.1.4.54693.30000007120706534864000001110"}
# Response: {error: "0", elements: array of elements corresponding to the request}
@server.call("DisplaySeries", opts)
end
def db_window_find(opts = {})
# Method: DBWindowFind
# Parameters:
# request: SQL request, see 'Predicate Format String Syntax' from Apple documentation
# table: OsiriX entity name: Image, Series, Study
# execute: Select, Open, Delete or Nothing - you may skip this entry
# execute is performed at the study level: you cannot delete a single series of a study
# Example: {request: "name == 'OsiriX'", table: "Study", execute: "Select"}
# Example: {request: "(name LIKE '*OSIRIX*')", table: "Study", execute: "Open"}
# Response: {error: "0", elements: array of elements corresponding to the request}
@server.call("DisplaySeries", opts)
end
def switch_to_default_db_if_needed
# Method: SwitchToDefaultDBIfNeeded
# Parameters:
# No parameters
# Response: {error: "0"}
@server.call("SwitchToDefaultDBIfNeeded")
end
def open_db(opts = {})
# Method: OpenDB
# Parameters:
# path: path of the folder containing the 'OsiriX Data' folder
# if path is valid, but not DB is found, OsiriX will create a new one
# Example: {path: "/Users/antoinerosset/Documents/"}
# Response: {error: "0"}
@server.call("OpenDB", opts)
end
def select_album(opts = {})
# Method: SelectAlbum
# Parameters:
# name: name of the album
# Example: {name: "Today"}
# Response: {error: "0"}
@server.call("SelectAlbum", opts)
end
def close_all_windows
# Method: CloseAllWindows
# Parameters: No Parameters
# Response: {error: "0"}
@server.call("CloseAllWindows")
end
def get_displayed_2d_viewer_series
# Method: GetDisplayed2DViewerSeries
# Parameters: No Parameters
# Response: {error: "0", elements: array of series corresponding to displayed windows}
@server.call("GetDisplayed2DViewerSeries")
end
def get_displayed_2d_viewer_studies
# Method: GetDisplayed2DViewerStudies
# Parameters: No Parameters
# Response: {error: "0", elements: array of studies corresponding to displayed windows}
@server.call("GetDisplayed2DViewerStudies")
end
def close_2d_viewer_with_series_uid(opts = {})
# Method: Close2DViewerWithSeriesUID
# Parameters:
# uid: series instance uid to close
# Example: {uid: "1.3.12.2.1107.5.1.4.51988.4.0.1164229612882469"}
# Response: {error: "0"}
@server.call("Close2DViewerWithSeriesUID", opts)
end
def close_2d_viewer_with_study_uid(opts = {})
# Method: Close2DViewerWithStudyUID
# Parameters:
# uid: study instance uid to close
# Example: {uid: "1.2.840.113745.101000.1008000.37915.4331.5559218"}
# Response: {error: "0"}
@server.call("Close2DViewerWithStudyUID", opts)
end
def retrieve(opts = {})
# Method: Retrieve
# Parameters:
# serverName:
# filterValue:
# filterKey:
# Example: osirix://?methodName=retrieve&serverName=Minipacs&filterKey=PatientID&filterValue=296228
# Response: {error: "0"}
# osirix://?methodName=retrieve&serverName=LaTour&filterKey=StudyInstanceUID&filterValue=2.16.840.1.113669.632.20.121711.10000348708
@server.call("Retrieve", opts)
end
def cmove(opts = {})
# Method: CMove
# Parameters:
# accessionNumber: accessionNumber of the study to retrieve
# server: server description where the images are located (See OsiriX Locations Preferences)
# Example: {accessionNumber: "UA876410", server: "Main-PACS"}
# Response: {error: "0"}
@server.call("CMove", opts)
end
def display_study_list_by_patient_name(opts = {})
# Method: DisplayStudyListByPatientName
# Parameters:
# PatientName: name of the patient
# Example: {PatientName: "DOE^JOHN"}
# Response: {error: "0"}
@server.call("DisplayStudyListByPatientName", opts)
end
def display_study_list_by_patient_id(opts = {})
# Method: DisplayStudyListByPatientId
# Parameters:
# PatientID: patient ID
# Example: {id: "0123456789"}
# Response: {error: "0"}
@server.call("DisplayStudyListByPatientId", opts)
end
def path_to_front_dcm(opts = {})
# Method: PathToFrontDCM
# Parameters:
# onlyfilename: string with value "yes" to activate only filename mode; if absent or not equal to "yes", the full path is returned
# Response: {error: "0", currentDCMPath: "/path/to/file.dcm"}
# {error: "0", currentDCMPath: "file.dcm"} if onlyfilename == "yes"
# {error: "0", currentDCMPath: ""} if no viewer is open
@server.call("PathToFrontDCM", opts)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment