PSAP41 ;BHM/DB - PRIME VENDOR CONVERSION ROUTINE ;3/30/04
;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**41**; 10/24/97
;References to ^PSDRUG( are covered by IA #2095
W !!,"This routine is only to be run prior to the first execution of the Drug",!,"Accountability upload utility used with the new prime vendor (McKesson).",!
ASK K DIR S DIR("A")="Is it safe to run this utility",DIR(0)="Y",DIR("B")="NO" D ^DIR W " ",$S($G(Y)=1:"YES",$G(Y)="^":"^ Install Aborted",1:"NO")
I $D(DIRUT) S (XPDQUIT,XPDABORT)=1 G DONE
K DIR I $G(Y)'=1 W !!,"This utility can be run at anytime in the future from the programmer prompt",!,"by running the routine PSAP41.",! G DONE
DEV W ! K DIR S DIR(0)="DA^NOW::ERSX",DIR("A")="When do you want to run this utility? ",DIR("B")="NOW",DIR("?")="Complete date and time must be stated." D ^DIR I $D(DIRUT) W !!,"Incomplete information, try again" G ASK
S ZTDTH=Y,ZTRTN="PSABGN^PSAP41",ZTDESC="DRUG ACCOUNTABILITY VSN CONVERSION",ZTIO="",PSADUZ=DUZ,ZTSAVE("PSADUZ")=""
D ^%ZTLOAD I '$D(ZTSK) D HOME^%ZIS W !,"Task was not started properly.",! G DONE
W !!,"Task Queued - Task Number: ",ZTSK,!!
G DONE
PSABGN ;begin process
S (PSADRG,PSACNT2)=0
1 S PSADRG=$O(^PSDRUG(PSADRG)) G MSG:PSADRG'>0 I '$D(^PSDRUG(PSADRG,1,0)) G 1
S PSASYN=0
2 S PSASYN=$O(^PSDRUG(PSADRG,1,PSASYN)) G 1:PSASYN'>0 S PSADATA=$G(^PSDRUG(PSADRG,1,PSASYN,0))
S PSAVEND=$P($G(PSADATA),"^",9),PSAVEND=$TR(PSAVEND,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
I PSAVEND["AMERISOURCE" S DIE="^PSDRUG("_PSADRG_",1,",DA(1)=PSADRG,DA=PSASYN,DR="400///UNKNOWN" D ^DIE K DA,DR S PSACNT2=$G(PSACNT2)+1
G 2
DONE K DIE,DA,DR,DIR,PSADRG,PSASYN,PSADATA,PSAVEND
Q Q
MSG S XMSUB="PSA*3*41 Pre-install routine completed"
S ^TMP("PSA",$J,1,0)="The post Amerisource/Pre-McKesson conversion of synonym data has completed."
S ^TMP("PSA",$J,2,0)=" ",^TMP("PSA",$J,3,0)="Synonym Vendor Stock Numbers converted: "_$G(PSACNT2)
S XMY(PSADUZ)="",XMDUZ="Drug Accountability Pre-installation routine",XMTEXT="^TMP(""PSA"",$J,"
D ^XMD K PSADUZ
G DONE
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSAP41 2076 printed Dec 13, 2024@01:49:57 Page 2
PSAP41 ;BHM/DB - PRIME VENDOR CONVERSION ROUTINE ;3/30/04
+1 ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**41**; 10/24/97
+2 ;References to ^PSDRUG( are covered by IA #2095
+3 WRITE !!,"This routine is only to be run prior to the first execution of the Drug",!,"Accountability upload utility used with the new prime vendor (McKesson).",!
ASK KILL DIR
SET DIR("A")="Is it safe to run this utility"
SET DIR(0)="Y"
SET DIR("B")="NO"
DO ^DIR
WRITE " ",$SELECT($GET(Y)=1:"YES",$GET(Y)="^":"^ Install Aborted",1:"NO")
+1 IF $DATA(DIRUT)
SET (XPDQUIT,XPDABORT)=1
GOTO DONE
+2 KILL DIR
IF $GET(Y)'=1
WRITE !!,"This utility can be run at anytime in the future from the programmer prompt",!,"by running the routine PSAP41.",!
GOTO DONE
DEV WRITE !
KILL DIR
SET DIR(0)="DA^NOW::ERSX"
SET DIR("A")="When do you want to run this utility? "
SET DIR("B")="NOW"
SET DIR("?")="Complete date and time must be stated."
DO ^DIR
IF $DATA(DIRUT)
WRITE !!,"Incomplete information, try again"
GOTO ASK
+1 SET ZTDTH=Y
SET ZTRTN="PSABGN^PSAP41"
SET ZTDESC="DRUG ACCOUNTABILITY VSN CONVERSION"
SET ZTIO=""
SET PSADUZ=DUZ
SET ZTSAVE("PSADUZ")=""
+2 DO ^%ZTLOAD
IF '$DATA(ZTSK)
DO HOME^%ZIS
WRITE !,"Task was not started properly.",!
GOTO DONE
+3 WRITE !!,"Task Queued - Task Number: ",ZTSK,!!
+4 GOTO DONE
PSABGN ;begin process
+1 SET (PSADRG,PSACNT2)=0
1 SET PSADRG=$ORDER(^PSDRUG(PSADRG))
if PSADRG'>0
GOTO MSG
IF '$DATA(^PSDRUG(PSADRG,1,0))
GOTO 1
+1 SET PSASYN=0
2 SET PSASYN=$ORDER(^PSDRUG(PSADRG,1,PSASYN))
if PSASYN'>0
GOTO 1
SET PSADATA=$GET(^PSDRUG(PSADRG,1,PSASYN,0))
+1 SET PSAVEND=$PIECE($GET(PSADATA),"^",9)
SET PSAVEND=$TRANSLATE(PSAVEND,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+2 IF PSAVEND["AMERISOURCE"
SET DIE="^PSDRUG("_PSADRG_",1,"
SET DA(1)=PSADRG
SET DA=PSASYN
SET DR="400///UNKNOWN"
DO ^DIE
KILL DA,DR
SET PSACNT2=$GET(PSACNT2)+1
+3 GOTO 2
DONE KILL DIE,DA,DR,DIR,PSADRG,PSASYN,PSADATA,PSAVEND
Q QUIT
MSG SET XMSUB="PSA*3*41 Pre-install routine completed"
+1 SET ^TMP("PSA",$JOB,1,0)="The post Amerisource/Pre-McKesson conversion of synonym data has completed."
+2 SET ^TMP("PSA",$JOB,2,0)=" "
SET ^TMP("PSA",$JOB,3,0)="Synonym Vendor Stock Numbers converted: "_$GET(PSACNT2)
+3 SET XMY(PSADUZ)=""
SET XMDUZ="Drug Accountability Pre-installation routine"
SET XMTEXT="^TMP(""PSA"",$J,"
+4 DO ^XMD
KILL PSADUZ
+5 GOTO DONE