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

HLEMP1.m

Go to the documentation of this file.
  1. HLEMP1 ;ALB/CJM-HL7 - Selector for Events Log Profiles ;07/10/2003
  1. ;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13,1995
  1. ;
  1. SELECT(USER,SCRNSIZE) ;
  1. ;Input:
  1. ; USER - the owner's DUZ
  1. ; SCRNSIZE is the number of lines available for scrolling
  1. ;Output;
  1. ; function returns ien of profile if selection is made, 0 otherwise
  1. ;
  1. Q:'$G(USER) 0
  1. I '$G(SCRNSIZE) S SCRNSIZE=10
  1. S SCRNSIZE=+$G(SCRNSIZE)-1
  1. S:SCRNSIZE<1 SCRNSIZE=1
  1. N COUNT,CNT,PICK,PROFILE,ARY,NAME
  1. S ARY="^TMP($J,""PROFILES"")"
  1. K @ARY
  1. S CNT=$$FINDALL(USER,ARY)
  1. ;
  1. ;return failure if no profiles found
  1. Q:CNT=0 0
  1. ;
  1. ;if CNT=1 return the only profile
  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 profiles, displaying them to the user and let him choose
  1. W !,"Please select the profile you wish to use"
  1. AGAIN ;
  1. S (PICK,NAME)="",COUNT=0
  1. F S NAME=$O(@ARY@("NAME",NAME)) Q:(PICK'="")!(NAME="") D
  1. .S PROFILE=0 F S PROFILE=$O(@ARY@("NAME",NAME,PROFILE)) Q:(PICK'="")!('PROFILE) D Q:NAME=""
  1. ..S COUNT=COUNT+1,@ARY@("#",COUNT)=PROFILE W !,COUNT," ",NAME
  1. ..I COUNT#SCRNSIZE=0 S PICK=$$CHOOSE(ARY)
  1. I (PICK=""),COUNT,COUNT#SCRNSIZE'=0 S PICK=$$CHOOSE(ARY)
  1. I PICK="" K DIR S DIR(0)="Y",DIR("A")="No profile 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(USER,ARY) ;finds all of the profiles belonging to USER and puts them on @ARY,returns the count
  1. N PROFILE,COUNT,NAME
  1. S NAME="",COUNT=0 F S NAME=$O(^HLEV(776.5,"C",USER,NAME)) Q:'$L(NAME) S PROFILE=$O(^HLEV(776.5,"C",USER,NAME,0)) I PROFILE,$D(^HLEV(776.5,PROFILE,0)) S @ARY@("NAME",$$UP^XLFSTR(NAME),PROFILE)="",COUNT=COUNT+1
  1. Q COUNT
  1. ;
  1. CHOOSE(ARY) ;asks the user to select a profile - @ARY@("#", is the array of profiles 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 profile
  1. .;make sure there are not two profiles 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 profile by the number or by it's name.",!
  1. D PAUSE
  1. S QUIT=1,NAME="",PICK="?",COUNT=0
  1. Q
  1. MSG ;
  1. W !,"You must enter the number or name of the profile!"
  1. D PAUSE
  1. Q
  1. PAUSE ;
  1. N ANS
  1. W !,$C(7),"Press RETURN to continue..." R ANS:DTIME
  1. Q