PSNPST ;BIR/WRT-POST INSTALL routine ; 02/03/00 7:52
;;4.0; NATIONAL DRUG FILE;**22**; 30 Oct 98
;
;Reference to ^PSDRUG supported by DBIA #2352
;Reference to ^PS(51.7 supported by DBIA #2935
;Reference to ^PS(50.7 supported by DBIA #2180
;
K ^TMP($J,"PSNFI") D FIX,BUILD,START,BRANCH3,KILL
Q
BUILD F NDT=0:0 S NDT=$O(^PS(51.7,NDT)) Q:'NDT S TEXT=^PS(51.7,NDT,2,1,0),^TMP($J,"PSNFI",TEXT)=NDT
Q
START U IO W !,"Converting DRUG file (#50)" F IFN=0:0 S IFN=$O(^PSDRUG(IFN)) Q:'IFN U IO W:'(IFN#100) "." S LINK=$P($G(^PSDRUG(IFN,"ND")),"^",3) I LINK D BRANCH1,BRANCH2
Q
BRANCH1 S FORMI=$P($G(^PSNDF(50.68,LINK,5)),"^") I FORMI]"" S $P(^PSDRUG(IFN,"ND"),"^",11)=FORMI
Q
BRANCH2 S NFR=$P($G(^PSNDF(50.68,LINK,6,1,0)),"^") I NFR]"",$D(^TMP($J,"PSNFI",NFR)) S ENTRY=$P(^TMP($J,"PSNFI",NFR),"^") D ENTER
Q
ENTER I '$D(^PSDRUG(IFN,9,0)) S DA(1)=IFN,DIC="^PSDRUG("_IFN_",9,",X=ENTRY,DIC(0)="L",DIC("P")=$P(^DD(50,37,0),"^",2),DLAYGO=50.037 D FILE^DICN
Q
KILL K ^TMP($J,"PSNFI"),LINK,NDT,IFN,FORMI,NFR,ENTRY,NFLAG,NFLAG1,PSSORDIT,ZZZ,IEN
Q
BRANCH3 U IO W !,"Converting PHARMACY ORDERABLE ITEM file (#50.7)" D BRANCH4
Q
BRANCH4 F PSSORDIT=0:0 S PSSORDIT=$O(^PS(50.7,PSSORDIT)) Q:'PSSORDIT U IO W:'(PSSORDIT#100) "." I $D(^PSDRUG("ASP",PSSORDIT)) S NFLAG=0,NFLAG1=0 F ZZZ=0:0 S ZZZ=$O(^PSDRUG("ASP",PSSORDIT,ZZZ)) Q:'ZZZ D NF1,NF2
Q
NF1 D:NFLAG=0 NF3
S:$P(^PSDRUG(ZZZ,0),"^",9)'="" NFLAG1=1
Q
NF2 I NFLAG=0 S $P(^PS(50.7,PSSORDIT,0),"^",12)=1
I NFLAG=1 S $P(^PS(50.7,PSSORDIT,0),"^",12)=""
Q
NF3 S:$P(^PSDRUG(ZZZ,0),"^",9)="" NFLAG=1
Q
FIX F IEN=0:0 S IEN=$O(^PSNDF(50.68,IEN)) Q:'IEN I '$D(^PSNDF(50.68,IEN,5)) S ^PSNDF(50.68,IEN,5)=0
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSNPST 1687 printed Dec 13, 2024@02:24:56 Page 2
PSNPST ;BIR/WRT-POST INSTALL routine ; 02/03/00 7:52
+1 ;;4.0; NATIONAL DRUG FILE;**22**; 30 Oct 98
+2 ;
+3 ;Reference to ^PSDRUG supported by DBIA #2352
+4 ;Reference to ^PS(51.7 supported by DBIA #2935
+5 ;Reference to ^PS(50.7 supported by DBIA #2180
+6 ;
+7 KILL ^TMP($JOB,"PSNFI")
DO FIX
DO BUILD
DO START
DO BRANCH3
DO KILL
+8 QUIT
BUILD FOR NDT=0:0
SET NDT=$ORDER(^PS(51.7,NDT))
if 'NDT
QUIT
SET TEXT=^PS(51.7,NDT,2,1,0)
SET ^TMP($JOB,"PSNFI",TEXT)=NDT
+1 QUIT
START USE IO
WRITE !,"Converting DRUG file (#50)"
FOR IFN=0:0
SET IFN=$ORDER(^PSDRUG(IFN))
if 'IFN
QUIT
USE IO
if '(IFN#100)
WRITE "."
SET LINK=$PIECE($GET(^PSDRUG(IFN,"ND")),"^",3)
IF LINK
DO BRANCH1
DO BRANCH2
+1 QUIT
BRANCH1 SET FORMI=$PIECE($GET(^PSNDF(50.68,LINK,5)),"^")
IF FORMI]""
SET $PIECE(^PSDRUG(IFN,"ND"),"^",11)=FORMI
+1 QUIT
BRANCH2 SET NFR=$PIECE($GET(^PSNDF(50.68,LINK,6,1,0)),"^")
IF NFR]""
IF $DATA(^TMP($JOB,"PSNFI",NFR))
SET ENTRY=$PIECE(^TMP($JOB,"PSNFI",NFR),"^")
DO ENTER
+1 QUIT
ENTER IF '$DATA(^PSDRUG(IFN,9,0))
SET DA(1)=IFN
SET DIC="^PSDRUG("_IFN_",9,"
SET X=ENTRY
SET DIC(0)="L"
SET DIC("P")=$PIECE(^DD(50,37,0),"^",2)
SET DLAYGO=50.037
DO FILE^DICN
+1 QUIT
KILL KILL ^TMP($JOB,"PSNFI"),LINK,NDT,IFN,FORMI,NFR,ENTRY,NFLAG,NFLAG1,PSSORDIT,ZZZ,IEN
+1 QUIT
BRANCH3 USE IO
WRITE !,"Converting PHARMACY ORDERABLE ITEM file (#50.7)"
DO BRANCH4
+1 QUIT
BRANCH4 FOR PSSORDIT=0:0
SET PSSORDIT=$ORDER(^PS(50.7,PSSORDIT))
if 'PSSORDIT
QUIT
USE IO
if '(PSSORDIT#100)
WRITE "."
IF $DATA(^PSDRUG("ASP",PSSORDIT))
SET NFLAG=0
SET NFLAG1=0
FOR ZZZ=0:0
SET ZZZ=$ORDER(^PSDRUG("ASP",PSSORDIT,ZZZ))
if 'ZZZ
QUIT
DO NF1
DO NF2
+1 QUIT
NF1 if NFLAG=0
DO NF3
+1 if $PIECE(^PSDRUG(ZZZ,0),"^",9)'=""
SET NFLAG1=1
+2 QUIT
NF2 IF NFLAG=0
SET $PIECE(^PS(50.7,PSSORDIT,0),"^",12)=1
+1 IF NFLAG=1
SET $PIECE(^PS(50.7,PSSORDIT,0),"^",12)=""
+2 QUIT
NF3 if $PIECE(^PSDRUG(ZZZ,0),"^",9)=""
SET NFLAG=1
+1 QUIT
FIX FOR IEN=0:0
SET IEN=$ORDER(^PSNDF(50.68,IEN))
if 'IEN
QUIT
IF '$DATA(^PSNDF(50.68,IEN,5))
SET ^PSNDF(50.68,IEN,5)=0
+1 QUIT