Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PSOTPPOS

PSOTPPOS.m

Go to the documentation of this file.
  1. PSOTPPOS ;BIR/RTR-Patch 145 Post Install routine ;07/27/03
  1. ;;7.0;OUTPATIENT PHARMACY;**145**;DEC 1997
  1. ;Reference to SDPHARM supported by DBIA 4193
  1. ;Reference to SDPBE supported by DBIA 4194
  1. ;Reference to DIC(19 supported by DBIA 2246
  1. ;Reference to DIC(4 supported by DBIA 2251
  1. ;
  1. G FILE
  1. N PSOTPLLZ,PSOTPFLG
  1. S PSOTPFLG=0
  1. S PSOTPLLZ="" F S PSOTPLLZ=$O(^PS(53,"B","NON-VA",PSOTPLLZ)) Q:PSOTPLLZ="" D
  1. .I $P($G(^PS(53,PSOTPLLZ,0)),"^")="NON-VA" S $P(^(0),"^",6)=5,PSOTPFLG=PSOTPFLG+1
  1. I '$G(PSOTPFLG) D BMES^XPDUTL("Could not find a NON-VA entry in the RX PATIENT STATUS file.") D MES^XPDUTL("Please contact National Vista Support!")
  1. I $G(PSOTPFLG)>1 D BMES^XPDUTL("Found multiple entries of NON-VA in the RX PATIENT STATUS file.") D MES^XPDUTL("Please contact National Vista Support!")
  1. ;
  1. FILE ;Populate TPB file
  1. ;N VARIABLE
  1. ;S ZTDTH=""
  1. ;I $D(ZTQUEUED) S ZTDTH=$H
  1. L +^XTMP("SDPSO145"):0 I '$T D Q
  1. .D BMES^XPDUTL("Post-Init for patch PSO*7*145 is already running. Halting..")
  1. ;I ZTDTH="" D
  1. ;.D BMES^XPDUTL("Auto-Populate TPB ELIGIBILITY (#52.91) File.")
  1. ;.D BMES^XPDUTL("If no start date/time is entered when prompted, the background job will ")
  1. ;.D MES^XPDUTL("be queued to run NOW.")
  1. ;.D GETDATE
  1. ;.D BMES^XPDUTL("Queuing background job to populate TPB ELIGIBILITY (#52.91) File.")
  1. ;S ZTDTH=@XPDGREF@("PSOPINIT")
  1. I '$G(^XTMP("SDPSO145","PSOTINIT")) D BMES^XPDUTL("Install aborted, cannot determine post-install task time..") Q
  1. S ZTDTH=$G(^XTMP("SDPSO145","PSOTINIT")) L -^XTMP("SDPSO145")
  1. S ZTRTN="START^PSOTPPOS",ZTIO="",ZTDESC="Populate TPB ELIGIBILITY FILE" D ^%ZTLOAD K ZTDTH,ZTRTN,ZTIO,ZTDESC
  1. I $D(ZTSK)&('$D(ZTQUEUED)) D BMES^XPDUTL("Task Queued!")
  1. Q
  1. START ;Build TPC Eligibility file
  1. I '$G(DT) S DT=$$DT^XLFDT
  1. S U="^"
  1. N PSOACTRX,PSOENRLD,PSOLPQT,PSONODAD,PSOTG1,PSOTG2,PSOTG3,PSOETOT,PSOITOT,PSOTLOCK,PSOTPSNM,PSOSTATI
  1. S (PSOETOT,PSOITOT)=0
  1. S PSOTLOCK=0
  1. L +^XTMP("SDPSO145"):0 I '$T S PSOTLOCK=1 D MAIL S:$D(ZTQUEUED) ZTREQ="@" Q
  1. K ^XTMP("SDPSO145")
  1. S X1=DT,X2=+60 D C^%DTC S ^XTMP("SDPSO145",0)=$G(X)_"^"_DT K X1,X2
  1. D NOW^%DTC S Y=% D DD^%DT S ^XTMP("SDPSO145","START")=$G(Y)
  1. D ^SDPHARM
  1. D ^SDPBE
  1. I '$D(^XTMP("SDPSO145","PAT")) G PASS
  1. S PSOTG1="" F S PSOTG1=$O(^XTMP("SDPSO145","PAT","E",PSOTG1)) Q:PSOTG1="" D
  1. .I $D(^PS(52.91,PSOTG1,0)) Q ;Multiple Installs check
  1. .S PSOLPQT=0
  1. .S PSOTG2="" F S PSOTG2=$O(^XTMP("SDPSO145","PAT","E",PSOTG1,PSOTG2)) Q:PSOTG2=""!(PSOLPQT) S PSOTG3="" F S PSOTG3=$O(^XTMP("SDPSO145","PAT","E",PSOTG1,PSOTG2,PSOTG3)) Q:PSOTG3=""!(PSOLPQT) D
  1. ..S PSONODAD=$G(^XTMP("SDPSO145","PAT","E",PSOTG1,PSOTG2,PSOTG3))
  1. ..I $P($G(^PS(52.91,PSOTG1,0)),"^",5),'PSONODAD D Q ;Entry exists, if this date is sooner, replace, if you get a Station Number
  1. ...I PSOTG3'<$P($G(^PS(52.91,PSOTG1,0)),"^",5) Q
  1. ...I PSOTG2=$P($G(^PS(52.91,PSOTG1,0)),"^",8) K DIE,DA,DR S DIE="^PS(52.91,",DA=PSOTG1,DR="4////"_PSOTG3 D ^DIE K DIE,DA,DR Q
  1. ...K PSOTPSNM,PSOSTATI,DIC,DIQ,DD,DR S DIC=4,DR="99",DA=+PSOTG2,DIQ(0)="I",DIQ="PSOSTATI" D EN^DIQ1 S PSOTPSNM=$G(PSOSTATI(4,+PSOTG2,99,"I")) K DIC,DIQ,DR,DA,PSOSTATI
  1. ...I $G(PSOTPSNM)="" K PSOTPSNM Q
  1. ...K DA,DIE,DR S DIE="^PS(52.91,",DA=PSOTG1,DR="4////"_PSOTG3_";6////"_PSOTPSNM_";7////"_PSOTG2 D ^DIE K DA,DIE,DR
  1. ...K PSOTPSNM
  1. ..I $D(^PS(52.91,PSOTG1,0)),'PSONODAD D Q
  1. ...I PSOTG2=$P($G(^PS(52.91,PSOTG1,0)),"^",8) K DIE,DA,DR S DIE="^PS(52.91,",DA=PSOTG1,DR="4////"_PSOTG3 D ^DIE K DIE,DA,DR Q
  1. ...K PSOTPSNM,PSOSTATI,DIC,DIQ,DD,DR S DIC=4,DR="99",DA=+PSOTG2,DIQ(0)="I",DIQ="PSOSTATI" D EN^DIQ1 S PSOTPSNM=$G(PSOSTATI(4,+PSOTG2,99,"I")) K DIC,DIQ,DR,DA,PSOSTATI
  1. ...I $G(PSOTPSNM)="" K PSOTPSNM Q
  1. ...K DA,DIE,DR S DIE="^PS(52.91,",DA=PSOTG1,DR="4////"_PSOTG3_";6////"_PSOTPSNM_";7////"_PSOTG2 D ^DIE K DA,DIE,DR
  1. ...K PSOTPSNM
  1. ..I $D(^PS(52.91,PSOTG1,0)) Q
  1. ..K PSOENRLD S PSOENRLD=$$ENR^PSOTPCRX(PSOTG1,3030725) I '$G(PSOENRLD) S ^XTMP("SDPSO145","NOTEN",PSOTG1)="",PSOLPQT=1 Q
  1. ..K PSOACTRX S PSOACTRX=$$RX^PSOTPCRX(PSOTG1) I $G(PSOACTRX) D EWL^PSOTPCRX S PSOLPQT=1 Q
  1. ..K PSOTPSNM
  1. ..K PSOSTATI,DIC,DIQ,DD,DR S DIC=4,DR="99",DA=+PSOTG2,DIQ(0)="I",DIQ="PSOSTATI" D EN^DIQ1 S PSOTPSNM=$G(PSOSTATI(4,+PSOTG2,99,"I")) K DIC,DIQ,DR,DA,PSOSTATI
  1. ..I $G(PSOTPSNM)="" S ^XTMP("SDPSO145","PROB1",PSOTG1)="" K PSOTPSNM Q
  1. ..I '$D(^PS(52.91,PSOTG1,0)) K DIC S DIC="^PS(52.91,",DIC(0)="L",(X,DINUM)=PSOTG1,DIC("DR")="1////"_DT_";5////"_"E"_";6////"_PSOTPSNM_";7////"_PSOTG2 S:'$G(PSONODAD) DIC("DR")=DIC("DR")_";4////"_PSOTG3 D
  1. ...K DD,DO D FILE^DICN K DD,DO,DIE,X,DINUM
  1. ...I Y'>0 S ^XTMP("SDPSO145","PROB",PSOTG1)="" Q
  1. ...S PSOETOT=PSOETOT+1
  1. ...K ^XTMP("SDPSO145","PROB",PSOTG1)
  1. ...K ^XTMP("SDPSO145","PROB1",PSOTG1)
  1. ;LOOP THROUGH SCHEDULING XTMP HERE
  1. D SCH^PSOTPCRX
  1. PASS ;
  1. S ^XTMP("SDPSO145","ELIG")=+$G(PSOETOT)
  1. S ^XTMP("SDPSO145","INEL")=+$G(PSOITOT)
  1. D EN^PSO145PS
  1. D NOW^%DTC S Y=% D DD^%DT S ^XTMP("SDPSO145","STOP")=$G(Y) K Y
  1. ;***need HL7 routine name (moved to phase 2)
  1. ;I '$$PATCH^XPDUTL("PSO*7.0*145") S ZTRTN="NAME^EXTRACT",ZTIO="",ZTDESC="TPB EIGIBILITY FILE EXTRACT",ZTDTH=$H D ^%ZTLOAD K ZTRTN,ZTIO,ZTDESC,ZTDTH
  1. D MAIL
  1. L -^XTMP("SDPSO145")
  1. K DA,DIE,DR S DA=$O(^DIC(19,"B","PSO TPB PATIENT ENTER/EDIT",0)) I DA S DIE="^DIC(19,",DR="2////"_"@" D ^DIE K DIE,DA,DR
  1. S:$D(ZTQUEUED) ZTREQ="@"
  1. Q
  1. MAIL ;
  1. N PSOTUCI,PSOTUCI1,XMTEXT,XMSUB,XMDUZ,XMY,PSOMLIN,PSOMLINN,PSOTDEL,PSOMNAME,PSOMLLP,PSOMLCT,PSOSTEXT,PSOQTIME,X,Y,%
  1. S PSOMLINN="" S PSOMLIN=$P($G(^XMB(1,1,"XUS")),"^",17) I PSOMLIN'>0 S PSOMLIN=$G(DUZ(2))
  1. I PSOMLIN S PSOMLINN=$P($G(^DIC(4,PSOMLIN,0)),"^")
  1. S XMSUB=$S($G(PSOMLINN)="":"Unknown Institution",1:$G(PSOMLINN)_" ("_$G(PSOMLIN)_")")_" TPB FILE BUILD"
  1. S XMDUZ="Patch PSO*7*145 Post Install" I $G(DUZ) S XMY(DUZ)=""
  1. X ^%ZOSF("UCI") S PSOTUCI=$P($G(Y),",") S PSOTUCI1=$P($G(^%ZOSF("PROD")),",") I PSOTUCI=PSOTUCI1 D
  1. .S XMY("TEMPLETON,SHANNON@DOMAIN.EXT")=""
  1. .S XMY("BROCKERT,JUDITH@DOMAIN.EXT")=""
  1. .S XMY("CHOW,ANGELA@DOMAIN.EXT")=""
  1. .S XMY("RUZBACKI,RON@DOMAIN.EXT")=""
  1. .S XMY("BARRON,LUANNE@DOMAIN.EXT")=""
  1. .S XMY("WASHINGTON,JANET P@DOMAIN.EXT")=""
  1. I $G(PSOTLOCK) D G MAILX
  1. .D NOW^%DTC S Y=% X ^DD("DD") S PSOQTIME=Y
  1. .K PSOSTEXT S PSOSTEXT(1)="The TPB ELIGIBILITY file building, and other post-install functions of",PSOSTEXT(2)="patch PSO*7*145, queued to run at "_$G(PSOQTIME)_",",PSOSTEXT(3)="was NOT run, because the XTMP patient global was locked."
  1. .S PSOSTEXT(4)="This Post-Install may have been queued by another user. Please contact",PSOSTEXT(5)="Customer Support."
  1. S PSOSTEXT(1)="The Post-Init from Patch PSO*7.0*145 is complete. The TPB ELIGIBILITY",PSOSTEXT(2)="File (#52.91) has been populated.",PSOSTEXT(3)=" "
  1. S PSOSTEXT(4)="The job started at "_$G(^XTMP("SDPSO145","START")),PSOSTEXT(5)="The job ended at "_$G(^XTMP("SDPSO145","STOP")),PSOSTEXT(6)=" "
  1. S PSOSTEXT(7)="Total number of eligible patients added to file = "_$G(^XTMP("SDPSO145","ELIG")),PSOSTEXT(8)="Total number of ineligible patients added to file = "_$G(^XTMP("SDPSO145","INEL")),PSOSTEXT(9)=" "
  1. S PSOMLCT=10
  1. S PSOTDEL="" F S PSOTDEL=$O(^XTMP("SDPSO145","PROB",PSOTDEL)) Q:PSOTDEL="" I $D(^PS(52.91,PSOTDEL,0)) K ^XTMP("SDPSO145","PROB",PSOTDEL)
  1. S PSOTDEL="" F S PSOTDEL=$O(^XTMP("SDPDO145","PROB1",PSOTDEL)) Q:PSOTDEL="" I $D(^PS(52.91,PSOTDEL,0)) K ^XTMP("SDPSO145","PROB1",PSOTDEL)
  1. I $O(^XTMP("SDPSO145","PROB",0)) D
  1. .S PSOSTEXT(PSOMLCT)="The following patients qualify for the Transitional Pharmacy",PSOMLCT=PSOMLCT+1,PSOSTEXT(PSOMLCT)="Benefit, but were unable to be added to the file for unknown reasons:",PSOMLCT=PSOMLCT+1
  1. .S PSOMLLP="" F S PSOMLLP=$O(^XTMP("SDPSO145","PROB",PSOMLLP)) Q:PSOMLLP="" D
  1. ..D PNM
  1. ..S PSOSTEXT(PSOMLCT)=$G(PSOMNAME)_$G(^XTMP("SDPSO145","PROB",PSOMLLP)),PSOMLCT=PSOMLCT+1
  1. I PSOMLCT>10 S PSOSTEXT(PSOMLCT)=" ",PSOMLCT=PSOMLCT+1
  1. I $O(^XTMP("SDPSO145","PROB1",0)) D
  1. .S PSOSTEXT(PSOMLCT)="The following patients qualify for the Transitional Pharmacy",PSOMLCT=PSOMLCT+1,PSOSTEXT(PSOMLCT)="Benefit, but were unable to be added to the file because a Station Number",PSOMLCT=PSOMLCT+1
  1. .S PSOSTEXT(PSOMLCT)="could not be found for the Institution associated with the patient:",PSOMLCT=PSOMLCT+1
  1. .S PSOMLLP="" F S PSOMLLP=$O(^XTMP("SDPSO145","PROB1",PSOMLLP)) Q:PSOMLLP="" D
  1. ..D PNM
  1. ..S PSOSTEXT(PSOMLCT)=$G(PSOMNAME)_$G(^XTMP("SDPSO145","PROB1",PSOMLLP)),PSOMLCT=PSOMLCT+1
  1. MAILX ;
  1. I $O(XMY(""))'="" S XMTEXT="PSOSTEXT(" N DIFROM D ^XMD
  1. K PSOSTEXT,XMTEXT,XMSUB,XMDUZ,XMY
  1. Q
  1. GETDATE ;
  1. N PSONOW,PSOTODAY,X,Y,PSOSAVEY,PSOSAVEX,PSOXXX
  1. S ZTDTH="",PSONOW=0
  1. D NOW^%DTC S (Y,PSOTODAY)=% D DD^%DT
  1. D BMES^XPDUTL("At the following prompt, enter a starting date@time")
  1. D MES^XPDUTL("or enter NOW to queue the job immediately.")
  1. D BMES^XPDUTL("If this prompting is during patch installation, you may not see what you type.")
  1. W ! K %DT D NOW^%DTC S %DT="RAEX",%DT(0)=%,%DT("A")="Queue TPB Eligibility File building job for what Date@Time: "
  1. D ^%DT K %DT I $D(DTOUT)!(Y<0) W "Task will be queued to run NOW" S ZTDTH=$H,PSONOW=1
  1. S PSOSAVEY=Y
  1. I 'PSONOW,PSOSAVEY>0 D
  1. .S Y=PSOSAVEY D DD^%DT
  1. .S PSOSAVEX=Y
  1. I 'PSONOW,$G(PSOSAVEY)<0 K PSOXXX,PSOSAVEX,PSOSAVEY,X,Y,PSONOW,PSOTODAY G GETDATE
  1. ASK ;
  1. D BMES^XPDUTL("Task will be queued to run "_$S(PSONOW:"NOW",1:PSOSAVEX)_". Is that correct? ")
  1. R PSOXXX:300 S:'$T!($G(PSOXXX)="") PSOXXX="Y" S PSOXXX=$$UP^XLFSTR(PSOXXX) I PSOXXX'="Y",PSOXXX'="YES",PSOXXX'="N",PSOXXX'="NO" W "Enter Y or N" G ASK
  1. I PSOXXX'="Y",PSOXXX'="YES" K PSOXXX,PSOSAVEX,PSOSAVEY,X,Y,PSONOW,PSOTODAY G GETDATE
  1. I PSOSAVEY>0,ZTDTH="" S ZTDTH=PSOSAVEY
  1. I ZTDTH="" S ZTDTH=$H
  1. Q
  1. PNM ;
  1. N DFN,VADM,VA,VAERR
  1. K PSOMNANE,VADM
  1. S DFN=+$G(PSOMLLP) I 'DFN Q
  1. D DEM^VADPT I $G(VADM(1))="" K VADM Q
  1. S PSOMNAME=$G(VADM(1))
  1. K VADM
  1. K VA,VAERR S DFN=+$G(PSOMLLP) D PID^VADPT6
  1. S PSOMNAME=PSOMNAME_" "_"("_$G(VA("BID"))_")"
  1. K VA,VAERR
  1. Q