Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) Add ability to track deleted fields in repeat component #455

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

CynthiaKamau
Copy link
Contributor

@CynthiaKamau CynthiaKamau commented Jan 7, 2025

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

Add ability to track deleted fields in repeat component, this is helpful in instances where the fields need to be voided. currently, the removed fields are not part of the context.

Screenshots

Related Issue

Other

@samuelmale
Copy link
Member

Thanks for working on this @CynthiaKamau! I think the remaining part is updating the encounter processor to void any deleted openmrs objects (I think merging the formFields with the deletedFields is the simplest approach):

export function prepareEncounter(
  context: FormContextProps,
  encounterDate: Date,
  encounterRole: string,
  encounterProvider: string,
  location: string,
) {
  const { patient, formJson, domainObjectValue: encounter, formFields, deletedFields, visit } = context;
  const allFormFields = [...formFields, ...deletedFields];
  const obsForSubmission = [];
  prepareObs(obsForSubmission, allFormFields);

Alternatively, you can explicitly handle the deleted fields for every datatype ie. obs, orders, diagnosis etc.

@CynthiaKamau
Copy link
Contributor Author

Thanks for working on this @CynthiaKamau! I think the remaining part is updating the encounter processor to void any deleted openmrs objects (I think merging the formFields with the deletedFields is the simplest approach):

export function prepareEncounter(
  context: FormContextProps,
  encounterDate: Date,
  encounterRole: string,
  encounterProvider: string,
  location: string,
) {
  const { patient, formJson, domainObjectValue: encounter, formFields, deletedFields, visit } = context;
  const allFormFields = [...formFields, ...deletedFields];
  const obsForSubmission = [];
  prepareObs(obsForSubmission, allFormFields);

Alternatively, you can explicitly handle the deleted fields for every datatype ie. obs, orders, diagnosis etc.

I think handling deleted fields for every field is easier, since most transformers are already handling that

@CynthiaKamau CynthiaKamau marked this pull request as ready for review January 8, 2025 08:48
Copy link

github-actions bot commented Jan 8, 2025

Size Change: +120 B (+0.01%)

Total Size: 1.27 MB

ℹ️ View Unchanged
Filename Size Change
dist/151.js 382 kB 0 B
dist/219.js 264 kB +103 B (+0.04%)
dist/225.js 2.58 kB 0 B
dist/260.js 114 kB 0 B
dist/277.js 11.9 kB 0 B
dist/300.js 645 B 0 B
dist/335.js 968 B 0 B
dist/353.js 3.02 kB 0 B
dist/41.js 3.37 kB 0 B
dist/422.js 3.05 kB 0 B
dist/499.js 2.51 kB 0 B
dist/540.js 2.63 kB 0 B
dist/55.js 758 B 0 B
dist/606.js 2.24 kB 0 B
dist/635.js 14.4 kB 0 B
dist/658.js 1.85 kB 0 B
dist/727.js 87.2 kB 0 B
dist/979.js 6.87 kB 0 B
dist/99.js 691 B 0 B
dist/993.js 3.09 kB 0 B
dist/main.js 357 kB +17 B (0%)
dist/openmrs-esm-form-engine-lib.js 3.8 kB 0 B

compressed-size-action

@samuelmale
Copy link
Member

samuelmale commented Jan 8, 2025

I think handling deleted fields for every field is easier, since most transformers are already handling that

@CynthiaKamau will that associate the voided OMRS object say, an obs with the encounter so that it gets posted to the backend on submission?

@CynthiaKamau
Copy link
Contributor Author

CynthiaKamau commented Jan 8, 2025

I think handling deleted fields for every field is easier, since most transformers are already handling that

@CynthiaKamau will that associate the voided OMRS object say, an obs with the encounter so that it gets posted to the backend on submission?

Actually no, i will append the deleted fields to the rest of the fields and handle the voided while preparing the fields that need to use anything that may be deleted, for now its only diagnosis

Copy link
Member

@samuelmale samuelmale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@CynthiaKamau CynthiaKamau merged commit ee44873 into main Jan 8, 2025
6 checks passed
@CynthiaKamau CynthiaKamau deleted the track-repeat branch January 8, 2025 19:11
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.

2 participants