Skip to content

Commit 64ae2ae

Browse files
feat: Implement SOAP clinical notes management system
- Added ClinicalNotesController to handle CRUD operations for clinical notes. - Created ClinicalNotesService for business logic related to clinical notes. - Developed ClinicalNotesRepository for database interactions with clinical notes. - Introduced clinical notes validation schema using Joi. - Established routes for clinical notes, including endpoints for creating, updating, retrieving, and deleting notes. - Enhanced user role authorization for accessing clinical notes based on user roles (doctor, admin, patient). - Implemented pagination for retrieving clinical notes. - Added logging for clinical notes operations to track actions and errors.
1 parent 19c812b commit 64ae2ae

File tree

11 files changed

+2484
-261
lines changed

11 files changed

+2484
-261
lines changed

README.md

Lines changed: 993 additions & 241 deletions
Large diffs are not rendered by default.

migrations/001_complete_schema.sql

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,17 +286,39 @@ CREATE TABLE appointments (
286286
-- CLINICAL DOCUMENTATION
287287
-- ========================================
288288

289-
-- Clinical notes
289+
-- Clinical notes with SOAP format support
290+
-- SOAP = Subjective, Objective, Assessment, Plan (standard medical documentation format)
290291
CREATE TABLE clinical_notes (
291292
id SERIAL PRIMARY KEY,
292-
patient_id INT REFERENCES patients(id),
293-
appointment_id INT REFERENCES appointments(id),
294-
doctor_id INT REFERENCES doctors(id),
295-
note_type TEXT DEFAULT 'general',
293+
patient_id INT REFERENCES patients(id) ON DELETE CASCADE,
294+
appointment_id INT REFERENCES appointments(id) ON DELETE CASCADE,
295+
doctor_id INT REFERENCES doctors(id) ON DELETE SET NULL,
296+
297+
-- SOAP Format Fields (standard medical documentation)
298+
subjective TEXT, -- Patient's complaints, symptoms, and reported history
299+
objective TEXT, -- Doctor's observations, physical findings, test results
300+
assessment TEXT, -- Diagnosis and professional evaluation
301+
plan TEXT, -- Treatment plan, recommendations, next steps
302+
303+
-- Legacy fields (kept for backward compatibility)
304+
note_type TEXT DEFAULT 'soap',
296305
content TEXT,
297306
diagnosis TEXT,
298307
treatment_plan TEXT,
299308
follow_up_instructions TEXT,
309+
310+
-- Additional Clinical Details
311+
treatment_performed TEXT, -- Specific treatments performed during this visit
312+
techniques_used TEXT[], -- Array of techniques used (e.g., spinal adjustment, soft tissue therapy)
313+
vitals JSONB, -- Vital signs: {"blood_pressure": "120/80", "pulse": 72, "temperature": 98.6}
314+
follow_up_notes TEXT, -- Internal notes for next visit
315+
next_appointment_recommendation TEXT, -- Recommended time for next visit
316+
visit_duration_minutes INTEGER, -- Length of visit
317+
318+
-- Privacy and Access Control
319+
is_private BOOLEAN DEFAULT TRUE CHECK (is_private = TRUE), -- Always private from patients
320+
321+
-- Metadata
300322
created_at TIMESTAMPTZ DEFAULT NOW(),
301323
updated_at TIMESTAMPTZ DEFAULT NOW()
302324
);
@@ -571,6 +593,9 @@ CREATE INDEX idx_appointments_updated_by ON appointments(updated_by);
571593
-- Clinical data indexes
572594
CREATE INDEX idx_clinical_notes_patient_id ON clinical_notes(patient_id);
573595
CREATE INDEX idx_clinical_notes_appointment_id ON clinical_notes(appointment_id);
596+
CREATE INDEX idx_clinical_notes_doctor_id ON clinical_notes(doctor_id);
597+
CREATE INDEX idx_clinical_notes_created_at ON clinical_notes(created_at DESC);
598+
CREATE INDEX idx_clinical_notes_patient_doctor ON clinical_notes(patient_id, doctor_id, created_at DESC);
574599
CREATE INDEX idx_vitals_patient_id ON vitals(patient_id);
575600
CREATE INDEX idx_vitals_appointment_id ON vitals(appointment_id);
576601

0 commit comments

Comments
 (0)