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

BDGAD5.m

Go to the documentation of this file.
  1. BDGAD5 ; IHS/ANMC/LJF - A&D PTS REMAINING ;
  1. ;;5.3;PIMS;**1009,1012**;APR 26, 2002
  1. ;
  1. ;cmi/anch/maw 2/11/2008 added fix in SERV PATCH 1009
  1. ;
  1. NEW PREV,CURR
  1. S CURR=BDGT
  1. S PREV=$$FMADD^XLFDT(CURR,-1) ;previous day
  1. ;
  1. SERV ; loop through services and fill in patients remaining
  1. NEW SRV,REMA,REMP,NEWA,NEWP,N
  1. S SRV=0 F S SRV=$O(^BDGCTX(SRV)) Q:'SRV D
  1. . Q:'$D(^BDGCTX(SRV,1,PREV,0)) ;cmi/maw 2/11/2008 quit if no current date for service PATCH 1009
  1. . Q:'$D(^BDGCTX(SRV,1,CURR,0)) ;cmi/maw 4/23/2010 quit if no current date for service PATCH 1012
  1. . ;
  1. . ; if no activity, bring old numbers forward
  1. . I $P(^BDGCTX(SRV,1,CURR,0),U,2,99)="" D Q
  1. .. S $P(^BDGCTX(SRV,1,CURR,0),U,2)=$P($G(^BDGCTX(SRV,1,PREV,0)),U,2)
  1. .. S $P(^BDGCTX(SRV,1,CURR,0),U,12)=$P($G(^BDGCTX(SRV,1,PREV,0)),U,12)
  1. . ;
  1. . ; else, perform calculations
  1. . S REMA=$P($G(^BDGCTX(SRV,1,PREV,0)),U,2) ;prev adults remaining
  1. . S REMP=$P($G(^BDGCTX(SRV,1,PREV,0)),U,12) ;prev peds remaining
  1. . S N=$G(^BDGCTX(SRV,1,CURR,0))
  1. . S NEWA=REMA+$P(N,U,3)-$P(N,U,4)+$P(N,U,5)-$P(N,U,6)-$P(N,U,7)
  1. . S NEWP=REMP+$P(N,U,13)-$P(N,U,14)+$P(N,U,15)-$P(N,U,16)-$P(N,U,17)
  1. . ;
  1. . S $P(^BDGCTX(SRV,1,CURR,0),U,2)=NEWA
  1. . S $P(^BDGCTX(SRV,1,CURR,0),U,12)=NEWP
  1. ;
  1. WARD ; loop through wards and fill in patients remaining
  1. NEW WARD,REM,REMA,REMP,NEW,NEWA,NEWP,N,N1
  1. S WARD=0 F S WARD=$O(^BDGCWD(WARD)) Q:'WARD D
  1. . ;
  1. . ; if no activity, bring old numbers forward
  1. . I $P(^BDGCWD(WARD,1,CURR,0),U,2,99)="" D
  1. .. S $P(^BDGCWD(WARD,1,CURR,0),U,2)=$P($G(^BDGCWD(WARD,1,PREV,0)),U,2)
  1. . ;
  1. . ; else, perform calculations
  1. . E D
  1. .. S REM=$P($G(^BDGCWD(WARD,1,PREV,0)),U,2) ;prev remaining
  1. .. S N=$G(^BDGCWD(WARD,1,CURR,0))
  1. .. S NEW=REM+$P(N,U,3)-$P(N,U,4)+$P(N,U,5)-$P(N,U,6)-$P(N,U,7)
  1. .. S $P(^BDGCWD(WARD,1,CURR,0),U,2)=NEW ;new remaining total
  1. . ;
  1. . ; for services within wards
  1. . S SRV=0 F S SRV=$O(^BDGCWD(WARD,1,PREV,1,SRV)) Q:'SRV D
  1. .. ;
  1. .. ; if no activity for service, bring numbers forward
  1. .. I '$D(^BDGCWD(WARD,1,CURR,1,SRV,0)) D Q
  1. ... S $P(^BDGCWD(WARD,1,CURR,1,0),U,3,4)=SRV_U_($P(^BDGCWD(WARD,1,CURR,1,0),U,4)+1)
  1. ... S ^BDGCWD(WARD,1,CURR,1,SRV,0)=SRV_U_(+$P(^BDGCWD(WARD,1,PREV,1,SRV,0),U,2))
  1. ... S $P(^BDGCWD(WARD,1,CURR,1,SRV,0),U,12)=+$P(^BDGCWD(WARD,1,PREV,1,SRV,0),U,12) ;peds remaining
  1. .. ;
  1. .. ; else, perform calculations
  1. .. S REMA=$P($G(^BDGCWD(WARD,1,PREV,1,SRV,0)),U,2) ;prev adults
  1. .. S REMP=$P($G(^BDGCWD(WARD,1,PREV,1,SRV,0)),U,12) ;prev peds
  1. .. S N=$G(^BDGCWD(WARD,1,CURR,1,SRV,0))
  1. .. S NEWA=REMA+$P(N,U,3)-$P(N,U,4)+$P(N,U,5)-$P(N,U,6)-$P(N,U,7)
  1. .. S NEWP=REMP+$P(N,U,13)-$P(N,U,14)+$P(N,U,15)-$P(N,U,16)-$P(N,U,17)
  1. .. ;
  1. .. S $P(^BDGCWD(WARD,1,CURR,1,SRV,0),U,2)=NEWA
  1. .. S $P(^BDGCWD(WARD,1,CURR,1,SRV,0),U,12)=NEWP
  1. . ;
  1. . ; for services added to ward for the first time, no prev date
  1. . S SRV=0 F S SRV=$O(^BDGCWD(WARD,1,CURR,1,SRV)) Q:'SRV D
  1. .. Q:$D(^BDGCWD(WARD,1,PREV,1,SRV)) ;only first timers
  1. .. ;
  1. .. ; perform calculations
  1. .. S N=$G(^BDGCWD(WARD,1,CURR,1,SRV,0))
  1. .. S NEWA=$P(N,U,3)-$P(N,U,4)+$P(N,U,5)-$P(N,U,6)-$P(N,U,7)
  1. .. S NEWP=$P(N,U,13)-$P(N,U,14)+$P(N,U,15)-$P(N,U,16)-$P(N,U,17)
  1. .. ;
  1. .. S $P(^BDGCWD(WARD,1,CURR,1,SRV,0),U,2)=NEWA
  1. .. S $P(^BDGCWD(WARD,1,CURR,1,SRV,0),U,12)=NEWP
  1. Q