Skip to content

Commit 6160d98

Browse files
Merge pull request #4558 from masslight/abraun/otr-1050-ehr-external-labs-in-order-form-pdf-office-address-overlaps
Fix(labs): fix overlapping location address
2 parents d1b58ae + 0d58e6d commit 6160d98

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

packages/zambdas/src/shared/pdf/external-labs-order-form-pdf.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import Oystehr from '@oystehr/sdk';
22
import { Address, Coverage, FhirResource, HumanName, Patient, RelatedPerson } from 'fhir/r4b';
33
import { min } from 'lodash';
44
import { DateTime } from 'luxon';
5-
import { BUCKET_NAMES, FHIR_IDENTIFIER_NPI, getFullestAvailableName, ORDER_ITEM_UNKNOWN, Secrets } from 'utils';
5+
import {
6+
BUCKET_NAMES,
7+
FHIR_IDENTIFIER_NPI,
8+
formatPhoneNumberDisplay,
9+
getFullestAvailableName,
10+
ORDER_ITEM_UNKNOWN,
11+
Secrets,
12+
} from 'utils';
613
import { LABS_DATE_STRING_FORMAT, resourcesForOrderForm } from '../../ehr/submit-lab-order/helpers';
714
import { makeZ3Url } from '../presigned-file-urls';
815
import { createPresignedUrl, uploadObjectToZ3 } from '../z3Utils';
@@ -81,6 +88,7 @@ async function createExternalLabsOrderFormPdfBytes(data: ExternalLabOrderFormDat
8188
console.log(
8289
`Drawing location details left column. xPos is ${pdfClient.getX()}. yPos is ${pdfClient.getY()}. Current page index is ${pdfClient.getCurrentPageIndex()} out of ${pdfClient.getTotalPages()} pages.`
8390
);
91+
const leftColumnBounds = { leftBound: pdfClient.getLeftBound(), rightBound: rightColumnXStart - 10 };
8492
const yPosAtStartOfLocation = pdfClient.getY();
8593
let yPosAtEndOfLocation = yPosAtStartOfLocation;
8694
if (
@@ -93,7 +101,7 @@ async function createExternalLabsOrderFormPdfBytes(data: ExternalLabOrderFormDat
93101
data.locationFax
94102
) {
95103
if (data.locationName) {
96-
pdfClient.drawTextSequential(data.locationName, textStyles.textBold);
104+
pdfClient.drawTextSequential(data.locationName, textStyles.textBold, leftColumnBounds);
97105
pdfClient.newLine(STANDARD_NEW_LINE);
98106
}
99107

@@ -106,18 +114,21 @@ async function createExternalLabsOrderFormPdfBytes(data: ExternalLabOrderFormDat
106114
if (data.locationStreetAddress) {
107115
pdfClient.drawTextSequential(data.locationStreetAddress.toUpperCase(), textStyles.text, {
108116
leftBound: xPosAfterImage,
109-
rightBound: pdfClient.getRightBound(),
117+
rightBound: leftColumnBounds.rightBound,
110118
});
111119
pdfClient.newLine(STANDARD_NEW_LINE);
112120
}
113121

114122
if (data.locationCity || data.locationState || data.locationZip) {
115-
pdfClient.drawStartXPosSpecifiedText(
123+
pdfClient.drawTextSequential(
116124
`${data.locationCity ? data.locationCity + ', ' : ''}${data.locationState ? data.locationState + ' ' : ''}${
117125
data.locationZip || ''
118126
}`.toUpperCase(),
119127
textStyles.text,
120-
xPosAfterImage
128+
{
129+
leftBound: xPosAfterImage,
130+
rightBound: leftColumnBounds.rightBound,
131+
}
121132
);
122133
pdfClient.newLine(STANDARD_NEW_LINE);
123134
}
@@ -129,12 +140,18 @@ async function createExternalLabsOrderFormPdfBytes(data: ExternalLabOrderFormDat
129140
{ ...iconStyleWithMargin, margin: { ...iconStyleWithMargin.margin, left: 0 } },
130141
textStyles.text
131142
);
132-
pdfClient.drawTextSequential(data.locationPhone, textStyles.text);
143+
pdfClient.drawTextSequential(formatPhoneNumberDisplay(data.locationPhone), textStyles.text, {
144+
leftBound: pdfClient.getX(),
145+
rightBound: leftColumnBounds.rightBound,
146+
});
133147
}
134148

135149
if (data.locationFax) {
136150
pdfClient.drawImage(faxIcon, iconStyleWithMargin, textStyles.text);
137-
pdfClient.drawTextSequential(data.locationFax, textStyles.text);
151+
pdfClient.drawTextSequential(data.locationFax, textStyles.text, {
152+
leftBound: pdfClient.getX(),
153+
rightBound: leftColumnBounds.rightBound,
154+
});
138155
}
139156

140157
if (data.locationPhone || data.locationFax) {
@@ -182,7 +199,7 @@ async function createExternalLabsOrderFormPdfBytes(data: ExternalLabOrderFormDat
182199
`Drawing patient info left column. xPos is ${pdfClient.getX()}. yPos is ${pdfClient.getY()}. Current page index is ${pdfClient.getCurrentPageIndex()} out of ${pdfClient.getTotalPages()} pages.`
183200
);
184201
pdfClient.drawTextSequential(
185-
`${data.patientLastName}, ${data.patientFirstName}${data.patientMiddleName ? ' ' + data.patientMiddleName : ''}, `,
202+
`${data.patientLastName}, ${data.patientFirstName}${data.patientMiddleName ? ' ' + data.patientMiddleName : ''} `,
186203
{ ...textStyles.header, newLineAfter: false }
187204
);
188205
pdfClient.drawTextSequential(`${data.patientSex}, ${data.patientDOB}`, textStyles.text);
@@ -198,7 +215,7 @@ async function createExternalLabsOrderFormPdfBytes(data: ExternalLabOrderFormDat
198215
);
199216
pdfClient.drawTextSequential(`${data.patientAddress} `, textStyles.text);
200217
pdfClient.drawImage(callIcon, iconStyleWithMargin, textStyles.text);
201-
pdfClient.drawTextSequential(data.patientPhone, textStyles.text);
218+
pdfClient.drawTextSequential(formatPhoneNumberDisplay(data.patientPhone), textStyles.text);
202219
pdfClient.newLine(STANDARD_NEW_LINE);
203220

204221
// Order date and collection date

packages/zambdas/src/shared/pdf/labs-results-form-pdf.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
convertActivityDefinitionToTestItem,
2626
createFilesDocumentReferences,
2727
EXTERNAL_LAB_RESULT_PDF_BASE_NAME,
28+
formatPhoneNumberDisplay,
2829
getFullestAvailableName,
2930
getOrderNumber,
3031
getOrderNumberFromDr,
@@ -173,7 +174,9 @@ const getResultDataConfigForDrResources = (
173174
patientSex: patient.gender || '',
174175
patientDOB: patient.birthDate ? DateTime.fromFormat(patient.birthDate, 'yyyy-MM-dd').toFormat('MM/dd/yyyy') : '',
175176
patientId: patient.id || '',
176-
patientPhone: patient.telecom?.find((telecomTemp) => telecomTemp.system === 'phone')?.value || '',
177+
patientPhone: formatPhoneNumberDisplay(
178+
patient.telecom?.find((telecomTemp) => telecomTemp.system === 'phone')?.value || ''
179+
),
177180
todayDate: now.setZone().toFormat(LABS_DATE_STRING_FORMAT),
178181
dateIncludedInFileName: diagnosticReport.effectiveDateTime || '',
179182
orderPriority: '',
@@ -244,7 +247,8 @@ const getResultDataConfig = (
244247
locationCity: location?.address?.city,
245248
locationState: location?.address?.state,
246249
locationZip: location?.address?.postalCode,
247-
locationPhone: location?.telecom?.find((t) => t.system === 'phone')?.value,
250+
locationPhone:
251+
formatPhoneNumberDisplay(location?.telecom?.find((t) => t.system === 'phone')?.value || '') || undefined,
248252
locationFax: location?.telecom?.find((t) => t.system === 'fax')?.value,
249253
providerName: providerName || '',
250254
providerNPI: (providerNPI || '') as string,
@@ -254,7 +258,9 @@ const getResultDataConfig = (
254258
patientSex: patient.gender || '',
255259
patientDOB: patient.birthDate ? DateTime.fromFormat(patient.birthDate, 'yyyy-MM-dd').toFormat('MM/dd/yyyy') : '',
256260
patientId: patient.id || '',
257-
patientPhone: patient.telecom?.find((telecomTemp) => telecomTemp.system === 'phone')?.value || '',
261+
patientPhone: formatPhoneNumberDisplay(
262+
patient.telecom?.find((telecomTemp) => telecomTemp.system === 'phone')?.value || ''
263+
),
258264
todayDate: now.setZone().toFormat(LABS_DATE_STRING_FORMAT),
259265
dateIncludedInFileName: serviceRequest.authoredOn || '',
260266
orderPriority: serviceRequest.priority || '',

0 commit comments

Comments
 (0)