- DVBCPSH2 ;ALB/RJA - DBQ PUSH UTILITY RPC; MAY 9, 2024@8:20am ; 5/9/24 8:20am
- ;;2.7;AMIE;**252**;Apr 10, 1995;Build 92
- ;Per VHA Directive 6402 this routine should not be modified
- ;
- Q
- ;
- LISTTEMP(DVBRET,DVBFILT,DVBSORT) ;
- ;DVBA CAPRI TEMP DEF LIST CAPRI-10314 RJA 05/10/24
- ;
- N DVBIEN,DVBCNT,DVBNM,DVBFLAGRLS,DVBFLAGUSR,DVBFLAGACT,DVBAD
- K ^TMP("DVBLTMP",$J)
- S DVBCNT=0
- ;Default filtering and sorting to 0 if no value is passed (No Filter, Alphabetical)
- I $G(DVBFILT)="" S DVBFILT=0
- I $G(DVBSORT)="" S DVBSORT=0
- S DVBIEN=0 F S DVBIEN=$O(^DVB(396.18,DVBIEN)) Q:DVBIEN=""!('DVBIEN) D
- .;DVBFILT=0: (Default) No Filter
- .I DVBFILT=0 D SETARRAY Q
- .S DVBFLAGRLS=0 I $$GET1^DIQ(396.18,DVBIEN,9)="YES" S DVBFLAGRLS=1
- .;DVBFILT=1: "Released"
- .I DVBFILT=1,DVBFLAGRLS D SETARRAY Q
- .;DVBFILT=2: "Selectable by User"
- .S DVBFLAGUSR=0 I $$GET1^DIQ(396.18,DVBIEN,7)="YES" S DVBFLAGUSR=1
- .I DVBFILT=2,DVBFLAGUSR D SETARRAY Q
- .;DVBFILT=3: "Activated"
- .S DVBFLAGACT=0 I $$GET1^DIQ(396.18,DVBIEN,3)="" S DVBFLAGACT=1
- .I DVBFILT=3,DVBFLAGACT D SETARRAY Q
- .;DVBFILT=4: "Released" & "Selectable by User"
- .I DVBFILT=4,DVBFLAGRLS,DVBFLAGUSR D SETARRAY Q
- .;DVBFILT=5: "Released" & "Activated"
- .I DVBFILT=5,DVBFLAGRLS,DVBFLAGACT D SETARRAY Q
- .;DVBFILT=6: "Selectable by User" & "Activated"
- .I DVBFILT=6,DVBFLAGUSR,DVBFLAGACT D SETARRAY Q
- .;DVBFILT=7: "Released" & "Selectable by User" & "Activated"
- .I DVBFILT=7,DVBFLAGRLS,DVBFLAGUSR,DVBFLAGACT D SETARRAY Q
- .Q
- ;DVBSORT=0: (Default) Alphabetical
- I DVBSORT=0 D SORT0
- ;DVBSORT=1: "Activated" followed by "Deactivated"
- I DVBSORT=1 D SORTACT,SORTDEACT
- ;DVBSORT=2: "Deactivated" followed by "Activated"
- I DVBSORT=2 D SORTDEACT,SORTACT
- K ^TMP("DVBLTMP",$J)
- Q
- SETARRAY ;
- S DVBNM=$$GET1^DIQ(396.18,DVBIEN,.01)
- ;Include DVBIEN as subnode so that duplicate template names with differing IENs are accounted for
- S DVBAD=$S($$GET1^DIQ(396.18,DVBIEN,3)="":"A",1:"D")
- S ^TMP("DVBLTMP",$J,DVBNM,DVBIEN)=DVBAD
- Q
- SORT0 ;
- ; DVBSORT=0: (Default) Alphabetical
- ;Set DVBRET array from ^TMP as it is already sorted alphabetical
- S DVBNM="",DVBCNT=0 F S DVBNM=$O(^TMP("DVBLTMP",$J,DVBNM)) Q:DVBNM="" D
- .;Include DVBIEN as subnode so that duplicate template names with differing IENs are accounted for
- .S DVBIEN="" F S DVBIEN=$O(^TMP("DVBLTMP",$J,DVBNM,DVBIEN)) Q:DVBIEN="" D
- ..S DVBRET(DVBCNT)=DVBNM_U_DVBIEN,DVBCNT=DVBCNT+1
- ..Q
- .Q
- Q
- SORTACT ;
- ; Set array with active template definitions
- S DVBNM="" F S DVBNM=$O(^TMP("DVBLTMP",$J,DVBNM)) Q:DVBNM="" D
- .;Include DVBIEN as subnode so that duplicate template names with differing IENs are accounted for
- .S DVBIEN="" F S DVBIEN=$O(^TMP("DVBLTMP",$J,DVBNM,DVBIEN)) Q:DVBIEN="" D
- ..;Set array only with activated template definitions (1)
- ..I $G(^TMP("DVBLTMP",$J,DVBNM,DVBIEN))="A" S DVBRET(DVBCNT)=DVBNM_U_DVBIEN,DVBCNT=DVBCNT+1
- ..Q
- .Q
- Q
- SORTDEACT ;
- ; Set array with deactivated template definitions
- S DVBNM="" F S DVBNM=$O(^TMP("DVBLTMP",$J,DVBNM)) Q:DVBNM="" D
- .;Include DVBIEN as subnode so that duplicate template names with differing IENs are accounted for
- .S DVBIEN="" F S DVBIEN=$O(^TMP("DVBLTMP",$J,DVBNM,DVBIEN)) Q:DVBIEN="" D
- ..;Set array only with deactivated template definitions (2)
- ..I $G(^TMP("DVBLTMP",$J,DVBNM,DVBIEN))="D" S DVBRET(DVBCNT)=DVBNM_U_DVBIEN,DVBCNT=DVBCNT+1
- ..Q
- .Q
- Q
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDVBCPSH2 3402 printed Apr 23, 2025@17:59:49 Page 2
- DVBCPSH2 ;ALB/RJA - DBQ PUSH UTILITY RPC; MAY 9, 2024@8:20am ; 5/9/24 8:20am
- +1 ;;2.7;AMIE;**252**;Apr 10, 1995;Build 92
- +2 ;Per VHA Directive 6402 this routine should not be modified
- +3 ;
- +4 QUIT
- +5 ;
- LISTTEMP(DVBRET,DVBFILT,DVBSORT) ;
- +1 ;DVBA CAPRI TEMP DEF LIST CAPRI-10314 RJA 05/10/24
- +2 ;
- +3 NEW DVBIEN,DVBCNT,DVBNM,DVBFLAGRLS,DVBFLAGUSR,DVBFLAGACT,DVBAD
- +4 KILL ^TMP("DVBLTMP",$JOB)
- +5 SET DVBCNT=0
- +6 ;Default filtering and sorting to 0 if no value is passed (No Filter, Alphabetical)
- +7 IF $GET(DVBFILT)=""
- SET DVBFILT=0
- +8 IF $GET(DVBSORT)=""
- SET DVBSORT=0
- +9 SET DVBIEN=0
- FOR
- SET DVBIEN=$ORDER(^DVB(396.18,DVBIEN))
- if DVBIEN=""!('DVBIEN)
- QUIT
- Begin DoDot:1
- +10 ;DVBFILT=0: (Default) No Filter
- +11 IF DVBFILT=0
- DO SETARRAY
- QUIT
- +12 SET DVBFLAGRLS=0
- IF $$GET1^DIQ(396.18,DVBIEN,9)="YES"
- SET DVBFLAGRLS=1
- +13 ;DVBFILT=1: "Released"
- +14 IF DVBFILT=1
- IF DVBFLAGRLS
- DO SETARRAY
- QUIT
- +15 ;DVBFILT=2: "Selectable by User"
- +16 SET DVBFLAGUSR=0
- IF $$GET1^DIQ(396.18,DVBIEN,7)="YES"
- SET DVBFLAGUSR=1
- +17 IF DVBFILT=2
- IF DVBFLAGUSR
- DO SETARRAY
- QUIT
- +18 ;DVBFILT=3: "Activated"
- +19 SET DVBFLAGACT=0
- IF $$GET1^DIQ(396.18,DVBIEN,3)=""
- SET DVBFLAGACT=1
- +20 IF DVBFILT=3
- IF DVBFLAGACT
- DO SETARRAY
- QUIT
- +21 ;DVBFILT=4: "Released" & "Selectable by User"
- +22 IF DVBFILT=4
- IF DVBFLAGRLS
- IF DVBFLAGUSR
- DO SETARRAY
- QUIT
- +23 ;DVBFILT=5: "Released" & "Activated"
- +24 IF DVBFILT=5
- IF DVBFLAGRLS
- IF DVBFLAGACT
- DO SETARRAY
- QUIT
- +25 ;DVBFILT=6: "Selectable by User" & "Activated"
- +26 IF DVBFILT=6
- IF DVBFLAGUSR
- IF DVBFLAGACT
- DO SETARRAY
- QUIT
- +27 ;DVBFILT=7: "Released" & "Selectable by User" & "Activated"
- +28 IF DVBFILT=7
- IF DVBFLAGRLS
- IF DVBFLAGUSR
- IF DVBFLAGACT
- DO SETARRAY
- QUIT
- +29 QUIT
- End DoDot:1
- +30 ;DVBSORT=0: (Default) Alphabetical
- +31 IF DVBSORT=0
- DO SORT0
- +32 ;DVBSORT=1: "Activated" followed by "Deactivated"
- +33 IF DVBSORT=1
- DO SORTACT
- DO SORTDEACT
- +34 ;DVBSORT=2: "Deactivated" followed by "Activated"
- +35 IF DVBSORT=2
- DO SORTDEACT
- DO SORTACT
- +36 KILL ^TMP("DVBLTMP",$JOB)
- +37 QUIT
- SETARRAY ;
- +1 SET DVBNM=$$GET1^DIQ(396.18,DVBIEN,.01)
- +2 ;Include DVBIEN as subnode so that duplicate template names with differing IENs are accounted for
- +3 SET DVBAD=$SELECT($$GET1^DIQ(396.18,DVBIEN,3)="":"A",1:"D")
- +4 SET ^TMP("DVBLTMP",$JOB,DVBNM,DVBIEN)=DVBAD
- +5 QUIT
- SORT0 ;
- +1 ; DVBSORT=0: (Default) Alphabetical
- +2 ;Set DVBRET array from ^TMP as it is already sorted alphabetical
- +3 SET DVBNM=""
- SET DVBCNT=0
- FOR
- SET DVBNM=$ORDER(^TMP("DVBLTMP",$JOB,DVBNM))
- if DVBNM=""
- QUIT
- Begin DoDot:1
- +4 ;Include DVBIEN as subnode so that duplicate template names with differing IENs are accounted for
- +5 SET DVBIEN=""
- FOR
- SET DVBIEN=$ORDER(^TMP("DVBLTMP",$JOB,DVBNM,DVBIEN))
- if DVBIEN=""
- QUIT
- Begin DoDot:2
- +6 SET DVBRET(DVBCNT)=DVBNM_U_DVBIEN
- SET DVBCNT=DVBCNT+1
- +7 QUIT
- End DoDot:2
- +8 QUIT
- End DoDot:1
- +9 QUIT
- SORTACT ;
- +1 ; Set array with active template definitions
- +2 SET DVBNM=""
- FOR
- SET DVBNM=$ORDER(^TMP("DVBLTMP",$JOB,DVBNM))
- if DVBNM=""
- QUIT
- Begin DoDot:1
- +3 ;Include DVBIEN as subnode so that duplicate template names with differing IENs are accounted for
- +4 SET DVBIEN=""
- FOR
- SET DVBIEN=$ORDER(^TMP("DVBLTMP",$JOB,DVBNM,DVBIEN))
- if DVBIEN=""
- QUIT
- Begin DoDot:2
- +5 ;Set array only with activated template definitions (1)
- +6 IF $GET(^TMP("DVBLTMP",$JOB,DVBNM,DVBIEN))="A"
- SET DVBRET(DVBCNT)=DVBNM_U_DVBIEN
- SET DVBCNT=DVBCNT+1
- +7 QUIT
- End DoDot:2
- +8 QUIT
- End DoDot:1
- +9 QUIT
- SORTDEACT ;
- +1 ; Set array with deactivated template definitions
- +2 SET DVBNM=""
- FOR
- SET DVBNM=$ORDER(^TMP("DVBLTMP",$JOB,DVBNM))
- if DVBNM=""
- QUIT
- Begin DoDot:1
- +3 ;Include DVBIEN as subnode so that duplicate template names with differing IENs are accounted for
- +4 SET DVBIEN=""
- FOR
- SET DVBIEN=$ORDER(^TMP("DVBLTMP",$JOB,DVBNM,DVBIEN))
- if DVBIEN=""
- QUIT
- Begin DoDot:2
- +5 ;Set array only with deactivated template definitions (2)
- +6 IF $GET(^TMP("DVBLTMP",$JOB,DVBNM,DVBIEN))="D"
- SET DVBRET(DVBCNT)=DVBNM_U_DVBIEN
- SET DVBCNT=DVBCNT+1
- +7 QUIT
- End DoDot:2
- +8 QUIT
- End DoDot:1
- +9 QUIT