PSN50P67 ;BIR/LDT - API FOR INFORMATION FROM FILE 50.607; 5 Sep 03
;;4.0; NATIONAL DRUG FILE;**80**; 30 Oct 98
;
ALL(PSNIEN,PSNFT,PSNFL,LIST) ;
;PSNIEN - IEN of entry in DRUG UNITS file (#50.607).
;PSNFT - Free Text name in DRUG UNITS file (#50.607).
;PSNFL - Inactive flag - "" - All entries.
; FileMan Date - Only entries with no Inactive Date or an Inactive Date greater than this date.
;LIST - Subscript of ^TMP array in the form ^TMP($J,LIST,Field Number where Field Number is the
;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 INACTIVATION DATE field (#1) of DRUG UNITS file (#50.607).
N DIERR,ZZERR,PSN50P67,PSN,SCR
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.607,"","B","`"_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.607,+PSNIEN2,".01;1","IE","PSN50P67") S PSN(1)=0
.F S PSN(1)=$O(PSN50P67(50.607,PSN(1))) Q:'PSN(1) D SETZRO
I $G(PSNIEN)="",$G(PSNFT)]"" D
.I PSNFT["??" D LOOP Q
.D FIND^DIC(50.607,,"@;.01;1","QP",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 PSN50P67 D GETS^DIQ(50.607,+PSNIEN,".01;1","IE","PSN50P67") S PSN(1)=0
..F S PSN(1)=$O(PSN50P67(50.607,PSN(1))) Q:'PSN(1) D SETZRO
K ^TMP("DILIST",$J)
Q
;
SETZRO ;
S ^TMP($J,LIST,+PSN(1),.01)=$G(PSN50P67(50.607,PSN(1),.01,"I"))
S ^TMP($J,LIST,"B",$G(PSN50P67(50.607,PSN(1),.01,"I")),+PSN(1))=""
S ^TMP($J,LIST,+PSN(1),1)=$S($G(PSN50P67(50.607,PSN(1),1,"I"))="":"",1:PSN50P67(50.607,PSN(1),1,"I")_"^"_PSN50P67(50.607,PSN(1),1,"E"))
Q
;
LOOP ;
N PSNIEN
S ^TMP($J,LIST,0)=0,PSNIEN=0 F S PSNIEN=$O(^PS(50.607,PSNIEN)) Q:'PSNIEN D
.I +$G(PSNFL)>0,$P($G(^PS(50.607,PSNIEN,0)),"^",2)]"",$P($G(^(0)),"^",2)'>PSNFL Q
.K PSN50P67 D GETS^DIQ(50.607,+PSNIEN,".01;1","IE","PSN50P67") S PSN(1)=0 D
..F S PSN(1)=$O(PSN50P67(50.607,PSN(1))) Q:'PSN(1) D SETZRO S ^TMP($J,LIST,0)=^TMP($J,LIST,0)+1
Q
;
SETSCRN ;
S SCR("S")="S ND=$P($G(^PS(50.607,+Y,0)),""^"",2) I ND=""""!(ND>PSNFL)"
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSN50P67 2621 printed Dec 13, 2024@02:22:39 Page 2
PSN50P67 ;BIR/LDT - API FOR INFORMATION FROM FILE 50.607; 5 Sep 03
+1 ;;4.0; NATIONAL DRUG FILE;**80**; 30 Oct 98
+2 ;
ALL(PSNIEN,PSNFT,PSNFL,LIST) ;
+1 ;PSNIEN - IEN of entry in DRUG UNITS file (#50.607).
+2 ;PSNFT - Free Text name in DRUG UNITS file (#50.607).
+3 ;PSNFL - Inactive flag - "" - All entries.
+4 ; FileMan Date - Only entries with no Inactive Date or an Inactive Date greater than this date.
+5 ;LIST - Subscript of ^TMP array in the form ^TMP($J,LIST,Field Number where Field Number is the
+6 ;LIST - Subscript of ^TMP array in the form ^TMP($J,LIST,Field Number where
+7 ; Field Number is the Field Number of the data piece being returned.
+8 ;Returns NAME field (#.01), and INACTIVATION DATE field (#1) of DRUG UNITS file (#50.607).
+9 NEW DIERR,ZZERR,PSN50P67,PSN,SCR
+10 IF $GET(LIST)']""
QUIT
+11 KILL ^TMP($JOB,LIST)
+12 IF $GET(PSNIEN)']""
IF ($GET(PSNFT)']"")
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+13 IF $GET(PSNIEN)]""
IF (+$GET(PSNIEN)'>0)
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+14 SET SCR("S")=""
+15 IF +$GET(PSNFL)>0
NEW ND
DO SETSCRN
+16 IF $GET(PSNIEN)]""
NEW PSNIEN2
SET PSNIEN2=$$FIND1^DIC(50.607,"","B","`"_PSNIEN,,SCR("S"),"")
Begin DoDot:1
+17 IF +PSNIEN2'>0
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+18 SET ^TMP($JOB,LIST,0)=1
+19 DO GETS^DIQ(50.607,+PSNIEN2,".01;1","IE","PSN50P67")
SET PSN(1)=0
+20 FOR
SET PSN(1)=$ORDER(PSN50P67(50.607,PSN(1)))
if 'PSN(1)
QUIT
DO SETZRO
End DoDot:1
+21 IF $GET(PSNIEN)=""
IF $GET(PSNFT)]""
Begin DoDot:1
+22 IF PSNFT["??"
DO LOOP
QUIT
+23 DO FIND^DIC(50.607,,"@;.01;1","QP",PSNFT,,"B",SCR("S"),,"")
+24 IF +$GET(^TMP("DILIST",$JOB,0))=0
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+25 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
+26 SET PSNIEN=+^TMP("DILIST",$JOB,PSNXX,0)
KILL PSN50P67
DO GETS^DIQ(50.607,+PSNIEN,".01;1","IE","PSN50P67")
SET PSN(1)=0
+27 FOR
SET PSN(1)=$ORDER(PSN50P67(50.607,PSN(1)))
if 'PSN(1)
QUIT
DO SETZRO
End DoDot:2
End DoDot:1
+28 KILL ^TMP("DILIST",$JOB)
+29 QUIT
+30 ;
SETZRO ;
+1 SET ^TMP($JOB,LIST,+PSN(1),.01)=$GET(PSN50P67(50.607,PSN(1),.01,"I"))
+2 SET ^TMP($JOB,LIST,"B",$GET(PSN50P67(50.607,PSN(1),.01,"I")),+PSN(1))=""
+3 SET ^TMP($JOB,LIST,+PSN(1),1)=$SELECT($GET(PSN50P67(50.607,PSN(1),1,"I"))="":"",1:PSN50P67(50.607,PSN(1),1,"I")_"^"_PSN50P67(50.607,PSN(1),1,"E"))
+4 QUIT
+5 ;
LOOP ;
+1 NEW PSNIEN
+2 SET ^TMP($JOB,LIST,0)=0
SET PSNIEN=0
FOR
SET PSNIEN=$ORDER(^PS(50.607,PSNIEN))
if 'PSNIEN
QUIT
Begin DoDot:1
+3 IF +$GET(PSNFL)>0
IF $PIECE($GET(^PS(50.607,PSNIEN,0)),"^",2)]""
IF $PIECE($GET(^(0)),"^",2)'>PSNFL
QUIT
+4 KILL PSN50P67
DO GETS^DIQ(50.607,+PSNIEN,".01;1","IE","PSN50P67")
SET PSN(1)=0
Begin DoDot:2
+5 FOR
SET PSN(1)=$ORDER(PSN50P67(50.607,PSN(1)))
if 'PSN(1)
QUIT
DO SETZRO
SET ^TMP($JOB,LIST,0)=^TMP($JOB,LIST,0)+1
End DoDot:2
End DoDot:1
+6 QUIT
+7 ;
SETSCRN ;
+1 SET SCR("S")="S ND=$P($G(^PS(50.607,+Y,0)),""^"",2) I ND=""""!(ND>PSNFL)"
+2 QUIT