Question
· Aug 28, 2017

padding string in BPL

Hi folks, I'm trying to pad my patient MRN to 10 characters before I do a SQL lookup in my BPL. I've tried various approaches, and have not been successful.

When I add a "code" statement with the following code, I get an error as below.

set context.NewID = "0000000000"
set $EXTRACT(context.NewID,10-len(context.PatientID)) = context.PatientID
 
ERROR <Ens>ErrException: <OBJECT DISPATCH>zS8+5 ^CHSLI.BPLQueryDatabaseforPatientID.Thread1.1 *Property 'NewID'
in class 'CHSLI.BPLQueryDatabaseforPatientID.Context'
must be MultiDimensional -- logged as '-'
number - @'
set $EXTRACT(context.NewID,10-len(context.PatientID)) = context.PatientID'

Any ideas/help would be appreciated.

Thanks.

Discussion (9)1
Log in or sign up to continue

I'm not exactly clear on which you intend to hold the new ID (context.newID maybe by the name?)

Regardless, you can also use the built-in pad method:

set context.NewID = ##class(Ens.Rule.FunctionSet).Pad(context.PatientID,-10,0)

where context.PatientID holds your original Patient ID. -10 means you want to prepend to be 10 characters, and "0" is the character you want prepended.