Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: IBDFU8

IBDFU8.m

Go to the documentation of this file.
  1. IBDFU8 ;ALB/CJM - ENCOUNTER FORM - selection routines for form components;OCT 8,1993
  1. ;;3.0;AUTOMATED INFO COLLECTION SYS;;APR 24, 1997
  1. ;
  1. SLCTBLK(FORM,SCRNSIZE,EXCLUDE) ;SCRNSIZE is the number of lines available for scrolling
  1. ;EXCLUDE is a block name that can be excluded (used to exclude the HEADER block from being edited)
  1. ;returns the block selected, returns "" if none selected
  1. ;only allows one to be selected
  1. ;
  1. Q:'FORM
  1. S SCRNSIZE=+$G(SCRNSIZE)-1
  1. S:SCRNSIZE<1 SCRNSIZE=4
  1. S EXCLUDE=$G(EXCLUDE)
  1. N COUNT,CNT,PICK,BLK,ARY,NAME
  1. S ARY="^TMP($J,""FORM BLOCKS"")"
  1. K @ARY
  1. S CNT=$$FINDALL ;FORM,EXCLUDE,ARY are inputs to FINDALL
  1. ;
  1. ;if CNT=1 return the only block
  1. I CNT=1 S NAME=$O(@ARY@("NAME","")) Q $S(NAME'="":$O(@ARY@("NAME",NAME,0)),1:"")
  1. ;
  1. ;if CNT'=1 loop through the blocks, displaying them to the user and let him choose
  1. AGAIN ;
  1. S (PICK,NAME)="",COUNT=0
  1. F S NAME=$O(@ARY@("NAME",NAME)) Q:(PICK'="")!(NAME="") D
  1. .S BLK=0 F S BLK=$O(@ARY@("NAME",NAME,BLK)) Q:(PICK'="")!('BLK) D Q:NAME=""
  1. ..S COUNT=COUNT+1,@ARY@("#",COUNT)=BLK W !,COUNT," ",NAME,?38,$E($P($G(^IBE(357.1,BLK,0)),"^",13),1,42)
  1. ..I COUNT#SCRNSIZE=0 S PICK=$$CHOOSE
  1. I (PICK=""),COUNT,COUNT#SCRNSIZE'=0 S PICK=$$CHOOSE
  1. 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
  1. I PICK="?" G AGAIN
  1. K @ARY
  1. Q $S((PICK'>0):"",1:PICK)
  1. ;
  1. FINDALL() ;finds all of the blocks on FORM (except the one named EXCLUDE) and puts them on @ARY,returns the cound
  1. N BLK,COUNT,NODE
  1. 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
  1. Q COUNT
  1. ;
  1. CHOOSE() ;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)
  1. ;sets NAME to " " and COUNT to 0 if ? is entered - starts display of list over
  1. N ANS,QUIT,PICK,NEXT1,NEXT2
  1. S QUIT=0
  1. F Q:QUIT D D:'QUIT MSG
  1. .S (PICK,ANS)=""
  1. .W !,"Choose 1-",COUNT,$S(COUNT<CNT:" or hit RETURN to see more",1:""),": "
  1. .R ANS:DTIME
  1. .I '$T!($E(ANS,1)="^") S PICK=-1,QUIT=1 Q
  1. .I ANS="" S QUIT=1 Q
  1. .I $E(ANS,1)="?" D HELP Q
  1. .;
  1. .;convert to upper case
  1. .S ANS=$$UP^XLFSTR(ANS)
  1. .
  1. .;if user entered a displayed number then he's made his choice
  1. .I $D(@ARY@("#",ANS)) S PICK=$G(@ARY@("#",ANS)),QUIT=1 Q
  1. .;
  1. .;if the user entered an exact name, and the name is unique then he's made his choice
  1. .S PICK=$O(@ARY@("NAME",ANS,PICK)) I PICK,'$O(@ARY@("NAME",ANS,PICK)) S QUIT=1 Q
  1. .Q:PICK ;don't set QUIT=1 because name is not unique
  1. .;
  1. .;if the user entered a partial name accept it if there is exactly one match
  1. .S NEXT1=$O(@ARY@("NAME",ANS)) Q:(NEXT1="")!($E(NEXT1,1,$L(ANS))'=ANS)
  1. .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
  1. .;make sure there are not two blocks with the same name - if ok, accept it
  1. .S PICK=$O(@ARY@("NAME",NEXT1,PICK)) Q:'PICK I '$O(@ARY@("NAME",NEXT1,PICK)) S QUIT=1 Q
  1. Q PICK
  1. ;
  1. HELP ;choosing help restarts the display (by setting NAME="")
  1. W !,"You can choose a block by the number or by it's name.",!
  1. D PAUSE^IBDFU5
  1. S QUIT=1,NAME="",PICK="?",COUNT=0
  1. Q
  1. MSG ;
  1. W !,"You must enter the number or name of the block!"
  1. D PAUSE^IBDFU5
  1. Q