diff --git a/config.py b/config.py index d2982cd..7160a81 100644 --- a/config.py +++ b/config.py @@ -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 diff --git a/main.py b/main.py index 85c4f1e..f866ee0 100644 --- a/main.py +++ b/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""" @@ -236,6 +268,8 @@ class DicomUploader: sop_uid = order.get('GdcUpreq_SopIUID') 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) @@ -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}")