Skip to content

BUG-01: Clinical Notes Are Never Saved (Silent Data Loss) #12

Description

@Iankodj

BUG-01 — Clinical Notes Are Never Saved (Silent Data Loss)

Severity: Critical
Component: Patient Profile
File: src/app/patients/patient-profile/patient-profile.ts
Status: Open


Summary

The "Save Notes" action in the Patient Profile page silently discards all clinical notes entered by the physician. The note is never written back to the data layer.


Description

The Patient Profile view includes a rich-text editor (powered by Kendo Editor) where a physician can write or update clinical notes for a patient. When the "Save" button is clicked, it invokes saveNotes():

// patient-profile.ts — line ~127
public saveNotes(): void {
  console.log('Saving patient notes...');
  // In a real app, save to backend service
}

This method only logs to the console. It never calls PatientsService.updatePatientNotes(), even though that method is fully implemented and ready to use:

// patients.service.ts
public updatePatientNotes(id: number, notes: string): boolean {
  const patient = this.patientsData.find((p) => p.id === id);
  if (patient) {
    patient.notes = notes;
    return true;
  }
  return false;
}

Additionally, saveNotes() does not read the current value from the editor component — no @ViewChild reference or two-way binding captures what the doctor has typed. Even if the service call were added, the wrong (or empty) value would be passed.

There is also no user feedback after clicking Save — no success toast, no error state, no loading indicator. The user has no way of knowing the save failed.


Steps to Reproduce

  1. Navigate to any patient profile: http://localhost:4200/#/patients/1
  2. Scroll to the "Patient Notes" section
  3. Type or modify content in the rich-text editor
  4. Click the Save button
  5. Navigate away and return to the same profile

Result: All edits are lost. The original note is displayed as if nothing was saved.
Expected: The updated note persists across navigation.


Root Cause

Two separate issues compound this bug:

  1. saveNotes() does not call the service. The implementation was left as a stub (console.log placeholder) and the real service call was never wired up.

  2. The editor's current value is not captured. The component has no [(ngModel)] binding or @ViewChild reference to the EditorComponent to read its current HTML content before saving.


Impact

  • Patient safety risk in a production context: clinical notes written by a physician — diagnoses, observations, treatment plans — are silently discarded with no warning.
  • No error surfaced: the UI gives no indication that the save failed; a user assumes the note was saved.
  • Data loss on every save action.

Fix Specification

Step 1 — Capture the editor value

Add a two-way binding or @ViewChild to the Kendo Editor in patient-profile.html:

<kendo-editor [(value)]="patientNoteContent" ...></kendo-editor>

And declare the property in patient-profile.ts:

public patientNoteContent: string = '';

Load the existing note value in loadPatientData():

private loadPatientData(): void {
  const patientData = this.patientsService.getPatientById(this.patientId);
  if (patientData) {
    this.patient = patientData;
    this.labResults = patientData.labResults;
    this.patientNoteContent = patientData.notes ?? '';  // ← populate editor
  } else {
    this.router.navigate(['/patients']);
  }
}

Step 2 — Wire up the service call

public saveNotes(): void {
  const success = this.patientsService.updatePatientNotes(
    this.patientId,
    this.patientNoteContent
  );

  if (success) {
    // Show success notification
  } else {
    // Show error notification
  }
}

Step 3 — Add user feedback

Use a Kendo Notification or a simple status flag to inform the user whether the save succeeded or failed.


Acceptance Criteria

  • Typing in the Patient Notes editor and clicking Save persists the content
  • Navigating away and returning to the same profile shows the saved note
  • A visible success message appears after a successful save
  • A visible error message appears if the save fails
  • The editor is pre-populated with the patient's existing notes on load

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingDemoAdditions, Improvements or fixes in a demo item from public sites

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions