source: FOIAVistA/tag/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/XLFMSMT2.m@ 1540

Last change on this file since 1540 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.7 KB
Line 
1XLFMSMT2 ;SLC,SF/MH,RWF - functions for conversion in measurment ;12/12/94 12:18
2 ;;8.0;KERNEL;;Jul 10, 1995
3WT I FROM=TO Q VAL_" "_TO
4 ; common metric unit is kilograms KG
5 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"
6 ; common english unit is pound LB
7 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"
8 ; the result of the above 2 IF statments will result in VAL being
9 ; converted to kilograms or pounds depending on the value of FROM
10 ;
11 ; VAL in metric and will convert to metric VAL in KG
12 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
13 ;
14 ; VAL in U.S. and will convert to U.S. VAL in LB
15 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
16 ;
17 ; VAL in U.S. and will convert to metric VAL in LB
18 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
19 ;
20 ; VAL in metric and will convert to U.S. VAL in KG
21 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
22 ;
23LN ;
24 ; -***- common metric unit is centimeters CM -***-
25 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"
26 ;
27 ; -***- common U.S. unit is inches IN -***-
28 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"
29 ;
30 ; VAL in metric (cm) and will convert to metric
31 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
32 ;
33 ; VAL in U.S. and will convert to U.S.
34 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
35 ;
36 ; VAL in U.S. and will convert to metric
37 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
38 ;
39 ; VAL in metric (cm) and will convert to U.S.
40 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
41 ;
42VOL ; common metric unit = mililiter ML
43 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"
44 ; common U.S. unit = cubic inches CI
45 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"
46 ;
47 ; VAL in U.S. (cubic inches) and will convert to metric
48 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
49 ;
50 ; VAL in metric (mililiter) and will convert to U.S.
51 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
52 ;
53 ; VAL in metric (mililiter) and will convert to metric
54 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
55 ;
56 ; VAL in U.S. (cubic inches) and will convert to U.S.
57 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
58 Q "ERROR"
59 ;
60 ;
61FORMAT(VAL) ;
62 N % S %=3 I VAL<1 S %=$L(+VAL),%=$S(%>10:10,1:%)
63 Q +$FN(VAL,"",%)
64 ;
65UPCASE(VAL) ;
66 Q $TR(VAL,"zxcvbnmlkjhgfdsaqwertyuiop","ZXCVBNMLKJHGFDSAQWERTYUIOP")
Note: See TracBrowser for help on using the repository browser.