VistA-WorldVistAEHR/r/NATIONAL_DRUG_FILE-PSN/PSN50P68.m

69 lines
3.9 KiB
Mathematica
Raw Permalink Normal View History

2009-11-29 13:37:14 -05:00
PSN50P68 ;BIR/LDT - API FOR INFORMATION FROM FILE 50.68; 5 Sep 03
;;4.0; NATIONAL DRUG FILE;**80,94,104,109**; 30 Oct 98
;
FORM(PSNIEN) ;
;PSNIEN - IEN of entry in VA PRODUCT file (#50.68).
;Returns NATIONAL FORMULARY NAME field (#4) of the VA PRODUCT file (#50.68).
I +$G(PSNIEN)'>0 Q ""
Q $P($G(^PSNDF(50.68,+PSNIEN,0)),"^",6)
;
DATA(PSNIEN,PSNFT,LIST) ;
;PSNIEN - IEN of entry in VA PRODUCT file (#50.68).
;PSNFT - Free Text name in VA PRODUCT file (#50.68).
;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.
N DIERR,ZZERR,PSN50P68,PSN,PSNSERVP
S PSNSERVP=$$PATCH^XPDUTL("PSN*4.0*103")
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.68,"","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.68,+PSNIEN2,".01;.05;3;4;11;12;13;19;2000","IE","PSN50P68") S PSN(1)=0
.F S PSN(1)=$O(PSN50P68(50.68,PSN(1))) Q:'PSN(1) D SETZRO
I $G(PSNIEN)="",$G(PSNFT)]"" D
.I PSNFT["??" D LOOP Q
.D FIND^DIC(50.68,,"@;.01","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 PSN50P68 D GETS^DIQ(50.68,+PSNIEN,".01;.05;3;4;11;12;13;19;2000","IE","PSN50P68") S PSN(1)=0
..F S PSN(1)=$O(PSN50P68(50.68,PSN(1))) Q:'PSN(1) D SETZRO
K ^TMP("DILIST",$J)
Q
SETZRO ;
S ^TMP($J,LIST,+PSN(1),.01)=$G(PSN50P68(50.68,PSN(1),.01,"I"))
S ^TMP($J,LIST,"B",$G(PSN50P68(50.68,PSN(1),.01,"I")),+PSN(1))=""
S ^TMP($J,LIST,+PSN(1),.05)=$S($G(PSN50P68(50.68,PSN(1),.05,"I"))="":"",1:$G(PSN50P68(50.68,PSN(1),.05,"I"))_"^"_$G(PSN50P68(50.68,PSN(1),.05,"E")))
S ^TMP($J,LIST,+PSN(1),3)=$S($G(PSN50P68(50.68,PSN(1),3,"I"))="":"",1:$G(PSN50P68(50.68,PSN(1),3,"I"))_"^"_$G(PSN50P68(50.68,PSN(1),3,"E")))
S ^TMP($J,LIST,+PSN(1),4)=$G(PSN50P68(50.68,PSN(1),4,"I"))
S ^TMP($J,LIST,+PSN(1),11)=$G(PSN50P68(50.68,PSN(1),11,"I"))
S ^TMP($J,LIST,+PSN(1),12)=$G(PSN50P68(50.68,PSN(1),12,"I"))
S ^TMP($J,LIST,+PSN(1),13)=$G(PSN50P68(50.68,PSN(1),13,"I"))
S ^TMP($J,LIST,+PSN(1),19)=$S($G(PSN50P68(50.68,PSN(1),19,"I"))="":"",1:$G(PSN50P68(50.68,PSN(1),19,"I"))_"^"_$G(PSN50P68(50.68,PSN(1),19,"E")))
I $G(PSNSERVP) S ^TMP($J,LIST,+PSN(1),2000)=$S($G(PSN50P68(50.68,PSN(1),2000,"I"))'="":$G(PSN50P68(50.68,PSN(1),2000,"I")),1:600000)
Q
;
LOOP ;
N PSNIEN,CNT,PSN50DD1,PSN50DD2,PSN50DD3,PSN1NOD,PSNZNOD,PSN1NOD,PSN7FED
D FIELD^DID(50.68,19,"Z","POINTER","PSN50DD1","PSN50DD2") S PSN50DD3=$G(PSN50DD1("POINTER"))
S CNT=0
S PSNIEN=0 F S PSNIEN=$O(^PSNDF(50.68,PSNIEN)) Q:'PSNIEN D
.S PSNZNOD=$G(^PSNDF(50.68,PSNIEN,0)),PSN1NOD=$G(^(1)),PSN7FED=$P($G(^(7)),"^")
.I $P(PSNZNOD,"^")="" Q
.S CNT=CNT+1
.S ^TMP($J,LIST,PSNIEN,.01)=$P(PSNZNOD,"^")
.S ^TMP($J,LIST,"B",$P(PSNZNOD,"^"),PSNIEN)=""
.S ^TMP($J,LIST,PSNIEN,.05)=$S($P(PSNZNOD,"^",2)="":"",1:$P(PSNZNOD,"^",2)_"^"_$P($G(^PSNDF(50.6,+$P(PSNZNOD,"^",2),0)),"^"))
.S ^TMP($J,LIST,PSNIEN,3)=$S($P(PSNZNOD,"^",5)="":"",1:$P(PSNZNOD,"^",5)_"^"_$P($G(^PS(50.607,+$P(PSNZNOD,"^",5),0)),"^"))
.S ^TMP($J,LIST,PSNIEN,4)=$P(PSNZNOD,"^",6)
.S ^TMP($J,LIST,PSNIEN,11)=$P(PSN1NOD,"^",5)
.S ^TMP($J,LIST,PSNIEN,12)=$P(PSN1NOD,"^",6)
.S ^TMP($J,LIST,PSNIEN,13)=$P(PSN1NOD,"^",7)
.I PSN50DD3'="",PSN7FED'="",PSN50DD3[(PSN7FED_":") S ^TMP($J,LIST,PSNIEN,19)=PSN7FED_"^"_$P($E(PSN50DD3,$F(PSN50DD3,(PSN7FED_":")),999),";")
.I '$D(^TMP($J,LIST,PSNIEN,19)) S ^TMP($J,LIST,PSNIEN,19)=""
.I $G(PSNSERVP) S ^TMP($J,LIST,PSNIEN,2000)=$S($P($G(^PSNDF(50.68,PSNIEN,"PFS")),"^")'="":$P($G(^PSNDF(50.68,PSNIEN,"PFS")),"^"),1:600000)
S ^TMP($J,LIST,0)=$S(+CNT>0:CNT,1:"-1^NO DATA FOUND")
Q