source: WorldVistAEHR/trunk/r/AUTOMATED_INFO_COLLECTION_SYS-IBD/IBDFU8.m@ 1111

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

initial load of WorldVistAEHR

File size: 3.3 KB
Line 
1IBDFU8 ;ALB/CJM - ENCOUNTER FORM - selection routines for form components;OCT 8,1993
2 ;;3.0;AUTOMATED INFO COLLECTION SYS;;APR 24, 1997
3 ;
4SLCTBLK(FORM,SCRNSIZE,EXCLUDE) ;SCRNSIZE is the number of lines available for scrolling
5 ;EXCLUDE is a block name that can be excluded (used to exclude the HEADER block from being edited)
6 ;returns the block selected, returns "" if none selected
7 ;only allows one to be selected
8 ;
9 Q:'FORM
10 S SCRNSIZE=+$G(SCRNSIZE)-1
11 S:SCRNSIZE<1 SCRNSIZE=4
12 S EXCLUDE=$G(EXCLUDE)
13 N COUNT,CNT,PICK,BLK,ARY,NAME
14 S ARY="^TMP($J,""FORM BLOCKS"")"
15 K @ARY
16 S CNT=$$FINDALL ;FORM,EXCLUDE,ARY are inputs to FINDALL
17 ;
18 ;if CNT=1 return the only block
19 I CNT=1 S NAME=$O(@ARY@("NAME","")) Q $S(NAME'="":$O(@ARY@("NAME",NAME,0)),1:"")
20 ;
21 ;if CNT'=1 loop through the blocks, displaying them to the user and let him choose
22AGAIN ;
23 S (PICK,NAME)="",COUNT=0
24 F S NAME=$O(@ARY@("NAME",NAME)) Q:(PICK'="")!(NAME="") D
25 .S BLK=0 F S BLK=$O(@ARY@("NAME",NAME,BLK)) Q:(PICK'="")!('BLK) D Q:NAME=""
26 ..S COUNT=COUNT+1,@ARY@("#",COUNT)=BLK W !,COUNT," ",NAME,?38,$E($P($G(^IBE(357.1,BLK,0)),"^",13),1,42)
27 ..I COUNT#SCRNSIZE=0 S PICK=$$CHOOSE
28 I (PICK=""),COUNT,COUNT#SCRNSIZE'=0 S PICK=$$CHOOSE
29 I PICK="" K DIR S DIR(0)="Y",DIR("A")="No block selected! Try again",DIR("B")="YES" D ^DIR K DIR I '$D(DIRUT),Y=1 G AGAIN
30 I PICK="?" G AGAIN
31 K @ARY
32 Q $S((PICK'>0):"",1:PICK)
33 ;
34FINDALL() ;finds all of the blocks on FORM (except the one named EXCLUDE) and puts them on @ARY,returns the cound
35 N BLK,COUNT,NODE
36 S BLK="",COUNT=0 F S BLK=$O(^IBE(357.1,"C",FORM,BLK)) Q:'BLK S NODE=$G(^IBE(357.1,BLK,0)),NAME=$P(NODE,"^") S:(NAME'="")&(NAME'=EXCLUDE)&($P(NODE,"^",2)=FORM) @ARY@("NAME",$$UP^XLFSTR(NAME),BLK)="",COUNT=COUNT+1
37 Q COUNT
38 ;
39CHOOSE() ;asks the user to select a blk - @ARY@("#", is the aray of blocks displayed so far(subscripted by the number on the list), @ARY@("NAME", the entire array (subscripted by name,ien)
40 ;sets NAME to " " and COUNT to 0 if ? is entered - starts display of list over
41 N ANS,QUIT,PICK,NEXT1,NEXT2
42 S QUIT=0
43 F Q:QUIT D D:'QUIT MSG
44 .S (PICK,ANS)=""
45 .W !,"Choose 1-",COUNT,$S(COUNT<CNT:" or hit RETURN to see more",1:""),": "
46 .R ANS:DTIME
47 .I '$T!($E(ANS,1)="^") S PICK=-1,QUIT=1 Q
48 .I ANS="" S QUIT=1 Q
49 .I $E(ANS,1)="?" D HELP Q
50 .;
51 .;convert to upper case
52 .S ANS=$$UP^XLFSTR(ANS)
53 .
54 .;if user entered a displayed number then he's made his choice
55 .I $D(@ARY@("#",ANS)) S PICK=$G(@ARY@("#",ANS)),QUIT=1 Q
56 .;
57 .;if the user entered an exact name, and the name is unique then he's made his choice
58 .S PICK=$O(@ARY@("NAME",ANS,PICK)) I PICK,'$O(@ARY@("NAME",ANS,PICK)) S QUIT=1 Q
59 .Q:PICK ;don't set QUIT=1 because name is not unique
60 .;
61 .;if the user entered a partial name accept it if there is exactly one match
62 .S NEXT1=$O(@ARY@("NAME",ANS)) Q:(NEXT1="")!($E(NEXT1,1,$L(ANS))'=ANS)
63 .S NEXT2=$O(@ARY@("NAME",NEXT1)) Q:($E(NEXT2,1,$L(ANS))=ANS) ;because user did not type in enough to uniquely identify the block
64 .;make sure there are not two blocks with the same name - if ok, accept it
65 .S PICK=$O(@ARY@("NAME",NEXT1,PICK)) Q:'PICK I '$O(@ARY@("NAME",NEXT1,PICK)) S QUIT=1 Q
66 Q PICK
67 ;
68HELP ;choosing help restarts the display (by setting NAME="")
69 W !,"You can choose a block by the number or by it's name.",!
70 D PAUSE^IBDFU5
71 S QUIT=1,NAME="",PICK="?",COUNT=0
72 Q
73MSG ;
74 W !,"You must enter the number or name of the block!"
75 D PAUSE^IBDFU5
76 Q
Note: See TracBrowser for help on using the repository browser.