XLFMSMT2 ;SLC,SF/MH,RWF - functions for conversion in measurment ;12/12/94 12:18 [ 04/02/2003 8:29 AM ]
;;8.0;KERNEL;**1002,1003,1004,1005,1007**;APR 1, 2003
;;8.0;KERNEL;;Jul 10, 1995
WT I FROM=TO Q VAL_" "_TO
; common metric unit is kilograms KG
I $P("^T^1^KG^1^G^1^MG^1",CKY,2) S VAL=VAL*$P("^T^1000^KG^1^G^.001^MG^.000001",CKY,2) S VAL=VAL_"M"
; common english unit is pound LB
I $P("^TN^1^LB^1^OZ^1^GR^1",CKY,2) S VAL=VAL*$P("^TN^2000^LB^1^OZ^.0625^GR^.0001302083",CKY,2) S VAL=VAL_"U"
; the result of the above 2 IF statments will result in VAL being
; converted to kilograms or pounds depending on the value of FROM
;
; VAL in metric and will convert to metric VAL in KG
I VAL["M",$P("^T^1^KG^1^G^1^MG^1",CKZ,2) S VAL=VAL*$P("^T^.00001^KG^1^G^1000^MG^10000",CKZ,2) Q $$FORMAT(VAL)_" "_TO
;
; VAL in U.S. and will convert to U.S. VAL in LB
I VAL["U",$P("^TN^1^LB^1^OZ^1^GR^1",CKZ,2) S VAL=VAL*$P("^TN^.0005^LB^1^OZ^16^GR^7680",CKZ,2) Q $$FORMAT(VAL)_" "_TO
;
; VAL in U.S. and will convert to metric VAL in LB
I VAL["U",$P("^T^1^KG^1^G^1^MG^1",CKZ,2) S VAL=VAL*$P("^T^.000454^KG^.454^G^454^MG^454000",CKZ,2) Q $$FORMAT(VAL)_" "_TO
;
; VAL in metric and will convert to U.S. VAL in KG
I VAL["M",$P("^TN^1^LB^1^OZ^1^GR^1",CKZ,2) S VAL=VAL*$P("^TN^.0011023^LB^2.2046^OZ^35.2736^GR^154300",CKZ,2) Q $$FORMAT(VAL)_" "_TO
;
LN ;
; -***- common metric unit is centimeters CM -***-
I $P("^KM^1^M^1^CM^1^MM^1",CKY,2) S VAL=VAL*+$P("^KM^100000^M^100^CM^1^MM^.1",CKY,2)_"M"
;
; -***- common U.S. unit is inches IN -***-
I $P("^MI^1^YD^1^FT^1^IN^1",CKY,2) S VAL=VAL*$P("^MI^63360^YD^36^FT^12^IN^1",CKY,2)_"U"
;
; VAL in metric (cm) and will convert to metric
I VAL["M",$P("^KM^1^M^1^CM^1^MM^1",CKZ,2) S VAL=VAL*$P("^KM^.001^M^.01^CM^1^MM^10^",CKZ,2) Q $$FORMAT(VAL)_" "_TO
;
; VAL in U.S. and will convert to U.S.
I VAL["U",$P("^MI^1^YD^1^FT^1^IN^1",CKZ,2) S VAL=VAL*$P("^MI^.0000157085^YD^.0277777778^FT^.0833333333^IN^1",CKZ,2) Q $$FORMAT(VAL)_" "_TO
;
; VAL in U.S. and will convert to metric
I VAL["U",$P("^KM^1^M^1^CM^1^MM^1",CKZ,2) S VAL=VAL*$P("^KM^.0000254^M^.0254^CM^2.540^MM^25.4",CKZ,2) Q $$FORMAT(VAL)_" "_TO
;
; VAL in metric (cm) and will convert to U.S.
I VAL["M",$P("^MI^1^YD^1^FT^1^IN^1",CKZ,2) S VAL=VAL*$P("^MI^.0000062^YD^.010936^FT^.032808^IN^.393696",CKZ,2) Q $$FORMAT(VAL)_" "_TO
;
VOL ; common metric unit = mililiter ML
I $P("^KL^1^HL^1^DAL^1^L^1^DL^1^CL^1^ML^1^",CKY,2) S VAL=VAL*+$P("^KL^1000000^HL^100000^DAL^10000^L^1000^DL^100^CL^10^ML^1",CKY,2)_"M"
; common U.S. unit = cubic inches CI
I $P("^CF^1^CI^1^GAL^1^QT^1^PT^1^C^1^OZ^1",CKY,2) S VAL=VAL*+$P("^CF^1728^CI^1^GAL^231^QT^57.75^PT^28.875^C^14.4375^OZ^1.805",CKY,2)_"U"
;
; VAL in U.S. (cubic inches) and will convert to metric
I VAL["U",$P("^KL^1^HL^1^DAL^1^L^1^DL^1^CL^1^ML^1^",CKZ,2) S VAL=VAL*+$P("^KL^.000016387^HL^.00016387^DAL^.0016387^L^.016387^DL^.16387^CL^1.6387^ML^16.387^",CKZ,2) Q $$FORMAT(VAL)_" "_TO
;
; VAL in metric (mililiter) and will convert to U.S.
I VAL["M",$P("^CF^1^CI^1^GAL^1^QT^1^PT^1^C^1^OZ^1",CKZ,2) S VAL=VAL*+$P("^CF^.00003531^CI^.0610^GAL^.0002642^QT^.0010568^PT^.0021136^C^.0042272^OZ^.033818^",CKZ,2) Q $$FORMAT(VAL)_" "_TO
;
; VAL in metric (mililiter) and will convert to metric
I VAL["M",$P("^KL^1^HL^1^DAL^1^L^1^CL^1^DL^1^ML^1",CKZ,2) S VAL=VAL*+$P("^KL^.000001^HL^.00001^DAL^.0001^L^.001^DL^.01^CL^.1^ML^1",CKZ,2) Q $$FORMAT(VAL)_" "_TO
;
; VAL in U.S. (cubic inches) and will convert to U.S.
I VAL["U",$P("^CF^1^CI^1^GAL^1^QT^1^PT^1^C^1^OZ^1",CKZ,2) S VAL=VAL*+$P("^CF^.0005787^CI^1^GAL^.004329^QT^.017316^PT^.034632^C^.069264^OZ^.554017",CKZ,2) Q $$FORMAT(VAL)_" "_TO
Q "ERROR"
;
;
FORMAT(VAL) ;
N % S %=3 I VAL<1 S %=$L(+VAL),%=$S(%>10:10,1:%)
Q +$FN(VAL,"",%)
;
UPCASE(VAL) ;
Q $TR(VAL,"zxcvbnmlkjhgfdsaqwertyuiop","ZXCVBNMLKJHGFDSAQWERTYUIOP")
XLFMSMT2 ;SLC,SF/MH,RWF - functions for conversion in measurment ;12/12/94 12:18 [ 04/02/2003 8:29 AM ]
+1 ;;8.0;KERNEL;**1002,1003,1004,1005,1007**;APR 1, 2003
+2 ;;8.0;KERNEL;;Jul 10, 1995
WT IF FROM=TO
QUIT VAL_" "_TO
+1 ; common metric unit is kilograms KG
+2 IF $PIECE("^T^1^KG^1^G^1^MG^1",CKY,2)
SET VAL=VAL*$PIECE("^T^1000^KG^1^G^.001^MG^.000001",CKY,2)
SET VAL=VAL_"M"
+3 ; common english unit is pound LB
+4 IF $PIECE("^TN^1^LB^1^OZ^1^GR^1",CKY,2)
SET VAL=VAL*$PIECE("^TN^2000^LB^1^OZ^.0625^GR^.0001302083",CKY,2)
SET VAL=VAL_"U"
+5 ; the result of the above 2 IF statments will result in VAL being
+6 ; converted to kilograms or pounds depending on the value of FROM
+7 ;
+8 ; VAL in metric and will convert to metric VAL in KG
+9 IF VAL["M"
IF $PIECE("^T^1^KG^1^G^1^MG^1",CKZ,2)
SET VAL=VAL*$PIECE("^T^.00001^KG^1^G^1000^MG^10000",CKZ,2)
QUIT $$FORMAT(VAL)_" "_TO
+10 ;
+11 ; VAL in U.S. and will convert to U.S. VAL in LB
+12 IF VAL["U"
IF $PIECE("^TN^1^LB^1^OZ^1^GR^1",CKZ,2)
SET VAL=VAL*$PIECE("^TN^.0005^LB^1^OZ^16^GR^7680",CKZ,2)
QUIT $$FORMAT(VAL)_" "_TO
+13 ;
+14 ; VAL in U.S. and will convert to metric VAL in LB
+15 IF VAL["U"
IF $PIECE("^T^1^KG^1^G^1^MG^1",CKZ,2)
SET VAL=VAL*$PIECE("^T^.000454^KG^.454^G^454^MG^454000",CKZ,2)
QUIT $$FORMAT(VAL)_" "_TO
+16 ;
+17 ; VAL in metric and will convert to U.S. VAL in KG
+18 IF VAL["M"
IF $PIECE("^TN^1^LB^1^OZ^1^GR^1",CKZ,2)
SET VAL=VAL*$PIECE("^TN^.0011023^LB^2.2046^OZ^35.2736^GR^154300",CKZ,2)
QUIT $$FORMAT(VAL)_" "_TO
+19 ;
LN ;
+1 ; -***- common metric unit is centimeters CM -***-
+2 IF $PIECE("^KM^1^M^1^CM^1^MM^1",CKY,2)
SET VAL=VAL*+$PIECE("^KM^100000^M^100^CM^1^MM^.1",CKY,2)_"M"
+3 ;
+4 ; -***- common U.S. unit is inches IN -***-
+5 IF $PIECE("^MI^1^YD^1^FT^1^IN^1",CKY,2)
SET VAL=VAL*$PIECE("^MI^63360^YD^36^FT^12^IN^1",CKY,2)_"U"
+6 ;
+7 ; VAL in metric (cm) and will convert to metric
+8 IF VAL["M"
IF $PIECE("^KM^1^M^1^CM^1^MM^1",CKZ,2)
SET VAL=VAL*$PIECE("^KM^.001^M^.01^CM^1^MM^10^",CKZ,2)
QUIT $$FORMAT(VAL)_" "_TO
+9 ;
+10 ; VAL in U.S. and will convert to U.S.
+11 IF VAL["U"
IF $PIECE("^MI^1^YD^1^FT^1^IN^1",CKZ,2)
SET VAL=VAL*$PIECE("^MI^.0000157085^YD^.0277777778^FT^.0833333333^IN^1",CKZ,2)
QUIT $$FORMAT(VAL)_" "_TO
+12 ;
+13 ; VAL in U.S. and will convert to metric
+14 IF VAL["U"
IF $PIECE("^KM^1^M^1^CM^1^MM^1",CKZ,2)
SET VAL=VAL*$PIECE("^KM^.0000254^M^.0254^CM^2.540^MM^25.4",CKZ,2)
QUIT $$FORMAT(VAL)_" "_TO
+15 ;
+16 ; VAL in metric (cm) and will convert to U.S.
+17 IF VAL["M"
IF $PIECE("^MI^1^YD^1^FT^1^IN^1",CKZ,2)
SET VAL=VAL*$PIECE("^MI^.0000062^YD^.010936^FT^.032808^IN^.393696",CKZ,2)
QUIT $$FORMAT(VAL)_" "_TO
+18 ;
VOL ; common metric unit = mililiter ML
+1 IF $PIECE("^KL^1^HL^1^DAL^1^L^1^DL^1^CL^1^ML^1^",CKY,2)
SET VAL=VAL*+$PIECE("^KL^1000000^HL^100000^DAL^10000^L^1000^DL^100^CL^10^ML^1",CKY,2)_"M"
+2 ; common U.S. unit = cubic inches CI
+3 IF $PIECE("^CF^1^CI^1^GAL^1^QT^1^PT^1^C^1^OZ^1",CKY,2)
SET VAL=VAL*+$PIECE("^CF^1728^CI^1^GAL^231^QT^57.75^PT^28.875^C^14.4375^OZ^1.805",CKY,2)_"U"
+4 ;
+5 ; VAL in U.S. (cubic inches) and will convert to metric
+6 IF VAL["U"
IF $PIECE("^KL^1^HL^1^DAL^1^L^1^DL^1^CL^1^ML^1^",CKZ,2)
SET VAL=VAL*+$PIECE("^KL^.000016387^HL^.00016387^DAL^.0016387^L^.016387^DL^.16387^CL^1.6387^ML^16.387^",CKZ,2)
QUIT $$FORMAT(VAL)_" "_TO
+7 ;
+8 ; VAL in metric (mililiter) and will convert to U.S.
+9 IF VAL["M"
IF $PIECE("^CF^1^CI^1^GAL^1^QT^1^PT^1^C^1^OZ^1",CKZ,2)
SET VAL=VAL*+$PIECE("^CF^.00003531^CI^.0610^GAL^.0002642^QT^.0010568^PT^.0021136^C^.0042272^OZ^.033818^",CKZ,2)
QUIT $$FORMAT(VAL)_" "_TO
+10 ;
+11 ; VAL in metric (mililiter) and will convert to metric
+12 IF VAL["M"
IF $PIECE("^KL^1^HL^1^DAL^1^L^1^CL^1^DL^1^ML^1",CKZ,2)
SET VAL=VAL*+$PIECE("^KL^.000001^HL^.00001^DAL^.0001^L^.001^DL^.01^CL^.1^ML^1",CKZ,2)
QUIT $$FORMAT(VAL)_" "_TO
+13 ;
+14 ; VAL in U.S. (cubic inches) and will convert to U.S.
+15 IF VAL["U"
IF $PIECE("^CF^1^CI^1^GAL^1^QT^1^PT^1^C^1^OZ^1",CKZ,2)
SET VAL=VAL*+$PIECE("^CF^.0005787^CI^1^GAL^.004329^QT^.017316^PT^.034632^C^.069264^OZ^.554017",CKZ,2)
QUIT $$FORMAT(VAL)_" "_TO
+16 QUIT "ERROR"
+17 ;
+18 ;
FORMAT(VAL) ;
+1 NEW %
SET %=3
IF VAL<1
SET %=$LENGTH(+VAL)
SET %=$SELECT(%>10:10,1:%)
+2 QUIT +$FNUMBER(VAL,"",%)
+3 ;
UPCASE(VAL) ;
+1 QUIT $TRANSLATE(VAL,"zxcvbnmlkjhgfdsaqwertyuiop","ZXCVBNMLKJHGFDSAQWERTYUIOP")