DGRRPSAD ; ALB/SGG - rtnDGRR PatientServices ADT Information ;09/30/03 ; Compiled December 9, 2003 15:22:22
;;5.3;Registration;**557**;Aug 13, 1993
;
DOC ;"_"^^^1"
QUIT
;
ADTC(ADTDT,CNT) ;ADT Collection of all movements associated with a specifed date
NEW ROWCNT
K VAIP,VAROOT,INDATA,VAHOW
SET ADTDT=$S($G(ADTDT)'="":ADTDT\1,1:DT)
SET ROWCNT=0
SET VAIP("D")=ADTDT
SET VAIP("M")=0
SET VAIP("L")=""
DO IN5^VADPT
IF VAIP(1)'="" DO
. NEW DGRRMIEN,DGRRCA,DGRRMVDT
. SET DGRRCA=VAIP(1)
. K ^TMP($J,"DGRRMVTS")
. SET DGRRMIEN=""
. F SET DGRRMIEN=$O(^DGPM("CA",+DGRRCA,DGRRMIEN)) Q:DGRRMIEN="" D
..; Set up TMP global to assure movements are in date/time order
..S DGRRMVDT=+$P($G(^DGPM(+DGRRMIEN,0)),"^")
..I DGRRMVDT>0 S ^TMP($J,"DGRRMVTS",DGRRMVDT,DGRRMIEN)=""
. ;Loop through TMP global
.N DGRRMDT,DGRRIEN
.S DGRRMDT=""
.F S DGRRMDT=$O(^TMP($J,"DGRRMVTS",DGRRMDT)) Q:DGRRMDT="" D
.. S DGRRIEN=""
.. F S DGRRIEN=$O(^TMP($J,"DGRRMVTS",DGRRMDT,DGRRIEN)) Q:DGRRIEN="" D
... K INDATA,VAROOT,VAIP
... SET ROWCNT=$G(ROWCNT)+1
... SET VAIP("E")=DGRRIEN
... SET VAROOT="INDATA"
... DO IN5^VADPT
... S ADTTYPE=$S(+$G(INDATA(2))=4!(+$G(INDATA(2))=5):"LODGER",+$G(INDATA(2))=3:"DISCHARGE",1:"CURRENT")
... DO BLD
.K ^TMP($J,"DGRRMVTS")
IF ROWCNT=0 D
.SET ROWCNT=ROWCNT+1
.DO BLD
Q
;
BLD ;Build array of data elements for each movement. Similar to elements
;defined for current inpatient and lodger activity. The word 'current'
;removed from element names.
;
SET CNT=$G(CNT)+1,PSARRAY(CNT)=">