PSN50P65 ;BIR/LDT - API FOR INFORMATION FROM FILE 50.605;Nov 16, 2018@10:30
;;4.0;NATIONAL DRUG FILE;**80,567**;30 Oct 98;Build 4
;
IEN(PSNIEN,PSNFT,LIST) ;
;PSNIEN - IEN of entry in VA DRUG CLASS file (#50.605).
;PSNFT - Free Text name in VA DRUG CLASS file (#50.605).
;LIST - Subscript of ^TMP array in the form ^TMP($J,LIST,Field Number where Field Number is the
; Field Number of the data piece beingreturned.
;Returns CODE field (#.01), and CLASSIFICATION field (#1) of VA DRUG CLASS file (#50.605).
N DIERR,ZZERR,PSN50P65,PSN
I $G(LIST)']"" Q
K ^TMP($J,LIST)
I +$G(PSNIEN)'>0,($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(50.605,"","B","`"_PSNIEN,,,"") D
.I +PSNIEN2'>0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
.S ^TMP($J,LIST,0)=1
.D GETS^DIQ(50.605,+PSNIEN2,".01;1","IE","PSN50P65") S PSN(1)=0
.F S PSN(1)=$O(PSN50P65(50.605,PSN(1))) Q:'PSN(1) D SETZRO
I $G(PSNIEN)="",$G(PSNFT)]"" D
.I PSNFT["??" D LOOP(1) Q
.D FIND^DIC(50.605,,"@;.01;1","QP",PSNFT,,"B",,,"")
.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 PSN50P65 D GETS^DIQ(50.605,+PSNIEN,".01;1","IE","PSN50P65") S PSN(1)=0
..F S PSN(1)=$O(PSN50P65(50.605,PSN(1))) Q:'PSN(1) D SETZRO
K ^TMP("DILIST",$J)
Q
;
ROOT(PSNC) ;
;Q "^PS(50.605, ""C"")" if PSNC is passed in as 1. If PSNC is null, Q "^PS(50.605,"
I $G(PSNC)'=1 Q "^PS(50.605,"
Q "^PS(50.605,""C"")"
;
C(PSNIEN,PSNFT,LIST) ;
;PSNIEN - IEN of entry in VA DRUG CLASS file (#50.605).
;PSNFT - Free Text name in VA DRUG CLASS file (#50.605).
;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 CODE field (#.01), CLASSIFICATION field (#1),PARENT CLASS field (#2), and TYPE field (#3)
;of VA DRUG CLASS file (#50.605).
N DIERR,ZZERR,PSN50P65,PSN
I $G(LIST)']"" Q
K ^TMP($J,LIST)
I +$G(PSNIEN)'>0,($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)>0 N PSNIEN2 S PSNIEN2=$$FIND1^DIC(50.605,"","A","`"_PSNIEN,"C",,"") D
.I +PSNIEN2'>0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
.S ^TMP($J,LIST,0)=1
.D GETS^DIQ(50.605,+PSNIEN2,".01;1;2;3","IE","PSN50P65") S PSN(1)=0
.F S PSN(1)=$O(PSN50P65(50.605,PSN(1))) Q:'PSN(1) D SETZRO2
I $G(PSNIEN)="",$G(PSNFT)]"" D
.I PSNFT["??" D LOOP(2) Q
.D FIND^DIC(50.605,,"@;.01;1","QP",PSNFT,,"C",,,"")
.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 PSN50P65 D GETS^DIQ(50.605,+PSNIEN,".01;1;2;3","IE","PSN50P65") S PSN(1)=0
..F S PSN(1)=$O(PSN50P65(50.605,PSN(1))) Q:'PSN(1) D SETZRO2
K ^TMP("DILIST",$J)
Q
;
SETZRO ;
S ^TMP($J,LIST,+PSN(1),.01)=$G(PSN50P65(50.605,PSN(1),.01,"I"))
S ^TMP($J,LIST,"B",$G(PSN50P65(50.605,PSN(1),.01,"I")),+PSN(1))=""
S ^TMP($J,LIST,+PSN(1),1)=$G(PSN50P65(50.605,PSN(1),1,"I"))
Q
;
SETZRO2 ;
S ^TMP($J,LIST,+PSN(1),.01)=$G(PSN50P65(50.605,PSN(1),.01,"I"))
S ^TMP($J,LIST,"C",$G(PSN50P65(50.605,PSN(1),.01,"I")),+PSN(1))=""
S ^TMP($J,LIST,+PSN(1),1)=$G(PSN50P65(50.605,PSN(1),1,"I"))
S ^TMP($J,LIST,+PSN(1),2)=$S($G(PSN50P65(50.605,PSN(1),2,"I"))="":"",1:PSN50P65(50.605,PSN(1),2,"I")_"^"_PSN50P65(50.605,PSN(1),2,"E"))
S ^TMP($J,LIST,+PSN(1),3)=$S($G(PSN50P65(50.605,PSN(1),3,"I"))="":"",1:PSN50P65(50.605,PSN(1),3,"I")_"^"_PSN50P65(50.605,PSN(1),3,"E"))
Q
;
LOOP(PSN) ;
N PSNIEN,CNT S CNT=0
S PSNIEN=0 F S PSNIEN=$O(^PS(50.605,PSNIEN)) Q:'PSNIEN D
.K PSN50P65 D GETS^DIQ(50.605,+PSNIEN,".01;1;2;3","IE","PSN50P65") S PSN(1)=0 D
..F S PSN(1)=$O(PSN50P65(50.605,PSN(1))) Q:'PSN(1) D @(PSN) S CNT=CNT+1
S ^TMP($J,LIST,0)=$S(+CNT>0:CNT,1:"-1^NO DATA FOUND")
Q
1 ;
D SETZRO
Q
;
2 ;
D SETZRO2
Q
SSET(PSNC,PSNCNT,PSNI,DIR,SUB) ;Pull back a subset of the PHARMACY ORDERABLE ITEM file (#50.7)
;
N PSNJ,X,Y
F Q:PSNC'<PSNCNT S PSNI=$O(^PS(50.605,"B",PSNI),DIR) Q:PSNI="" S PSNJ=0 F S PSNJ=$O(^PS(50.605,"B",PSNI,PSNJ)) Q:'PSNJ D
. S Y=$G(^PS(50.605,PSNJ,0)) I $P(Y,"^",2)["INACTIVE" Q
. I $P(Y,"^",3)="",PSNI'="HA000" Q
. S PSNC=PSNC+1,^TMP(SUB,$J,1,PSNC)=PSNJ_"^"_PSNI_" - "_$P(Y,"^",2)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSN50P65 4715 printed Sep 15, 2024@21:46:46 Page 2
PSN50P65 ;BIR/LDT - API FOR INFORMATION FROM FILE 50.605;Nov 16, 2018@10:30
+1 ;;4.0;NATIONAL DRUG FILE;**80,567**;30 Oct 98;Build 4
+2 ;
IEN(PSNIEN,PSNFT,LIST) ;
+1 ;PSNIEN - IEN of entry in VA DRUG CLASS file (#50.605).
+2 ;PSNFT - Free Text name in VA DRUG CLASS file (#50.605).
+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 beingreturned.
+5 ;Returns CODE field (#.01), and CLASSIFICATION field (#1) of VA DRUG CLASS file (#50.605).
+6 NEW DIERR,ZZERR,PSN50P65,PSN
+7 IF $GET(LIST)']""
QUIT
+8 KILL ^TMP($JOB,LIST)
+9 IF +$GET(PSNIEN)'>0
IF ($GET(PSNFT)']"")
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+10 IF $GET(PSNIEN)]""
IF +$GET(PSNIEN)'>0
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+11 IF $GET(PSNIEN)]""
NEW PSNIEN2
SET PSNIEN2=$$FIND1^DIC(50.605,"","B","`"_PSNIEN,,,"")
Begin DoDot:1
+12 IF +PSNIEN2'>0
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+13 SET ^TMP($JOB,LIST,0)=1
+14 DO GETS^DIQ(50.605,+PSNIEN2,".01;1","IE","PSN50P65")
SET PSN(1)=0
+15 FOR
SET PSN(1)=$ORDER(PSN50P65(50.605,PSN(1)))
if 'PSN(1)
QUIT
DO SETZRO
End DoDot:1
+16 IF $GET(PSNIEN)=""
IF $GET(PSNFT)]""
Begin DoDot:1
+17 IF PSNFT["??"
DO LOOP(1)
QUIT
+18 DO FIND^DIC(50.605,,"@;.01;1","QP",PSNFT,,"B",,,"")
+19 IF +$GET(^TMP("DILIST",$JOB,0))=0
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+20 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
+21 SET PSNIEN=+^TMP("DILIST",$JOB,PSNXX,0)
KILL PSN50P65
DO GETS^DIQ(50.605,+PSNIEN,".01;1","IE","PSN50P65")
SET PSN(1)=0
+22 FOR
SET PSN(1)=$ORDER(PSN50P65(50.605,PSN(1)))
if 'PSN(1)
QUIT
DO SETZRO
End DoDot:2
End DoDot:1
+23 KILL ^TMP("DILIST",$JOB)
+24 QUIT
+25 ;
ROOT(PSNC) ;
+1 ;Q "^PS(50.605, ""C"")" if PSNC is passed in as 1. If PSNC is null, Q "^PS(50.605,"
+2 IF $GET(PSNC)'=1
QUIT "^PS(50.605,"
+3 QUIT "^PS(50.605,""C"")"
+4 ;
C(PSNIEN,PSNFT,LIST) ;
+1 ;PSNIEN - IEN of entry in VA DRUG CLASS file (#50.605).
+2 ;PSNFT - Free Text name in VA DRUG CLASS file (#50.605).
+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 CODE field (#.01), CLASSIFICATION field (#1),PARENT CLASS field (#2), and TYPE field (#3)
+6 ;of VA DRUG CLASS file (#50.605).
+7 NEW DIERR,ZZERR,PSN50P65,PSN
+8 IF $GET(LIST)']""
QUIT
+9 KILL ^TMP($JOB,LIST)
+10 IF +$GET(PSNIEN)'>0
IF ($GET(PSNFT)']"")
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+11 IF $GET(PSNIEN)]""
IF +$GET(PSNIEN)'>0
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+12 IF +$GET(PSNIEN)>0
NEW PSNIEN2
SET PSNIEN2=$$FIND1^DIC(50.605,"","A","`"_PSNIEN,"C",,"")
Begin DoDot:1
+13 IF +PSNIEN2'>0
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+14 SET ^TMP($JOB,LIST,0)=1
+15 DO GETS^DIQ(50.605,+PSNIEN2,".01;1;2;3","IE","PSN50P65")
SET PSN(1)=0
+16 FOR
SET PSN(1)=$ORDER(PSN50P65(50.605,PSN(1)))
if 'PSN(1)
QUIT
DO SETZRO2
End DoDot:1
+17 IF $GET(PSNIEN)=""
IF $GET(PSNFT)]""
Begin DoDot:1
+18 IF PSNFT["??"
DO LOOP(2)
QUIT
+19 DO FIND^DIC(50.605,,"@;.01;1","QP",PSNFT,,"C",,,"")
+20 IF +$GET(^TMP("DILIST",$JOB,0))=0
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+21 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
+22 SET PSNIEN=+^TMP("DILIST",$JOB,PSNXX,0)
KILL PSN50P65
DO GETS^DIQ(50.605,+PSNIEN,".01;1;2;3","IE","PSN50P65")
SET PSN(1)=0
+23 FOR
SET PSN(1)=$ORDER(PSN50P65(50.605,PSN(1)))
if 'PSN(1)
QUIT
DO SETZRO2
End DoDot:2
End DoDot:1
+24 KILL ^TMP("DILIST",$JOB)
+25 QUIT
+26 ;
SETZRO ;
+1 SET ^TMP($JOB,LIST,+PSN(1),.01)=$GET(PSN50P65(50.605,PSN(1),.01,"I"))
+2 SET ^TMP($JOB,LIST,"B",$GET(PSN50P65(50.605,PSN(1),.01,"I")),+PSN(1))=""
+3 SET ^TMP($JOB,LIST,+PSN(1),1)=$GET(PSN50P65(50.605,PSN(1),1,"I"))
+4 QUIT
+5 ;
SETZRO2 ;
+1 SET ^TMP($JOB,LIST,+PSN(1),.01)=$GET(PSN50P65(50.605,PSN(1),.01,"I"))
+2 SET ^TMP($JOB,LIST,"C",$GET(PSN50P65(50.605,PSN(1),.01,"I")),+PSN(1))=""
+3 SET ^TMP($JOB,LIST,+PSN(1),1)=$GET(PSN50P65(50.605,PSN(1),1,"I"))
+4 SET ^TMP($JOB,LIST,+PSN(1),2)=$SELECT($GET(PSN50P65(50.605,PSN(1),2,"I"))="":"",1:PSN50P65(50.605,PSN(1),2,"I")_"^"_PSN50P65(50.605,PSN(1),2,"E"))
+5 SET ^TMP($JOB,LIST,+PSN(1),3)=$SELECT($GET(PSN50P65(50.605,PSN(1),3,"I"))="":"",1:PSN50P65(50.605,PSN(1),3,"I")_"^"_PSN50P65(50.605,PSN(1),3,"E"))
+6 QUIT
+7 ;
LOOP(PSN) ;
+1 NEW PSNIEN,CNT
SET CNT=0
+2 SET PSNIEN=0
FOR
SET PSNIEN=$ORDER(^PS(50.605,PSNIEN))
if 'PSNIEN
QUIT
Begin DoDot:1
+3 KILL PSN50P65
DO GETS^DIQ(50.605,+PSNIEN,".01;1;2;3","IE","PSN50P65")
SET PSN(1)=0
Begin DoDot:2
+4 FOR
SET PSN(1)=$ORDER(PSN50P65(50.605,PSN(1)))
if 'PSN(1)
QUIT
DO @(PSN)
SET CNT=CNT+1
End DoDot:2
End DoDot:1
+5 SET ^TMP($JOB,LIST,0)=$SELECT(+CNT>0:CNT,1:"-1^NO DATA FOUND")
+6 QUIT
1 ;
+1 DO SETZRO
+2 QUIT
+3 ;
2 ;
+1 DO SETZRO2
+2 QUIT
SSET(PSNC,PSNCNT,PSNI,DIR,SUB) ;Pull back a subset of the PHARMACY ORDERABLE ITEM file (#50.7)
+1 ;
+2 NEW PSNJ,X,Y
+3 FOR
if PSNC'<PSNCNT
QUIT
SET PSNI=$ORDER(^PS(50.605,"B",PSNI),DIR)
if PSNI=""
QUIT
SET PSNJ=0
FOR
SET PSNJ=$ORDER(^PS(50.605,"B",PSNI,PSNJ))
if 'PSNJ
QUIT
Begin DoDot:1
+4 SET Y=$GET(^PS(50.605,PSNJ,0))
IF $PIECE(Y,"^",2)["INACTIVE"
QUIT
+5 IF $PIECE(Y,"^",3)=""
IF PSNI'="HA000"
QUIT
+6 SET PSNC=PSNC+1
SET ^TMP(SUB,$JOB,1,PSNC)=PSNJ_"^"_PSNI_" - "_$PIECE(Y,"^",2)
End DoDot:1
+7 QUIT