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'
|
||||
|
||||
# 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
|
||||
MAX_RETRIES = 3
|
||||
|
||||
46
main.py
46
main.py
@@ -66,7 +66,7 @@ class DicomUploader:
|
||||
Status 0 indicates pending orders
|
||||
"""
|
||||
# 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
|
||||
today = datetime.now()
|
||||
@@ -220,8 +220,40 @@ class DicomUploader:
|
||||
|
||||
def _update_status(self, order_id, status):
|
||||
"""Update order status in database (placeholder)"""
|
||||
|
||||
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):
|
||||
"""Process all pending orders"""
|
||||
@@ -237,6 +269,8 @@ class DicomUploader:
|
||||
|
||||
logger.info(f"Processing order {order_id} for study {study_uid}")
|
||||
|
||||
# self._update_status(order_id, 1) # ? PROGRES: apakah perlu?
|
||||
|
||||
# Retrieve DICOM files
|
||||
dicom_files = self._retrieve_dicom(study_uid, series_uid, sop_uid)
|
||||
logger.info(f"Retrieved {len(dicom_files)} DICOM files")
|
||||
@@ -256,11 +290,11 @@ class DicomUploader:
|
||||
|
||||
# Update status
|
||||
if failure_count == 0 and success_count > 0:
|
||||
self._update_status(order_id, "COMPLETED")
|
||||
elif success_count > 0:
|
||||
self._update_status(order_id, "PARTIALLY_COMPLETED")
|
||||
self._update_status(order_id, 2)
|
||||
# elif success_count > 0:
|
||||
# self._update_status(order_id, "PARTIALLY_COMPLETED")
|
||||
else:
|
||||
self._update_status(order_id, "FAILED")
|
||||
self._update_status(order_id, 3)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error processing order: {e}")
|
||||
|
||||
Reference in New Issue
Block a user