@@ -2,7 +2,14 @@ import Oystehr from '@oystehr/sdk';
22import { Address , Coverage , FhirResource , HumanName , Patient , RelatedPerson } from 'fhir/r4b' ;
33import { min } from 'lodash' ;
44import { 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' ;
613import { LABS_DATE_STRING_FORMAT , resourcesForOrderForm } from '../../ehr/submit-lab-order/helpers' ;
714import { makeZ3Url } from '../presigned-file-urls' ;
815import { 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
0 commit comments