PSN56 ;BIR/LDT - API FOR INFORMATION FROM FILE 56; 5 Sep 03
;;4.0; NATIONAL DRUG FILE;**80**; 30 Oct 98
;
ALL(PSNIEN,PSNFT,LIST) ;
;PSNIEN - IEN of entry in DRUG INTERACTION file (#56).
;PSNFT - Free Text name in DRUG INTERACTION file (#56).
;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), INGREDIENT field (#1), INGREDIENT2 field (#2), SEVERITY field (#3),
;NATIONALLY ENTERED field (#4), TOTAL INDEXES field (#5), LOACLLY EDITED field (#6), and
;INACTIVATION DATE field (#7) of DRUG INTERACTION file (#56).
N DIERR,ZZERR,PSNP56,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
I $G(PSNIEN)]"" N PSNIEN2 S PSNIEN2=$$FIND1^DIC(56,"","A","`"_PSNIEN,,,"") D
.I +PSNIEN2'>0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
.S ^TMP($J,LIST,0)=1
.D GETS^DIQ(56,+PSNIEN2,".01;1;2;3;4;5;6;7","IE","PSNP56") S PSN(1)=0
.F S PSN(1)=$O(PSNP56(56,PSN(1))) Q:'PSN(1) D SETALL
I $G(PSNIEN)="",$G(PSNFT)]"" D
.I PSNFT["??" D LOOP Q
.D FIND^DIC(56,,"@;.01;","QP",PSNFT,,"B",,,"")
.I +$G(^TMP("DILIST",$J,0))=0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
.S ^TMP($J,LIST,0)=+^TMP("DILIST",$J,0)
.I +^TMP("DILIST",$J,0)>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 PSNP56 D GETS^DIQ(56,+PSNIEN,".01;1;2;3;4;5;6;7","IE","PSNP56") S PSN(1)=0
..F S PSN(1)=$O(PSNP56(56,PSN(1))) Q:'PSN(1) D SETALL
K ^TMP("DILIST",$J)
Q
;
SETALL ;
S ^TMP($J,LIST,+PSN(1),.01)=$G(PSNP56(56,PSN(1),.01,"I"))
S ^TMP($J,LIST,"B",$G(PSNP56(56,PSN(1),.01,"I")),+PSN(1))=""
S ^TMP($J,LIST,+PSN(1),1)=$S($G(PSNP56(56,PSN(1),1,"I"))="":"",1:PSNP56(56,PSN(1),1,"I")_"^"_PSNP56(56,PSN(1),1,"E"))
S ^TMP($J,LIST,+PSN(1),2)=$S($G(PSNP56(56,PSN(1),2,"I"))="":"",1:PSNP56(56,PSN(1),2,"I")_"^"_PSNP56(56,PSN(1),2,"E"))
S ^TMP($J,LIST,+PSN(1),3)=$S($G(PSNP56(56,PSN(1),3,"I"))="":"",1:PSNP56(56,PSN(1),3,"I")_"^"_PSNP56(56,PSN(1),3,"E"))
S ^TMP($J,LIST,+PSN(1),4)=$S($G(PSNP56(56,PSN(1),4,"I"))="":"",1:PSNP56(56,PSN(1),4,"I")_"^"_PSNP56(56,PSN(1),4,"E"))
S ^TMP($J,LIST,+PSN(1),5)=$G(PSNP56(56,PSN(1),5,"I"))
S ^TMP($J,LIST,+PSN(1),7)=$S($G(PSNP56(56,PSN(1),7,"I"))="":"",1:PSNP56(56,PSN(1),7,"I")_"^"_PSNP56(56,PSN(1),7,"E"))
S ^TMP($J,LIST,+PSN(1),6)=$S($G(PSNP56(56,PSN(1),6,"I"))="":"",1:PSNP56(56,PSN(1),6,"I")_"^"_PSNP56(56,PSN(1),6,"E"))
Q
;
SETING ;
S ^TMP($J,LIST,+PSN(1),.01)=$G(PSNP56(56,PSN(1),.01,"I"))
S ^TMP($J,LIST,"APD",$G(PSNP56(56,PSN(1),.01,"I")),+PSN(1))=""
S ^TMP($J,LIST,+PSN(1),1)=$S($G(PSNP56(56,PSN(1),1,"I"))="":"",1:PSNP56(56,PSN(1),1,"I")_"^"_PSNP56(56,PSN(1),1,"E"))
S ^TMP($J,LIST,+PSN(1),2)=$S($G(PSNP56(56,PSN(1),2,"I"))="":"",1:PSNP56(56,PSN(1),2,"I")_"^"_PSNP56(56,PSN(1),2,"E"))
S ^TMP($J,LIST,+PSN(1),3)=$S($G(PSNP56(56,PSN(1),3,"I"))="":"",1:PSNP56(56,PSN(1),3,"I")_"^"_PSNP56(56,PSN(1),3,"E"))
S ^TMP($J,LIST,+PSN(1),7)=$S($G(PSNP56(56,PSN(1),7,"I"))="":"",1:PSNP56(56,PSN(1),7,"I")_"^"_PSNP56(56,PSN(1),7,"E"))
Q
;
LOOP ;
S PSNIEN=0,^TMP($J,LIST,0)=0 F S PSNIEN=$O(^PS(56,PSNIEN)) Q:'PSNIEN D
.K PSNP56 D GETS^DIQ(56,+PSNIEN,".01;1;2;3;4;5;6;7","IE","PSNP56") S ^TMP($J,LIST,0)=^TMP($J,LIST,0)+1,PSN(1)=0 D
..F S PSN(1)=$O(PSNP56(56,PSN(1))) Q:'PSN(1) D SETALL
Q
;
IEN(PSNING1,PSNING2,PSNFL,LIST) ;
;PSNING1 - Drug Identifier for Ingredient 1.
;PSNING2 - Drug Identifier for Ingredient 2.
;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
; Field Number of the data piece being returned.
;Returns NAME field (#.01), INGREDIENT field (#1), INGREDIENT2 field (#2), and INACTIVATION DATE field (#7)
;of DRUG INTERACTION file (#56).
N PSNNXX,PSNXTOT,PSNXNODE,PSNP56,PSN
I $G(LIST)']"" Q
K ^TMP($J,LIST)
I $G(PSNING1)']""!($G(PSNING2)']"") S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
S PSNXTOT=0
F PSNNXX=0:0 S PSNNXX=$O(^PS(56,"APD",PSNING1,PSNING2,PSNNXX)) Q:'PSNNXX D
.I '$D(^PS(56,PSNNXX,0)) Q
.S PSNXNODE=$G(^PS(56,PSNNXX,0)) I $P(PSNXNODE,"^")="" Q
.I $G(PSNFL),$P(PSNXNODE,"^",7),$P(PSNXNODE,"^",7)'>PSNFL Q
.K PSNP56 D GETS^DIQ(56,+PSNNXX,".01;1;2;3;7","IE","PSNP56") S PSN(1)=0 D
..F S PSN(1)=$O(PSNP56(56,PSN(1))) Q:'PSN(1) D SETING S PSNXTOT=PSNXTOT+1
S ^TMP($J,LIST,0)=$S(+$G(PSNXTOT)>0:PSNXTOT,1:-1_"^"_"NO DATA FOUND")
Q
PSN56 ;BIR/LDT - API FOR INFORMATION FROM FILE 56; 5 Sep 03
+1 ;;4.0; NATIONAL DRUG FILE;**80**; 30 Oct 98
+2 ;
ALL(PSNIEN,PSNFT,LIST) ;
+1 ;PSNIEN - IEN of entry in DRUG INTERACTION file (#56).
+2 ;PSNFT - Free Text name in DRUG INTERACTION file (#56).
+3 ;LIST - Subscript of ^TMP array in the form ^TMP($J,LIST,Field Number where Field Number is the
+4 ; Field Number of the data piece being returned.
+5 ;Returns NAME field (#.01), INGREDIENT field (#1), INGREDIENT2 field (#2), SEVERITY field (#3),
+6 ;NATIONALLY ENTERED field (#4), TOTAL INDEXES field (#5), LOACLLY EDITED field (#6), and
+7 ;INACTIVATION DATE field (#7) of DRUG INTERACTION file (#56).
+8 NEW DIERR,ZZERR,PSNP56,PSN
+9 IF $GET(LIST)']""
QUIT
+10 KILL ^TMP($JOB,LIST)
+11 IF $GET(PSNIEN)']""
IF ($GET(PSNFT)']"")
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+12 IF $GET(PSNIEN)]""
IF (+$GET(PSNIEN)'>0)
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+13 IF $GET(PSNIEN)]""
NEW PSNIEN2
SET PSNIEN2=$$FIND1^DIC(56,"","A","`"_PSNIEN,,,"")
Begin DoDot:1
+14 IF +PSNIEN2'>0
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+15 SET ^TMP($JOB,LIST,0)=1
+16 DO GETS^DIQ(56,+PSNIEN2,".01;1;2;3;4;5;6;7","IE","PSNP56")
SET PSN(1)=0
+17 FOR
SET PSN(1)=$ORDER(PSNP56(56,PSN(1)))
IF 'PSN(1)
QUIT
DO SETALL
End DoDot:1
+18 IF $GET(PSNIEN)=""
IF $GET(PSNFT)]""
Begin DoDot:1
+19 IF PSNFT["??"
DO LOOP
QUIT
+20 DO FIND^DIC(56,,"@;.01;","QP",PSNFT,,"B",,,"")
+21 IF +$GET(^TMP("DILIST",$JOB,0))=0
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+22 SET ^TMP($JOB,LIST,0)=+^TMP("DILIST",$JOB,0)
+23 IF +^TMP("DILIST",$JOB,0)>0
NEW PSNXX
SET PSNXX=0
FOR
SET PSNXX=$ORDER(^TMP("DILIST",$JOB,PSNXX))
IF 'PSNXX
QUIT
Begin DoDot:2
+24 SET PSNIEN=+^TMP("DILIST",$JOB,PSNXX,0)
KILL PSNP56
DO GETS^DIQ(56,+PSNIEN,".01;1;2;3;4;5;6;7","IE","PSNP56")
SET PSN(1)=0
+25 FOR
SET PSN(1)=$ORDER(PSNP56(56,PSN(1)))
IF 'PSN(1)
QUIT
DO SETALL
End DoDot:2
End DoDot:1
+26 KILL ^TMP("DILIST",$JOB)
+27 QUIT
+28 ;
SETALL ;
+1 SET ^TMP($JOB,LIST,+PSN(1),.01)=$GET(PSNP56(56,PSN(1),.01,"I"))
+2 SET ^TMP($JOB,LIST,"B",$GET(PSNP56(56,PSN(1),.01,"I")),+PSN(1))=""
+3 SET ^TMP($JOB,LIST,+PSN(1),1)=$SELECT($GET(PSNP56(56,PSN(1),1,"I"))="":"",1:PSNP56(56,PSN(1),1,"I")_"^"_PSNP56(56,PSN(1),1,"E"))
+4 SET ^TMP($JOB,LIST,+PSN(1),2)=$SELECT($GET(PSNP56(56,PSN(1),2,"I"))="":"",1:PSNP56(56,PSN(1),2,"I")_"^"_PSNP56(56,PSN(1),2,"E"))
+5 SET ^TMP($JOB,LIST,+PSN(1),3)=$SELECT($GET(PSNP56(56,PSN(1),3,"I"))="":"",1:PSNP56(56,PSN(1),3,"I")_"^"_PSNP56(56,PSN(1),3,"E"))
+6 SET ^TMP($JOB,LIST,+PSN(1),4)=$SELECT($GET(PSNP56(56,PSN(1),4,"I"))="":"",1:PSNP56(56,PSN(1),4,"I")_"^"_PSNP56(56,PSN(1),4,"E"))
+7 SET ^TMP($JOB,LIST,+PSN(1),5)=$GET(PSNP56(56,PSN(1),5,"I"))
+8 SET ^TMP($JOB,LIST,+PSN(1),7)=$SELECT($GET(PSNP56(56,PSN(1),7,"I"))="":"",1:PSNP56(56,PSN(1),7,"I")_"^"_PSNP56(56,PSN(1),7,"E"))
+9 SET ^TMP($JOB,LIST,+PSN(1),6)=$SELECT($GET(PSNP56(56,PSN(1),6,"I"))="":"",1:PSNP56(56,PSN(1),6,"I")_"^"_PSNP56(56,PSN(1),6,"E"))
+10 QUIT
+11 ;
SETING ;
+1 SET ^TMP($JOB,LIST,+PSN(1),.01)=$GET(PSNP56(56,PSN(1),.01,"I"))
+2 SET ^TMP($JOB,LIST,"APD",$GET(PSNP56(56,PSN(1),.01,"I")),+PSN(1))=""
+3 SET ^TMP($JOB,LIST,+PSN(1),1)=$SELECT($GET(PSNP56(56,PSN(1),1,"I"))="":"",1:PSNP56(56,PSN(1),1,"I")_"^"_PSNP56(56,PSN(1),1,"E"))
+4 SET ^TMP($JOB,LIST,+PSN(1),2)=$SELECT($GET(PSNP56(56,PSN(1),2,"I"))="":"",1:PSNP56(56,PSN(1),2,"I")_"^"_PSNP56(56,PSN(1),2,"E"))
+5 SET ^TMP($JOB,LIST,+PSN(1),3)=$SELECT($GET(PSNP56(56,PSN(1),3,"I"))="":"",1:PSNP56(56,PSN(1),3,"I")_"^"_PSNP56(56,PSN(1),3,"E"))
+6 SET ^TMP($JOB,LIST,+PSN(1),7)=$SELECT($GET(PSNP56(56,PSN(1),7,"I"))="":"",1:PSNP56(56,PSN(1),7,"I")_"^"_PSNP56(56,PSN(1),7,"E"))
+7 QUIT
+8 ;
LOOP ;
+1 SET PSNIEN=0
SET ^TMP($JOB,LIST,0)=0
FOR
SET PSNIEN=$ORDER(^PS(56,PSNIEN))
IF 'PSNIEN
QUIT
Begin DoDot:1
+2 KILL PSNP56
DO GETS^DIQ(56,+PSNIEN,".01;1;2;3;4;5;6;7","IE","PSNP56")
SET ^TMP($JOB,LIST,0)=^TMP($JOB,LIST,0)+1
SET PSN(1)=0
Begin DoDot:2
+3 FOR
SET PSN(1)=$ORDER(PSNP56(56,PSN(1)))
IF 'PSN(1)
QUIT
DO SETALL
End DoDot:2
End DoDot:1
+4 QUIT
+5 ;
IEN(PSNING1,PSNING2,PSNFL,LIST) ;
+1 ;PSNING1 - Drug Identifier for Ingredient 1.
+2 ;PSNING2 - Drug Identifier for Ingredient 2.
+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 ; Field Number of the data piece being returned.
+7 ;Returns NAME field (#.01), INGREDIENT field (#1), INGREDIENT2 field (#2), and INACTIVATION DATE field (#7)
+8 ;of DRUG INTERACTION file (#56).
+9 NEW PSNNXX,PSNXTOT,PSNXNODE,PSNP56,PSN
+10 IF $GET(LIST)']""
QUIT
+11 KILL ^TMP($JOB,LIST)
+12 IF $GET(PSNING1)']""!($GET(PSNING2)']"")
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+13 SET PSNXTOT=0
+14 FOR PSNNXX=0:0
SET PSNNXX=$ORDER(^PS(56,"APD",PSNING1,PSNING2,PSNNXX))
IF 'PSNNXX
QUIT
Begin DoDot:1
+15 IF '$DATA(^PS(56,PSNNXX,0))
QUIT
+16 SET PSNXNODE=$GET(^PS(56,PSNNXX,0))
IF $PIECE(PSNXNODE,"^")=""
QUIT
+17 IF $GET(PSNFL)
IF $PIECE(PSNXNODE,"^",7)
IF $PIECE(PSNXNODE,"^",7)'>PSNFL
QUIT
+18 KILL PSNP56
DO GETS^DIQ(56,+PSNNXX,".01;1;2;3;7","IE","PSNP56")
SET PSN(1)=0
Begin DoDot:2
+19 FOR
SET PSN(1)=$ORDER(PSNP56(56,PSN(1)))
IF 'PSN(1)
QUIT
DO SETING
SET PSNXTOT=PSNXTOT+1
End DoDot:2
End DoDot:1
+20 SET ^TMP($JOB,LIST,0)=$SELECT(+$GET(PSNXTOT)>0:PSNXTOT,1:-1_"^"_"NO DATA FOUND")
+21 QUIT