Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM: Integration form engine 2 #2273

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
01edd06
VATEAM-87714: Add KISS configuration for Digital Forms (#2213)
derekhouck Aug 6, 2024
fd22547
VATEAM-88634: Create a normalization layer for Digital Forms (#2215)
derekhouck Aug 10, 2024
49ce1af
Add OMB info to Digital Form GraphQL query
derekhouck Aug 29, 2024
0cec642
Normalize OMB info
derekhouck Aug 29, 2024
4d7dc20
Remove Date object from formatDate
derekhouck Sep 6, 2024
52edb57
VATEAM-90733: Normalize OMB info fields (#2252)
derekhouck Sep 12, 2024
b64c733
Add Identification Information fragment
derekhouck Sep 16, 2024
62fdaab
Import identificationInformation fragment into digitalForm fragment
derekhouck Sep 16, 2024
ee1a69f
Extract Identification Information fields
derekhouck Sep 16, 2024
9a6014e
Fix imports
derekhouck Sep 16, 2024
66f5048
VATEAM-87714: Add KISS configuration for Digital Forms (#2213)
derekhouck Aug 6, 2024
e3d84e6
VATEAM-88634: Create a normalization layer for Digital Forms (#2215)
derekhouck Aug 10, 2024
a314931
Merge branch 'main' into integration-form-engine-2
derekhouck Oct 2, 2024
3633329
Merge branch '90733-normalize-omb-info-section' into integration-form…
derekhouck Oct 2, 2024
628f6cb
Merge branch '91741-normalize-identification-information' into integr…
derekhouck Oct 2, 2024
0166a12
VATEAM-92265: Normalize Address Digital Form pattern output (#2301)
derekhouck Oct 4, 2024
02d5d12
VATEAM-94290: Remove "Digital Form:" from content-build output (#2304)
derekhouck Oct 9, 2024
1d80dde
Merge branch 'main' into integration-form-engine-2
derekhouck Oct 16, 2024
a0310be
VATEAM-93401: Normalize Phone and Email Digital Form pattern output (…
derekhouck Oct 16, 2024
00433c4
VATEAM-94709: Normalize Your Personal Information chapter (#2338)
derekhouck Nov 4, 2024
56aee27
VATEAM-93614: Normalize List and Loop pattern output (#2350)
derekhouck Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
*
* The "Address" Digital Form pattern.
*
* Pattern documentation:
* https://design.va.gov/patterns/ask-users-for/addresses
*
*/
module.exports = `
fragment address on ParagraphDigitalFormAddress {
fieldTitle
fieldMilitaryAddressCheckbox
}
`;
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
const nameAndDateOfBirth = require('./nameAndDateOfBirth.graphql');
const address = require('./address.graphql');
const phoneAndEmail = require('./phoneAndEmail.graphql');
const yourPersonalInformation = require('./yourPersonalInformation.graphql');
const listLoop = require('./listLoop.graphql');

/*
*
* The "Digital Form" Content Type in the VA.gov CMS
*
*/
module.exports = `
${nameAndDateOfBirth}
${address}
${listLoop}
${phoneAndEmail}
${yourPersonalInformation}

fragment digitalForm on NodeDigitalForm {
nid
entityLabel
fieldVaFormNumber
fieldOmbNumber
fieldRespondentBurden
fieldExpirationDate {
value
}
fieldChapters {
entity {
entityId
Expand All @@ -22,7 +32,10 @@ module.exports = `
entityLabel
}
}
...nameAndDateOfBirth
...address
...listLoop
...phoneAndEmail
...yourPersonalInformation
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
*
* The "Identification Information" Digital Form pattern.
*
* Pattern documentation:
* https://design.va.gov/patterns/ask-users-for/social-security-number
*
*/
module.exports = `
fragment identificationInformation on ParagraphDigitalFormIdentificationInfo {
fieldTitle
fieldIncludeVeteranSService
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
*
* The "List & Loop" Digital Form pattern.
*
* Pattern documentation:
* https://design.va.gov/patterns/ask-users-for/multiple-responses
*
*/
module.exports = `
fragment listLoop on ParagraphDigitalFormListLoop {
fieldTitle
fieldOptional
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
*
* The "Phone and Email Address" Digital Form pattern.
*
* Pattern documentation:
* https://design.va.gov/patterns/ask-users-for/phone-numbers
*
*/
module.exports = `
fragment phoneAndEmail on ParagraphDigitalFormPhoneAndEmail {
fieldTitle
fieldIncludeEmail
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const identificationInformation = require('./identificationInformation.graphql');
const nameAndDateOfBirth = require('./nameAndDateOfBirth.graphql');

/*
*
* The "Your personal information" Digital Form pattern.
*
* Pattern documentation:
* https://github.com/department-of-veterans-affairs/vets-website/blob/0ae48c0b017a37d84f6ae425c67c332f4c67fb8b/src/applications/simple-forms/mock-simple-forms-patterns-v3/config/form.js#L40
*
*/
module.exports = `
${identificationInformation}
${nameAndDateOfBirth}

fragment yourPersonalInformation on ParagraphDigitalFormYourPersonalInfo {
fieldNameAndDateOfBirth {
entity {
...nameAndDateOfBirth
}
}
fieldIdentificationInformation {
entity {
...identificationInformation
}
}
}
`;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,69 @@
const { logDrupal } = require('../../utilities-drupal');

const extractAdditionalFields = entity => {
const additionalFields = {};
const { entityId } = entity.type.entity;

if (entity.type.entity.entityId === 'digital_form_name_and_date_of_bi') {
additionalFields.includeDateOfBirth = entity.fieldIncludeDateOfBirth;
switch (entityId) {
case 'digital_form_address':
return {
militaryAddressCheckbox: entity.fieldMilitaryAddressCheckbox,
};
case 'digital_form_list_loop':
return {
optional: entity.fieldOptional,
};
case 'digital_form_phone_and_email':
return {
includeEmail: entity.fieldIncludeEmail,
};
default:
return {};
}

return additionalFields;
};
const extractForms = resultObject => resultObject?.data?.nodeQuery?.entities;

const formatDate = dateString => {
const removeLeadingZero = s => s.replace(/^0+/, '');
const [year, month, day] = dateString.split('-');
return `${removeLeadingZero(month)}/${removeLeadingZero(day)}/${year}`;
};

const stripPrefix = label => label.replace('Digital Form: ', '');

const normalizeChapter = ({ entity }) => {
return {
const type = entity.type.entity.entityId;
const initialChapter = {
id: parseInt(entity.entityId, 10),
chapterTitle: entity.fieldTitle,
type: entity.type.entity.entityId,
pageTitle: entity.type.entity.entityLabel,
type,
};

if (type === 'digital_form_your_personal_info') {
const identificationInformation =
entity.fieldIdentificationInformation.entity;
const nameAndDateOfBirth = entity.fieldNameAndDateOfBirth.entity;

return {
...initialChapter,
chapterTitle: stripPrefix(entity.type.entity.entityLabel),
pages: [
{
pageTitle: nameAndDateOfBirth.fieldTitle,
includeDateOfBirth: nameAndDateOfBirth.fieldIncludeDateOfBirth,
},
{
pageTitle: identificationInformation.fieldTitle,
includeServiceNumber:
identificationInformation.fieldIncludeVeteranSService,
},
],
};
}

return {
...initialChapter,
additionalFields: extractAdditionalFields(entity),
chapterTitle: entity.fieldTitle,
pageTitle: stripPrefix(entity.type.entity.entityLabel),
};
};

Expand All @@ -27,7 +73,11 @@ const normalizeForm = (form, logger = logDrupal) => {
cmsId: form.nid,
formId: form.fieldVaFormNumber,
title: form.entityLabel,
ombNumber: form.fieldOmbNumber,
ombInfo: {
expDate: formatDate(form.fieldExpirationDate.value),
ombNumber: form.fieldOmbNumber,
resBurden: form.fieldRespondentBurden,
},
chapters: form.fieldChapters.map(normalizeChapter),
};
} catch (error) {
Expand Down
Loading
Loading