Skip to content

feat(#10706): port lineage manipulation helpers for hierarchy operations#11187

Open
vikrantwiz02 wants to merge 1 commit into
medic:10706-dmp-2026-add-api-endpoints-for-advanced-contact-management-operationsfrom
vikrantwiz02:10706-move-port-lineage-helpers
Open

feat(#10706): port lineage manipulation helpers for hierarchy operations#11187
vikrantwiz02 wants to merge 1 commit into
medic:10706-dmp-2026-add-api-endpoints-for-advanced-contact-management-operationsfrom
vikrantwiz02:10706-move-port-lineage-helpers

Conversation

@vikrantwiz02

@vikrantwiz02 vikrantwiz02 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

First bit of the move work, the next operation in #10706 after delete. This one's just groundwork, no endpoint yet. It ports the lineage helpers from cht-conf that the move (and later merge) service will need, so it's only plain functions with tests for now.

These don't exist server-side, so I put them in a new api/src/services/hierarchy/ folder:

  • replace-lineage.js rewrites a doc's parent/contact lineage in place. It's got a merge flag for the merge variant too, so this'll cover the merge case later as well.
  • lineage-manipulation.js has createLineageFromDoc and pluckIdsFromLineage, and re-exports the replace-lineage functions.

Couple of things I changed from cht-conf, shout if you'd rather I didn't:

  • Left out cht-conf's minifyLineagesInDoc. It's basically a copy of minify from @medic/lineage, which we already have here and does a bit more (recursion guard, data_record cleanup), so the move service will just use that instead of carrying another copy.
  • Switched the function declarations to arrow functions to keep eslint happy. cht-conf doesn't have the func-style rule but we do.

Changes

  • api/src/services/hierarchy/replace-lineage.js
  • api/src/services/hierarchy/lineage-manipulation.js
  • api/tests/mocha/services/hierarchy/replace-lineage.spec.js
  • api/tests/mocha/services/hierarchy/lineage-manipulation.spec.js

npm run unit-api: lint clean, 13 passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant