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

ALPBPALL.m

Go to the documentation of this file.
  1. ALPBPALL ;OIFO-DALLAS MW,SED,KC-PRINT 3-DAY MAR BCMA BACLUP REPORT FOR ALL WARDS ;01/01/03
  1. ;;3.0;BAR CODE MED ADMIN;**8,29**;Mar 2004
  1. ;
  1. ; based on original code by FD@NJHCS, May 2002
  1. ;
  1. W !,"Inpatient Pharmacy Orders for all wards"
  1. ;
  1. ; get all or just current orders?...
  1. S DIR(0)="SA^A:ALL;C:CURRENT"
  1. S DIR("A")="Report [A]LL or [C]URRENT orders? "
  1. S DIR("B")="CURRENT"
  1. S DIR("?")="[A]LL=all orders in the file, [C]URRENT=orders not yet expired."
  1. W ! D ^DIR K DIR
  1. I $D(DIRUT) K DIRUT,DTOUT,X,Y Q
  1. S ALPBOTYP=Y
  1. ;
  1. ; print how many days MAR?...
  1. S DIR(0)="NA^1:7"
  1. S DIR("A")="Print how many days MAR? "
  1. S DIR("B")=$$DEFDAYS^ALPBUTL()
  1. S DIR("?")="The default is shown; you may choose 3 or 7."
  1. W ! D ^DIR K DIR
  1. I $D(DIRUT) K ALPBOTYP,DIRUT,DTOUT,X,Y Q
  1. S ALPBDAYS=+Y
  1. ;
  1. ; BCMA Med Log info for how many ?...
  1. S DIR(0)="NA^1:99"
  1. S DIR("B")=$$DEFML^ALPBUTL3()
  1. S DIR("A")="Select how many BCMA Medication Log history: "
  1. S DIR("A",1)=" "
  1. S DIR("?",1)="Select a number of BCMA Medication log entries"
  1. S DIR("?",2)="for each of the patient's orders"
  1. S DIR("?")="They are listed by the most current entry first"
  1. D ^DIR K DIR
  1. I $D(DIRUT) K ALPBOTYP,ALPBWARD,DIRUT,DTOUT,X,Y Q
  1. S ALPBMLOG=Y
  1. ;
  1. S %ZIS="Q"
  1. S %ZIS("B")=$$DEFPRT^ALPBUTL()
  1. I %ZIS("B")="" K %ZIS("B")
  1. W ! D ^%ZIS K %ZIS
  1. I POP K POP Q
  1. ;
  1. ; output not queued...
  1. I '$D(IO("Q")) D
  1. .U IO
  1. .D DQ
  1. .I IO'=IO(0) D ^%ZISC
  1. ;
  1. ; set up the task...
  1. I $D(IO("Q")) D
  1. .S ZTRTN="DQ^ALPBPALL"
  1. .S ZTDESC="PSB INPT PHARM ORDER FOR ALL WARDS"
  1. .S ZTIO=ION
  1. .S ZTSAVE("ALPBMLOG")=""
  1. .S ZTSAVE("ALPBOTYP")=""
  1. .S ZTSAVE("ALPBDAYS")=""
  1. .D ^%ZTLOAD
  1. .D HOME^%ZIS
  1. .W !,$S($G(ZTSK):"Task number "_ZTSK_" queued.",1:"ERROR -- NOT QUEUED!")
  1. .K IO("Q"),ZTSK
  1. K ALPBDAYS,ALPBMLOG,ALPBOTYP
  1. Q
  1. ;
  1. DQ ; output entry point...
  1. K ^TMP($J)
  1. ;
  1. ; set report date...MOD 11/03/03 SED
  1. S ALPBRDAT=$S(ALPBOTYP="C":$$NOW^XLFDT(),1:"")
  1. ;
  1. ; loop through ward cross reference in 53.7...
  1. S ALPBWARD=""
  1. F S ALPBWARD=$O(^ALPB(53.7,"AW",ALPBWARD)) Q:ALPBWARD="" D
  1. .S ALPBPTN=""
  1. .F S ALPBPTN=$O(^ALPB(53.7,"AW",ALPBWARD,ALPBPTN)) Q:ALPBPTN="" D
  1. ..S ALPBIEN=0
  1. ..F S ALPBIEN=$O(^ALPB(53.7,"AW",ALPBWARD,ALPBPTN,ALPBIEN)) Q:'ALPBIEN D
  1. ...D ORDS^ALPBUTL(ALPBIEN,ALPBRDAT,.ALPBORDS)
  1. ...I +ALPBORDS(0)'>0 K ALPBORDS Q
  1. ...S ALPBOIEN=0
  1. ...F S ALPBOIEN=$O(ALPBORDS(ALPBOIEN)) Q:'ALPBOIEN D
  1. ....S ALPBDATA=$G(^ALPB(53.7,ALPBIEN,2,ALPBOIEN,1))
  1. ....I ALPBOTYP="C"&($P(ALPBDATA,U,2)<ALPBRDAT) K ALPBDATA Q
  1. ....S ALPBOCT=$P($G(^ALPB(53.7,ALPBIEN,2,ALPBOIEN,3)),U,1)
  1. ....S:$P($G(^ALPB(53.7,ALPBIEN,2,ALPBOIEN,4)),U,3)["PRN" ALPBOCT=ALPBOCT_"P"
  1. ....S ALPBORDN=ALPBORDS(ALPBOIEN)
  1. ....S ALPBOST=$$STAT2^ALPBUTL1(ALPBORDS(ALPBOIEN,2))
  1. ....I '$D(^TMP($J,ALPBWARD,ALPBPTN)) S ^TMP($J,ALPBWARD,ALPBPTN)=ALPBIEN
  1. ....S ^TMP($J,ALPBWARD,ALPBPTN,ALPBOCT,ALPBOST,ALPBORDN)=ALPBOIEN
  1. ....K ALPBDATA,ALPBORDN,ALPBOST,ALPBOCT
  1. ...K ALPBOIEN,ALPBORDS
  1. ..K ALPBIEN
  1. .K ALPBPTN
  1. K ALPBWARD
  1. ;
  1. ; process through our sorted list...
  1. S ALPBPG=0
  1. S ALPBWARD=""
  1. F S ALPBWARD=$O(^TMP($J,ALPBWARD)) Q:ALPBWARD="" D
  1. .S ALPBPTN=""
  1. .F S ALPBPTN=$O(^TMP($J,ALPBWARD,ALPBPTN)) Q:ALPBPTN="" D
  1. ..S ALPBIEN=+^TMP($J,ALPBWARD,ALPBPTN)
  1. ..S ALPBPDAT(0)=$G(^ALPB(53.7,ALPBIEN,0))
  1. ..M ALPBPDAT(1)=^ALPB(53.7,ALPBIEN,1)
  1. ..; paginate between patients...
  1. ..I ALPBPG=0 D PAGE
  1. ..S ALPBOCT=""
  1. ..F S ALPBOCT=$O(^TMP($J,ALPBWARD,ALPBPTN,ALPBOCT)) Q:ALPBOCT="" D
  1. ...S ALPBOST=""
  1. ...F S ALPBOST=$O(^TMP($J,ALPBWARD,ALPBPTN,ALPBOCT,ALPBOST)) Q:ALPBOST="" D
  1. ....S ALPBORDN=""
  1. ....F S ALPBORDN=$O(^TMP($J,ALPBWARD,ALPBPTN,ALPBOCT,ALPBOST,ALPBORDN)) Q:ALPBORDN="" D
  1. .....S ALPBOIEN=^TMP($J,ALPBWARD,ALPBPTN,ALPBOCT,ALPBOST,ALPBORDN)
  1. .....; get and print this order's data...
  1. .....M ALPBDATA=^ALPB(53.7,ALPBIEN,2,ALPBOIEN)
  1. .....D F132^ALPBFRM1(.ALPBDATA,ALPBDAYS,ALPBMLOG,.ALPBFORM,ALPBIEN)
  1. .....I $Y+ALPBFORM(0)>IOSL D PAGE
  1. .....S ALPBX=0
  1. .....F S ALPBX=$O(ALPBFORM(ALPBX)) Q:'ALPBX W !,ALPBFORM(ALPBX)
  1. .....K ALPBDATA,ALPBFORM,ALPBOIEN,ALPBX
  1. ....K ALPBORDN
  1. ...K ALPBOST
  1. ..K ALPBIEN,ALPBPDAT,ALPBOCT
  1. ..S ALPBPG=0
  1. ..; print footer at end of this patient's record...
  1. ..D FOOT^ALPBFRMU
  1. ..;Print a blank page between patients
  1. ..W @IOF
  1. .K ALPBPTN
  1. ;
  1. K ALPBDAYS,ALPBMLOG,ALPBOTYP,ALPBPG,ALPBRDAT,ALPBWARD,^TMP($J)
  1. I $D(ZTQUEUED) S ZTREQ="@"
  1. Q
  1. ;
  1. PAGE ; paginate and print header for a patient...
  1. W @IOF
  1. ; increment page count...
  1. S ALPBPG=ALPBPG+1
  1. D HDR^ALPBFRMU(.ALPBPDAT,ALPBPG,.ALPBHDR)
  1. S ALPBX=0
  1. F S ALPBX=$O(ALPBHDR(ALPBX)) Q:'ALPBX W !,ALPBHDR(ALPBX)
  1. K ALPBHDR,ALPBX
  1. Q