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

PSJ089B.m

Go to the documentation of this file.
  1. PSJ089B ;BIR/MLV-Check for Orderable Items ;02 MAY 02 / 4:29 PM
  1. ;;5.0; INPATIENT MEDICATIONS ;**89**;16 DEC 97
  1. ;
  1. ; Reference to ^PS(55 is supported by DBIA# 2191.
  1. ;
  1. ENNV ; Begin check of existing orders
  1. I $G(DUZ)="" W !,"Your DUZ is not defined. It must be defined to run this routine." Q
  1. K ZTSAVE,ZTSK S ZTRTN="ENQN^PSJ089B",ZTDESC="Inpatient Orders Check (INPATIENT MEDS)",ZTIO="" D ^%ZTLOAD
  1. W !!,"The check of existing Pharmacy orders is",$S($D(ZTSK):"",1:" NOT")," queued",!
  1. I $D(ZTSK) D
  1. . W " (to start NOW).",!!,"YOU WILL RECEIVE A MAILMAN MESSAGES WHEN TASK #"_ZTSK_" HAS COMPLETED."
  1. Q
  1. ENQN ; Check of existing Pharmacy orders.
  1. N ND0,ND2,PSJBEG,PSJPDFN,PSJORD,CREAT,OCNT,PSJCNTX,PSJCNTY,PSJX,PSJOI,BDT,WBDT
  1. S (PSJCNTX,PSJCNTY)=0
  1. D NOW^%DTC S PSJSTART=$E(%,1,12),CREAT=$E(%,1,7)
  1. ; S WBDT to the date before PSJ*5*70 was released.
  1. S BDT=3020325
  1. F PSJPDFN=0:0 S PSJPDFN=$O(^PS(55,PSJPDFN)) Q:'PSJPDFN F WBDT=BDT:0 S WBDT=$O(^PS(55,PSJPDFN,5,"AUS",WBDT)) Q:'WBDT F PSJORD=0:0 S PSJORD=$O(^PS(55,PSJPDFN,5,"AUS",WBDT,PSJORD)) Q:'PSJORD I '+$G(^PS(55,PSJPDFN,5,PSJORD,.2)) D
  1. . S ND0=$G(^PS(55,PSJPDFN,5,PSJORD,0)),ND2=$G(^PS(55,PSJPDFN,5,PSJORD,2))
  1. . I $P(ND2,U,2)]"",($P(ND2,U,4)]""),($P(ND0,U,21)="") D Q
  1. .. NEW XX S XX=$$ACTIVE^PSJORREN(PSJPDFN,PSJORD_"U")
  1. .. I +XX=2 S $P(^PS(55,PSJPDFN,5,PSJORD,.2),U)=$P(XX,U,2)
  1. .. I +XX=0,($P(ND0,U,24)="R"),($P(ND0,U,25)["U") D
  1. ... S $P(^PS(55,PSJPDFN,5,PSJORD,.2),U)=$P($G(^PS(55,PSJPDFN,5,+$P(ND0,U,25),.2)),U)
  1. .. S PSJOI=+$G(^PS(55,PSJPDFN,5,PSJORD,.2))
  1. .. I +PSJOI D EN1^PSJHL2(PSJPDFN,"SN",PSJORD_"U") S PSJCNTY=PSJCNTY+1
  1. .. I '+PSJOI S PSJCNTX=PSJCNTX+1,PSJX(PSJCNTX)=PSJPDFN_U_PSJORD
  1. D SENDMSG
  1. DONE ;
  1. K DAYS,MINS,HOURS,PSG,PSJSTART,X,XMDUZ,XMSUB,XMTEXT,XMY,Y,ZTDESC,ZTDTH,ZTIO,ZTREQ,ZTRTN,ZTSAVE,ZTSK S ZTREQ="@"
  1. Q
  1. SENDMSG ;Send mail message when check is complete.
  1. K PSG,XMY NEW X
  1. S XMDUZ="MEDICATIONS,INPATIENT"
  1. S XMSUB="PSJ*5*89 INPATIENT MEDS ORDERABLE ITEMS ORDER CHECK COMPLETED"
  1. S XMTEXT="PSG(",XMY(DUZ)=""
  1. D NOW^%DTC S Y=% X ^DD("DD")
  1. S PSG(1,0)="The check of existing Pharmacy orders for use with Inpatient"
  1. S PSG(2,0)="Medications 5.0 completed as of "_Y_"."
  1. S X=$$FMDIFF^XLFDT(%,PSJSTART,3)
  1. S:$L(X," ")>1 DAYS=+$P(X," "),X=$P(X," ",2)
  1. S HOURS=+$P(X,":"),MINS=+$P(X,":",2)
  1. S PSG(3,0)=" "
  1. S PSG(4,0)="This process checked orders for patients in "_$S($G(DAYS):DAYS_" day"_$E("s",DAYS'=1)_", ",1:"")_HOURS_" hour"_$E("s",HOURS'=1),PSG(5,0)="and "_MINS_" minute"_$E("s",MINS'=1)_"."
  1. S PSG(6,0)=" "
  1. I PSJCNTY S PSG(7,0)="Updated the orders with the appropriate Orderable Items."
  1. I PSJCNTX=0,'PSJCNTY S PSG(7,0)="There are no Orderable Items missing from the orders."
  1. I PSJCNTX>0 S PSG(7,0)="The following order(s) are without the Orderable Item. Please contact the",PSG(8,0)="NATIONAL HELP DESK for assistance:" D
  1. . S PSG(9,0)="",OCNT=10
  1. . F X=0:0 S X=$O(PSJX(X)) Q:'X S PSG(OCNT,0)="DFN: "_+PSJX(X)_" ORDER #: "_$P(PSJX(X),U,2)_"U",OCNT=OCNT+1
  1. D ^XMD
  1. Q
  1. ;
  1. SET ;
  1. Q