source: WorldVistAEHR/trunk/r/VA_FILEMAN-ARJT-DI-DD-DM-DT-%DT-%RCR/DIR3.m@ 1211

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

initial load of WorldVistAEHR

File size: 3.5 KB
RevLine 
[613]1DIR3 ;SFISC/DCM,RDS-READER-MAID (PROCESS RANGE/LIST) ;12:19 PM 8 Feb 2000
2 ;;22.0;VA FileMan;**30**;Mar 30, 1999
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;12364;2913754;3396;
5 ;
6L ; LIST OR RANGE
7 N %I,%I1,%I2,%BA,%X,%C,%1,%2,%3,%4,%
8 K ^TMP($J,"DIR")
9 S Y(0)="",%C=0,%I1=1,%I2=2,%BA=$S($D(DIR("S")):DIR("S"),1:"I 1")
10 F %I=1:1 S %X=$P(X,",",%I) Q:%E!'$L($P(X,",",%I,999)) D
11 . I %X'?.".".N.".".N."-".N.".".N S %E=4 Q
12 . I $E(%X)="-" S %E=3 Q
13 . I $L($P(%X,"."))>24 S %E=1 Q
14 . I '%B3,$L($P(+%X,".",2)) S %E=2
15 I '%E D @$S(%A["C"&'$D(DIR("S")):"LC",%A["C"&$D(DIR("S")):"LL",1:"LL")
16 I '%E,Y(%C)="" S %E=4
17 I $G(%E),'%N D
18 . S %W=$P($T(@(%E)),";;",2)
19 . I %W[";",%E=1 S %W=$P(%W,";")_+%B1_$P(%W,";",2)_" "_%B2
20 . I %W[";",%E=2 S %W=$P(%W,";")_+%B3_$P(%W,";",2)_$S(%B3>1:"s",1:"")
21 I $G(%E) K Y S Y="" Q ; Prevent Erronious Data
22 S Y=Y(0)
23 Q
24 ;
25LL ; handle uncompressed lists & screened compressed lists
26 I %B3 D LCD
27 F %I=1:1 S %X=$P(X,",",%I) Q:%E!'$L($P(X,",",%I,999)) D L0
28 Q:%E
29 I %A["C" D LIST
30 Q
31L0 N %J
32 D LCK
33 Q:%E I %X?.N!(%X?1N.".".N) S %J=+%X G L1
34 I %B3 D Q
35 . S %J=+%X D L1 S $P(%X,"-")=%X+%I1
36 . F %J=+%X:%I1:$P(%X,"-",2) D L1
37 F %J=$P(%X,"-"):1:$P(%X,"-",2) D L1
38 Q
39L1 I %A["C" D Q
40 . S Y=%J X %BA Q:'$T
41 . S (%1,%2)=%J
42 . D LC1
43 I $L(Y(%C)_%J)>220 S %C=%C+1,Y(%C)=""
44 F %=0:1:%C I ","_Y(%)_","[(","_%J_",") S %=-1 Q
45 I %'<0 S Y=%J X %BA S:$T Y(%C)=Y(%C)_%J_","
46 Q
47 ;
48 ; check one list element
49 ;%A = $P#1 "^" of DIR(0)
50 ;%B = $P#2 "^" of DIR(0)
51 ;%B1 = $P#1 ":" Low Value
52 ;%B2 = $P#2 ":" High Value
53 ;%B3 = $P#3 ":" Number of Decimals; Null If Undefed
54 ;%X = Range Entered, i.e. 2-4
55 ;% = End of Range Entered i.e. 4
56LCK I %X["-" D Q
57 . N % S %=$P(%X,"-",2) I '% S %E=4 Q
58 . I %A'["I",%<+%X S %E=4 Q
59 . I %A["I",%<+%X N %3 S %3=%,%=+%X,$P(%X,"-",2)=%,$P(%X,"-")=%3
60 . I %<%B1!(+%X>%B2) S %E=1 Q
61 . I +%X<%B1 S $P(%X,"-")=%B1
62 . I +%>%B2 S %E=1 Q
63 . I $L($P(+%X,".",2))>%B3!($L($P(+%,".",2))>%B3) S %E=2 Q
64 I +%X<%B1!(+%X>%B2) S %E=1 Q
65 I %B3,$L($P(+%X,".",2))>%B3 S %E=2 Q
66 Q
67 ;
68LCD ; determine increment size for ranges (handle decimals)
69 S %1="." I %B3>1 F %=1:1:%B3-1 S %1=%1_"0"
70 S %I2=%1_2,%I1=%1_1
71 Q
72 ;
73LC ; handle unscreened compressed lists (no DIR("S"))
74 ; LC to LIST checks the user's list in X, building ^TMP($J,"DIR")
75 I %B3 D LCD
76 F %=1:1:$L(X,",") S %1=$P(X,",",%) D LC0 Q:%E
77 Q:'$D(^TMP($J,"DIR"))
78LIST ; transfer output list from ^TMP($J,"DIR") to Y
79 S %1="",Y(%C)="" D
80 . F S %1=$O(^TMP($J,"DIR",%1)) Q:%1="" D
81 . . S:$D(^(%1))=1 Y(%C)=Y(%C)_%1_","
82 . . S:$L(Y(%C))>220 %C=%C+1,Y(%C)=""
83 . . I $D(^(%1))=10 S Y(%C)=Y(%C)_$O(^TMP($J,"DIR",%1,""))_"-"_%1_","
84 I Y(%C)="" D Q:%E
85 . I %C=0 S %E=4
86 . E K Y(%C) S %C=%C-1
87 K ^TMP($J,"DIR")
88 Q
89LC0 ; check one list element, calls LC1 to put it in ^TMP($J,"DIR")
90 S %E=0,%X=%1 D LCK Q:%E S (%1,%2)=%X
91 I %1["-" S %1=+%1,%2=+$P(%2,"-",2)
92 S %1=+%1,%2=+%2
93 D LC1
94 Q
95LC1 ; modify ^TMP($J,"DIR") to incorporate a list element, handle overlap
96 S %3=$O(^TMP($J,"DIR",%1-%I2)) I %3]"",%3<%2 D
97 . I $D(^(%3))=1,%1-%I1=%3 S %1=%3
98 . I $D(^(%3))>9 S %4=$O(^(%3,"")) I %4<%1 S %1=%4
99 S %3=$O(^TMP($J,"DIR",%2-$S(%B3:%I1,1:1))) I %3]"" D
100 . I $D(^(%3))=1,%2+%I1=%3 S %2=%3
101 . I $D(^(%3))>9 S %4=$O(^(%3,"")) S:%4'>(%2+%I1) %2=%3 S:%4<%1 %1=%4
102 S %3=%1-%I1 F S %3=$O(^TMP($J,"DIR",%3)) Q:%3=""!(%3>%2) K ^(%3)
103 I %1'=%2 S ^TMP($J,"DIR",%2,%1)=""
104 E S ^TMP($J,"DIR",%1)=""
105 Q
106 ;
1071 ;;Response should be no less than ; and no greater than
1082 ;;Response must be no more than ; decimal digit
1093 ;;Response must be a positive number
1104 ;;Invalid number or range
Note: See TracBrowser for help on using the repository browser.