-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MHV-60285 blue-button-txt-updates (#33443)
- Loading branch information
Showing
7 changed files
with
276 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/applications/mhv-medical-records/util/txtHelpers/accountSummary.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { generateAccountSummaryContent } from '../pdfHelpers/accountSummary'; | ||
|
||
// Function to parse account summaries | ||
export const parseAccountSummary = records => { | ||
// Generate the structured content | ||
const accountSummaryContent = generateAccountSummaryContent(records || {}); | ||
|
||
// Initialize an array to hold the formatted text | ||
const formattedText = []; | ||
|
||
// Process 'details' section if it exists | ||
if ( | ||
accountSummaryContent.details && | ||
Array.isArray(accountSummaryContent.details.items) | ||
) { | ||
accountSummaryContent.details.items.forEach(item => { | ||
const title = item.title || 'Unknown'; | ||
const value = item.value || 'No information provided'; | ||
formattedText.push(`${title}: ${value}`); | ||
}); | ||
} | ||
|
||
// Process 'results' section if it exists | ||
if ( | ||
accountSummaryContent.results && | ||
Array.isArray(accountSummaryContent.results.items) | ||
) { | ||
formattedText.push('\nVA Treatment Facilities:'); | ||
accountSummaryContent.results.items.forEach(facility => { | ||
const header = facility.header || 'Unknown Facility'; | ||
formattedText.push(`\n${header}:`); | ||
if (Array.isArray(facility.items)) { | ||
facility.items.forEach(item => { | ||
const title = item.title || 'Unknown'; | ||
const value = item.value || 'No information provided'; | ||
formattedText.push(` ${title}: ${value}`); | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
// Join the formatted text array into a single string | ||
return ` | ||
11) Account Summary | ||
My HealtheVet account summary | ||
${formattedText.join('\n')} | ||
`; | ||
}; |
75 changes: 75 additions & 0 deletions
75
src/applications/mhv-medical-records/util/txtHelpers/appointments.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { generateAppointmentsContent } from '../pdfHelpers/appointments'; | ||
|
||
// Helper function to format appointment content into plain text | ||
const formatAppointmentsContentToText = content => { | ||
const sections = content.results.items; | ||
|
||
// Preface text | ||
const { preface } = content.results; | ||
|
||
// Format each appointment section into plain text | ||
const formattedSections = sections | ||
.map(section => { | ||
const header = `Date: ${section.header || 'Unknown Date'}`; | ||
const itemsText = section.items | ||
.map(item => { | ||
// Check if item.value is an array of objects | ||
if ( | ||
Array.isArray(item.value) && | ||
item.value.every(val => typeof val === 'object') | ||
) { | ||
// Format each object in the array | ||
const formattedValues = item.value | ||
.map(val => { | ||
return Object.entries(val) | ||
.map(([key, value]) => `${key}: ${value}`) | ||
.join(', '); | ||
}) | ||
.join('\n'); | ||
return `${item.title}:\n${formattedValues}`; | ||
} | ||
// For other types, display as usual | ||
return `${item.title}: ${item.value || 'No information provided'}`; | ||
}) | ||
.join('\n'); // Join each item with a newline | ||
|
||
return `${header}\n${itemsText}`; | ||
}) | ||
.join('\n\n'); // Separate sections with double newlines | ||
|
||
return `${preface}\n\n${formattedSections}`; | ||
}; | ||
|
||
// Main function | ||
export const parseAppointments = appointments => { | ||
// Filter appointments into upcoming and past | ||
const upcomingAppointments = appointments.filter( | ||
appointment => appointment.isUpcoming, | ||
); | ||
const pastAppointments = appointments.filter( | ||
appointment => !appointment.isUpcoming, | ||
); | ||
|
||
// Generate content for upcoming and past appointments | ||
const upcomingContent = generateAppointmentsContent(upcomingAppointments); | ||
const pastContent = generateAppointmentsContent(pastAppointments); | ||
|
||
// Format content into plain text | ||
const formattedUpcomingContent = formatAppointmentsContentToText( | ||
upcomingContent, | ||
); | ||
const formattedPastContent = formatAppointmentsContentToText(pastContent); | ||
|
||
return ` | ||
8) Appointments | ||
'Your VA appointments may be by telephone, video, or in person. Always bring your insurance information with you to your appointment.', | ||
Records: | ||
- Upcoming Appointments: | ||
${formattedUpcomingContent} | ||
- Past Appointments: | ||
${formattedPastContent} | ||
`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/applications/mhv-medical-records/util/txtHelpers/demographics.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { generateDemographicsContent } from '../pdfHelpers/demographics'; | ||
|
||
// Helper function to format the demographics content into plain text | ||
const formatDemographicsContentToText = content => { | ||
// Extract the `items` array from the nested structure | ||
const sections = content.results.items; | ||
|
||
// Format each section into plain text | ||
return sections | ||
.map(section => { | ||
// Extract the header (if any) and items in the section | ||
const header = section.header ? `${section.header}:\n` : ''; | ||
const itemsText = section.items | ||
.map( | ||
item => | ||
`${item.title || 'Unknown'}: ${item.value || | ||
'No information provided'}`, | ||
) | ||
.join('\n'); // Join item strings with newlines | ||
|
||
return `${header}${itemsText}`; | ||
}) | ||
.join('\n\n'); // Separate sections with double newlines | ||
}; | ||
|
||
// Function to parse demographics | ||
export const parseDemographics = records => { | ||
return ` | ||
9) Demographics | ||
Each of your VA facilities may have different demographic information for you. | ||
If you need to update your information, contact your facility. | ||
${records | ||
.map(record => { | ||
// Generate content and format it as text | ||
let demographicsContent; | ||
try { | ||
demographicsContent = generateDemographicsContent(record); | ||
// Format content into plain text | ||
demographicsContent = formatDemographicsContentToText( | ||
demographicsContent, | ||
); | ||
} catch (error) { | ||
demographicsContent = 'Error formatting demographics content'; | ||
} | ||
return ` | ||
VA Facility: ${record.facility || 'Unknown Facility'} | ||
titleMoveDownAmount: 0.5, | ||
${demographicsContent} | ||
`; | ||
}) | ||
.join('\n\n')} // Add line breaks between records | ||
`; | ||
}; |
44 changes: 44 additions & 0 deletions
44
src/applications/mhv-medical-records/util/txtHelpers/medications.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { generateMedicationsContent } from '../pdfHelpers/medications'; | ||
|
||
export const parseMedications = records => { | ||
return ` | ||
7) Medications | ||
This is a list of prescriptions and other medications in your VA medical records. | ||
When you share your medications list with providers, make sure you also tell them | ||
about your allergies and reactions to medications. When you download medications records, | ||
we also include a list of allergies and reactions in your VA medical records. | ||
Showing ${records.length} medications, alphabetically by name: | ||
${records | ||
.map(record => { | ||
const title = record.prescriptionName; | ||
const content = generateMedicationsContent(record); | ||
// Check if content.details exists and is an array | ||
const formattedDetails = content.details?.length | ||
? content.details | ||
.map(detail => { | ||
const header = `\n${detail.header}:\n`; | ||
const items = detail.items | ||
.map(item => { | ||
if (item.title && item.value) { | ||
return `- ${item.title}: ${item.value}`; | ||
} | ||
if (item.value) { | ||
return `- ${item.value}`; | ||
} | ||
return ''; | ||
}) | ||
.join('\n'); | ||
return `${header}${items}`; | ||
}) | ||
.join('\n\n') | ||
: 'No details available for this record.'; | ||
// Combine title and formatted details | ||
return `Title: ${title}\n${formattedDetails}`; | ||
}) | ||
.join('\n\n')} | ||
`; | ||
}; |
11 changes: 11 additions & 0 deletions
11
src/applications/mhv-medical-records/util/txtHelpers/militaryService.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const parseMilitaryService = records => { | ||
const militaryServiceText = records; | ||
|
||
return ` | ||
10) Military Service | ||
Title: DOD Military Service Information | ||
${militaryServiceText} | ||
`; | ||
}; |