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

BISELEC1.m

Go to the documentation of this file.
  1. BISELEC1 ;IHS/CMI/MWR - GENERIC SELETION UTILITY; MAY 10, 2010
  1. ;;8.5;IMMUNIZATION;;SEP 01,2011
  1. ;;* MICHAEL REMILLARD, DDS * CIMARRON MEDICAL INFORMATICS, FOR IHS *
  1. ;; LISTMANAGER DRIVER ROUTINE FOR GENERIC SELECTION UTILITY.
  1. ;
  1. ;
  1. ;----------
  1. START(BIARR1,BIGBL,BIITEMS,BITITEMS,BIPIECE,BISCRN,BIID,BICOL,BIFLD,BIPOP) ;EP
  1. ;---> Call Listmanager to select a list of Items.
  1. ;---> Parameters:
  1. ; 1 - BIARR1 (req) Selection Array (local).
  1. ; 2 - BIGBL (req) Lookup global.
  1. ; 3 - BIITEMS (req) Catagoric name of Items being selected.
  1. ; 4 - BITITEMS (req) Title name of selected Items.
  1. ; 5 - BIPIECE (req) Piece of zero node to display as ItemName.
  1. ; 6 - BISCRN (opt) Screen used in selection lookup.
  1. ; 7 - BIID (opt) Identifier and code.
  1. ; 8 - BICOL (opt) Column header text.
  1. ; 9 - BIFLD (opt) Field# in BIFILE with Set of Codes to select.
  1. ; 10 - BIPOP (ret) BIPOP, =1 if quit or error.
  1. ;
  1. ;
  1. ;---> New VALMQUIT so that quit from "ENTIRE1^BISELEC2" will work but
  1. ;---> will not cause the calling/parent instance of Listman to quit also.
  1. D SETVARS^BIUTL5 N VALMQUIT
  1. S BIPOP=0
  1. D EN^VALM("BI GENERIC SELECTION")
  1. D FULL^VALM1
  1. D EXIT
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. HDR ;EP
  1. ;---> Header code.
  1. N X,Y
  1. S VALMHDR(1)=""
  1. S X=" Select one or more "_BITITEMS_":"
  1. S VALMHDR(2)=X
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. INIT ;EP
  1. ;---> Initialize variables and list array.
  1. K ^TMP("BILMGS",$J),^TMP("BILMGS1",$J),^TMP("BILMGS2",$J)
  1. ;
  1. ;---> Check for necessary variables present.
  1. I $$CHECK^BISELECT() S BIPOP=1,VALMQUIT="" Q
  1. ;
  1. ;---> *** SET OF CODES
  1. ;---> If this is a Set of Codes, go to INIT1, then QUIT.
  1. I +$G(BIFLD) D INIT1 Q
  1. ;
  1. ;---> Continue with selection from a file.
  1. I '$O(@(BIARR1_"(0)")) S VALMCNT=0 Q
  1. ;
  1. ;---> Set Lower Frame Bar and Screen Title.
  1. S VALMSG="Type ?? for more actions."
  1. ;S VALM("TITLE")="Select "_BIITEMS
  1. ;
  1. ;---> Set Column Header line.
  1. D:$G(BICOL)]""
  1. .S VALMCAP=$$PAD^BIUTL5(BICOL,80)
  1. ;
  1. ;---> Convert IEN-sorted array to ItemName-sorted array.
  1. ;---> This will present Items in a numbered list, 1,2,3...,
  1. ;---> with the Item names in alphabetical order, so the user
  1. ;---> can search the list of Items in order.
  1. ;
  1. ;---> First, build array sorted by ItemName.
  1. N BIIEN S BIIEN=0
  1. F S BIIEN=$O(@(BIARR1_"(BIIEN)")) Q:'BIIEN D
  1. .;
  1. .;---> If IEN passed does not really exist in the File,
  1. .;---> remove it from the Selection Array.
  1. .I '$D(@(BIGBL_"BIIEN,0)")) K @(BIARR1_"(BIIEN)") Q
  1. .;
  1. .;---> If (previously stored) IEN does not pass the screen,
  1. .;---> then remove it from the Selection Array.
  1. .I BISCRN]"" N Y S Y=BIIEN X BISCRN I '$T K @(BIARR1_"(BIIEN)") Q
  1. .;
  1. .N BI0,BINAME,BIIDTX
  1. .S BI0=@(BIGBL_"BIIEN,0)")
  1. .S BINAME=$P(BI0,U,BIPIECE)
  1. .Q:BINAME=""
  1. .;
  1. .;---> Set Identifer if passed.
  1. .D:BIID]""
  1. ..;---> BIID Identifier: Three pieces delimited by ";".
  1. ..; 1st piece = the "^" piece of 0 node to get X.
  1. ..; 2nd piece = Code to set X=text of identifier.
  1. ..; 3rd piece = Tab for identfier in Listman.
  1. ..;
  1. ..;---> Get piece (BIPC) of zero node that holds Identifier data.
  1. ..N BIPC,X S BIPC=$P(BIID,";")
  1. ..Q:'BIPC
  1. ..;---> Get Identifier data.
  1. ..S X=$P(BI0,U,BIPC)
  1. ..Q:X=""
  1. ..;---> Xecute code to process X (return ID text in X).
  1. ..;---> If there is no code, then value of X is displayed unchanged.
  1. ..X $P(BIID,";",2)
  1. ..S BIIDTX=X
  1. ..Q:BIIDTX=""
  1. ..;---> Tab out to specified column.
  1. ..N BITAB S BITAB=$P(BIID,";",3)
  1. ..N BIADD S BIADD=BITAB-($L(BINAME)+5)
  1. ..;---> Minimum of 2 spaces between Name and Identifier.
  1. ..S:BIADD<1 BIADD=2
  1. ..S BIIDTX=$$SP^BIUTL5(BIADD)_BIIDTX
  1. .;
  1. .;---> Each node=IEN of Item_^_ItemName.
  1. .;---> The array will be sorted alphabetically by ItemName.
  1. .;---> Append IEN to ItemName to include legitimate duplicate names.
  1. .S ^TMP("BILMGS1",$J,BINAME_BIIEN)=BIIEN_U_BINAME_$G(BIIDTX)
  1. ;
  1. ;
  1. ;---> Now, convert ItemName-sorted array to Item-numbered array.
  1. N I,N S N=0
  1. F I=1:1 S N=$O(^TMP("BILMGS1",$J,N)) Q:N="" D
  1. .S ^TMP("BILMGS2",$J,I)=^TMP("BILMGS1",$J,N)
  1. ;
  1. ;---> Insert blank line at the top of the List Region.
  1. S ^TMP("BILMGS",$J,1,0)=""
  1. S ^TMP("BILMGS",$J,"IDX",1,1)=""
  1. ;
  1. ;---> Set each Item (or previously) selected into the array.
  1. N N S N=0
  1. F S N=$O(^TMP("BILMGS2",$J,N)) Q:'N D
  1. .;---> Build display line for this Item.
  1. .N X
  1. .S X=" "_$J(N,3)_" "_$P(^TMP("BILMGS2",$J,N),U,2)
  1. .;
  1. .;---> Set formatted Item line and index in ^TMP.
  1. .S ^TMP("BILMGS",$J,N+1,0)=X
  1. .S ^TMP("BILMGS",$J,"IDX",N+1,N)=""
  1. ;
  1. ;---> Finish up Listmanager List Count.
  1. S VALMCNT=I
  1. I VALMCNT>13 D
  1. .S VALMSG="Scroll down to view more. Type ?? for more actions."
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. INIT1 ;EP
  1. ;
  1. I $O(@(BIARR1_"(0)"))="" S VALMCNT=0 Q
  1. ;
  1. ;---> Set Lower Frame Bar and Screen Title.
  1. S VALMSG="Type ?? for more actions."
  1. ;S VALM("TITLE")="Select "_BIITEMS
  1. ;
  1. ;---> Set Column Header line.
  1. D:$G(BICOL)]""
  1. .S VALMCAP=$$PAD^BIUTL5(BICOL,80)
  1. ;
  1. ;---> Convert CODE-sorted array to CodeName-sorted array.
  1. ;---> This will present Items in a numbered list, 1,2,3...,
  1. ;---> with the Item names in alphabetical order, so the user
  1. ;---> can search the list of Items in order.
  1. ;
  1. Q:'$D(^DD(BIFILE,BIFLD,0))
  1. N BISET S BISET=$P(^DD(BIFILE,BIFLD,0),U,3)
  1. ;
  1. ;---> First, build array sorted by Code.
  1. N BICODE S BICODE=0
  1. F S BICODE=$O(@(BIARR1_"(BICODE)")) Q:BICODE="" D
  1. .;
  1. .;---> If the Code does not really exist in the Set of Codes,
  1. .;---> remove it from the Selection Array.
  1. .I BISET'[BICODE_":" K @(BIARR1_"(BICODE)") Q
  1. .;
  1. .N BICODNM
  1. .S BICODNM=$P($P(BISET,BICODE_":",2),";")
  1. .;
  1. .;---> The array will be sorted alphabetically by CodeName.
  1. .;---> Append Code to CodeName to include legitimate duplicate names.
  1. .S ^TMP("BILMGS1",$J,BICODNM_BICODE)=BICODE_U_BICODNM
  1. ;
  1. ;---> Now, convert ItemName-sorted array to Item-numbered array.
  1. N I,N S N=0
  1. F I=1:1 S N=$O(^TMP("BILMGS1",$J,N)) Q:N="" D
  1. .S ^TMP("BILMGS2",$J,I)=^TMP("BILMGS1",$J,N)
  1. ;
  1. ;---> Insert blank line at the top of the List Region.
  1. S ^TMP("BILMGS",$J,1,0)=""
  1. S ^TMP("BILMGS",$J,"IDX",1,1)=""
  1. ;
  1. ;---> Set each Item (or previously) selected into the array.
  1. N N S N=0
  1. F S N=$O(^TMP("BILMGS2",$J,N)) Q:'N D
  1. .;---> Build display line for this Item.
  1. .N X,Y
  1. .S Y=^TMP("BILMGS2",$J,N)
  1. .S X=" "_$J(N,3)_" "_$$PAD^BIUTL5($P(Y,U,2),32)_$P(Y,U)
  1. .;
  1. .;---> Set formatted Item line and index in ^TMP. Also, save
  1. .;---> "Left Column Number" and its corresponding Code, for deletions.
  1. .S ^TMP("BILMGS",$J,N+1,0)=X
  1. .S ^TMP("BILMGS",$J,"IDX",N+1,N)=""
  1. ;
  1. ;---> Finish up Listmanager List Count.
  1. S VALMCNT=I
  1. I VALMCNT>13 D
  1. .S VALMSG="Scroll down to view more. Type ?? for more actions."
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. RESET ;EP
  1. ;---> Update partition for return to Listmanager.
  1. I $D(VALMQUIT) S VALMBCK="Q" Q
  1. D TERM^VALM0 S VALMBCK="R"
  1. D INIT,HDR
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. HELP ;EP
  1. ;----> Help text display when "?" is entered.
  1. N BIXX S BIXX=$S($G(BIITEMS)="":"Items",1:BIITEMS)
  1. D EN^XBNEW("HELP1^BISELEC1","VALM*;IO*;BIXX")
  1. D RESET
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. HELP1 ;EP
  1. ;---> Display Help Text in Listmanager.
  1. ;
  1. ;---> Set Help Text into local array.
  1. N BITEXT D TEXT1(.BITEXT)
  1. ;---> Insert the passed Item Name into the Help Text array.
  1. N N S N=0
  1. F S N=$O(BITEXT(N)) Q:'N D
  1. .Q:BITEXT(N)'[" BIXX"
  1. .N X S X=$P(BITEXT(N),"BIXX")_BIXX_$P(BITEXT(N),"BIXX",2),BITEXT(N)=X
  1. ;
  1. D START^BIHELP("LIST SELECTION UTILITY - HELP",.BITEXT)
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. TEXT1(BITEXT) ;EP
  1. ;;This allows you to select and build a list of BIXX
  1. ;;for your report. The following four actions are available:
  1. ;;
  1. ;;ADD...: Use this to select BIXX from the file of
  1. ;; BIXX and add them to your list.
  1. ;;
  1. ;;DELETE: Use this to remove items from your list.
  1. ;;
  1. ;;ENTIRE: Use this to add ALL items from the file to your list.
  1. ;; This may be useful if you want to select MOST of the items
  1. ;; in the file by adding all and then deleting the few items
  1. ;; you do not want. This will only work for up to 300 items.
  1. ;; If the file contains more than 300 items, it will simply add
  1. ;; ALL items and quit.
  1. ;;
  1. ;;CLEAR.: Use this to remove all items from your list (and start over).
  1. ;;
  1. ;;Your personal list of BIXX will be saved each time
  1. ;;you build it. Whenever you return to this list, the previous
  1. ;;list of BIXX you built will be presented as a
  1. ;;default list.
  1. ;;
  1. D LOADTX("TEXT1",,.BITEXT)
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. EXIT ;EP
  1. K ^TMP("BILMGS",$J),^TMP("BILMGS1",$J),^TMP("BILMGS2",$J),^TMP("BILMGS3",$J)
  1. D CLEAR^VALM1
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. LOADTX(BILINL,BITAB,BITEXT) ;EP
  1. Q:$G(BILINL)=""
  1. N I,T,X S T="" S:'$D(BITAB) BITAB=5 F I=1:1:BITAB S T=T_" "
  1. F I=1:1 S X=$T(@BILINL+I) Q:X'[";;" S BITEXT(I)=T_$P(X,";;",2)
  1. Q