102 lines
2.4 KiB
Markdown
102 lines
2.4 KiB
Markdown
# DICOM Migration REST API
|
|
|
|
A simple REST API that triggers DICOM study migration for a specific Accession Number.
|
|
|
|
## How to Run
|
|
|
|
```bash
|
|
# Start the server on default port 8000
|
|
python run.py
|
|
|
|
# Custom port
|
|
python run.py --port 9000
|
|
|
|
# Custom token
|
|
python run.py --token your-secure-token
|
|
|
|
# Development mode with auto-reload
|
|
python run.py --reload
|
|
```
|
|
|
|
## How to Use
|
|
|
|
### Make a Request
|
|
|
|
```bash
|
|
# Using curl
|
|
curl -X POST "http://localhost:8000/migrate/R.20240401.0138" \
|
|
-H "Authorization: Bearer token-his2-untuk-hit-api-migrasi-clarity" \
|
|
-H "Content-Type: application/json"
|
|
```
|
|
|
|
### Response Example
|
|
|
|
```json
|
|
{
|
|
"success":true,
|
|
"message":"Berhasil migrasi file DICOM Accession Number: R.20240401.0138",
|
|
"details":
|
|
{
|
|
"accession_number":"R.20240401.0138",
|
|
"process_start_time":"2025-07-11 15:27:26",
|
|
"steps_completed":[
|
|
"study_found","study_retrieved","study_sent","log_created","his_api_success","cleanup_success"
|
|
],
|
|
"study_uid":"1.2.826.1.3680043.9.5282.150415.544835.202404010138",
|
|
"patient_id":"00544835",
|
|
"study_description":"A103 - Thorax PA",
|
|
"instances_retrieved":4,
|
|
"files_sent":2,
|
|
"total_files":2,
|
|
"c_store_success":true,
|
|
"series_count":4,
|
|
"his_api_status_code":200,
|
|
"his_integration_success":true,
|
|
"cleanup_success":true,
|
|
"process_end_time":"2025-07-11 15:27:46"
|
|
}
|
|
}
|
|
```
|
|
|
|
## Logs
|
|
|
|
- Main API logs: `logs/api.log`
|
|
- Process details: `logs/api_process.log`
|
|
|
|
## Simple Workflow
|
|
|
|
1. API receives request with accession number
|
|
2. Finds study UID using C-FIND
|
|
3. Downloads DICOM files using C-GET
|
|
4. Uploads files to destination PACS using C-STORE
|
|
5. Updates HIS system via API call
|
|
6. Cleans up all temporary DICOM files
|
|
7. Returns success/failure response
|
|
|
|
## Troubleshooting Tips
|
|
|
|
- Check PACS connectivity in `config/settings.py`
|
|
- Verify the accession number exists in source PACS
|
|
- Ensure permissions for log directories
|
|
- Check both log files for detailed error messages
|
|
- Verify HIS API connectivity for end-to-end success
|
|
|
|
## Quick Test
|
|
|
|
1. Start the server:
|
|
```bash
|
|
python run.py
|
|
```
|
|
|
|
2. In another terminal, test the root endpoint:
|
|
```bash
|
|
curl http://localhost:8000/
|
|
```
|
|
|
|
3. Test migration with a valid accession number:
|
|
```bash
|
|
curl -X POST "http://localhost:8000/migrate/R.20240401.0138" \
|
|
-H "Authorization: Bearer token-his2-untuk-hit-api-migrasi-clarity"
|
|
```
|
|
|