PSN50P6 ;BIR/LDT - API FOR INFORMATION FROM FILE 50.6; 5 Sep 03
;;4.0; NATIONAL DRUG FILE;**80**; 30 Oct 98
;
ZERO(PSNIEN,PSNFT,PSNFL,PSNX,LIST) ;
;PSNIEN - IEN of entry in VA GENERIC file (#50.6).
;PSNFT - Free Text name in VA GENERIC file (#50.6).
;PSNFL - Inactive flag - "" - All entries
; FileMan Date - Only entries with no Inactive Date or an Inactive Date
; greater than this date.
;PSNX - exact match flag 1 - exact match wanted
;LIST - Subscript of ^TMP array in the form ^TMP($J,LIST,Field Number where Field Number is the
; Field Number of the data piece being returned.
;Returns NAME field (#.01), and INACTIVE DATE field (#1) of VA GENERIC file (#50.6).
N DIERR,ZZERR,PSNP50P6,SCR,PSN
I $G(LIST)']"" Q
K ^TMP($J,LIST)
I $G(PSNIEN)']"",($G(PSNFT)']"") S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
I $G(PSNIEN)]"",(+$G(PSNIEN)'>0) S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
S SCR("S")=""
I +$G(PSNFL)>0 N ND D SETSCRN
I $G(PSNIEN)]"" N PSNIEN2 S PSNIEN2=$$FIND1^DIC(50.6,"","A","`"_PSNIEN,,SCR("S"),"") D
.I +PSNIEN2'>0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
.S ^TMP($J,LIST,0)=1
.D GETS^DIQ(50.6,+PSNIEN2,".01;1","IE","PSNP50P6") S PSN(1)=0
.F S PSN(1)=$O(PSNP50P6(50.6,PSN(1))) Q:'PSN(1) D SETALL
I $G(PSNIEN)="",$G(PSNFT)]"" D
.I PSNFT["??" D LOOP Q
.D FIND^DIC(50.6,,"@;.01;","QP"_$S($G(PSNX)=1:"X",1:""),PSNFT,,"B",SCR("S"),,"")
.I +$G(^TMP("DILIST",$J,0))=0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
.I +^TMP("DILIST",$J,0)>0 S ^TMP($J,LIST,0)=+^TMP("DILIST",$J,0) N PSNXX S PSNXX=0 F S PSNXX=$O(^TMP("DILIST",$J,PSNXX)) Q:'PSNXX D
..S PSNIEN=+^TMP("DILIST",$J,PSNXX,0) K PSNP50P6 D GETS^DIQ(50.6,+PSNIEN,".01;1","IE","PSNP50P6") S PSN(1)=0
..F S PSN(1)=$O(PSNP50P6(50.6,PSN(1))) Q:'PSN(1) D SETALL
K ^TMP("DILIST",$J)
Q
;
ROOT() ;
;get version dependent NDF reference
I $$VERSION^XPDUTL("PSN")<4 Q "^PSNDF("
Q "^PSNDF(50.6," ; new reference for ver 4.0
;
SETALL ;
S ^TMP($J,LIST,+PSN(1),.01)=$G(PSNP50P6(50.6,PSN(1),.01,"I"))
S ^TMP($J,LIST,"B",$G(PSNP50P6(50.6,PSN(1),.01,"I")),+PSN(1))=""
S ^TMP($J,LIST,+PSN(1),1)=$S($G(PSNP50P6(50.6,PSN(1),1,"I"))="":"",1:PSNP50P6(50.6,PSN(1),1,"I")_"^"_PSNP50P6(50.6,PSN(1),1,"E"))
Q
;
SETSCRN ;Set Screen for inactive VA Generic
;Naked reference below refers to ^PS(50.6,+Y,0)
S SCR("S")="S ND=$P($G(^(0)),U,2) I ND=""""!(ND>PSNFL)"
Q
;
LOOP ;
N PSNIEN,CNT S CNT=0
S PSNIEN=0 F S PSNIEN=$O(^PSNDF(50.6,PSNIEN)) Q:'PSNIEN D
.I $G(PSNFL),$P($G(^PSNDF(50.6,PSNIEN,0)),"^",2),$P($G(^(0)),"^",2)'>PSNFL Q
.K PSNP50P6 D GETS^DIQ(50.6,+PSNIEN,".01;1","IE","PSNP50P6") S PSN(1)=0 D
..F S PSN(1)=$O(PSNP50P6(50.6,PSN(1))) Q:'PSN(1) D SETALL S CNT=CNT+1
S ^TMP($J,LIST,0)=+CNT
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSN50P6 2832 printed Dec 13, 2024@02:22:37 Page 2
PSN50P6 ;BIR/LDT - API FOR INFORMATION FROM FILE 50.6; 5 Sep 03
+1 ;;4.0; NATIONAL DRUG FILE;**80**; 30 Oct 98
+2 ;
ZERO(PSNIEN,PSNFT,PSNFL,PSNX,LIST) ;
+1 ;PSNIEN - IEN of entry in VA GENERIC file (#50.6).
+2 ;PSNFT - Free Text name in VA GENERIC file (#50.6).
+3 ;PSNFL - Inactive flag - "" - All entries
+4 ; FileMan Date - Only entries with no Inactive Date or an Inactive Date
+5 ; greater than this date.
+6 ;PSNX - exact match flag 1 - exact match wanted
+7 ;LIST - Subscript of ^TMP array in the form ^TMP($J,LIST,Field Number where Field Number is the
+8 ; Field Number of the data piece being returned.
+9 ;Returns NAME field (#.01), and INACTIVE DATE field (#1) of VA GENERIC file (#50.6).
+10 NEW DIERR,ZZERR,PSNP50P6,SCR,PSN
+11 IF $GET(LIST)']""
QUIT
+12 KILL ^TMP($JOB,LIST)
+13 IF $GET(PSNIEN)']""
IF ($GET(PSNFT)']"")
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+14 IF $GET(PSNIEN)]""
IF (+$GET(PSNIEN)'>0)
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+15 SET SCR("S")=""
+16 IF +$GET(PSNFL)>0
NEW ND
DO SETSCRN
+17 IF $GET(PSNIEN)]""
NEW PSNIEN2
SET PSNIEN2=$$FIND1^DIC(50.6,"","A","`"_PSNIEN,,SCR("S"),"")
Begin DoDot:1
+18 IF +PSNIEN2'>0
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+19 SET ^TMP($JOB,LIST,0)=1
+20 DO GETS^DIQ(50.6,+PSNIEN2,".01;1","IE","PSNP50P6")
SET PSN(1)=0
+21 FOR
SET PSN(1)=$ORDER(PSNP50P6(50.6,PSN(1)))
if 'PSN(1)
QUIT
DO SETALL
End DoDot:1
+22 IF $GET(PSNIEN)=""
IF $GET(PSNFT)]""
Begin DoDot:1
+23 IF PSNFT["??"
DO LOOP
QUIT
+24 DO FIND^DIC(50.6,,"@;.01;","QP"_$SELECT($GET(PSNX)=1:"X",1:""),PSNFT,,"B",SCR("S"),,"")
+25 IF +$GET(^TMP("DILIST",$JOB,0))=0
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+26 IF +^TMP("DILIST",$JOB,0)>0
SET ^TMP($JOB,LIST,0)=+^TMP("DILIST",$JOB,0)
NEW PSNXX
SET PSNXX=0
FOR
SET PSNXX=$ORDER(^TMP("DILIST",$JOB,PSNXX))
if 'PSNXX
QUIT
Begin DoDot:2
+27 SET PSNIEN=+^TMP("DILIST",$JOB,PSNXX,0)
KILL PSNP50P6
DO GETS^DIQ(50.6,+PSNIEN,".01;1","IE","PSNP50P6")
SET PSN(1)=0
+28 FOR
SET PSN(1)=$ORDER(PSNP50P6(50.6,PSN(1)))
if 'PSN(1)
QUIT
DO SETALL
End DoDot:2
End DoDot:1
+29 KILL ^TMP("DILIST",$JOB)
+30 QUIT
+31 ;
ROOT() ;
+1 ;get version dependent NDF reference
+2 IF $$VERSION^XPDUTL("PSN")<4
QUIT "^PSNDF("
+3 ; new reference for ver 4.0
QUIT "^PSNDF(50.6,"
+4 ;
SETALL ;
+1 SET ^TMP($JOB,LIST,+PSN(1),.01)=$GET(PSNP50P6(50.6,PSN(1),.01,"I"))
+2 SET ^TMP($JOB,LIST,"B",$GET(PSNP50P6(50.6,PSN(1),.01,"I")),+PSN(1))=""
+3 SET ^TMP($JOB,LIST,+PSN(1),1)=$SELECT($GET(PSNP50P6(50.6,PSN(1),1,"I"))="":"",1:PSNP50P6(50.6,PSN(1),1,"I")_"^"_PSNP50P6(50.6,PSN(1),1,"E"))
+4 QUIT
+5 ;
SETSCRN ;Set Screen for inactive VA Generic
+1 ;Naked reference below refers to ^PS(50.6,+Y,0)
+2 SET SCR("S")="S ND=$P($G(^(0)),U,2) I ND=""""!(ND>PSNFL)"
+3 QUIT
+4 ;
LOOP ;
+1 NEW PSNIEN,CNT
SET CNT=0
+2 SET PSNIEN=0
FOR
SET PSNIEN=$ORDER(^PSNDF(50.6,PSNIEN))
if 'PSNIEN
QUIT
Begin DoDot:1
+3 IF $GET(PSNFL)
IF $PIECE($GET(^PSNDF(50.6,PSNIEN,0)),"^",2)
IF $PIECE($GET(^(0)),"^",2)'>PSNFL
QUIT
+4 KILL PSNP50P6
DO GETS^DIQ(50.6,+PSNIEN,".01;1","IE","PSNP50P6")
SET PSN(1)=0
Begin DoDot:2
+5 FOR
SET PSN(1)=$ORDER(PSNP50P6(50.6,PSN(1)))
if 'PSN(1)
QUIT
DO SETALL
SET CNT=CNT+1
End DoDot:2
End DoDot:1
+6 SET ^TMP($JOB,LIST,0)=+CNT
+7 QUIT