A Django application that provides an API for uploading and storing DICOM files along with their associated metadata. This project utilizes Django REST Framework for building RESTful APIs and pydicom for extracting metadata from DICOM files.
- Upload DICOM files with associated metadata.
- Extract metadata such as Patient ID, Modality, Series Instance UID, and Study Instance UID from uploaded DICOM files.
- Validate uploaded files to ensure they are in the DICOM format.
- Admin interface for managing uploaded DICOM files.
- Django
- Django REST Framework
- pydicom
- PostgreSQL
- Python 3.x
- Docker
- Docker Compose
-
Clone the repository:
git clone https://github.com/amiradmin/dicom_project.git
-
Navigate to the project directory:
cd dicom_project
- Environment Variables
POSTGRES_DB=yourdbname
POSTGRES_USER=yourdbuser
POSTGRES_PASSWORD=yourdbpassword
DATABASE_URL=postgres://yourdbuser:yourdbpassword@db:5432/yourdbname
SECRET_KEY=your-secret-key
DJANGO_SUPERUSER_USERNAME=admin
DJANGO_SUPERUSER_EMAIL=[email protected]
DJANGO_SUPERUSER_PASSWORD=your_superuser_password
DEBUG=1
4Access the application:
Open your browser and navigate to http://127.0.0.1:8000 to access the API.
Usage
Accessing the Admin Interface
Visit http://127.0.0.1:8000/admin/ and log in with the superuser credentials defined in your environment variables.
- API Endpoints
Endpoint: /api/dicom/upload/
Method: POST
Request:
file: The DICOM file to upload.
doctype: The type of document.
Response:
On success, returns the serialized data of the uploaded file.
On error, returns validation errors.
- Authentication
- The API uses JWT (JSON Web Tokens) for authentication.
POST /api/token/: Obtain JWT token.
Data Validation and Error Handling
Data Validation: Ensured through Django and DRF serializers (e.g., ensuring unique identifiers).
Error Handling: Standardized error responses with appropriate HTTP status codes.
Setup and Deployment
Prerequisites
Docker
Docker Compose
- Build and start the containers:
- Run the following command to build the Docker images and start the application:
docker-compose up --build