12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import json
- import orthancInterface
- import orthancDatabaseBrowser
- import os
- class orthancQR:
-
- def __init__(self,server):
- self.net=orthancInterface.orthancInterface()
- fconfig=os.path.join(os.path.expanduser('~'),'.labkey',f'{server}.json')
- self.net.init(fconfig)
- def addModality(self,name,aet,host,port):
- apiURL='/'.join([self.net.getCoreURL(),'modalities',name])
- v={"AET":aet,"Host":host,"Port":port}
- response=self.net.put(apiURL,json.dumps(v),'json')
- def removeModality(self,name):
- apiURL='/'.join([self.net.getCoreURL(),'modalities',name])
- response=self.net.delete(apiURL)
- def cEcho(self,name):
- apiURL='/'.join([self.net.getCoreURL(),'modalities',name,'echo'])
- v={}
- response=self.net.get(apiURL)
- #OK if empty,JSON if fail
- return orthancDatabaseBrowser.extractJSON(response.data)
- def sendCFind(self,name,query):
- v={"Level":"Study","Query":query}
- apiURL='/'.join([self.net.getCoreURL(),'modalities',name,'query'])
- response=self.net.post(apiURL,json.dumps(v),'json')
- #pair of ID/Path json object
- return orthancDatabaseBrowser.extractJSON(response.data)
- def getCFindAnswers(self,queryId):
- apiURL='/'.join([self.net.getCoreURL(),'queries',queryId,'answers'])
- response=self.net.get(apiURL)
- #list of answers
- return orthancDatabaseBrowser.extractJSON(response.data)
- def getCFindAnswerContent(self,queryId,answerId):
- apiURL='/'.join([self.net.getCoreURL(),'queries',queryId,'answers',answerId,'content'])
- response=self.net.get(apiURL)
- #content of answer, object with DICOM codes (IDs etc)
- return orthancDatabaseBrowser.extractJSON(response.data)
|