From 316abb291361bcd5b5cdb0eb40066bfbd4ba9e8c Mon Sep 17 00:00:00 2001 From: Stephen Hand Date: Tue, 17 Dec 2024 15:59:26 +0000 Subject: [PATCH] Add callType to prepopulate --- functions/hrm/prepopulateForm.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/functions/hrm/prepopulateForm.ts b/functions/hrm/prepopulateForm.ts index 8caff32a..3ffbfb0b 100644 --- a/functions/hrm/prepopulateForm.ts +++ b/functions/hrm/prepopulateForm.ts @@ -80,9 +80,14 @@ type ChannelTypes = | 'line' | 'modica'; +const callTypes = { + child: 'Child calling about self', + caller: 'Someone calling about a child', +}; + type HrmContactRawJson = { definitionVersion?: string; - callType: string; + callType: typeof callTypes[keyof typeof callTypes]; childInformation: Record; callerInformation: Record; caseInformation: Record; @@ -410,6 +415,10 @@ export const prepopulateForm = async ( const isValidSurvey = Boolean(answers?.aboutSelf); // determines if the memory has valid values or if it was aborted const isAboutSelf = answers.aboutSelf === 'Yes'; + if (isValidSurvey) { + // eslint-disable-next-line no-param-reassign + contact.rawJson.callType = isAboutSelf ? callTypes.child : callTypes.caller; + } if (preEngagementData) { await populateContactSection( contact.rawJson.caseInformation,