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

ACDRR2C.m

Go to the documentation of this file.
ACDRR2C ; IHS/ADC/EDE/KML - GATHER WORKLOAD DATA ; 
 ;;4.1;CHEMICAL DEPENDENCY MIS;;MAY 11, 1998
 ;
 ; This routine processes each visit within date range, gathers
 ; provider workload data, then processes other file entries
 ; by the same date range.
 ;
START ;
 D INIT
 D VISITS
 D COMPUTE1
 D PREVENT
 D INTERV
 D EOJ
 Q
 ;
INIT ;
 S (ACDBT,ACDBTH)=$H,ACDJOB=$J
 K ^TMP("ACDRR2",$J)
 Q
 ;
VISITS ; PROCESS ALL VISITS WITHIN DATE RANGE
 S ACDVDATE=$O(^ACDVIS("B",ACDDTLO),-1)
 F  S ACDVDATE=$O(^ACDVIS("B",ACDVDATE)) Q:ACDVDATE=""!(ACDVDATE>ACDDTHI)  D
 . S ACDVIEN=0
 . F  S ACDVIEN=$O(^ACDVIS("B",ACDVDATE,ACDVIEN)) Q:'ACDVIEN  D VISIT
 . Q
 Q
 ;
VISIT ; PROCESS ONE VISIT
 Q:'$D(^ACDVIS(ACDVIEN,0))  ;           bad xref
 Q:$G(^ACDVIS(ACDVIEN,"BWP"))'=ACDPGM  ;not from current program
 S X=^ACDVIS(ACDVIEN,0)
 S ACDTC=$P(X,U,4) ;                    type contact
 S Y=$P(X,U,3) ;                        primary provider
 ;D PFTV^XBPFTV(6,Y,.ACDPPROV) ; ** ^DIC(6, **
 S ACDPPROV=$P($G(^VA(200,Y,0)),U)
 S:ACDPPROV="" ACDPPROV=Y
 S ACDPIEN=$P(X,U,5) ;                  patient ien
 I ACDPIEN D
 .  S ^TMP("ACDRR2",ACDJOB,ACDBT,"PATIENT",ACDPIEN)=""
 .  S ^TMP("ACDRR2",ACDJOB,ACDBT,"PP",ACDPPROV,ACDPIEN)=""
 .  Q
 D @("PRC"_ACDTC) ;                     process iif/td
 Q
 ;
PRCIN ; INITIAL
 D PRCIIF
 Q
 ;
PRCRE ; REOPEN
 D PRCIIF
 Q
 ;
PRCFU ; FOLLOWUP
 D PRCIIF
 Q
 ;
PRCIR ; INFO/REFERRAL
 D PRCIIF
 Q
 ;
PRCOT ; CRISIS BRIEF
 D PRCIIF
 Q
 ;
PRCIIF ; PROCESS IIF ENTRY
 S ACDIIEN=$O(^ACDIIF("C",ACDVIEN,0))
 Q:'ACDIIEN  ;                          no iif entry
 Q:'$D(^ACDIIF(ACDIIEN,0))  ;           bad xref
 S ^("COUNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPPROV,"VT",ACDTC,"COUNT"))+1
 S ^("COUNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE",ACDTC,"COUNT"))+1
 S X=^ACDIIF(ACDIIEN,0)
 S ACDHRS=$P(X,U,6)
 I 'ACDHRS S ^("HOURS NR")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPPROV,"VT",ACDTC,"HOURS NR"))+1,^("HOURS NR")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE",ACDTC,"HOURS NR"))+1 Q
 S ^("HOURS")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPPROV,"VT",ACDTC,"HOURS"))+ACDHRS,^("HOURS")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE",ACDTC,"HOURS"))+ACDHRS
 S ^("HOURS CNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPPROV,"VT",ACDTC,"HOURS CNT"))+1,^("HOURS CNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE",ACDTC,"HOURS CNT"))+1
 Q
 ;
PRCTD ; TRANS/DISC/CLOSE ENTRY
 S ACDTIEN=$O(^ACDTDC("C",ACDVIEN,0))
 Q:'ACDTIEN  ;                          no tdc entry
 Q:'$D(^ACDTDC(ACDTIEN,0))  ;           bad xref
 S ^("COUNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPPROV,"VT",ACDTC,"COUNT"))+1
 S X=^ACDTDC(ACDTIEN,0)
 S ACDHRS=$P(X,U,29)
 I 'ACDHRS S ^("HOURS NR")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPPROV,"VT",ACDTC,"HOURS NR"))+1,^("HOURS NR")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE",ACDTC,"HOURS NR"))+1 Q
 S ^("HOURS")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPPROV,"VT",ACDTC,"HOURS"))+ACDHRS,^("HOURS")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE",ACDTC,"HOURS"))+ACDHRS
 S ^("HOURS CNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPPROV,"VT",ACDTC,"HOURS CNT"))+1,^("HOURS CNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE",ACDTC,"HOURS CNT"))+1
 Q
 ;
PRCCS ; CLIENT SERVICES
 S ACDCSIEN=0
 F  S ACDCSIEN=$O(^ACDCS("C",ACDVIEN,ACDCSIEN)) Q:'ACDCSIEN  I $D(^ACDCS(ACDCSIEN,0)) S X=^(0) D
 .  S ^("COUNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE",ACDTC,"COUNT"))+1
 .  S ACDCS=$P(X,U,2)
 .  S ACDHRS=$P(X,U,4)
 .  I 'ACDHRS S ^("HOURS NR")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE",ACDTC,"HOURS NR"))+1 Q
 .  S ^("HOURS")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE",ACDTC,"HOURS"))+ACDHRS
 .  S ^("HOURS CNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE",ACDTC,"HOURS CNT"))+1
 .  S ^("HOURS")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE",ACDTC,ACDCS,"HOURS"))+ACDHRS
 .  S ^("HOURS CNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE",ACDTC,ACDCS,"HOURS CNT"))+1
 .  S ACDWPIEN=0
 . ;F  S ACDWPIEN=$O(^ACDCS(ACDCSIEN,1,ACDWPIEN)) Q:'ACDWPIEN  S X=+^(ACDWPIEN,0) D PFTV^XBPFTV(6,X,.ACDWPROV) D  ; ** ^DIC(6, **
 .  F  S ACDWPIEN=$O(^ACDCS(ACDCSIEN,1,ACDWPIEN)) Q:'ACDWPIEN  S X=+^(ACDWPIEN,0),ACDWPROV=$P($G(^VA(200,X,0)),U) S:ACDWPROV="" ACDWPROV=X D
 ..  S ^("COUNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDWPROV,"VT",ACDTC,"COUNT"))+1
 ..  S ^("HOURS")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDWPROV,"VT",ACDTC,"HOURS"))+ACDHRS
 ..  S ^("HOURS CNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDWPROV,"VT",ACDTC,"HOURS CNT"))+1
 ..  S ^("HOURS")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDWPROV,"VT",ACDTC,ACDCS,"HOURS"))+ACDHRS
 ..  S ^("HOURS CNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDWPROV,"VT",ACDTC,ACDCS,"HOURS CNT"))+1
 ..  Q
 .  Q
 Q
 ;
COMPUTE1 ; COMPUTE TOTALS TO PASS TO PRINT ROUTINE
 S (C,ACDPIEN)=0
 ; compute number of patients seen
 F  S ACDPIEN=$O(^TMP("ACDRR2",ACDJOB,ACDBT,"PATIENT",ACDPIEN)) Q:'ACDPIEN  S C=C+1
 S ^TMP("ACDRR2",ACDJOB,ACDBT,"SEEN")=C
 K ^TMP("ACDRR2",ACDJOB,ACDBT,"PATIENT")
 ; compute number of patients each provider is the pri-prov for
 S ACDPROV=""
 F  S ACDPROV=$O(^TMP("ACDRR2",ACDJOB,ACDBT,"PP",ACDPROV)) Q:ACDPROV=""  D
 .  S (C,ACDPIEN)=0
 .  F  S ACDPIEN=$O(^TMP("ACDRR2",ACDJOB,ACDBT,"PP",ACDPROV,ACDPIEN)) Q:'ACDPIEN  S C=C+1
 .  S ^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPROV,"PP")=C
 .  Q
 K ^TMP("ACDRR2",ACDJOB,ACDBT,"PP")
 ; compute totals by provider
 S ACDPROV=""
 F  S ACDPROV=$O(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPROV)) Q:ACDPROV=""  D
 .  S ACDTC=""
 .  F  S ACDTC=$O(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPROV,"VT",ACDTC)) Q:ACDTC=""  D
 ..  I ACDTC="CS" D CS Q  ;         compute CS and quit
 ..  S Y=+$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPROV,"VT",ACDTC,"HOURS"))
 ..  S ^("TOTAL HOURS")=+$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPROV,"TOT","TOTAL HOURS"))+Y
 ..  D CLASS
 ..  S:ACDCLASS=1 ^("IN/RE/TD/FU HOURS")=+$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPROV,"TOT","IN/RE/TD/FU HOURS"))+Y
 ..  S:ACDCLASS=2 ^("IR HOURS")=+$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPROV,"TOT","IR HOURS"))+Y
 ..  S:ACDCLASS=3 ^("OT HOURS")=+$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPROV,"TOT","OT HOURS"))+Y
 ..  S Y=+$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPROV,"VT",ACDTC,"HOURS NR"))
 ..  S ^("HOURS NR")=+$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPROV,"TOT","HOURS NR"))+Y
 ..  Q
 .  Q
 Q
 ;
CLASS ; COMPUTE CLASS OF VISIT
 S ACDCLASS=1
 I ACDTC="IR" S ACDCLASS=2 Q
 I ACDTC="OT" S ACDCLASS=3 Q
 Q
 ;
CS ; COMPUTE CS TOTALS
 S ACDCS=0
 F  S ACDCS=$O(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPROV,"VT",ACDTC,ACDCS)) Q:'ACDCS  S Y=+$G(^(ACDCS,"HOURS")) D
 .  S ^("TOTAL HOURS")=+$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPROV,"TOT","TOTAL HOURS"))+Y
 .  S ^("CS HOURS")=+$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDPROV,"CS HOURS"))+Y
 .  Q
 Q
 ;
 ;
PREVENT ; PROCESS ALL PREVENTIONS WITHIN DATE RANGE
 S ACDPDATE=$O(^ACDPD("B",ACDDTLO),-1)
 F  S ACDPDATE=$O(^ACDPD("B",ACDPDATE)) Q:ACDPDATE=""!(ACDPDATE>ACDDTHI)  D
 . S ACDPIEN=0
 . F  S ACDPIEN=$O(^ACDPD("B",ACDPDATE,ACDPIEN)) Q:'ACDPIEN  D
 ..  Q:'$D(^ACDPD(ACDPIEN,0))  ;          bad xref
 ..  S X=^ACDPD(ACDPIEN,0)
 ..  S X=$P(X,U,5) ;                      primary provider
 .. ;D PFTV^XBPFTV(6,X,.ACDPPROV) ; ** ^DIC(6, **
 ..  S ACDPPROV=$P($G(^VA(200,X,0)),U)
 ..  S:ACDPPROV="" ACDPPROV=X
 ..  S ACDPDAY=0
 ..  F  S ACDPDAY=$O(^ACDPD(ACDPIEN,1,ACDPDAY)) Q:'ACDPDAY  D PRVDAY
 ..  Q
 . Q
 Q
 ;
PRVDAY ; PROCESS ONE PREVENTION DAY
 S X=^ACDPD(ACDPIEN,1,ACDPDAY,0)
 S ^("COUNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE","PREV","COUNT"))+1
 S ACDPACT=$P(X,U,2)
 S ACDHRS=$P(X,U,8)
 I 'ACDHRS S ^("HOURS NR")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE","PREV","HOURS NR"))+1 Q
 S ^("HOURS")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE","PREV","HOURS"))+ACDHRS
 S ^("HOURS CNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE","PREV","HOURS CNT"))+1
 S ^("HOURS")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE","PREV",ACDPACT,"HOURS"))+ACDHRS
 S ^("HOURS CNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"VISIT TYPE","PREV",ACDPACT,"HOURS CNT"))+1
 S ACDPRVM=0
 F  S ACDPRVM=$O(^ACDPD(ACDPIEN,1,ACDPDAY,"PRV",ACDPRVM)) Q:'ACDPRVM  D
 .  S ACDWPROV=+^ACDPD(ACDPIEN,1,ACDPDAY,"PRV",ACDPRVM,0)
 . ;D PFTV^XBPFTV(6,ACDWPROV,.ACDWPROV) ; ** ^DIC(6, **
 .  S ACDX=$P($G(^VA(200,ACDWPROV,0)),U)
 .  S:ACDX'="" ACDWPROV=ACDX
 .  S ^("COUNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDWPROV,"VT","PREV","COUNT"))+1
 .  S ^("HOURS CNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDWPROV,"VT","PREV","HOURS CNT"))+1
 .  S ^("HOURS")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDWPROV,"VT","PREV","HOURS"))+ACDHRS
 .  S ^("COUNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDWPROV,"VT","PREV",ACDPACT,"COUNT"))+1
 .  S ^("HOURS")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDWPROV,"VT","PREV",ACDPACT,"HOURS"))+ACDHRS
 .  S ^("HOURS CNT")=$G(^TMP("ACDRR2",ACDJOB,ACDBT,"PROV",ACDWPROV,"VT","PREV",ACDPACT,"HOURS CNT"))+1
 .  Q
 Q
 ;
INTERV ; PROCESS ALL INTERVENTIONS WITHIN DATE RANGE
 D INTERV^ACDRR2CB
 Q
 ;
EOJ ;
 S ACDET=$H
 K C,X,Y,Z
 Q