source: WorldVistAEHR/trunk/r/RADIOLOGY_NUCLEAR_MEDICINE-RA/RASELCT.m@ 1154

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

initial load of WorldVistAEHR

File size: 7.1 KB
Line 
1RASELCT ;HISC/DAD-Generic file entry selector ;7/1/98 15:48
2 ;;5.0;Radiology/Nuclear Medicine;**83**;Mar 16, 1998;Build 4
3 ;
4 ;*** SELECTS A GROUP OF RECORDS FROM A FILE ***
5 ;
6 ;REQUIRES:
7 ; RADIC = FILE NUMBER OR GLOBAL ROOT
8 ; RADIC(0) = DIC(0) STRING
9 ; RAUTIL = NODE TO STORE DATA UNDER IN ^TMP($J,RAUTIL,
10 ;
11 ;OPTIONAL:
12 ; RADIC("A") = DIC("A") STRING
13 ; RADIC("B") = DIC("B") STRING
14 ; RADIC("S") = DIC("S") STRING
15 ; RADIC("W") = DIC("W") STRING
16 ; RAARRY = LOCAL ARRAY TO STORE DATA IN
17 ; RAFLD = field to sort by if valid data to be stored as
18 ; ^TMP($J,RAUTIL,external value of RAFLD,IEN)=""
19 ; RAFLD must reside on the zero (0) node to be valid!
20 ; RAINPUT = ONE/MANY/ALL DISTINCTION (1=ALL, 0=ONE/MANY)
21 ;
22 ;RETURNS:
23 ; 1) RAQUIT = $S(UP_ARROW_OUT:1 , NOTHING_SELECTED:1 , 1:0)
24 ; 2) ^TMP($J,RAUTIL,EXTERNAL_.01_FIELD_DATA,IEN) = ""
25 ; 3) if $D(RAFLD), ^TMP($J,RAUTIL,EXTERNAL_RAFLD_DATA,IEN) = ""
26 ;
27EN1(RADIC,RAUTIL,RAARRY,RAINPUT,RAFLD) ;
28 S RAQUIT=0 I ($D(RADIC)[0)!($D(RADIC(0))[0)!($D(RAUTIL)[0) S RAQUIT=1 G EXIT
29 I (RADIC="")!(RADIC(0)="")!(RAUTIL="") S RAQUIT=1 G EXIT
30 I $G(RAINPUT)=0 K RADIC("B")
31 D K S DIC=RADIC I DIC S (RADIC,DIC)=$S($D(^DIC(DIC,0,"GL"))#2:^("GL"),1:"") I DIC="" S RAQUIT=1 G EXIT
32 S DIC(0)=RADIC(0),DIC(0)=$TR(DIC(0),"AL") S:DIC(0)'["Z" DIC(0)=DIC(0)_"Z" S RADIC(0)=DIC(0)
33 D DO^DIC1 S RAFNUM=+DO(2),RAFNAME=$P(DO,"^"),RAFLD01=$P(^DD(RAFNUM,.01,0),"^"),RAFSCR=$S($D(DO("SCR"))#2:DO("SCR"),1:"") K DO
34 I $G(RAFLD)]"" S RAQUIT=$$FLD(RAFNUM,RAFLD) G:RAQUIT EXIT
35 S RACASE=$S($E(RAFLD01,($L(RAFLD01)))?1L:"s",1:"S")
36 F X="A","B","S","W" S RADIC(X)=$S($D(RADIC(X))#2:RADIC(X),1:"")
37 S:RADIC("A")="" RADIC("A")="Select "_RAFNAME_" "_RAFLD01_": "
38 S RAALL=0,RANUM=1 K ^TMP($J,RAUTIL) D HOME^%ZIS
391 D SETDIC W !!,$S(RANUM>1:"Another one (Select/De-Select): ",1:DIC("A")),$S((RANUM=1)&(RADIC("B")]""):RADIC("B")_"// ",1:"")
40 R X:DTIME S:('$T)!($E(X)="^") RAQUIT=1 G:RAQUIT EXIT S:(RANUM=1)&(X="")&(RADIC("B")]"") X=RADIC("B") G:X="" EXIT S RADSEL=$S(X?1"-"1.E:1,1:0) S:RADSEL X=$E(X,2,$L(X))
41 ; RA*5*83 require exactly 3 chars when checking for "ALL"
42 I $L(X),(($L(X)=3&("Aa"[$E(X))&("Ll"[$E(X,2))&("Ll"[$E(X,3)))!(X["*")) D ALL G EXIT:RAQUIT,1:RAALL
43 D HELP:$E(X)="?"
44 I $L($G(DIC("S")))<235 S DIC("S")=$S($G(DIC("S"))]"":DIC("S")_" ",1:"")_"I $$SEL^RASELCT(Y)"
45 D ^DIC K DIC G:+Y'>0 1
46 S RAMASK=+Y
47 I $$CHFLD(RAFNUM)["D" D
48 . N %DT,X
49 . S X=Y(0,0),%DT="ST" D ^%DT S Y(0,0)=Y
50 . Q
51 S Y=RAMASK
52 I $G(RAFLD)']"" D
53 . I 'RADSEL,'$D(^TMP($J,RAUTIL,$E(Y(0,0),1,63),+Y)) S ^(+Y)="",RANUM=RANUM+1
54 . I RADSEL,$D(^TMP($J,RAUTIL,$E(Y(0,0),1,63),+Y)) K ^(+Y) S RANUM=RANUM-$S(RANUM>0:1,1:0)
55 . Q
56 E D
57 . S RAVALUE=$$FLDSRT(RAFNUM,RAFLD) Q:RAVALUE']""
58 . I 'RADSEL,'$D(^TMP($J,RAUTIL,$E(RAVALUE,1,63),+Y)) S ^(+Y)="",RANUM=RANUM+1
59 . I RADSEL,$D(^TMP($J,RAUTIL,$E(RAVALUE,1,63),+Y)) K ^(+Y) S RANUM=RANUM-$S(RANUM>0:1,1:0)
60 . Q
61 G 1
62EXIT ;
63 I 'RAQUIT,($L($G(RAARRY))),('$D(@RAARRY)) D
64 . S %X="^TMP($J,"""_RAUTIL_""",",%Y=RAARRY_"("
65 . D %XY^%RCR
66 . Q
67 S RAQUIT=$S(RAQUIT:1,$O(^TMP($J,RAUTIL,""))="":1,1:0) K RADIC,RAUTIL
68K K %,%X,%Y,%Z,C,D0,DA,DIC,DIK,DIR,DO,RA,RAALL,RACASE,RAD0,RADSEL,RAFLD01
69 K RAFNAME,RAFNUM,RAFSCR,RALINE,RAMASK,RANUM,RAVALUE,X,Y
70 Q
71ALL ;
72 ;I $G(RAINPUT)=0 Q
73 S RAALL=1 ; Assume the user answers desires ALL entries!
74 N PAT,RAX S RAX=X N X
75 I RAX["*" D
76 . N CHAR,I,TEMP
77 . S PAT="Y'?",TEMP=""
78 . F I=1:1:$L(RAX) D
79 .. S CHAR=$E(RAX,I)
80 .. I CHAR'="*" S TEMP=TEMP_CHAR Q
81 .. D BLDPAT
82 .. Q
83 . D BLDPAT
84 . Q
85 F RAD0=0:0 S RAD0=$O(@(RADIC_"RAD0)")) Q:RAD0'>0 D AL
86 W:RANUM=1&'RADSEL " ??",$C(7)
87 Q
88AL I RAFSCR]"" D SETDIC I $D(@(RADIC_"RAD0,0)"))#2 S (D0,DA,Y)=RAD0 X RAFSCR Q:'$T
89 I RADIC("S")]"" D SETDIC I $D(@(RADIC_"RAD0,0)"))#2 S (D0,DA,Y)=RAD0 X DIC("S") Q:'$T
90 S Y=$P($G(@(RADIC_"RAD0,0)")),"^"),C=$P(^DD(RAFNUM,.01,0),"^",2)
91 Q:Y="" D Y^DIQ
92 I $$CHFLD(RAFNUM)["D" D
93 . N %DT,X
94 . S X=Y,%DT="ST" D ^%DT
95 . Q
96 I RAX["*",@PAT Q
97 I $G(RAFLD)']"" D
98 . I 'RADSEL,'$D(^TMP($J,RAUTIL,$E(Y,1,63),RAD0)) S ^(RAD0)="",RANUM=RANUM+1
99 . I RADSEL,$D(^TMP($J,RAUTIL,$E(Y,1,63),RAD0)) K ^(RAD0) S RANUM=RANUM-$S(RANUM>0:1,1:0)
100 . Q
101 E D
102 . N Y S Y=+RAD0,Y(0)=$G(@(RADIC_+Y_",0)")),Y(0,0)=$P(Y(0),"^")
103 . S RAVALUE=$$FLDSRT(RAFNUM,RAFLD) Q:RAVALUE']""
104 . I 'RADSEL,'$D(^TMP($J,RAUTIL,$E(RAVALUE,1,63),RAD0)) S ^(RAD0)="",RANUM=RANUM+1
105 . I RADSEL,$D(^TMP($J,RAUTIL,$E(RAVALUE,1,63),RAD0)) K ^(RAD0) S RANUM=RANUM-$S(RANUM>0:1,1:0)
106 . Q
107 Q
108HELP ;
109 N X S RA="Select a "_RAFNAME_" "_RAFLD01_" from the displayed list." D WRAP
110 W !?5,"To deselect a ",RAFLD01," type a minus sign (-)",!?5,"in front of it, e.g., -",RAFLD01,"."
111 I $G(RAINPUT)=1 W !?5,"To get all ",RAFLD01,"S type ALL."
112 W !?5,"Use an asterisk (*) to do a wildcard selection, e.g.,"
113 W !?5,"enter ",RAFLD01,"* to select all entries that begin"
114 W !?5,"with the text '",RAFLD01,"'. Wildcard selection is"
115 W !?5,"case sensitive."
116 G:$O(^TMP($J,RAUTIL,""))="" HLP
117SHOW S RALINE=$Y,RA="" W !!,"You have already selected:"
118 F S RA=$O(^TMP($J,RAUTIL,RA)) Q:RA=""!RAQUIT F RAD0=0:0 S RAD0=$O(^TMP($J,RAUTIL,RA,RAD0)) Q:RAD0'>0!RAQUIT D SHO
119HLP W ! S RAQUIT=0
120 Q
121SHO I $G(RAFLD)]"" S RA(0)=$P($G(@(RADIC_+RAD0_",0)")),"^")
122 E S RA(0)=RA
123 I $$CHFLD(RAFNUM)["D" D
124 . N Y
125 . S Y=RA(0) X ^DD("DD") S RA(0)=Y
126 . Q
127 I RADIC(0)["N" W !?3,RAD0,?15,RA(0)
128 E W !?3,RA(0)
129 D SETDIC I $D(DIC("W"))#2,DIC("W")]"",$D(@(RADIC_"RAD0,0)"))#2 S (D0,DA,Y)=RAD0 X DIC("W")
130 I $Y>(IOSL+RALINE-3) D PAUSE S RALINE=$Y
131 Q
132WRAP ;
133 W ! F S Y=$L($E(RA,1,IOM-20)," ") W !?5,$P(RA," ",1,Y) S RA=$P(RA," ",Y+1,999) Q:RA=""
134 Q
135PAUSE ;
136 K DIR S DIR(0)="E" D ^DIR K DIR S RAQUIT=$S(Y:0,1:1)
137 Q
138SETDIC ;
139 K DIC,DO S DIC=RADIC
140 F X="0","A","B","S","W" I RADIC(X)]"" S DIC(X)=RADIC(X)
141 D DO^DIC1
142 Q
143CHFLD(X) ;
144 N A
145 S A=$P($G(^DD(X,.01,0)),U,2)
146 Q:A'["P" A
147 F D Q:A'["P"
148 . S A=$TR(A,$TR(A,".0123456789"))
149 . S A=$$CHFLD(A)
150 . Q
151 Q A
152SEL(Y) ;
153 N %DT,DA,DIC,DIQ,DR,RAEXTRN,RAPOINT,X
154 S (RAPOINT,DA)=Y,DIC=RAFNUM,DR=.01,DIQ(0)="E",DIQ="RAEXTRN("
155 D EN^DIQ1 S RAEXTRN=$G(RAEXTRN(RAFNUM,RAPOINT,.01,"E"))
156 I $$CHFLD(RAFNUM)["D" S X=RAEXTRN,%DT="ST" D ^%DT S RAEXTRN=Y
157 S X=$D(^TMP($J,RAUTIL,RAEXTRN,RAPOINT))
158 Q $S(X#2&RADSEL:1,X[0&'RADSEL:1,1:0)
159BLDPAT ;
160 I TEMP]"" S PAT=PAT_"1"""_TEMP_""""
161 I CHAR="*",$E(PAT,$L(PAT)-1,$L(PAT))'=".E" S PAT=PAT_".E"
162 S TEMP=""
163 Q
164FLD(RAFNUM,RAFLD) ; Validate if field can be sorted on i.e, if
165 ; non-multiple and is either a pointer, free text, set of codes,
166 ; numeric or a date/time field.
167 ; 'RAFNUM' = File # 'RAFLD' = Field #
168 ; returns RAPASS: 0 if valid, else 1
169 Q:RAFLD=.01 1 ; .01 field is not valid!
170 Q:'($D(^DD(RAFNUM,RAFLD,0))#2) 1 ; field does not exist
171 N RA,RAPASS S RA(0)=$G(^DD(RAFNUM,RAFLD,0)),RA(2)=$P(RA(0),"^",2)
172 S RA(4)=$P(RA(0),"^",4)
173 Q:+RA(2)>0&($D(^DD(+RA(2),.01,0))) 1 ; field is a multiple, not valid
174 Q:RA(4)'["0;" 1 ; field does not reside on the 0 node, not valid
175 S RAPASS=1 ; set initially to not valid
176 F RA="D","F","N","P","S" S:RA(2)[RA RAPASS=0 Q:'RAPASS
177 Q RAPASS
178FLDSRT(RAFNUM,RAFLD) ; Converts the internal value to the external value
179 ; for sets of codes & pointers.
180 ; 'RAFNUM' = File # 'RAFLD' = Field #
181 ; 'RAPCE' = piece position on 0 node
182 N RAPCE S RAPCE=$P($P($G(^DD(RAFNUM,RAFLD,0)),"^",4),";",2)
183 Q $$EXTERNAL^DILFD(RAFNUM,RAFLD,"",$P(Y(0),"^",RAPCE))
Note: See TracBrowser for help on using the repository browser.