[613] | 1 | LRAFUNC7 ;SLC/MRH/FHS - FUNCTION CALL CONVERSION IN MEASUREMENT A5AFUNC7
|
---|
| 2 | ;;5.2;LAB SERVICE;;Sep 27, 1994
|
---|
| 3 | N I,X
|
---|
| 4 | W !!,"Routine: "_$T(+0),! F I=8:1 S X=$T(LRAFUNC7+I) Q:'$L(X) I X[";;" W !,X
|
---|
| 5 | W !!
|
---|
| 6 | Q
|
---|
| 7 | ;
|
---|
| 8 | CAP(X,Y,Z) ;; convert metric capacity to U.S. capacity and visa versa
|
---|
| 9 | ;; Call by value
|
---|
| 10 | ;; Mililiters to cubic inches or quarts or ounces
|
---|
| 11 | ;; returns equivilent value with units
|
---|
| 12 | ;; X must contain a positive numeric value
|
---|
| 13 | ;; Y must contain the units of measure of X
|
---|
| 14 | ;; Z must contain the units of measure to convert X to
|
---|
| 15 | ;; eg. S X=$$CAP(12,"CF","ML") will return a value of X (12)
|
---|
| 16 | ;; in mililiters
|
---|
| 17 | ;; Valid units in either uppercase or lowercase are:
|
---|
| 18 | ;; kl = kiloliter
|
---|
| 19 | ;; hl = hectoliter
|
---|
| 20 | ;; dal = dekaliter
|
---|
| 21 | ;; l = liters
|
---|
| 22 | ;; dl = deciliter
|
---|
| 23 | ;; cl = centiliter
|
---|
| 24 | ;; ml = mililiter
|
---|
| 25 | ;;
|
---|
| 26 | ;; cf = feet
|
---|
| 27 | ;; ci = inch
|
---|
| 28 | ;; gal = gallon
|
---|
| 29 | ;; qt = quart
|
---|
| 30 | ;; pt = pint
|
---|
| 31 | ;; c = cup
|
---|
| 32 | ;; oz = ounce
|
---|
| 33 | ;
|
---|
| 34 | N CKY,CKZ
|
---|
| 35 | I '$G(X) Q 0
|
---|
| 36 | I X[".",$L(X)>19 Q 0_" ILLEGAL NUMBER"
|
---|
| 37 | I $L(X)>18 Q 0_" ILLEGAL NUMBER"
|
---|
| 38 | S Y=$$UPCASE(Y),Z=$$UPCASE(Z)
|
---|
| 39 | Q:'$L(Y)!('$L(Z)) 0
|
---|
| 40 | S CKY=U_Y_U
|
---|
| 41 | I "^KL^HL^DAL^L^DL^CL^ML^CF^CI^GAL^QT^PT^C^OZ^"'[CKY Q "ERROR"
|
---|
| 42 | S CKZ=U_Z_U
|
---|
| 43 | I "^KL^HL^DAL^L^DL^CL^ML^CF^CI^GAL^QT^PT^C^OZ^"'[CKZ Q "ERROR"
|
---|
| 44 | ; quit with no conversion
|
---|
| 45 | I Y=Z Q X_" "_Z
|
---|
| 46 | ;
|
---|
| 47 | ; common metric unit = mililiter ML
|
---|
| 48 | I $P("^KL^1^HL^1^DAL^1^L^1^DL^1^CL^1^ML^1^",CKY,2) S X=X*+$P("^KL^1000000^HL^100000^DAL^10000^L^1000^DL^100^CL^10^ML^1",CKY,2)_"M"
|
---|
| 49 | ; common U.S. unit = cubic inches CI
|
---|
| 50 | I $P("^CF^1^CI^1^GAL^1^QT^1^PT^1^C^1^OZ^1",CKY,2) S X=X*+$P("^CF^1728^CI^1^GAL^231^QT^57.75^PT^28.875^C^14.4375^OZ^1.805",CKY,2)_"U"
|
---|
| 51 | ;
|
---|
| 52 | ; X in U.S. (cubic inches) and will convert to metric
|
---|
| 53 | I X["U",$P("^KL^1^HL^1^DAL^1^L^1^DL^1^CL^1^ML^1^",CKZ,2) S X=X*+$P("^KL^.000016387^HL^.00016387^DAL^.0016387^L^.016387^DL^.16387^CL^1.6387^ML^16.387^",CKZ,2) Q $$FORMAT(X)_" "_Z
|
---|
| 54 | ;
|
---|
| 55 | ; X in metric (mililiter) and will convert to U.S.
|
---|
| 56 | I X["M",$P("^CF^1^CI^1^GAL^1^QT^1^PT^1^C^1^OZ^1",CKZ,2) S X=X*+$P("^CF^.00003531^CI^.0610^GAL^.0002642^QT^.0010568^PT^.0021136^C^.0042272^OZ^.033818^",CKZ,2) Q $$FORMAT(X)_" "_Z
|
---|
| 57 | ;
|
---|
| 58 | ; X in metric (mililiter) and will convert to metric
|
---|
| 59 | I X["M",$P("^KL^1^HL^1^DAL^1^L^1^CL^1^DL^1^ML^1",CKZ,2) S X=X*+$P("^KL^1000000^HL^100000^DAL^10000^L^1000^CL^100^CL^10^ML^1",CKZ,2) Q $$FORMAT(X)_" "_Z
|
---|
| 60 | ;
|
---|
| 61 | ; X in U.S. (cubic inches) and will convert to U.S.
|
---|
| 62 | I X["U",$P("^CF^1^CI^1^GAL^1^QT^1^PT^1^C^1^OZ^1",CKZ,2) S X=X*+$P("^CF^.0005787^CI^1^GAL^.004329^QT^.017316^PT^.034632^C^.069264^OZ^.554017",CKZ,2) Q $$FORMAT(X)_" "_Z
|
---|
| 63 | Q "ERROR"
|
---|
| 64 | ;
|
---|
| 65 | FORMAT(X) ;
|
---|
| 66 | S X=$S(X>.9:$FN(X,"",3),1:$FN(X,"",4))
|
---|
| 67 | Q $S($P(X,".",2):X,1:$FN(X,"",0))
|
---|
| 68 | ;
|
---|
| 69 | UPCASE(X) ;
|
---|
| 70 | Q $TR(X,"zxcvbnmlkjhgfdsaqwertyuiop","ZXCVBNMLKJHGFDSAQWERTYUIOP")
|
---|