Skip to main content

CR Notes

This page explains how note reading and note creation work in the Caution Report flow.

For editing an existing note, use CR Update Notes.

API Endpoints

  • GET /data/caution-report/get-all-notes
  • GET /data/caution-report/by-id/:id
  • POST /data/caution-report/note/create

Bottom line

The Get All Notes and Get CR Notes flowcharts are both useful, but they describe two different note views in the current implementation:

  • Get All Notes is a real backend endpoint and returns only top-level CR notes with no activityId
  • Get CR Notes is reflected in the CR detail response shape, where activity-linked notes are grouped under each CR activity

So the two note views are both real, but they are not the same API flow.

Purpose

CR notes capture user or system commentary and are shown in two main ways:

  • as top-level CR notes
  • as activity-linked notes under CR activities

When new notes are created through the portal note form, they are activity-linked and must also synchronize to TMF.

Read path A: Get All Notes

This is the explicit backend endpoint used by the portal notes table.

Confirmed endpoint

  • GET /data/caution-report/get-all-notes

What it returns

The backend query is intentionally filtered with activityId: IsNull().

That means this endpoint returns:

  • notes belonging to the CR
  • only notes without an activity link
  • newest-first ordering
  • paged response with count and data

Current portal usage

The CR detail page calls this endpoint in loadCrNotes() and uses it to populate the main notes table.

Read path B: Get CR Notes

In the current codebase, I did not find a separate standalone get-cr-notes controller endpoint for CR.

What I could confirm is that CR detail mapping already splits notes into two buckets:

  • notesWithoutActivity
  • notesWithActivity

Then the backend response maps them like this:

  • top-level CR response notes gets notes without activityId
  • each grouped activity in activityList gets only the notes whose activityId matches that activity

So the practical meaning of Get CR Notes in the current implementation is:

  • activity-scoped notes shown inside the CR detail activity sections
  • not the same thing as the top-level get-all-notes endpoint

Read behavior summary

Note viewCurrent sourceWhat it shows
Get All Notesexplicit backend endpointtop-level CR notes with no activity link
Get CR NotesCR detail response mappingnotes attached to a specific CR activity

Create note flow

When a user creates a note from the CR detail page, the current implementation does not behave like a simple local comment save.

Main flow

StepBusiness meaning
load CR and status contextnote target must exist
save local CR notelocal note record is created first
find CR activity by CR id + activity idnote must attach to a valid activity
build TMF note payloaddownstream payload is prepared
send note to TMFexternal sync happens
if TMF fails, delete local note and rejectrollback behavior exists
if TMF succeeds, write success audit and return notecreate completes

Confirmed implementation behavior

  • portal loads top-level notes from GET /data/caution-report/get-all-notes
  • portal creates notes via POST /data/caution-report/note/create
  • note form requires both activityId and note
  • backend requires a matching CR activity for the selected activityId
  • backend deletes the just-created local note if TMF note sync fails

Important implementation nuance

There is a useful distinction here for the docs and for onboarding:

  • top-level notes are read from the dedicated notes endpoint
  • newly created portal notes are activity-linked
  • activity-linked notes are later shown inside activity-level note views in the CR detail response

So “all notes” in everyday conversation can sound broader than what the actual get-all-notes endpoint returns.

Flowchart verdict

The note flowcharts are mostly correct, but they should be read as two different views:

  • Get All Notes matches the real endpoint-backed top-level note list
  • Get CR Notes matches the activity-level note grouping visible in CR detail behavior

That is the most accurate code-checked interpretation of the current repo.

Code references

  • intt-portal/src/app/components/pages/main-modules/cr/cr-details/cr-details.component.ts
  • mvp2-data-service/src/modules/caution-report/caution-report.controller.ts
  • mvp2-data-service/src/modules/caution-report/caution-report.service.ts
  • mvp2-data-service/src/modules/caution-report/caution-report-response.model.ts