Skip to content

Commit

Permalink
ET-889: fix(elation): resolving document (#573)
Browse files Browse the repository at this point in the history
* fix(elation): resovlign document

* chore(): docs

* chore(): pr review
  • Loading branch information
nckhell authored Feb 3, 2025
1 parent 66c6233 commit 93c4cd2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,20 @@ export const fields = {
),
},
},
resolvingDocument: {
id: 'resolvingDocument',
label: 'Resolving document',
type: FieldType.NUMERIC,
required: true,
description:
'The ID of the document that resolves the referral order. Can be f.e. a reference to a non-visit note. Required if the resolution state is "fulfilled".',
},
} satisfies Record<string, Field>

export const FieldsValidationSchema = z.object({
referralOrderId: NumericIdSchema,
resolutionState: ResolutionStateSchema,
// Making it optional as making it required would break the extension for existing workflows
// I'll make it required once we've updated the Suvida flows
resolvingDocument: NumericIdSchema.optional(),
} satisfies Record<keyof typeof fields, ZodTypeAny>)
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ describe('Elation - Update referral order resolution', () => {
fields: {
referralOrderId: 142685415604249,
resolutionState: 'fulfilled',
resolvingDocument: 1234567890,
},
settings: {
client_id: 'clientId',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export const updateReferralOrderResolution: Action<
previewable: false,
dataPoints,
onEvent: async ({ payload, onComplete, onError }): Promise<void> => {
const { referralOrderId, resolutionState } = FieldsValidationSchema.parse(
payload.fields,
)
const { referralOrderId, resolutionState, resolvingDocument } =
FieldsValidationSchema.parse(payload.fields)
const api = makeAPIClient(payload.settings)

try {
await api.updateReferralOrder(referralOrderId, {
resolution: {
state: resolutionState,
resolving_document: resolvingDocument,
},
})
} catch (error) {
Expand Down

0 comments on commit 93c4cd2

Please sign in to comment.