Skip to content

Commit

Permalink
fix: [DHIS2-15967] allow enrolling TEIs with mandatory TET attributes (
Browse files Browse the repository at this point in the history
  • Loading branch information
superskip authored Nov 16, 2023
1 parent 29e9c70 commit cc87a8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ import type { ExistingUniqueValueDialogActionsComponent } from '../withErrorMess
import type { InputAttribute } from './hooks/useFormValues';
import { RenderFoundation, ProgramStage } from '../../../metaData';

type TrackedEntityAttributes = Array<{
attribute: string,
value: any,
}>;

export type EnrollmentPayload = {|
trackedEntity: string,
trackedEntityType: string,
orgUnit: string,
geometry: any,
attributes: TrackedEntityAttributes,
enrollments: [
{|
occurredAt: string,
Expand All @@ -23,10 +29,7 @@ export type EnrollmentPayload = {|
events: Array<{
orgUnit: string,
}>,
attributes: Array<{
attribute: string,
value: any,
}>,
attributes: TrackedEntityAttributes,
|}
]
|}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,15 @@ export const useBuildEnrollmentPayload = ({
? [firstStageDuringRegistrationEvent, ...autoGenerateEvents]
: autoGenerateEvents;

const attributes = deriveAttributesFromFormValues(formServerValues);

const enrollment = {
program: programId,
status: 'ACTIVE',
orgUnit: orgUnitId,
occurredAt,
enrolledAt,
attributes: deriveAttributesFromFormValues(formServerValues),
attributes,
events: allEventsToBeCreated,
};

Expand All @@ -177,6 +179,7 @@ export const useBuildEnrollmentPayload = ({
trackedEntity: teiId || generateUID(),
orgUnit: orgUnitId,
trackedEntityType: trackedEntityTypeId,
attributes,
geometry,
enrollments: [enrollment],
};
Expand Down

0 comments on commit cc87a8a

Please sign in to comment.