From f17b19cf6f9733849c3a1a9eaaed2e6118543546 Mon Sep 17 00:00:00 2001 From: mario Date: Mon, 28 Apr 2025 14:10:48 +0700 Subject: [PATCH] edit: clear readme, pdu, query level --- README.md | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- main.py | 39 ++++++++++++++++++++++----------- test.http | 3 ++- 3 files changed, 91 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index cc2a616..885cc18 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,65 @@ # pydicom-uploader -Gateway untuk retrieve order di BISONE yang perlu di upload ke Google Healthcare \ No newline at end of file +## Overview +pydicom-uploader adalah sebuah gateway untuk mengambil order dari BISONE yang perlu diunggah ke Google Healthcare. Proyek ini dirancang untuk mempermudah proses pengambilan dan pengunggahan file DICOM dari PACS ke Google Healthcare API melalui Go OHIF Proxy. + +### Fitur Utama +- Mengambil daftar order yang perlu diproses dari API BISONE. +- Mengambil file DICOM dari PACS menggunakan protokol DICOM C-GET. +- Mengunggah file DICOM ke Google Healthcare API. +- Memperbarui status order di API BISONE setelah proses selesai. +- Logging yang terstruktur untuk memantau proses. + +## Alur Kerja Sederhana +1. Aplikasi mengambil daftar order yang perlu diproses dari API BISONE. + ``` + # Contoh GET Request + GET https://devone.aplikasi.web.id/one-api/mockup/godicomupreq/godicomupreq/get_uprequests?startDate=2025-04-22&endDate=2025-04-22&status=0 + ``` +2. Untuk setiap order: + - Mengambil file DICOM dari PACS berdasarkan StudyInstanceUID. + - Mengunggah file DICOM ke Google Healthcare API melalui Go OHIF Proxy. + - Memperbarui status order di API BISONE. + +3. Membersihkan file sementara setelah proses selesai. + +## Development + +### Prasyarat +- Python 3.9 atau lebih baru. +- Virtual environment (opsional, tetapi disarankan). + +### Langkah-langkah +1. Clone repository ini: + ```bash + git clone + cd pydicom-google-uploader + ``` + +2. Buat virtual environment dan aktifkan: + ```bash + python3 -m venv venv + source venv/bin/activate # Untuk Linux/Mac + venv\Scripts\activate # Untuk Windows + ``` + +3. Install dependencies: + ```bash + pip install -r requirements.txt + ``` + +4. Konfigurasi file `config.py` sesuai dengan kebutuhan Anda, seperti: + - `PACS_HOST`, `PACS_PORT`, `PACS_AE_TITLE`, dan `LOCAL_AE_TITLE` untuk konfigurasi PACS. + - `PROXY_URL` untuk URL Go OHIF Proxy. + - `API_URL` untuk endpoint API BISONE. + +5. Jalankan aplikasi: + ```bash + python main.py + ``` + +6. Untuk pengembangan, Anda dapat menggunakan file `test.http` untuk menguji endpoint HTTP. + +### Catatan +- Pastikan Anda memiliki akses ke PACS dan API BISONE yang dikonfigurasi. +- Gunakan log file (`server.log`) untuk memantau proses dan debugging jika terjadi kesalahan. \ No newline at end of file diff --git a/main.py b/main.py index f866ee0..7a05cd6 100644 --- a/main.py +++ b/main.py @@ -102,6 +102,8 @@ class DicomUploader: """ ae = AE(ae_title=self.local_ae_title) ae.add_requested_context(PatientRootQueryRetrieveInformationModelGet) + + # ae.maximum_pdu_size = 130816 # * Kalau ingin set maximum PDU size to 128kB. Harus set di sisi DCM4CHEE juga storage_uids = [ '1.2.840.10008.5.1.4.1.1.1', # CR Storage @@ -151,22 +153,33 @@ class DicomUploader: if assoc.is_established: ds = Dataset() - - if sop_instance_uid: - ds.QueryRetrieveLevel = 'IMAGE' - ds.StudyInstanceUID = study_instance_uid - ds.SeriesInstanceUID = series_instance_uid - ds.SOPInstanceUID = sop_instance_uid - elif series_instance_uid: - ds.QueryRetrieveLevel = 'SERIES' - ds.StudyInstanceUID = study_instance_uid - ds.SeriesInstanceUID = series_instance_uid - else: - ds.QueryRetrieveLevel = 'STUDY' - ds.StudyInstanceUID = study_instance_uid + + # * Kalau level image nanti cuma 1 image aja yang digetscu + # if sop_instance_uid: + # ds.QueryRetrieveLevel = 'IMAGE' + # ds.StudyInstanceUID = study_instance_uid + # ds.SeriesInstanceUID = series_instance_uid + # ds.SOPInstanceUID = sop_instance_uid + + # * Kalau level series nanti cget semua image dalam 1 series id itu + # elif series_instance_uid: + # ds.QueryRetrieveLevel = 'SERIES' + # ds.StudyInstanceUID = study_instance_uid + # ds.SeriesInstanceUID = series_instance_uid + + # * Kalau level study nanti cget semua image dalam 1 study id itu + # else: + # ds.QueryRetrieveLevel = 'STUDY' + # ds.StudyInstanceUID = study_instance_uid + + # * Default: Study level. Sampai ada kasus yang membutuhkan level lain + ds.QueryRetrieveLevel = 'STUDY' + ds.StudyInstanceUID = study_instance_uid # Send C-GET request and collect responses responses = assoc.send_c_get(ds, PatientRootQueryRetrieveInformationModelGet) + + logger.info(f"Query Retrieval Level: {ds.QueryRetrieveLevel}") for status, identifier in responses: if status: diff --git a/test.http b/test.http index 0465c2d..1d23b0e 100644 --- a/test.http +++ b/test.http @@ -1,3 +1,4 @@ -@host = http://128.199.154.150:5555 +@host = http://152.42.173.210:5555 +# Test go-ohif-proxy GET {{host}}/dicomWeb/studies \ No newline at end of file