-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'DHIS2-17192' into DHIS2-18018
- Loading branch information
Showing
9 changed files
with
102 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...s/capture-core/components/DataEntries/EnrollmentRegistrationEntry/hooks/getRedirectIds.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// @flow | ||
import { ProgramStage } from '../../../../metaData'; | ||
import { relatedStageActions } from '../../../WidgetRelatedStages'; | ||
|
||
/** | ||
* An event can be | ||
* - created during first stage registration | ||
* - created and linked during first stage registration | ||
* - autogenerated | ||
* When the event will be created redirect to enrollmentEventEdit | ||
* When the event will not be created redirect to enrollmentEventNew | ||
*/ | ||
export const getRedirectIds = ({ | ||
stages, | ||
relatedStageLinkedEvent, | ||
linkMode, | ||
firstStageDuringRegistrationEvent, | ||
autoGenerateEvents, | ||
}: { | ||
stages: Map<string, ProgramStage>, | ||
linkMode: ?string, | ||
relatedStageLinkedEvent: ?{ | ||
programStage: string, | ||
event: string, | ||
}, | ||
firstStageDuringRegistrationEvent: ?{ | ||
programStage: string, | ||
event: string, | ||
}, | ||
autoGenerateEvents: Array<{ | ||
programStage: string, | ||
event: string, | ||
orgUnit: string, | ||
}>, | ||
}): { programStageId?: string, eventId?: string } => { | ||
if (relatedStageLinkedEvent && linkMode === relatedStageActions.ENTER_DATA) { | ||
return { eventId: relatedStageLinkedEvent.event }; | ||
} | ||
|
||
const [firstStageWithOpenAfterEnrollment] = [...stages.values()].filter( | ||
({ openAfterEnrollment }) => openAfterEnrollment, | ||
); | ||
|
||
if (firstStageWithOpenAfterEnrollment) { | ||
// event will be created during first stage registration | ||
if ( | ||
firstStageDuringRegistrationEvent && | ||
firstStageDuringRegistrationEvent.programStage === firstStageWithOpenAfterEnrollment.id | ||
) { | ||
return { eventId: firstStageDuringRegistrationEvent.event }; | ||
} | ||
|
||
// event will be autogenerated | ||
const autoGenerateEvent = autoGenerateEvents.find(e => e.programStage === firstStageWithOpenAfterEnrollment.id); | ||
if (autoGenerateEvent) { | ||
return { eventId: autoGenerateEvent.event }; | ||
} | ||
|
||
return { programStageId: firstStageWithOpenAfterEnrollment.id }; | ||
} | ||
|
||
return {}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 0 additions & 74 deletions
74
...es/capture-core/components/Pages/New/RegistrationDataEntry/helpers/getPageToRedirectTo.js
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
src/core_modules/capture-core/components/Pages/New/RegistrationDataEntry/helpers/index.js
This file was deleted.
Oops, something went wrong.