How to remove leading zeros

220 views
Skip to first unread message

MightyMouse

unread,
Dec 19, 2012, 12:43:46 PM12/19/12
to Ensemble-in...@googlegroups.com
I have a MRN received from an EHR that may or may not have leading zeros that I need to remove.  Is there an objectscript function (I have looked but could not find one) that I can use to strip them?
 
Thanks,
LG

Ed de Moel

unread,
Dec 19, 2012, 12:46:19 PM12/19/12
to Ensemble-in...@googlegroups.com
If the MRN is an integer number, then +MRN should do the trick.
Ed

--
**************************************************************
This electronic mail transmission contains confidential and/or
privileged information intended only for the person(s) named.
Any use, distribution, copying or disclosure by another person
is strictly prohibited.
**************************************************************

Manel Tremols

unread,
Dec 19, 2012, 12:47:03 PM12/19/12
to Ensemble-in...@googlegroups.com

Set MRN=+MRN

 

8-)

 

Manel Trèmols
Technical Specialist

 

InterSystems Iberia S.L.

Avda. de les Corts Catalanes, 5-7

08173 Sant Cugat del Vallés, Barcelona

Telf.:

+34 93 504 10 50

Directe:

+34 93 504 16 58

Mòbil:

+34 649 09 27 66

InterSystems.es

--
You received this message because you are subscribed to the Google Groups "InterSystems: Ensemble in Healthcare Community" group.
To post to this group, send email to Ensemble-in...@googlegroups.com
To unsubscribe from this group, send email to Ensemble-in-Healt...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Ensemble-in-Healthcare?hl=en

David Loveluck

unread,
Dec 19, 2012, 12:50:49 PM12/19/12
to Ensemble-in...@googlegroups.com

If you are in DTL you can use the Strip()  function. It is a wrapper for $Zstrip() so you could use that directly. In either case, use the $zstrip documentation.

 

USER>w $ZStrip("0000333000333000","<","0")

333000333000

USER>

--

MightyMouse

unread,
Dec 19, 2012, 12:56:00 PM12/19/12
to Ensemble-in...@googlegroups.com
EdM and Manuel, thank you for the quick response, but it is a string (sorry I didn't mention that)!
 
Mr. David Loveluck, that did the trick!  Thank you very much!  I can now lower my blood pressure back to healthy levels!

Manel Tremols

unread,
Dec 19, 2012, 12:59:38 PM12/19/12
to Ensemble-in...@googlegroups.com

It’s not a problem, it will work !

 

W +”00000123”

123

 

Can you imagine what will return

 

W “2 apples”+”3 oranges”

 

?

 

Manel

--

Ed de Moel

unread,
Dec 19, 2012, 1:07:24 PM12/19/12
to Ensemble-in...@googlegroups.com
On 19-Dec-12 12:56, MightyMouse wrote:
> EdM and Manuel, thank you for the quick response, but it is a string
> (sorry I didn't mention that)!
>
If it's a string, then
For Quit:$Extract(MRN,1)'="0" Set $Extract(MRN,1)=""
would do it.

Lawrence Grace

unread,
Dec 19, 2012, 1:27:52 PM12/19/12
to Ensemble-in...@googlegroups.com
5!
 
That's so cool.  And simple too!
--
Lawrence Grace
 

Lawrence Harris

unread,
Dec 19, 2012, 2:42:57 PM12/19/12
to <Ensemble-in-Healthcare@googlegroups.com>
Yes if it's numeric and you 'know' that to be true then +MRN will strip leading zeros but be careful.  I had a value that was something like 5E49532 and if you + that it will give you a  <MAXNUMBER> error as it tries to evaluate the Exponent.  So using 'knowing' that MRN's are not zero and using +MRN>0 to determine if it's numeric is dangerous.

If MRN contains the value in question then this is fairly safe.

If MRN?1.N Set MRN=+MRN
Else  -something else or error condition-

Lawrence

Reply all
Reply to author
Forward
0 new messages