Age Related Z Programs
Arguments: A = birthdate YYYYMMDD
B = base date YYYYMMDD Optional, uses @.today otherwise
Returns: Age in years, months days, according to the following scheme:
Under 1 year
nM dD
Under 5 years
nY mM
5 or over
nn
Example call: %Z.age(@birthdate,@.today) returns age
%Z.age(19560315,20000421) returns 44
Notes:
MEDITECH age fields are stored in this format. @ADM.PAT.age for example. Do not compare ages stored in the format with > and < because the ASCII value does not always correspond to the age. Reformat the age with %Z.age.with.years, Z.age.format.strip or Z.age.in.years if you need to do comparisons.
Arguments: A = age in Z.age format
B = not nil if “weeks gestational age” allowed
Returns: Users input if valid, nil if not valid.
Example call: %Z.age.ck(@age) returns @age
%Z.age.ck(“4Y 11M”) returns “4Y 11M”
%Z.age.ck(“6Y 11M”) returns “” (bad format)
ARGUMENT: A = a formatted age (e.g., 0Y 04M 11D)
RETURNS: Stripped age (e.g., 4M 11D)
Example Call: %Z.age.format.strip(“1Y 01M”) returns “1Y 1M”
Arguments: A = birth date
B = admit date
Returns Age Group (Canadian)
NB = NEWBORN
UM = UNDER 1 MONTH
00 = UNDER 1 YEAR
99 = 100 YRS or MORE
AU = AGE UNKNOWN
= Others (no age group returned)
Note: Canadian hospitals only.
Arguments: A = birthdate YYYYMMDD
B = date as of YYYYMMDD
Returns: Age in Years
Example Call: %Z.age.in.years(19580101,20000101) Returns 42
Converts an age to a computed birthdate.
Arguments: A = age (for example: 32, 3Y 6M, 2M 15D)
B = base date (age A was recorded on this date; generally
today or admission date) YYYYMMDD format.
Returns: Computed birthdate in YYYYMMDD format.
Example Call: %Z.age.to.birthdate(42,20000422) returns 19580422
Allows compiled reports to compare ages.
Arguments: A = birthdate
B = OPTIONAL base date (e.g., admission date) – program uses IF{B;@.today}
Returns: Age in years, months, days. If the age is less than one year, “0Y “
is returned in front of the number of months and days.
Examples: 32, 3Y 10M, 0Y 0M 21D
Example Call: %Z.age.with.years(20000101,20000421) returns 0Y 03M 20D
Date and Time Related Z Programs
Arguments A = External Date (MM/DD/YY US DD/MM/YY Canada)
Returns Internal Date based on system century = current year – 99
Example Call: %Z.date.in(“04/02/00”) Returns 20000402
Argument: A = internal date YYYYMMDD
B = integer, days to add to A (for negative use 0-N or “-N”
Returns” Internal date N days from A
Example Call: %Z.date.add(20000101,90) returns 20000331
Arguments: A = clinical date or S(0) (Seconds since 3/1/1980)
Returns: External Date (MM/DD/YY US, DD/MM/YY Canada).
This yields the same results as: %Z.date.out(%Z.date.in.magic(input))
Example Call: %Z.date.clin.to.out(S(0)) (on 04/21/00) returns “04/21/00”
%Z.date.clin.to.out(7356) returns “04/21/00”
This program takes a clinical date and returns a ‘text’ form of it.
Arguments: A = date (days since 3/1/1980 or S(0))
B = format indicator: Use M, m, N, n, D, d, Y, y.
(Capital letter means long form; Small letter means abbreviated form)
(All other characters are taken literally.)
Examples:
September 03, 1990 “M D, Y”
September 3, 90 “M d, y”
Sep 03, 1990 “m D, Y”
03Sep90 “Dmy”
3 Sep 90 “d m y”
3-Sep-90 “d-m-y”
09/03/90 “N/D/Y”
[For text month only:]
C = “I” to print month with inital capital only, for example, September or Sep.
=”A” to print month with all capitals, e.g., SEPTEMBER or SEP
DEFAULTS:
B = “m d,Y” \_____ Sep 3, 1990
C =”I” /
Example Call %Z.date.clin.to.text(7356,”M D, Y”) returns “April 21, 2000
Arguments: A = Internal Date YYYYMMDD
Returns: Clinical Date (Number of days since 3/1/1980
If the A is not eight characters, A is returned.
Example Call: %Z.date.clinical(20000421) returns 7356
Arguments: A = mm/dd/yy or T or T+n or T-n
Returns: YYYYMMDD
Example Call: %Z.date.in(“03/01/00”) with system century = 1900 returns “19000301”
%Z.date.in(“03/01/00”) with system century = 1930 returns “20000301”
Arguments: A = S(0) or @.sd or clinical date
Returns: YYYYMMDD
Example Call: %Z.date.in.magic(7356) Returns 20000421
Arguments: A = YYYYMMDD
Returns: YYJJJ–The Julian date.
Example call: %Z.date.julian(20000421) returns 00112
Arguments: A = YYJJJ
Returns: YYYYMMDD
Example call: %Z.date.julian.to.in(“00112”) returns 20000421
Arguments: A = internal date YYYYMMDD
B = if non-nil, return A if format checks fail
C = 5 return MM/DD or DD/MM
C = 10 return MM/DD/YYYY or DD/MM/YYYY
Returns: MM/DD/YY or MMDDYYYY depending on system century or argument C
Example Call: %Z.date.out(20000421) returns 04/21/00
%Z.date.out(20000421,””,5) returns 04/21
%Z.date.out(20000421,””,10) returns 04/21/2000”
Argument: A = YYYYMMDD
Returns: MM/DD/YYYY
(US format only)
Example Call %Z.date.out.long(20000421) Returns 04/21/2000
Arguments: A = more recent date
B = older date
Returns: Number of days between B and A
If A or B are nil, returns nil
Example Call: %Z.date.sub(20000415,20000101) returns 105
Arguments: A date in (YYYYMMDD or MM/DD/YY or MM/DD/YYYY)< /p> B = format indicator: Use M, m, N, n, D, d, Y, y.
Capital letter means long form; Small letter means abbreviated form)
(All other characters are taken literally.)
Examples:
September 03, 1990 “M D, Y”< /p> September 3, 90 “M d, y”
Sep 03, 1990 “m D, Y”
03Sep90 “Dmy”
3 Sep 90 “d m y”
3-Sep-90 “d-m-y”
09/03/90 “N/D/Y”
[For text month only:]
C = “I” to print month with inital capital only, e.g, September or Sep.
C = “A” to print month with all capitals, e.g., SEPTEMBER or SEP
DEFAULTS:
B = “m d, Y” \_____ Sep 3, 1990
C = “I” /
Arguments: A = YYYYMMDD
Returns: Day of the week (integer)
Example Call: %Z.day.from.date(20000421) Returns 6
Converts a three-letter mnemonic (ex. “MON”) for a day into a number (ex. 2).
Arguments: Three letter day mnemonic ex: SUN, MON, TUE, WED.
Returns: Day of the week (SUN = 1)
Example Call: %Z.day.in(“FRI”) returns 6
Converts number 1–7 to corresponding mnemonic for day of the week
Arguments: Integer 1–7
Returns: SUN–SAT
Example Call: %Z.day.out(6) Returns “FRI”
Converts an internal month (1-12) into an external mnemonic (ex. “FEB”).
Example Call: %Z.month.out(1) returns “JAN”
Arguments: A = internal date YYMMDD
B = time HHMM
C = number of minutes to add (may be a negative number)
Returns: Q(new.date,new.time) new.date = YYMMDD new.time = HHMM
Example: A = 19910103
B = 0700
C = “-600” (i.e., subtract 10 hours)
Returns: Q(19910102,2100)
Example Call: Z.time.add(20000421,1200,60*24*3) returns 20000424 1200
Arguments: A HHMM time
Returns: S(0) time
Example Call %Z.time.in(1300) returns 46800
Arguments: A = time (HHMM or NNNNN*)
B = format indicator: Use H, h, M, m, A, a, N
(Capital letter means keep lead zero; Small letter means don’t)
(Use ‘A’ or ‘a’ for AM/PM. ‘A’ means use ‘AM’ or ‘PM’; ‘a’ = ‘A’ or ‘P’)
(N means to return military time)
(All other characters are taken literally)
Examples:
09:10am “H:MA”
9:10 a “h:M a”
9:10 am “h:M A”
0910 am “HM A”
0910a “HMa”
1530 “N” (with input as 1530)
C = “C” to capitalize AM and PM
= “S” to use small letters for am and pm
D = 1 to indicate that argument A is internal time in seconds.
If A is NNNNN (seconds), it will be converted to HHMM *UNLESS* it looks
like HHMM already. It is best to pass in HHMM time. If you cannot,
pass in D=1 so that the program knows that the time is in internal form.
(i.e., 0000-2359 seconds is indistinguishable from 0000-2359 HHMM, except
where X%1>59; however, note that 2359 seconds is only = 0039 HHMM, a small
time window).
DEFAULTS:
B = “h:MA” \___ e.g., 9:10am
C = “S” /
Example call: %Z.time.text(1300,”h:mmA”,”C”) Returns “1:00PM”
Graphics and Printer Z programs
Arguments A = string to be printed in barcode
B = number of columns the cursor should have moved to the right when the program returns
C = not used
D = type of bar code: nil Code 3 of 9 “POSTNET”–Postnet
Returns Nil
Barcodes should be printed one line high. User can print the same data on two successive lines if a taller barcode is desired.
The following programs are called from Z.bar.code to handle specific printers:
%Z.bar.code.eltron
%Z.bar.code.fargo
%Z.bar.code.hp
%Z.bar.code.genicom
Selects an output device, opens ! to it.
Arguments A = “N” – submerged spooling will not be allowed;
else allow it unless @Z.spool.bj.no non-nil
B – prompt, default is “Print on: “
C – default response, . implies
MIS.USER.default.device[@.logical.device]
Use this program to open a prefix to a particular printer via a program.
Argument:
A – mnemonic of the output device
B – If present open port in that mode, eg, “I” for instrument buffer.
When printing from a program, you should use this program to close ! when printing is complete. Otherwise, depending on how a remote printer is managed, you will lose all the output, or not get the last page.
Arguments: None
Arguments:
A = Box type 0 – black border
1 – grey box
2 – grey box and black border
B = length of box
C = ht of box (DFT=1) (can be 0 for just a horizontal line)
D = number of chars to move right (+) or left (-) before starting box
E = number of chars to move down (+) or (-) before starting box.
F = gray scale (default = 10%)
G = width of lines (DFT=5)
Arguments: None
Returns: Name of current (MAGIC) directory
MEDITECH Workstation DOS commands
Arguments: A = source file
Returns: nil–file not found
1 file opened
99 error
Arguments: A = path and file name
Arguments: A = complete path
Returns: {@error,@exists,@path}
where @exists is a flag, and @path is a valid dos path to the file, and @error
is a short message indicating why the filename is not valid
if wildcards are used, returns the first file that matches
if no matches, filename is considered valid, but no path returned
possible return value combinations and their interpretations:
@error @exists @path interpretation
—— ——- —– ————–
“” “” “” valid name, file doesn’t exist, wildcard used in arg
; “” “” defined valid name, path to file returned
; “” 1 “” valid name, wildcard used, >1 file matches pattern
; “” 1 defined valid name, file exists
;(“” 2 defined valid name, wildcard used, only this file matches ptrn)
; defined “” “” invalid name (invalid path, other error, or “error”)
; defined “” defined this case isn’t used
; defined 1 “” this case isn’t used
; defined 1 defined reserved file name, invalid for use (usually)
;
; from empirical results, this assumes that if DOS (i.e. $DOS.DIR) returns a “File not Found”
; error, that the filename is otherwise valid.
Arguments: A = executable
Prompts for a filename
Arguments A = executable
B = command line/ file name
Arguments: A = source file path on PC
B = new file name
Returns: nil = file not found or denied
1 = file renamed
99 = error encountered
Valid dos name should be no longer than 8 characters extension no longer than 3.
Arguments: A = source file path on PC
B = name of structure containing text. [B][1]..[B][n]
C = 1 to delete temp file
D = 1 read as an ASCII file
else as a “flat” file
E = longest line to allow, if TEXT type transfer, dft = 202 (i.e. 200 char of text.)}
Arguments: A = name of structure containing text. [A][1]..[A][n]
B = name of temp file to be used
C = 1 write as an ASCII file
else as a “flat” file
Misc String Functions
Arguments:
A = Money value between 0.00 and 999999.99
B = Optional maximum length, if exceeded, message printed instead of amount
Returns: String indicating amount in words, cents are returned as digits.
C\100^C},
Uses $NM.STRIP translate string to UPPER CASE names and strip punctuation and
numbers. It discards any middle name. Translated names are used in some ID
programs to find possible matches for the name entered.
Arguments A = name
Returns: Q(last name,first name)
Example call %Z.convert.name(Berman,Joel F”) returns |0 = BERMAN |1 = JOEL
Not available prior to release 4.7
Arguments
A = string to be converted
B = if true, treat as a name, convert to lastfirst
C= if true, convert strings less than 6 characters to mixed case. If C is nil, 1-5 character strings are left unchanged.
%Z.convert.to.mixed.case(“GRAND RAPIDS”)
Grand Rapids
%Z.convert.to.mixed.case(“TOM SAWYER”,1,1)
Sawyer,Tom
%Z.convert.to.mixed.case(“TOM SAWYER,””,1)
Tom Sawyer
%Z.convert.to.mixed.case(“THE RAIN IN SPAIN FALLS MAINLY IN THE PLAIN”,””,1)
The Rain In Spain Falls Mainly In The Plain
Checks validity of MONEY, SMONEY & PMONEY data types, and adds decimals on if appropriate.
Returns 2 decimal number if OK, else nil
Arguments:
A = name in lastname,firstrest of name format
Returns: Title First Last Etc
eg. SMITH,DR WILLIAM III becomes DR WILLIAM SMITH III
Example Call: %Z.name.inversion(“Berman,Joel F III MD”) returns
Joel F Berman, III, MD
I believe 4.7 has an MIS title dictionary to allow a site to tweak this program.
Formats phone numbers according to MIS parameter.
Arguments:
A is input
B is # of max columns in field
C suppresses messages to screen
Formats phone numbers according to MIS parameter. This is identical to phone.ck except it does not prompt the user to accept a non standard format. Instead it uses argument C to decide whether to accept it.
This program checks for legal zip codes and postal codes. A legal zip code is either: nnnnn or nnnnn-nnnn A legal postal code is: ana nan (02141 or 02141-1234) (A1B 2K3)
Arguments:
A = user’s entry
B = Y or N (allow user to override a bad entry, after a warning)
C = Z, P, or nil Z=only allow zip code form,
P=only allow postal code form,
nil=allow both)
RETURNS: TRUE if there is an error.
decide whether to accept it.
Arguments:
A is input
B is # of max columns in field
C if true accept a format which does not match the standard format
Formats phone numbers according to MIS parameter. This is identical to phone.ck except it does not prompt the user to accept a non standard format. Instead it uses argument C to decide whether to accept it.
Arguments:
A is input
B is # of max columns in field
C if true accept a format which does not match the standard format
Formats phone numbers according to MIS parameter. This is identical to phone.ck except it does not prompt the user to accept a non standard format. Instead it uses argument C to decide whether to accept it.
Arguments:
A is input
B is # of max columns in field
C if true accept a format which does not match the standard format
MISC Z programs
Arguments: A = url or filename with path or unc filename
Expects a single ‘A’ argument
Returns:
; D(0) ok
; D(128) There is not enough memory to perform the specified action.
; D(130) The specified file was not found.
; D(131) The specified path was not found.
; D(154) There was a sharing violation
; D(157) The DDE transaction failed.
; D(159) There is no application associated with the given file name extension.
Note: Return codes are handled by the Workstation, and are only captured here with the
%Z.cmd.read(1) syntax (following the shell invocation) in order to clear the input buffer.
Uses the new Workstation SHELL command: D(30)_”sh_”_{\path\filename}^#
to invoke the PC program that is associated with the FILE TYPE of the
‘A’ argument. Valid arguments would be of the format:
; “C:\Documents\Important Information.doc”
; “\\server\shared files\group docum.xls”
; “http://www.microsoft.com”
Note: It is not necessary to test for return codes.
Window and Message Z programs, General Text Editor
Arguments A = ^file of choices, consisting of choice text and 1-2 letter mnemonics.
subscript is the display.order
See arg E for file structure of text and mnemonics
B = default mnemonics
; optional arguments:
C = Q(R,C,@center) = where to put window (dft is “field-based”)
IF{C|2 @CENTERED.WINDOW;@WINDOW.AT.R.C}
D = title (default is “CHOICES”)
E – address of mnemonic and text:
E|0 = Address of mnemonic:
If “” – use subscript of file as the mnemonic
else E|0 is the packed piece where the mnemonic is stored.
E|1 = Address of text:
If “” – use value of file, ie, [A,sub]
else E|1 is the packed piece where the name is stored.
Thus if E = Q(“”,””), file structure is [A,mnemonic]=text
if E = Q(0,1), file structure is [A,display.order]=Q(mnemonic,text)
Returns option.letter or nil
Example call: %Z.choice.list(^/CH,2,Q(“”,””,1),”Title”,Q(“”,1))
Given structure:
/CH[1]=Q(5,”Five”)
/CH[2]=Q(4,”Four”)
/CH[3]=Q(3,”Three”)
/CH[4]=Q(2,”Two”)
/CH[5]=Q(1,”One”)
/CH[6]=Q(0,”Blastoff”)
Sends a message to the system caretaker print file.
Arguments:
A = message text
B = message group (DEFAULTS to /.APPL)
C = OPTIONAL end of message text, e.g., sign-on errors
; select a date
; A = relative window row
; B = optional title
; C = if TRUE, leave cursor OFF when done
Pops up a date and time selection scrolling window. Returns Z.date.clinical and time when a date and time are selected in |0 and |1.
Example call: %Z.scroll.date(“”)
Arguments:
A Q(Choice1,Choice2,etc…)
B Q(top left row,top left column,# rows,#columns)
C title
Example Call: %Z.scroll.menu(Q(“Happy Meal”,”Chicken Shapes”,”Hot Dogs”,”French Fries “,”Mac & Cheese”),Q(10,10,5,20),”Title”)
Returns
|0 number of selection in queued list
|1 key stroke used to select (13 is C/R 18 is Rt Arrow, 147 is file)
Exit or Escape return nil in |0.
Example call: %Z.scroll.date(“”)
This procedure is used to set up a text file for editing by the text editor
kernal (Z.text.ed.kern).
A text box of any size can be defined as long as it is no more than 79 characters wide, and it’s bottom margin is less than 24. Although the kernal will accept a larger edit area (92 by 28), this particular shell has been set up with these maximums. This procedure establishes the temporary RAF which is used by the kernal. It also defines a special function program and data for this program in special nodes in the RAF.
Arguments:
A – Nameof (^) textfile
B – Top margin. Defaults to 3. (A screen-editor message displays)
C – Bottom margin. Defaults to 23.
D – Line length. Defaults to 79. Text lines that exceed this
length are reformatted by; 1st – stripping trailing spaces,
2nd – stripping leading spaces, 3rd – breaking line into
two or more lines.
E – Left margin. Defaults to 0. When added to line length
cannnot exceed 79.
F – Has value “D” if display only, otherwise display and edit
is assumed. If F=”Q”, then copy queue will be preserved from
last use of editor.
G,H – Name of DPM and element where additional on-line help
documentation is defined.
I – (optional) COLOR only; override special editor functions:
Q(special.func.pgm,D(key.ascii,key.ascii,…),argument)
I|2 is saved in !Z.ARG for use by program in I|0.
Defaults to Q(Z.text.ed.spec.fn.keys,D(148,149,164),””)
J – (optional). Indicates the maximum number of lines for that file
Returns: 1 if text has been edited, otherwise nil.
Message should be in /.WO
;If /.Z.MACRO.OUT is non-nil, # is closed, and ! is open, output goes to !
;
;If /Z.SCHED.LOG is non-nil (# will be closed), procedure is being called from a
; background “scheduled report”. This variable contains the address of a structure
; in which messages may be logged. Any yes/no or @W.err messages are considered an
; error condition and termination of job is indicated by setting /Z.SCHED.ERR to 1.
;
;A=0, field relative (centered, 2 lines below, highlight field)
; =1, centered and 2 rows below current window
; =2, centered and 2 rows below current window – nil response allowed
;B=1, ring bell
; 0, don’t
;C=0 or nil, don’t prompt for anything (@W.err, @W.return)
; =1 prompt for Y/N with no default (@W.yes.no)
; =2 prompt for Y/N with ‘Y’ default (@W.yes.no.y)
; =3 prompt for Y/N with ‘N’ default (@W.yes.no.n)
; =4 prompt for CHOICE (@W.choice)
; =5 @W.display
; COLOR only. Copied from %Z.w.macro, but for MULTI-LINE windows.
; Expects lines of text in: /.WO[q] = text
; /.WO = max line length of text.
; = 0 or “” to close display-only window.
; = . to have program calculate this.
; /.WD = default if C=4 or C=6
; /.WC = choice string if C=4, check code if C=6 [use F as user’s response]
;
; EXAMPLES:
; @W.err SCREEN = %Z.wm.macro(0,1)
; @W.err PROCEDURE LOGIC = %Z.wm.macro(1,1)
; @W.return = %Z.wm.macro(1,0,0)
; @W.yes.no = %Z.wm.macro(1,0,1) ,2) or ,3)
; @W.choice = %Z.wm.macro(1,0,4) [set up /.WD and /.WC as noted above]
; @W.display = %Z.wm.macro(1,0,5) [call with /.WO=0 or nil to close]
; Ask & check response (new) = %Z.wm.macro(1,0,6) [set up /.WD and /.WC as noted above]
;
; A=0, field relative (centered, 2 lines below, highlight field)
; =1, centered and 2 rows below current window
; =2, centered and 2 rows below current window – nil response allowed
; B=1, ring bell
; 0, don’t
; C=nil or 0, don’t prompt for anything (@W.err, @W.return)
; =1 prompt for Y/N with no default (@W.yes.no)
; =2 prompt for Y/N with ‘Y’ default (@W.yes.no.y)
; =3 prompt for Y/N with ‘N’ default (@W.yes.no.n)
; =4 prompt for CHOICE (@W.choice)
; =5 @W.display;
; =6 prompt and check response with V(/.WC)
; D=response length if C=6
; E=non-nil if nil response ok.
Note: The standard MEDITECH front ends (FE and FEC) will do a %Z.ws.hd(“”) at every prompt, so you cannot use this program from the standard MT front ends.