bisa upload dan update
This commit is contained in:
@@ -11,7 +11,7 @@ LOCAL_AE_TITLE = 'DCM UPLOADER' # Replace with your local AE Title
|
|||||||
PROXY_URL = 'http://128.199.154.150:5555'
|
PROXY_URL = 'http://128.199.154.150:5555'
|
||||||
|
|
||||||
# API Configuration
|
# API Configuration
|
||||||
API_URL = 'https://devone.aplikasi.web.id/one-api/mockup/godicomupreq/godicomupreq/get_uprequests'
|
API_URL = 'https://devone.aplikasi.web.id/one-api/mockup/godicomupreq/godicomupreq'
|
||||||
|
|
||||||
# Processing Configuration
|
# Processing Configuration
|
||||||
MAX_RETRIES = 3
|
MAX_RETRIES = 3
|
||||||
|
|||||||
46
main.py
46
main.py
@@ -66,7 +66,7 @@ class DicomUploader:
|
|||||||
Status 0 indicates pending orders
|
Status 0 indicates pending orders
|
||||||
"""
|
"""
|
||||||
# Using the corrected endpoint
|
# Using the corrected endpoint
|
||||||
url = "https://devone.aplikasi.web.id/one-api/mockup/godicomupreq/godicomupreq/get_uprequests"
|
url = f"{config.API_URL}/get_uprequests"
|
||||||
|
|
||||||
# Add required query parameters
|
# Add required query parameters
|
||||||
today = datetime.now()
|
today = datetime.now()
|
||||||
@@ -220,8 +220,40 @@ class DicomUploader:
|
|||||||
|
|
||||||
def _update_status(self, order_id, status):
|
def _update_status(self, order_id, status):
|
||||||
"""Update order status in database (placeholder)"""
|
"""Update order status in database (placeholder)"""
|
||||||
|
|
||||||
logger.info(f"Updated order {order_id} status to {status}")
|
logger.info(f"Updated order {order_id} status to {status}")
|
||||||
# Implement actual status update logic here
|
|
||||||
|
url = f"{config.API_URL}/update_dicom_upstatus"
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
"GdcUpreqID": order_id,
|
||||||
|
"GdcUpreq_DicomUpStatus": status
|
||||||
|
}
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.post(url, json=payload, headers=headers)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
response_data = response.json()
|
||||||
|
|
||||||
|
if response_data.get("status") == "OK":
|
||||||
|
logger.info(f"Successfully updated order {order_id} status to {status}")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
logger.error(f"Failed to update order {order_id} status: {response_data.get('message')}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
logger.error(f"Error updating order {order_id} status: {e}")
|
||||||
|
return False
|
||||||
|
except ValueError as e:
|
||||||
|
logger.error(f"Invalid response format for order {order_id}: {e}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def process_pending_orders(self):
|
def process_pending_orders(self):
|
||||||
"""Process all pending orders"""
|
"""Process all pending orders"""
|
||||||
@@ -236,6 +268,8 @@ class DicomUploader:
|
|||||||
sop_uid = order.get('GdcUpreq_SopIUID')
|
sop_uid = order.get('GdcUpreq_SopIUID')
|
||||||
|
|
||||||
logger.info(f"Processing order {order_id} for study {study_uid}")
|
logger.info(f"Processing order {order_id} for study {study_uid}")
|
||||||
|
|
||||||
|
# self._update_status(order_id, 1) # ? PROGRES: apakah perlu?
|
||||||
|
|
||||||
# Retrieve DICOM files
|
# Retrieve DICOM files
|
||||||
dicom_files = self._retrieve_dicom(study_uid, series_uid, sop_uid)
|
dicom_files = self._retrieve_dicom(study_uid, series_uid, sop_uid)
|
||||||
@@ -256,11 +290,11 @@ class DicomUploader:
|
|||||||
|
|
||||||
# Update status
|
# Update status
|
||||||
if failure_count == 0 and success_count > 0:
|
if failure_count == 0 and success_count > 0:
|
||||||
self._update_status(order_id, "COMPLETED")
|
self._update_status(order_id, 2)
|
||||||
elif success_count > 0:
|
# elif success_count > 0:
|
||||||
self._update_status(order_id, "PARTIALLY_COMPLETED")
|
# self._update_status(order_id, "PARTIALLY_COMPLETED")
|
||||||
else:
|
else:
|
||||||
self._update_status(order_id, "FAILED")
|
self._update_status(order_id, 3)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error processing order: {e}")
|
logger.error(f"Error processing order: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user