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) O3-3239 Add support for program enrollments using meta tag #277

Merged
merged 2 commits into from
May 21, 2024

Conversation

CynthiaKamau
Copy link
Contributor

@CynthiaKamau CynthiaKamau commented May 17, 2024

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

  • This pr adds on to the program enrollments AFE : RFE parity by adding a function in the transformer to convert program meta tags to post submission handlers and creates/updates exisiting enrollments

Screenshots

Screen.Recording.2024-05-17.at.18.32.24.mov

Related Issue

https://openmrs.atlassian.net/browse/O3-3239

Other

Copy link

github-actions bot commented May 17, 2024

Size Change: -329 kB (-23.79%) 🎉

Total Size: 1.05 MB

Filename Size Change
dist/432.js 0 B -203 kB (removed) 🏆
dist/66.js 0 B -78.5 kB (removed) 🏆
dist/797.js 0 B -18.7 kB (removed) 🏆
dist/main.js 298 kB -10.8 kB (-3.51%)
ℹ️ View Unchanged
Filename Size Change
dist/125.js 0 B -5.64 kB (removed) 🏆
dist/184.js 11.2 kB 0 B
dist/225.js 2.56 kB 0 B
dist/29.js 157 kB -87 B (-0.06%)
dist/300.js 682 B 0 B
dist/31.js 4.9 kB 0 B
dist/318.js 2.42 kB 0 B
dist/327.js 1.83 kB +108 B (+6.28%) 🔍
dist/335.js 955 B 0 B
dist/353.js 3.02 kB 0 B
dist/368.js 240 kB -557 B (-0.23%)
dist/371.js 71.5 kB 0 B
dist/41.js 3.36 kB 0 B
dist/436.js 752 B 0 B
dist/505.js 0 B -6.94 kB (removed) 🏆
dist/540.js 2.64 kB +11 B (+0.42%)
dist/55.js 2.14 kB 0 B
dist/635.js 14.3 kB +40 B (+0.28%)
dist/760.js 0 B -5.25 kB (removed) 🏆
dist/779.js 203 kB 0 B
dist/8.js 3.67 kB 0 B
dist/942.js 482 B 0 B
dist/979.js 6.85 kB 0 B
dist/99.js 690 B 0 B
dist/993.js 3.08 kB 0 B
dist/998.js 15.5 kB 0 B
dist/openmrs-form-engine-lib.js 3.76 kB -60 B (-1.57%)

compressed-size-action

Copy link
Contributor

@arodidev arodidev left a comment

Choose a reason for hiding this comment

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

Thanks @CynthiaKamau, left a review comment.

@@ -191,7 +191,11 @@ const FormEngine: React.FC<FormProps> = ({
if (result?.data) {
encounterData.push(result.data);
}
if (result?.uuid) {
encounterData.push(result);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to combine the two if statements and then access data from the results object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could try something like this :

if (result?.data || result?.uuid) {
  encounterData.push(result.data ?? result);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the likelihood that both of these resolve to true? And in that instance, won't it prefer results.data over results? I am trying to figure out the use cases for both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The result cannot be in two formats, it will either return with the data object or not

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood.

@CynthiaKamau CynthiaKamau changed the title (feat) Add support for program enrollments using meta tag : RFE AFE p… O3-3239 Add support for program enrollments using meta tag May 20, 2024
if (form.meta.programs.isEnrollment) {
config['enrollmentDate'] = '';
} else {
config['completionDate'] = form.meta.programs.discontinuationDateQuestionId;
Copy link
Member

Choose a reason for hiding this comment

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

  1. Does AFE support discontinuation from a program? If so, is it driven by programs.discontinuationDateQuestionId
  2. What happens is there is no discontinuation date question defined in the form? Do we fallback to new Date()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the programs.discontinuationDateQuestionId is what is used for discontinuation, its a mandatory field.

Copy link
Member

Choose a reason for hiding this comment

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

Does AFE support discontinuation from a program? If so, is it driven by programs.discontinuationDateQuestionId

Copy link
Member

Choose a reason for hiding this comment

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

@CynthiaKamau did you see the above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Defaulting to new date if the discontinuation date is null?

Copy link
Member

Choose a reason for hiding this comment

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

Does the AFE support discontinuation of a program?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, the meta tag is added in discontinuation forms

Copy link
Member

Choose a reason for hiding this comment

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

How is that configured in AFE, can you link me to a documentation or an example? I'm looking for an example where we discontinue a program the AFE way

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sample schema is here

AFE code lives here

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @CynthiaKamau, clear enough!

Comment on lines 12 to 14
if(form?.meta?.programs) {
handleProgramMetaTags(form);
}
Copy link
Member

Choose a reason for hiding this comment

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

  • Fix formatting issues here.
  • Can the form object be null/undefined?

Copy link
Contributor Author

@CynthiaKamau CynthiaKamau May 20, 2024

Choose a reason for hiding this comment

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

The meta object of the form object will be undefined except for people migrating from afe to rfe

Copy link
Member

Choose a reason for hiding this comment

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

Yes for the meta object it may be undefined but not the form object so:

form.meta?.programs

Can you also fix the formatting issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@arodidev arodidev left a comment

Choose a reason for hiding this comment

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

Thanks @CynthiaKamau LGTM

@pirupius pirupius changed the title O3-3239 Add support for program enrollments using meta tag (feat) O3-3239 Add support for program enrollments using meta tag May 21, 2024
@samuelmale samuelmale merged commit 18844bd into main May 21, 2024
4 checks passed
@samuelmale samuelmale deleted the programs-meta-tag branch May 21, 2024 11:45
vasharma05 pushed a commit that referenced this pull request May 27, 2024
* (feat) Add support for program enrollments using meta tag : RFE AFE parity

* code review
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.

3 participants