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-12615][DHIS2-12616][DHIS2-15906] Add new Relationship (Feature-parity) #3401

Merged
merged 133 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 127 commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
ac4b6fe
feat: [DHIS2-12362] add widget relationship component
jasminenguyennn Jan 21, 2022
7d9f3de
feat: first draft to New TEI relationship
eirikhaugstulen Jan 21, 2022
07b42fa
feat: [DHIS2-12362] add relationship widget
jasminenguyennn Jan 25, 2022
c85b9d0
feat: [DHIS2-12362] compute tei data
jasminenguyennn Jan 26, 2022
11a2bf7
feat: [DHIS2-12362] add relationship in redux
jasminenguyennn Jan 27, 2022
9362c1a
feat: [DHIS2-12362] minor change
jasminenguyennn Jan 27, 2022
f15bf33
Merge remote-tracking branch 'origin/master' into eh/feat/new-tei-rel…
eirikhaugstulen Jan 30, 2022
addbe06
feat: first draft to new TEI relationshiphandler
eirikhaugstulen Jan 31, 2022
98445b7
fix: add constraint to state
eirikhaugstulen Feb 3, 2022
e944f77
Merge branch 'master' into DHIS2-12362
jasminenguyennn Feb 4, 2022
748fecc
fix: [DHIS2-12362] minor update
jasminenguyennn Feb 4, 2022
56c568b
fix: [DHIS2-12362] minor update
jasminenguyennn Feb 4, 2022
6b6d0dd
fix: [DHIS2-12362] add event relationshio
jasminenguyennn Feb 4, 2022
2fb5620
fix: [DHIS2-12362] update tet
jasminenguyennn Feb 7, 2022
279f639
chore: [DHIS2-12362] cleanup fromconstraint
jasminenguyennn Feb 8, 2022
d8a1e89
fix: [DHIS2-12362] fix flow
jasminenguyennn Feb 8, 2022
6ff4edb
fix: [DHIS2-12362] fix flow
jasminenguyennn Feb 8, 2022
fd5c535
fix: [DHIS2-12362] fix flow
jasminenguyennn Feb 8, 2022
5faa3e1
fix: [DHIS2-12362] fix flow
jasminenguyennn Feb 8, 2022
65b9ecc
fix: [DHIS2-12362] minor fix
jasminenguyennn Feb 8, 2022
a9492bd
fix: [DHIS2-12362] minor fix
jasminenguyennn Feb 8, 2022
6650036
fix: [DHIS2-12362] minor fix
jasminenguyennn Feb 8, 2022
8f3a652
Merge branch 'master' into DHIS2-12362
jasminenguyennn Feb 14, 2022
02a2802
chore: [DHIS2-12362] update relationships
jasminenguyennn Feb 14, 2022
e9b4a70
chore: [DHIS2-12362] update relationships
jasminenguyennn Feb 14, 2022
eb7239d
fix: [DHIS2-12362] fix flow
jasminenguyennn Feb 14, 2022
ffb7b2f
feat: [DHIS2-12362] add relationship to view enrollment event
jasminenguyennn Feb 15, 2022
4abf6ef
Merge remote-tracking branch 'origin/master' into eh/feat/new-tei-rel…
eirikhaugstulen Feb 17, 2022
d0b115d
fix: changed object for displaying relationships & breadcrumbs
eirikhaugstulen Feb 18, 2022
d88383a
feat: initial layout for linking relationship to existing TEI
eirikhaugstulen Feb 25, 2022
f9dd6e1
fix: close modal on link complete
eirikhaugstulen Feb 25, 2022
7d8b4b7
fix: LGTM
eirikhaugstulen Feb 25, 2022
7c76be0
Merge branch 'master' into DHIS2-12362
jasminenguyennn Mar 2, 2022
88cf85a
Merge branch 'master' into DHIS2-12362
jasminenguyennn Mar 9, 2022
09fa106
Merge branch 'master' into DHIS2-12362
jasminenguyennn Mar 14, 2022
5c66bcd
Merge branch 'master' into DHIS2-12362
jasminenguyennn Mar 20, 2022
363d214
chore: [DHIS2-12362] refactor
jasminenguyennn Mar 23, 2022
6ebc99d
chore: [DHIS2-12362] rename funcs
jasminenguyennn Mar 24, 2022
bdb5562
chore: [DHIS2-12362] use new API
jasminenguyennn Mar 24, 2022
7dd0f93
chore: [DHI2-12362] change type
jasminenguyennn Mar 24, 2022
038ce39
chore: [DHI2-12362] change type
jasminenguyennn Mar 24, 2022
0e43a26
chore: [DHIS2-12362] fix edit event
jasminenguyennn Mar 25, 2022
3b2f70a
Merge branch 'master' into DHIS2-12362
jasminenguyennn Mar 25, 2022
42e6032
Merge branch 'master' into DHIS2-12362
jasminenguyennn Apr 6, 2022
72b7df5
chore: [DHIS2-12362] minor change
jasminenguyennn Apr 6, 2022
7f97c0f
fix: [DHIS2-12362] fix combinations
jasminenguyennn Apr 8, 2022
a788cd1
Merge branch 'master' into DHIS2-12362
jasminenguyennn Apr 21, 2022
f309105
chore: [DHIS2-12362] restructure the components
jasminenguyennn Apr 30, 2022
5183509
Merge branch 'master' into DHIS2-12362
jasminenguyennn May 1, 2022
9682ffe
chore: [DHIS2-12362] change await/async loop
jasminenguyennn May 2, 2022
4e55df3
feat: [DHIS2-12377] Event relationship (#2726)
jasminenguyennn May 2, 2022
ab89592
chore: [DHIS2-12362] address review comments
jasminenguyennn May 4, 2022
dbfe1fb
chore: [DHIS2-12362] rename files
jasminenguyennn May 4, 2022
5a7eec4
chore: [DHIS2-12362] minor change
jasminenguyennn May 5, 2022
e92c9b2
feat: [DHIS2-12362] add display fields
jasminenguyennn May 5, 2022
594ca2a
feat: [DHIS2-12362] add display fields
jasminenguyennn May 5, 2022
81672fc
feat: [DHIS2-12362] add display fields
jasminenguyennn May 5, 2022
015c4b3
chore: [DHIS2-12362] minor change
jasminenguyennn May 5, 2022
2d1af84
chore:[DHIS2-12362] update user storage
jasminenguyennn May 10, 2022
6f09736
chore: [DHIS2-12362] minor change
jasminenguyennn May 10, 2022
7efe0ef
chore: [DHIS2-12362] add creation date
jasminenguyennn May 19, 2022
4e21fc4
chore: [DHIS2-12362] update event
jasminenguyennn May 23, 2022
9ae1f0e
Merge branch 'master' into DHIS2-12362
jasminenguyennn May 23, 2022
ef24bc2
chore: [DHIS2-12362] move type def
jasminenguyennn May 23, 2022
3bce665
chore: [DHIS2-12362] move type def
jasminenguyennn May 23, 2022
59e1026
chore: [DHIS2-12362] minor fix
jasminenguyennn May 23, 2022
f3d5d2d
chore: [DHIS2-12362] return all types
jasminenguyennn May 24, 2022
587180c
Merge branch 'master' into DHIS2-12362
jasminenguyennn May 24, 2022
0607b79
chore: [DHIS2-12362] add created relationship date
jasminenguyennn Jun 4, 2022
c68a666
chore: [DHIS2-12362] use display name
jasminenguyennn Jun 9, 2022
a638306
Merge branch 'master' into DHIS2-12362
jasminenguyennn Jun 27, 2022
419ae84
fix: [DHIS2-13202] fix occurred at label in stages
jasminenguyennn Jul 15, 2022
9202d4d
Merge branch 'master' into DHIS2-12362
jasminenguyennn Jul 20, 2022
8c1fd1e
fix: [DHIS2-12362] cypress
jasminenguyennn Jul 20, 2022
6d2e029
Merge branch 'master' into DHIS2-12362
jasminenguyennn Jul 22, 2022
17836e2
Merge branch 'master' into DHIS2-12362
jasminenguyennn Jul 26, 2022
9886119
Merge branch 'master' into DHIS2-12362
jasminenguyennn Jul 28, 2022
5fd15f8
fix: [DHIS2-12362] convert date
jasminenguyennn Aug 2, 2022
c689e4d
chore: [DHIS2-12362] UI improvements
jasminenguyennn Aug 29, 2022
63bc722
chore: [DHIS2-12362] minor
jasminenguyennn Aug 29, 2022
83cbc52
fix: [DHIS2-12362] fix flow
jasminenguyennn Aug 29, 2022
8d099c0
Merge branch 'master' into DHIS2-12362
jasminenguyennn Aug 29, 2022
d184468
chore: [DHIS2-12362] sort most recent event
jasminenguyennn Aug 30, 2022
bd912e1
Merge branch 'master' into DHIS2-12362
jasminenguyennn Aug 30, 2022
320259c
feat: [DHIS2-12372] view linked record (#2780)
jasminenguyennn Aug 30, 2022
067e1a5
Merge branch 'master' into DHIS2-12362
jasminenguyennn Sep 2, 2022
b60af3f
Merge branch 'DHIS2-12362' of work:dhis2/capture-app into DHIS2-12362
jasminenguyennn Sep 2, 2022
ee5b02f
Merge branch 'master' into DHIS2-12362
jasminenguyennn Sep 12, 2022
2c91cc6
chore: useMetadataQuery utility method
JoakimSM Dec 8, 2022
a87bb76
chore: useIndexedDB utility method
JoakimSM Dec 8, 2022
0f8ece0
feat: changed a hook to implement the custom hooks
eirikhaugstulen Dec 13, 2022
7fa38a2
fix: added error handling to the useIndexedDBQuery
eirikhaugstulen Dec 21, 2022
25cec6e
feat: init relationships
JoakimSM Jun 16, 2022
a36e9f7
Merge remote-tracking branch 'origin/eh/TECH/TECH-1486_UtilityHookFor…
JoakimSM Jan 5, 2023
67b827a
feat: continue relationships
JoakimSM Jan 5, 2023
bc15dc4
Merge branch 'master' into DHIS2-12615
JoakimSM Apr 18, 2023
1e76f2f
fix: postmerge
JoakimSM Apr 18, 2023
7a5cf96
Merge remote-tracking branch 'origin/DHIS2-12362' into DHIS2-12615
eirikhaugstulen Apr 24, 2023
dc5b88d
chore: temp
eirikhaugstulen Apr 27, 2023
43a9c57
feat: first iteration of Relationships Widget
eirikhaugstulen May 2, 2023
7685ec3
fix: code cleanup
eirikhaugstulen May 3, 2023
c3331c8
chore: review comments
eirikhaugstulen May 23, 2023
518456a
chore: review comments
eirikhaugstulen May 26, 2023
4ad1bea
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12362…
eirikhaugstulen May 26, 2023
5c49e06
feat: [DHIS2-12362] display relationships
JoakimSM Jun 5, 2023
7ebdb59
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12615…
eirikhaugstulen Jul 21, 2023
c14d0eb
feat: add search functionality
eirikhaugstulen Jul 22, 2023
cb5aa6c
Merge remote-tracking branch 'origin/eh/epics/DHIS2-12361_TeiRelation…
eirikhaugstulen Jul 28, 2023
350d2ac
chore: flow
eirikhaugstulen Jul 28, 2023
438d2cd
feat: [DHIS2-12362][DHIS2-12455] View and filter relationships (#3241)
eirikhaugstulen Jul 28, 2023
4b88893
Merge remote-tracking branch 'origin/eh/epics/DHIS2-12361_TeiRelation…
eirikhaugstulen Jul 28, 2023
30c77c4
chore: flow
eirikhaugstulen Jul 28, 2023
14a2530
chore: temp
eirikhaugstulen Aug 4, 2023
72ac535
feat: create new tei from relationship
eirikhaugstulen Aug 14, 2023
261d312
fix: change program in search
eirikhaugstulen Aug 14, 2023
cb84cf4
chore: upgrade cacheVersion
eirikhaugstulen Aug 15, 2023
c7eafe7
fix: chore remove success snackbar
eirikhaugstulen Aug 24, 2023
abdf53c
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12616…
eirikhaugstulen Sep 11, 2023
f943323
fix: pr-review
eirikhaugstulen Sep 11, 2023
04e93ed
fix: pr-review
eirikhaugstulen Sep 12, 2023
ebe355d
Merge remote-tracking branch 'origin/master' into eh/epics/DHIS2-1236…
eirikhaugstulen Sep 12, 2023
bc933b6
Merge remote-tracking branch 'origin/eh/epics/DHIS2-12361_TeiRelation…
eirikhaugstulen Sep 12, 2023
07766e1
chore: typo
eirikhaugstulen Sep 12, 2023
d978ed8
chore: loading spinner
eirikhaugstulen Sep 12, 2023
f880324
chore: pr-reviews
eirikhaugstulen Sep 28, 2023
a93bef9
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12616…
eirikhaugstulen Oct 3, 2023
6016b85
feat: [DHIS2-15906] Add form features for relationship
eirikhaugstulen Oct 17, 2023
afb28dc
docs: [DHIS2-12361] Relationships widget (#3430)
eirikhaugstulen Oct 20, 2023
3ab905d
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12616…
eirikhaugstulen Oct 20, 2023
c9f297b
chore: bump cache version
eirikhaugstulen Oct 22, 2023
d677101
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12616…
eirikhaugstulen Oct 23, 2023
b0b54e5
Merge remote-tracking branch 'origin/master' into eh/feat/DHIS2-12616…
eirikhaugstulen Oct 24, 2023
7bb1032
chore: change tests
eirikhaugstulen Oct 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [100.41.2](https://github.com/dhis2/capture-app/compare/v100.41.1...v100.41.2) (2023-10-12)


### Bug Fixes

* [DHIS2-15827] remove effects of 'Prevent adding new events to stage' action from the form ([#3418](https://github.com/dhis2/capture-app/issues/3418)) ([f17d087](https://github.com/dhis2/capture-app/commit/f17d087f368cf4d6b26923fd5cf4fb15d7795ba2))

## [100.41.1](https://github.com/dhis2/capture-app/compare/v100.41.0...v100.41.1) (2023-10-09)


### Bug Fixes

* [DHIS2-15734] assign effect dynamic formId object key ([#3422](https://github.com/dhis2/capture-app/issues/3422)) ([85f242b](https://github.com/dhis2/capture-app/commit/85f242b2b0c6092b46e92f087e21e102a2e1e19d))

# [100.41.0](https://github.com/dhis2/capture-app/compare/v100.40.1...v100.41.0) (2023-10-03)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ Feature: Hidden program stage
Scenario: The user cannot add an event in a hidden program stage
Given you add an enrollment event that will result in a rule effect to hide a program stage
Then the New Postpartum care visit event button is disabled in the stages and events widget
And and an error is show in the Postpartum care visit stage
And the Postpartum care visit button is disabled in the enrollmentEventNew page
12 changes: 0 additions & 12 deletions cypress/integration/EnrollmentPage/HiddenProgramStage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,6 @@ Then('the New Postpartum care visit event button is disabled in the stages and e
.should('be.disabled');
});

Then('and an error is show in the Postpartum care visit stage', () => {
cy.visit(
'/#/enrollmentEventNew?enrollmentId=fmhIsWXVDmS&orgUnitId=s7SLtx8wmRA&programId=WSGAb5XwJ3Y&teiId=uW8Y7AIcRKA&stageId=bbKtnxRZKEP',
);
cy.contains('[data-test="dhis2-uicore-button"]', 'Complete')
.should('be.disabled');
cy.contains('[data-test="dhis2-uicore-button"]', 'Save without completing')
.should('be.disabled');
cy.contains('[data-test="dhis2-uicore-noticebox-content"]', 'You can\'t add any more Postpartum care visit events')
.should('exist');
});

Then('the Postpartum care visit button is disabled in the enrollmentEventNew page', () => {
cy.visit(
'/#/enrollmentEventNew?enrollmentId=fmhIsWXVDmS&orgUnitId=s7SLtx8wmRA&programId=WSGAb5XwJ3Y&teiId=uW8Y7AIcRKA',
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions docs/user/using-the-capture-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,12 @@ You can set multiple program stages within a program to be auto-generating (this
A program can be configured to automatically take the user to register a new event immediately after enrolling a tracked entity instance. To enable this behavior, the program must have at least one program stage with the "Open data entry form after registration" option checked. If more than one program stage has this option enabled, the first stage will be used.

To configure it, you must follow the steps described in the [Enrollment with auto generated events](#enrollment-with-auto-generated-events) section and then check the option "Open data entry form after enrollment".

![](resources/images/open-data-entry-form-after-enrollment.png)

### Enrollment with first stage on registration page

For tracker programs enable the "First stage appears on registration page" flag in the Maintenance. The enrollment registration page will now display the first program stage the user has access to.

![](resources/images/first-stage-during-registration.png)

#### Active type of event

Expand Down
61 changes: 50 additions & 11 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2023-09-29T14:14:34.330Z\n"
"PO-Revision-Date: 2023-09-29T14:14:34.330Z\n"
"POT-Creation-Date: 2023-09-12T06:24:49.265Z\n"
"PO-Revision-Date: 2023-09-12T06:24:49.265Z\n"

msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
Expand Down Expand Up @@ -947,6 +947,18 @@ msgstr "Event could not be loaded"
msgid "Organisation unit could not be loaded"
msgstr "Organisation unit could not be loaded"

msgid "Selected program"
msgstr "Selected program"

msgid "Search {{uniqueAttrName}}"
msgstr "Search {{uniqueAttrName}}"

msgid "Search by attributes"
msgstr "Search by attributes"

msgid "Could not retrieve metadata. Please try again later."
msgstr "Could not retrieve metadata. Please try again later."

msgid "Possible duplicates found"
msgstr "Possible duplicates found"

Expand Down Expand Up @@ -1010,9 +1022,6 @@ msgstr "Search {{name}}"
msgid "Search by {{name}}"
msgstr "Search by {{name}}"

msgid "Search by attributes"
msgstr "Search by attributes"

msgid "all programs"
msgstr "all programs"

Expand Down Expand Up @@ -1070,12 +1079,6 @@ msgstr "Missing search criteria"
msgid "Results found"
msgstr "Results found"

msgid "Selected program"
msgstr "Selected program"

msgid "Search {{uniqueAttrName}}"
msgstr "Search {{uniqueAttrName}}"

msgid "Saved lists in this program"
msgstr "Saved lists in this program"

Expand Down Expand Up @@ -1359,6 +1362,42 @@ msgstr "{{ scheduledEvents }} scheduled"
msgid "Stages and Events"
msgstr "Stages and Events"

msgid "New TEI Relationship"
msgstr "New TEI Relationship"

msgid "Missing implementation step"
msgstr "Missing implementation step"

msgid "Go back without saving relationship"
msgstr "Go back without saving relationship"

msgid "New Relationship"
msgstr "New Relationship"

msgid "Link to an existing {{tetName}}"
msgstr "Link to an existing {{tetName}}"

msgid "An error occurred while adding the relationship"
msgstr "An error occurred while adding the relationship"

msgid "Something went wrong while loading relationships. Please try again later."
msgstr "Something went wrong while loading relationships. Please try again later."

msgid "{{trackedEntityTypeName}} relationships"
msgstr "{{trackedEntityTypeName}} relationships"

msgid "To open this relationship, please wait until saving is complete"
msgstr "To open this relationship, please wait until saving is complete"

msgid "Type"
msgstr "Type"

msgid "Created date"
msgstr "Created date"

msgid "Program stage name"
msgstr "Program stage name"

msgid "Working list could not be loaded"
msgstr "Working list could not be loaded"

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "capture-app",
"homepage": ".",
"version": "100.41.0",
"version": "100.41.2",
"cacheVersion": "6",
"serverVersion": "38",
"license": "BSD-3-Clause",
Expand All @@ -10,7 +10,7 @@
"packages/rules-engine"
],
"dependencies": {
"@dhis2/rules-engine-javascript": "100.41.0",
"@dhis2/rules-engine-javascript": "100.41.2",
"@dhis2/app-runtime": "^3.9.3",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/d2-icons": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/rules-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dhis2/rules-engine-javascript",
"version": "100.41.0",
"version": "100.41.2",
"license": "BSD-3-Clause",
"main": "./build/cjs/index.js",
"scripts": {
Expand Down
26 changes: 15 additions & 11 deletions src/components/App/AppPages.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@ import { EnrollmentPage } from 'capture-core/components/Pages/Enrollment';
import { StageEventListPage } from 'capture-core/components/Pages/StageEvent';
import { EnrollmentEditEventPage } from 'capture-core/components/Pages/EnrollmentEditEvent';
import { EnrollmentAddEventPage } from 'capture-core/components/Pages/EnrollmentAddEvent';
import { ReactQueryDevtools } from 'react-query/devtools';

export const AppPages = () => (
<Switch>
<Route path="/viewEvent" component={ViewEventPage} />
<Route path="/search" component={SearchPage} />
<Route path="/new" component={NewPage} />
<Route path="/enrollment/stageEvents" component={StageEventListPage} />
<Route path="/enrollmentEventEdit" component={EnrollmentEditEventPage} />
<Route path="/enrollmentEventNew" component={EnrollmentAddEventPage} />
<Route path="/enrollment" component={EnrollmentPage} />
<Route path="/:keys" component={MainPage} />
<Route path="/" component={MainPage} />
</Switch>
<>
<ReactQueryDevtools />
<Switch>
<Route path="/viewEvent" component={ViewEventPage} />
<Route path="/search" component={SearchPage} />
<Route path="/new" component={NewPage} />
<Route path="/enrollment/stageEvents" component={StageEventListPage} />
<Route path="/enrollmentEventEdit" component={EnrollmentEditEventPage} />
<Route path="/enrollmentEventNew" component={EnrollmentAddEventPage} />
<Route path="/enrollment" component={EnrollmentPage} />
<Route path="/:keys" component={MainPage} />
<Route path="/" component={MainPage} />
</Switch>
</>
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,38 @@ import { useSelector } from 'react-redux';
import { EnrollmentRegistrationEntryComponent } from './EnrollmentRegistrationEntry.component';
import type { OwnProps } from './EnrollmentRegistrationEntry.types';
import { useLifecycle } from './hooks';
import { useCurrentOrgUnitInfo } from '../../../hooks/useCurrentOrgUnitInfo';
import { useRulesEngineOrgUnit } from '../../../hooks';
import { dataEntryHasChanges } from '../../DataEntry/common/dataEntryHasChanges';
import {
useBuildEnrollmentPayload,
} from './hooks/useBuildEnrollmentPayload';

export const EnrollmentRegistrationEntry: ComponentType<OwnProps> = ({
selectedScopeId,
id,
saveButtonText,
trackedEntityInstanceAttributes,
orgUnitId,
teiId,
onSave,
...passOnProps
}) => {
const orgUnitId = useCurrentOrgUnitInfo().id;
const { orgUnit, error } = useRulesEngineOrgUnit(orgUnitId);
const {
teiId,
ready,
skipDuplicateCheck,
firstStageMetaData,
formId,
enrollmentMetadata,
formFoundation,
} = useLifecycle(selectedScopeId, id, trackedEntityInstanceAttributes, orgUnit);
} = useLifecycle(selectedScopeId, id, trackedEntityInstanceAttributes, orgUnit, teiId, selectedScopeId);
const { buildTeiWithEnrollment } = useBuildEnrollmentPayload({
programId: selectedScopeId,
dataEntryId: id,
orgUnitId,
teiId,
trackedEntityTypeId: enrollmentMetadata?.trackedEntityType?.id,
});

const isUserInteractionInProgress: boolean = useSelector(
state =>
Expand All @@ -41,10 +50,16 @@ export const EnrollmentRegistrationEntry: ComponentType<OwnProps> = ({
const isSavingInProgress = useSelector(({ possibleDuplicates, newPage }) =>
possibleDuplicates.isLoading || possibleDuplicates.isUpdating || !!newPage.uid);


if (error) {
return error.errorComponent;
}

const onSaveWithEnrollment = () => {
const teiWithEnrollment = buildTeiWithEnrollment();
onSave(teiWithEnrollment);
};

return (
<EnrollmentRegistrationEntryComponent
{...passOnProps}
Expand All @@ -62,7 +77,7 @@ export const EnrollmentRegistrationEntry: ComponentType<OwnProps> = ({
orgUnit={orgUnit}
isUserInteractionInProgress={isUserInteractionInProgress}
isSavingInProgress={isSavingInProgress}
onSave={() => onSave(formFoundation, firstStageMetaData)}
onSave={onSaveWithEnrollment}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,32 @@ import type { ExistingUniqueValueDialogActionsComponent } from '../withErrorMess
import type { InputAttribute } from './hooks/useFormValues';
import { RenderFoundation, ProgramStage } from '../../../metaData';

export type EnrollmentPayload = {|
trackedEntity: string,
trackedEntityType: string,
orgUnit: string,
geometry: any,
enrollments: [
{|
occurredAt: string,
orgUnit: string,
program: string,
status: string,
enrolledAt: string,
events: Array<{
orgUnit: string,
}>,
attributes: Array<{
attribute: string,
value: any,
}>,
|}
]
|}

export type OwnProps = $ReadOnly<{|
id: string,
orgUnitId: string,
selectedScopeId: string,
fieldOptions?: Object,
onSave: SaveForDuplicateCheck,
Expand Down
Loading
Loading