|
@@ 37-59 (lines=23) @@
|
| 34 |
|
|
| 35 |
|
return r.status_code, r.json() |
| 36 |
|
|
| 37 |
|
@staticmethod |
| 38 |
|
def postOrthanc(endpoint, data): |
| 39 |
|
""" |
| 40 |
|
Get from a Orthanc endpoint |
| 41 |
|
:param endpoint: |
| 42 |
|
:param data |
| 43 |
|
:return: bool on if such PSCID (INSTITUTIONID + PROJECTID + SUBJECTID) exist already. |
| 44 |
|
""" |
| 45 |
|
logger = logging.getLogger('Orthanc_post') |
| 46 |
|
logger.info("Post Orthanc endpoint: "+ endpoint + "at") |
| 47 |
|
success = load_dotenv() |
| 48 |
|
if not success: |
| 49 |
|
raise ImportError("Credential .env NOT FOUND! Please ensure .env is set with all the necessary credentials!") |
| 50 |
|
url = os.getenv("OrthancURL") |
| 51 |
|
updatedurl = url + endpoint |
| 52 |
|
logger.info(updatedurl) |
| 53 |
|
|
| 54 |
|
with requests.Session() as s: |
| 55 |
|
r = s.post(updatedurl, files=data) |
| 56 |
|
|
| 57 |
|
logger.info("Post Result:" + str(r.status_code) + r.reason) |
| 58 |
|
|
| 59 |
|
return r.status_code, r |
| 60 |
|
|
| 61 |
|
@staticmethod |
| 62 |
|
def deleteOrthanc(endpoint): |
|
@@ 61-81 (lines=21) @@
|
| 58 |
|
|
| 59 |
|
return r.status_code, r |
| 60 |
|
|
| 61 |
|
@staticmethod |
| 62 |
|
def deleteOrthanc(endpoint): |
| 63 |
|
""" |
| 64 |
|
Delete from a Orthanc endpoint |
| 65 |
|
:param endpoint: |
| 66 |
|
:return: bool on if such PSCID (INSTITUTIONID + PROJECTID + SUBJECTID) exist already. |
| 67 |
|
""" |
| 68 |
|
logger = logging.getLogger('Orthanc_delete') |
| 69 |
|
logger.info("Deleting Orthanc endpoint: "+ endpoint + "at") |
| 70 |
|
success = load_dotenv() |
| 71 |
|
if not success: |
| 72 |
|
raise ImportError("Credential .env NOT FOUND! Please ensure .env is set with all the necessary credentials!") |
| 73 |
|
url = os.getenv("OrthancURL") |
| 74 |
|
updatedurl = url + endpoint |
| 75 |
|
logger.info(updatedurl) |
| 76 |
|
|
| 77 |
|
with requests.Session() as s: |
| 78 |
|
r = s.delete(updatedurl) |
| 79 |
|
logger.info("Deletion Result:" + str(r.status_code) + r.reason) |
| 80 |
|
|
| 81 |
|
return r.status_code, r.json() |
| 82 |
|
|
| 83 |
|
@staticmethod |
| 84 |
|
def getPatientZipOrthanc(endpoint): |
|
@@ 15-35 (lines=21) @@
|
| 12 |
|
|
| 13 |
|
class orthanc_query: |
| 14 |
|
|
| 15 |
|
@staticmethod |
| 16 |
|
def getOrthanc(endpoint): |
| 17 |
|
""" |
| 18 |
|
Get from a Orthanc endpoint |
| 19 |
|
:param endpoint: |
| 20 |
|
:return: bool on if such PSCID (INSTITUTIONID + PROJECTID + SUBJECTID) exist already. |
| 21 |
|
""" |
| 22 |
|
logger = logging.getLogger('Orthanc_get') |
| 23 |
|
logger.info("Getting Orthanc endpoint: "+ endpoint + "at") |
| 24 |
|
success = load_dotenv() |
| 25 |
|
if not success: |
| 26 |
|
raise ImportError("Credential .env NOT FOUND! Please ensure .env is set with all the necessary credentials!") |
| 27 |
|
url = os.getenv("OrthancURL") |
| 28 |
|
updatedurl = url + endpoint |
| 29 |
|
logger.info(updatedurl) |
| 30 |
|
|
| 31 |
|
with requests.Session() as s: |
| 32 |
|
r = s.get(updatedurl) |
| 33 |
|
logger.info("Get Result:" + str(r.status_code) + r.reason) |
| 34 |
|
|
| 35 |
|
return r.status_code, r.json() |
| 36 |
|
|
| 37 |
|
@staticmethod |
| 38 |
|
def postOrthanc(endpoint, data): |