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: [DHIS2-9661][DHIS2-14830] first stage registration #3267

Merged
merged 58 commits into from
Oct 3, 2023

Conversation

simonadomnisoru
Copy link
Contributor

@simonadomnisoru simonadomnisoru commented May 25, 2023

DHIS2-9661. The PR builds on work done previously in #3217.

Tech summary
Currently, the D2Form is rendered between the TOP and BOTTOM dataEntrySections definitions. I introduced the concept of placements.BEFORE_METADATA_BASED_SECTION to be able to render the stage dataEntrySections definitions in between the concatenated enrollment metadata and the stage metadata. The getCustomContent callback implements the logic to render the placements.BEFORE_METADATA_BASED_SECTION dataEntrySections based on beforeSectionId value.

  • useBuildFirstStageRegistration retrieve the firstStageMetaData from IndexDB and computes the firstStage with access
  • useMergeFormFoundationsIfApplicable when the useFirstStageDuringRegistration flag is active, the hook will create a new RenderFoundation which concatenates the enrollment and first program stage metadata. The concatenated formFoundation will be used by the EnrollmentWithFirstStageDataEntry and the program rules execution.
  • useDataEntrySections defines the dataEntrySections of the EnrollmentWithFirstStageDataEntry form with the help of the new placements.BEFORE_METADATA_BASED_SECTION concept.
  • EnrollmentWithFirstStageDataEntry.component.js is a DataEntry wrapper to build the form for the first program stage event.
  • deriveFirstStageDuringRegistrationEvent prepares the event data in the format expected by the API.
  • getStageWithOpenAfterEnrollment checks if the user should be redirected to /enrollmentEventNew or /enrollmentEventEdit after creating the TEI. The place where it is redirected depends if the event will be created or not. The event can be created either during first-stage registration or autogenerated.
  • In RegistrationDataEntry.epics.js, the eventIndex is calculated and will be used when the user is redirected to /enrollmentEventEdit.
  • Adapted the convertGeometryOut to be able to convert not only the foundation.featureType but also any customFeatureType like the stageGeometry
  • Adapted the getApplicableRuleEffectsForTrackerProgram to accept a custom formFoundation and use it as the base for foundationForPostProcessing
  • convertAndGroupBySection in RenderFoundation
    • loop the form values
    • grab the associated data element
    • convert the value
    • group it by the section group
  • initMode - a new URL param used when navigating to the /enrollmentEventEdit page. When initMode is set up, this overrides any page logic on the initial load.

@simonadomnisoru simonadomnisoru marked this pull request as ready for review June 2, 2023 12:41
@simonadomnisoru simonadomnisoru requested a review from a team as a code owner June 2, 2023 12:41
@eirikhaugstulen
Copy link
Contributor

Hey @simonadomnisoru,
I've run into this issue where the required elements in the first stage is not treated the same ways of TEAs. The form treats them as valid after touch. See video below.

Skjermopptak.2023-06-20.kl.16.11.06.mov

@simonadomnisoru
Copy link
Contributor Author

We should show the AOC selection if there are any program stages with «auto-generate event» or «show first stage on registration page» is selected for the program. We should use the same logic for the new and old dashboard.

This means that we should generate events for program stages with «auto-generate event» and «open data entry form after enrollment», even if we are using the new dashboard. The effect of «open data entry form after enrollment» will be that we navigate to the edit event page (not the new event page). We will have to add another url param to make this work I think (initMode=edit, this overrides any page logic on the initial load).

We should follow the logic described here for auto-generating the event: https://docs.google.com/document/d/1E5dBP5_BZZ0pLt573Xd0GQB6kve2WUpNdoew3kCFnUo/edit#bookmark=id.12acp8ay7jwz

Hey @JoakimSM, code updated. Can you take a look? Thanks!

Copy link
Member

@JoakimSM JoakimSM left a comment

Choose a reason for hiding this comment

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

🎉 Nice, good work @simonadomnisoru.

@github-actions
Copy link

github-actions bot commented Sep 28, 2023

Copy link

@geethaalwan geethaalwan left a comment

Choose a reason for hiding this comment

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

Tested successfully on 2.41,2.40.2,2.39.3,2.38.5 versions

@simonadomnisoru simonadomnisoru merged commit 6e5f6fe into master Oct 3, 2023
35 of 37 checks passed
@simonadomnisoru simonadomnisoru deleted the DHIS2-9661 branch October 3, 2023 06:49
dhis2-bot added a commit that referenced this pull request Oct 3, 2023
# [100.41.0](v100.40.1...v100.41.0) (2023-10-03)

### Features

* [DHIS2-9661][DHIS2-14830] first stage on registration page  ([#3267](#3267)) ([6e5f6fe](6e5f6fe))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 100.41.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

superskip pushed a commit that referenced this pull request Oct 27, 2023
Co-authored-by: jasminenguyennn <jasmine@dhis2.org>
Co-authored-by: Joakim Storløkken Melseth <joakim.melseth@gmail.com>
superskip pushed a commit that referenced this pull request Oct 27, 2023
# [100.41.0](v100.40.1...v100.41.0) (2023-10-03)

### Features

* [DHIS2-9661][DHIS2-14830] first stage on registration page  ([#3267](#3267)) ([6e5f6fe](6e5f6fe))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants