Skip to content

Commit

Permalink
fix: [DHIS2-15686] fix program rule variables for edit profile mode (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
superskip authored Nov 30, 2023
1 parent fcde52c commit a24bb27
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// @flow
import type { ProgramRulesContainer } from '@dhis2/rules-engine-javascript';
import { getTrackedEntityAttributeId, getProgramId, getProgramRuleActions, getProgramStageId } from '../helpers';
import { getTrackedEntityAttributeId, getDataElementId, getProgramId, getProgramRuleActions, getProgramStageId } from '../helpers';
import { getRulesAndVariablesFromProgramIndicators } from '../../../../metaDataMemoryStoreBuilders/programs/getRulesAndVariablesFromIndicators';

const addProgramVariables = (program, programRuleVariables) => {
program.programRuleVariables = programRuleVariables.map(programRulesVariable => ({
...programRulesVariable,
programId: getProgramId(programRulesVariable),
dataElementId: getDataElementId(programRulesVariable),
trackedEntityAttributeId: getTrackedEntityAttributeId(programRulesVariable),
}));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const getClientFormattedDataValuesAsObject = (dataValues, elementsById) =>
dataValues.reduce((acc, { dataElement: id, value }) => {
const dataElement = elementsById[id];
if (dataElement) {
acc[id] = convertValue(value, elementsById[id].type);
acc[id] = convertValue(value, dataElement.valueType);
}
return acc;
}, {});
Expand Down Expand Up @@ -39,8 +39,8 @@ export const useEvents = (enrollment: any, elementsById: Array<any>) => {
enrollmentId: event.enrollment,
enrollmentStatus: event.enrollmentStatus,
status: event.status,
eventDate: convertDate(event.eventDate),
dueDate: convertDate(event.dueDate),
occurredAt: convertDate(event.occurredAt),
scheduledAt: convertDate(event.scheduledAt),
...getClientFormattedDataValuesAsObject(event.dataValues, elementsById),
})),
[elementsById, enrollment, orgUnitNames],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const useLifecycle = ({
const state = useSelector(stateArg => stateArg);
const enrollment = useSelector(({ enrollmentDomain }) => enrollmentDomain?.enrollment);
const dataElements: DataElements = useDataElements(programAPI);
const otherEvents = useEvents(enrollment, programAPI);
const otherEvents = useEvents(enrollment, dataElements);
const orgUnit: ?OrgUnit = useOrganisationUnit(orgUnitId).orgUnit;
const rulesContainer: ProgramRulesContainer = useRulesContainer(programAPI);
const formFoundation: RenderFoundation = useFormFoundation(programAPI);
Expand Down

0 comments on commit a24bb27

Please sign in to comment.