9.9 KiB
Agent Instructions:
You are a senior Django architect and full-stack developer. This is a very large, mission-critical project—do not dump all code at once. Follow this strict phased plan-and-approve workflow to minimize hallucination and ensure accuracy:
Phase 1 – Planning
- Produce a high-level outline of every app/module, its responsibilities, and the key models, views/endpoints, HTMX interactions, Celery tasks, HL7 and DICOM/PACS interfaces, AI analytics hooks, and compliance/multitenancy considerations.
- Pause and wait for my confirmation before proceeding.
Phase 2 – Scoping & Approval (per app)
For each confirmed app (one at a time):
- List all models, fields, relationships, and choice enums in full detail.
- List required UI views (with HTMX attributes) and REST API endpoints/URLs.
- List any Celery tasks, HL7/DICOM integration points, IoT hooks, and AI rule triggers.
- Pause and wait for my “👍 go ahead with [app_name]” before generating any code.
Phase 3 – Implementation (per app)
When I approve an app:
- Generate models.py for that app only.
- Pause for my review and approval.
- Generate serializers.py and/or forms.py, then pause for review.
- Generate views.py, templates/, and any necessary HTMX snippets, then pause for review.
- Generate static asset scaffolding (SASS partials, HTMX/JS modules) and pause for review.
Phase 4 – Shared Tooling & Final Integration
After all apps are complete:
- Generate Webpack (or Django-Webpack-Loader) setup, SCSS/JS bundling, and
django-compressorconfig. - Generate Celery configuration with Redis broker and example tasks (including HL7/DICOM polling, IoT data ingestion, AI analytics jobs).
- Generate the hl7_interface and pacs_interface apps: models, utilities, management commands, and Celery tasks for HL7 v2.x and DICOM messaging.
- Generate DRF API docs (Swagger) config, pytest setup, and GitHub Actions CI workflow.
- Generate example Gunicorn + Nginx deployment snippets with multitenancy and SSL/TLS, and notes on GDPR/HIPAA compliance (encryption at rest, audit logs, consent management).
- Provide a comprehensive README covering:
- Python virtualenv setup
npm install && npm run buildmanage.py migrate, superuser setup- ColorAdmin license integration
- HTMX usage guidelines
- HL7/DICOM endpoint configuration
- IoT device onboarding
- AI risk-scoring configuration
- Multitenancy setup
- Compliance controls (2FA, encryption, consent capture)
Project Specification
Project name: hospital_management
UI theme: ColorAdmin template (all CSS/JS centralized—no inline or per-template scripts/styles)
Dynamic behavior: HTMX for all interactive features
Messaging: Optional inbound/outbound HL7 and DICOM/PACS interfaces
Analytics: AI-driven predictive risk scoring hooks in decision_support
Security & Compliance:
- Two-factor authentication, encryption at rest, GDPR/HIPAA audit trails
- Consent management, digital signatures, detailed audit logs
- Tenant-scoped data isolation for multi-hospital support
Apps, Models & Fields
-
accounts
User(extends AbstractUser): username, email, first_name, last_name, password, role (choices: Admin, Doctor, Nurse, LabTech, Pharmacist, Receptionist, Patient, EMS), is_active, date_joined, tenantTwoFactorDevice: user FK, device_type, secret_key, confirmedSocialAccount(django-allauth)
-
core
AuditLogEntry: user FK, action, timestamp, object_type, object_id, change_detail- HL7Utility & DICOMUtility modules (no models; parsing/building functions)
-
patients
PatientProfile: user FK (Patient), medical_record_number, date_of_birth, gender, blood_type, allergies (text), address, phone, emergency_contact FK, insurance_info FKEmergencyContact: patient FK, name, relationship, phone, emailInsuranceInfo: patient FK, provider, policy_number, group_number, coverage_start_date, coverage_end_dateConsentForm: patient FK, form_type, document (FileField), signed_at, signed_by FK
-
appointments
AppointmentRequest: patient FK, doctor FK, department, requested_datetime, status (Pending/Confirmed/Cancelled), created_at, updated_atSlotAvailability: doctor FK, date, start_time, end_time, is_availableWaitingQueue: appointment FK, position, created_at- VirtualCare scheduled via
TelemedicineSession: patient FK, provider FK, session_url, start_time, end_time, status
-
inpatients
Ward: name, floor, capacity, departmentBed: ward FK, bed_number, bed_type (choices: General/ICU/Private), statusAdmission: patient FK, ward FK, bed FK, admitted_at, admitted_by FK, reason, statusDischargeSummary: admission FK, summary_text, discharged_at, discharged_by FKTransfer: admission FK, from_ward FK, to_ward FK, transferred_at, reasonSurgerySchedule: patient FK, surgeon FK, or_block FK, scheduled_at, duration, status
-
emr
Encounter: patient FK, encounter_date, provider FK, encounter_type, notesVitalSigns: encounter FK, recorded_at, temperature, heart_rate, bp_systolic, bp_diastolic, respiratory_rate, oxygen_saturationProblemList: patient FK, description, onset_date, status, notesCarePlan: encounter FK, goal, interventions, statusClinicalNote: encounter FK, note_type, content, created_at, created_by FK
-
billing
Invoice: patient FK, date_issued, due_date, total_amount, statusChargeItem: invoice FK, description, code, quantity, unit_price, total_pricePayment: invoice FK, amount, method, paid_at, transaction_idInsuranceClaim: invoice FK, claim_number, status, submitted_at, adjudicated_at
-
pharmacy
Medication: name, code, description, unit, dosage_formPrescription: patient FK, prescriber FK, prescribed_at, statusDispenseRecord: prescription FK, medication FK, quantity, dispensed_at, dispenser FKStockItem: medication FK, batch_number, expiration_date, quantity_on_hand, minimum_threshold
-
laboratory
LabTest: name, code, description, specimen_type, departmentSpecimen: lab_test FK, patient FK, collected_at, collected_by FK, statusResult: specimen FK, result_value, units, reference_range, result_date, verified_by FKLISIntegrationLog: message_id, direction, payload, status, processed_at
-
radiology
RadiologyOrder: patient FK, imaging_type, ordered_by FK, order_date, priority, statusImagingStudy: order FK, modality, study_date, images_count, report_statusRadiologyReport: study FK, report_text, dictated_by FK, dictated_at, approved_by FK, approved_atDICOMStudy: study_instance_uid, patient_fk, modality, study_date, series_data (JSON)
-
inventory
SupplyItem: name, sku, description, category, unit, reorder_level, locationPurchaseOrder: supplier FK, order_date, expected_date, status, total_amountStockTransaction: item FK, transaction_type, quantity, transaction_date, reference
-
decision_support
CDSSRule: name, trigger_event, condition_expression, action, activeAlertLog: rule FK, patient FK, triggered_at, message, status- AI hooks: risk_scoring_config (JSON), last_run, score_thresholds
-
reporting
CustomReport: name, description, owner FK, query_definition (JSON), created_at, updated_atDashboardWidget: name, report FK, widget_type, settings (JSON), position
-
hl7_interface
HL7Endpoint: name, host, port, protocol, is_active, last_checkedHL7MessageLog: endpoint FK, direction, message_type, raw_message, parsed_message, sent_at, received_at, status
-
pacs_interface
PACSConnection: name, ae_title, host, port, is_activePACSLog: connection FK, direction, dicom_uid, raw_payload, processed_at, status
-
operating_theatre
ORBlock: name, theater_number, department, available_slots (JSON)EquipmentReservation: device FK, or_block FK, reserved_from, reserved_to, status
-
assets
MedicalDevice: name, serial_number, category, location, status, last_maintenanceMaintenanceLog: device FK, performed_at, performed_by FK, notesIoTSensorReading: device FK, timestamp, data (JSON)
-
ems
DispatchRequest: caller_info, location, priority, status, created_atAmbulance: identifier, capacity, status, locationCrewMember: user FK, ambulance FK, roleTripLog: dispatch FK, ambulance FK, start_time, end_time, patient_fk
-
nutrition
MealPlan: patient FK, date, meals (JSON), dietary_restrictionsDietaryOrder: patient FK, meal_type, order_time, statusKitchenTask: plan FK, task_description, assigned_to FK, status, completed_at
-
security
EncryptionKey: key_name, key_type, created_at, rotation_dateAuditLogEntry(enhanced for GDPR/HIPAA as above)
Shared Tooling, Interactivity & Deployment
- Assets: SCSS in
assets/scss/→static/dist/main.css; JS inassets/js/→static/dist/main.jsvia Webpack + Babel;django-compressorfor compression. - HTMX: All dynamic features use
hx-*attributes—no per-template JS. - API: DRF ModelViewSets under
/api/v1/, secured with JWT/OAuth2, Swagger UI at/api/docs/. - Background: Celery+Redis for notifications, HL7/DICOM messaging, IoT ingestion, AI scoring.
- Testing/CI:
pytest+ GitHub Actions for lint/test/build. - Deployment: Gunicorn+Nginx configs, multitenancy notes, SSL/TLS, GDPR/HIPAA compliance checklist, 2FA setup, consent management, and monitoring guidance.
Ensure phased execution and strictly pause for approvals at each step. Good luck!