Skip to content

Refactor Health Record Schema to Support Unified Structure with Parent-Child Relationship #26

@AladinJmila

Description

@AladinJmila

The current MongoDB schema separates the main health record and its updates into two different Mongoose models. This task aims to refactor the schema to follow a more unified structure, similar to the SQL backend, where updates are treated as child records of a parent health record.

Requirements

  • Merge the health record and update schemas into a single unified schema.
  • Introduce an optional parentId field:
      - If parentId is null or undefined, the record is a top-level health record.
      - If parentId is set, the record is considered an update (child).
  • Add an optional updates array to top-level records to store child record IDs.
  • Ensure that only top-level records (i.e., those without a parentId) are allowed to have an updates array.
  • Implement logic to prevent infinite nesting of updates (i.e., children cannot have their own updates arrays).
  • Update any existing logic that fetches or processes updates to work with the new structure.

Notes

  • This change is intended to align the MongoDB schema more closely with the SQL backend design.
  • The updated structure should still support expansion of child records into full objects when queried.

Metadata

Metadata

Labels

enhancementImproving existing implmentationrefactorCode refactor

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions