Skip to content

Commit cec8a23

Browse files
saewitzclaude
andcommitted
fix(pdf): show 'Do you have an attorney?' row in attorney section
When a patient selects 'I do not have an attorney' the attorney section was entirely hidden, which caused the answer to not appear at all (or in older code, to overlap with the section title). Now: - The 'attorney-mva-has-attorney' answer is extracted from the QuestionnaireResponse and threaded into AttorneyInfo/AttorneyDataInput - The section renders when the has-attorney answer is populated, even if no attorney details exist - A proper 'Do you have an attorney? / I do not have an attorney' label-value row renders as the first field in the section Closes OTR-1884. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 99f4b97 commit cec8a23

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

packages/zambdas/src/shared/pdf/sections/attorneyInfo.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import { ATTORNEY_FIRM_EXTENSION_URL, formatPhoneNumberDisplay } from 'utils';
22
import { createConfiguredSection, DataComposer } from '../pdf-common';
33
import { AttorneyDataInput, AttorneyInfo, PdfSection } from '../types';
44

5-
export const composeAttorneyData: DataComposer<AttorneyDataInput, AttorneyInfo> = ({ attorneyRelatedPerson }) => {
5+
export const composeAttorneyData: DataComposer<AttorneyDataInput, AttorneyInfo> = ({
6+
attorneyRelatedPerson,
7+
hasAttorneyAnswer,
8+
}) => {
69
if (!attorneyRelatedPerson) {
710
return {
11+
hasAttorneyAnswer,
812
firm: '',
913
firstName: '',
1014
lastName: '',
@@ -29,6 +33,7 @@ export const composeAttorneyData: DataComposer<AttorneyDataInput, AttorneyInfo>
2933
const fax = getPhoneDisplay('fax');
3034

3135
return {
36+
hasAttorneyAnswer,
3237
firm,
3338
firstName,
3439
lastName,
@@ -39,7 +44,7 @@ export const composeAttorneyData: DataComposer<AttorneyDataInput, AttorneyInfo>
3944
};
4045

4146
const hasAttorneyInfo = (info: AttorneyInfo): boolean =>
42-
!!(info.firm || info.firstName || info.lastName || info.email || info.mobile || info.fax);
47+
!!(info.hasAttorneyAnswer || info.firm || info.firstName || info.lastName || info.email || info.mobile || info.fax);
4348

4449
export const createAttorneyInfoSection = <TData extends { attorney?: AttorneyInfo }>(): PdfSection<
4550
TData,
@@ -53,6 +58,18 @@ export const createAttorneyInfoSection = <TData extends { attorney?: AttorneyInf
5358
// Each row is gated by `shouldShow` (so customer `hiddenFields` overrides
5459
// are honored) and by truthiness of the value (compact render: empty
5560
// optional fields are omitted, like the original behavior).
61+
if (shouldShow('attorney-mva-has-attorney') && attorneyInfo.hasAttorneyAnswer) {
62+
client.drawLabelValueRow(
63+
'Do you have an attorney?',
64+
attorneyInfo.hasAttorneyAnswer,
65+
styles.textStyles.regular,
66+
styles.textStyles.regular,
67+
{
68+
drawDivider: true,
69+
dividerMargin: 8,
70+
}
71+
);
72+
}
5673
if (shouldShow('attorney-mva-firm') && attorneyInfo.firm) {
5774
client.drawLabelValueRow('Firm', attorneyInfo.firm, styles.textStyles.regular, styles.textStyles.regular, {
5875
drawDivider: true,

packages/zambdas/src/shared/pdf/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ export interface OccupationalMedicineEmployerInfo extends PdfData {
737737
}
738738

739739
export interface AttorneyInfo extends PdfData {
740+
hasAttorneyAnswer?: string;
740741
firm: string;
741742
firstName: string;
742743
lastName: string;
@@ -846,6 +847,7 @@ export interface OccupationalMedicineEmployerDataInput {
846847

847848
export interface AttorneyDataInput {
848849
attorneyRelatedPerson?: RelatedPerson;
850+
hasAttorneyAnswer?: string;
849851
}
850852

851853
export interface PatientPaymentsDataInput {

packages/zambdas/src/shared/pdf/visit-details-pdf.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
AppointmentContext,
33
BUCKET_NAMES,
4+
flattenQuestionnaireAnswers,
45
getCoding,
56
getReasonForVisitAndAdditionalDetailsFromAppointment,
67
getReasonForVisitOptionsForServiceCategory,
@@ -112,7 +113,12 @@ const composeVisitDetailsData: DataComposer<VisitDetailsInput, VisitDetailsData>
112113
consentForms: composeConsentFormsData({ encounter, consents, questionnaireResponse, timezone }),
113114
documents: composeDocumentsData(documents),
114115
emergencyContact: composeEmergencyContactData({ emergencyContactResource }),
115-
attorney: composeAttorneyData({ attorneyRelatedPerson }),
116+
attorney: composeAttorneyData({
117+
attorneyRelatedPerson,
118+
hasAttorneyAnswer: flattenQuestionnaireAnswers(questionnaireResponse?.item ?? []).find(
119+
(item) => item.linkId === 'attorney-mva-has-attorney'
120+
)?.answer?.[0]?.valueString,
121+
}),
116122
employer: composeEmployerData({
117123
employer: employerOrganization,
118124
workersCompCoverage: coverages.workersComp,

0 commit comments

Comments
 (0)