PXRRPCE1 ;HIN/MjK - Clinic Specfic Workload Reports ;9/23/96
;;1.0;PCE PATIENT CARE ENCOUNTER;**3**;Aug 12, 1996
EN ;_._._._._._._._._._._._.Total Appt By Type_._._._._._._._._._._._._.
;THIS ROUTINE EXECUTES THE SCHEDULING PACKAGE ROUTINES @ (SET^SDCWL3)
;FOR CLINIC APPT DATA WHICH IS RETURNED IN THE FOLLOWING TMP GLOBALS
;^TMP($J,"CL",CLINIC TEXT NAME ;TOTAL ENCOUNTERS
;^TMP($J,1,CLINIC TEXT NAME,APPT DATE,"SD" ;# SCHEDULED APPTS
;^TMP($J,1,CLINIC TEXT NAME,APPT DATE,"OB" ;# OVERBOOKED APPTS
;^TMP($J,1,CLINIC TEXT NAME,APPT DATE,"IN" ;# INPATIENT APPTS
;^TMP($J,1,CLINIC TEXT NAME,APPT DATE,"UN" ;# UNSCHEDULED APPTS
;^TMP($J,1,CLINIC TEXT NAME,APPT DATE,"NS" ;# NO SHOWED APPTS
;^TMP($J,1,CLINIC TEXT NAME,APPT DATE,"CA" ;# CANCELLED APPTS
;THE PCE DATA FILES ARE SEPARATELY CHECKED,
;BY DATE RANGE ; ^AUPNVSIT("B",
;AND THEN HOSPITAL LOCATION ; $P(^AUPNVSIT(D0,0),U,22)
;THE ASSOCIATED V CPT RECORDS ARE REVIEWED ; ^AUPNVCPT("AD",
;AGAINST THE IBE TYPE OF VISIT FILE ; ^IBE(357.60,
;TO DISTINGUISH E&M CODES FROM OTHER NON-E&M CPT CODES
ALL S (PXRR,PXRRCN)=0 F S PXRR=$O(PXRRCLIN(PXRR)) Q:'PXRR S PXRRCL=$P(PXRRCLIN(PXRR),U) D SETUP I $D(^TMP($J,1,PXRRCL)) S PXRRCN=PXRRCN+1,PXRRCLIN=$P(PXRRCLIN(PXRR),U,2) D
SDDATA . ;_._._._._._.Initialize Appt Types from Scheduling data_._._._._.
. F X="UN","CA","NS" S Y=0 F S Y=$O(^TMP($J,1,PXRRCL,Y)) Q:'Y S ^TMP($J,PXRRCL,X)=^TMP($J,PXRRCL,X)+$G(^TMP($J,1,PXRRCL,Y,X))
SDTOTAL . ;_._._._._._._.Total Visits per Clinic & All Clinics_._._._._._._.
. S ^TMP($J,PXRRCL,"TOT")=$S($P(^TMP($J,"CL",1,PXRRCL),U,2)="":0,1:$P(^TMP($J,"CL",1,PXRRCL),U,2))
PCEDATA ;_._._._._._._._._._._._Patient Encounters_._._._._._._._._._._
;F= visit ifn ;C= enctr counter
N F
F S PXRR=$O(PXRRCLIN(PXRR)) Q:'PXRR S PXRRCL=$P(PXRRCLIN(PXRR),U),PXRRCLIN=$P(PXRRCLIN(PXRR),U,2) S PXRRVDT=PXRRBDT,(C,PXRRNVCP)=0 F S PXRRVDT=$O(^AUPNVSIT("B",PXRRVDT)) Q:'PXRRVDT!(PXRRVDT>PXRREDT) D
. S F=0 F S F=$O(^AUPNVSIT("B",PXRRVDT,F)) Q:'F I $P(^AUPNVSIT(F,0),U,22)=PXRRCLIN S X=$P($G(^AUPNVSIT(F,0)),U,7) I (X="A")!(X="I")!(X="S") S C=C+1,^TMP($J,PXRRCL,"ENT")=C D
.. ;_.If no x-ref exists, there are no associated CPTs for the enctr_.
.. I '$D(^AUPNVCPT("AD",F)) S PXRRNVCP=PXRRNVCP+1,^TMP($J,PXRRCL,"NVCPT")=PXRRNVCP Q
PCEPROC .. ;_._._._._._._._._._.Encounter Visit Codes_._._._._._._._._._.
.. S G=0 F S G=$O(^AUPNVCPT("AD",F,G)) Q:'G S PXRRVCPT=$P(^AUPNVCPT(G,0),U) I $D(^IBE(357.69,PXRRVCPT)) S PXRVST=1
.. ;_.If none of the associated procedures is a Type of Visit code_.
.. I '$D(PXRVST) S ^TMP($J,PXRRCL,"OTHER CPT")=^TMP($J,PXRRCL,"OTHER CPT")+1 Q
.. K PXRVST
PCEENM .. ;_._._._._._._._.All Procedures Which Are Visit Codes_._._._._._.
.. S G=0 F S G=$O(^AUPNVCPT("AD",F,G)) Q:'G S PXRRVCPT=$P(^AUPNVCPT(G,0),U) D:$D(^IBE(357.69,PXRRVCPT))&('$D(PXRVST))
... ;_._._.Category of Type of Visit (i.e. NEW,EST,CONSULT,OTHER)_._._.
... ;_._._.Use the First Type of Visit Code Found for Encounter_._._._.
... S X=$P(^IBE(357.69,PXRRVCPT,0),U,5),X=$S(X=1:"NEW",X=2:"ESTABLISHED",X=3:"CONSULT",1:"OTHER"),^TMP($J,PXRRCL,X)=^TMP($J,PXRRCL,X)+1,PXRVST=1
.. K PXRVST
PCETOT ;_._._._._._._.Total PCE Enctrs for All Selected Clinics_._._._._._.
S (^TMP($J,"TVCO"),X)=0 F S X=$O(PXRRCLIN(X)) Q:'X S ^TMP($J,"TVCO")=^TMP($J,"TVCO")+$G(^TMP($J,$P(PXRRCLIN(X),U),"ENT"))
EXIT Q
SETUP ;_._._.TMP Array_._._.
F I="UN","CA","NS","NEW","ESTABLISHED","CONSULT","OTHER","OTHER CPT","ENT","NVCPT","TOT" S ^TMP($J,PXRRCL,I)=0
Q
PXRRPCE1 ;HIN/MjK - Clinic Specfic Workload Reports ;9/23/96
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**3**;Aug 12, 1996
EN ;_._._._._._._._._._._._.Total Appt By Type_._._._._._._._._._._._._.
+1 ;THIS ROUTINE EXECUTES THE SCHEDULING PACKAGE ROUTINES @ (SET^SDCWL3)
+2 ;FOR CLINIC APPT DATA WHICH IS RETURNED IN THE FOLLOWING TMP GLOBALS
+3 ;^TMP($J,"CL",CLINIC TEXT NAME ;TOTAL ENCOUNTERS
+4 ;^TMP($J,1,CLINIC TEXT NAME,APPT DATE,"SD" ;# SCHEDULED APPTS
+5 ;^TMP($J,1,CLINIC TEXT NAME,APPT DATE,"OB" ;# OVERBOOKED APPTS
+6 ;^TMP($J,1,CLINIC TEXT NAME,APPT DATE,"IN" ;# INPATIENT APPTS
+7 ;^TMP($J,1,CLINIC TEXT NAME,APPT DATE,"UN" ;# UNSCHEDULED APPTS
+8 ;^TMP($J,1,CLINIC TEXT NAME,APPT DATE,"NS" ;# NO SHOWED APPTS
+9 ;^TMP($J,1,CLINIC TEXT NAME,APPT DATE,"CA" ;# CANCELLED APPTS
+10 ;THE PCE DATA FILES ARE SEPARATELY CHECKED,
+11 ;BY DATE RANGE ; ^AUPNVSIT("B",
+12 ;AND THEN HOSPITAL LOCATION ; $P(^AUPNVSIT(D0,0),U,22)
+13 ;THE ASSOCIATED V CPT RECORDS ARE REVIEWED ; ^AUPNVCPT("AD",
+14 ;AGAINST THE IBE TYPE OF VISIT FILE ; ^IBE(357.60,
+15 ;TO DISTINGUISH E&M CODES FROM OTHER NON-E&M CPT CODES
ALL SET (PXRR,PXRRCN)=0
FOR
SET PXRR=$ORDER(PXRRCLIN(PXRR))
IF 'PXRR
QUIT
SET PXRRCL=$PIECE(PXRRCLIN(PXRR),U)
DO SETUP
IF $DATA(^TMP($JOB,1,PXRRCL))
SET PXRRCN=PXRRCN+1
SET PXRRCLIN=$PIECE(PXRRCLIN(PXRR),U,2)
Begin DoDot:1
SDDATA ;_._._._._._.Initialize Appt Types from Scheduling data_._._._._.
+1 FOR X="UN","CA","NS"
SET Y=0
FOR
SET Y=$ORDER(^TMP($JOB,1,PXRRCL,Y))
IF 'Y
QUIT
SET ^TMP($JOB,PXRRCL,X)=^TMP($JOB,PXRRCL,X)+$GET(^TMP($JOB,1,PXRRCL,Y,X))
SDTOTAL ;_._._._._._._.Total Visits per Clinic & All Clinics_._._._._._._.
+1 SET ^TMP($JOB,PXRRCL,"TOT")=$SELECT($PIECE(^TMP($JOB,"CL",1,PXRRCL),U,2)="":0,1:$PIECE(^TMP($JOB,"CL",1,PXRRCL),U,2))
End DoDot:1
PCEDATA ;_._._._._._._._._._._._Patient Encounters_._._._._._._._._._._
+1 ;F= visit ifn ;C= enctr counter
+2 NEW F
+3 FOR
SET PXRR=$ORDER(PXRRCLIN(PXRR))
IF 'PXRR
QUIT
SET PXRRCL=$PIECE(PXRRCLIN(PXRR),U)
SET PXRRCLIN=$PIECE(PXRRCLIN(PXRR),U,2)
SET PXRRVDT=PXRRBDT
SET (C,PXRRNVCP)=0
FOR
SET PXRRVDT=$ORDER(^AUPNVSIT("B",PXRRVDT))
IF 'PXRRVDT!(PXRRVDT>PXRREDT)
QUIT
Begin DoDot:1
+4 SET F=0
FOR
SET F=$ORDER(^AUPNVSIT("B",PXRRVDT,F))
IF 'F
QUIT
IF $PIECE(^AUPNVSIT(F,0),U,22)=PXRRCLIN
SET X=$PIECE($GET(^AUPNVSIT(F,0)),U,7)
IF (X="A")!(X="I")!(X="S")
SET C=C+1
SET ^TMP($JOB,PXRRCL,"ENT")=C
Begin DoDot:2
+5 ;_.If no x-ref exists, there are no associated CPTs for the enctr_.
+6 IF '$DATA(^AUPNVCPT("AD",F))
SET PXRRNVCP=PXRRNVCP+1
SET ^TMP($JOB,PXRRCL,"NVCPT")=PXRRNVCP
QUIT
PCEPROC ;_._._._._._._._._._.Encounter Visit Codes_._._._._._._._._._.
+1 SET G=0
FOR
SET G=$ORDER(^AUPNVCPT("AD",F,G))
IF 'G
QUIT
SET PXRRVCPT=$PIECE(^AUPNVCPT(G,0),U)
IF $DATA(^IBE(357.69,PXRRVCPT))
SET PXRVST=1
+2 ;_.If none of the associated procedures is a Type of Visit code_.
+3 IF '$DATA(PXRVST)
SET ^TMP($JOB,PXRRCL,"OTHER CPT")=^TMP($JOB,PXRRCL,"OTHER CPT")+1
QUIT
+4 KILL PXRVST
PCEENM ;_._._._._._._._.All Procedures Which Are Visit Codes_._._._._._.
+1 SET G=0
FOR
SET G=$ORDER(^AUPNVCPT("AD",F,G))
IF 'G
QUIT
SET PXRRVCPT=$PIECE(^AUPNVCPT(G,0),U)
IF $DATA(^IBE(357.69,PXRRVCPT))&('$DATA(PXRVST))
Begin DoDot:3
+2 ;_._._.Category of Type of Visit (i.e. NEW,EST,CONSULT,OTHER)_._._.
+3 ;_._._.Use the First Type of Visit Code Found for Encounter_._._._.
+4 SET X=$PIECE(^IBE(357.69,PXRRVCPT,0),U,5)
SET X=$SELECT(X=1:"NEW",X=2:"ESTABLISHED",X=3:"CONSULT",1:"OTHER")
SET ^TMP($JOB,PXRRCL,X)=^TMP($JOB,PXRRCL,X)+1
SET PXRVST=1
End DoDot:3
+5 KILL PXRVST
End DoDot:2
End DoDot:1
PCETOT ;_._._._._._._.Total PCE Enctrs for All Selected Clinics_._._._._._.
+1 SET (^TMP($JOB,"TVCO"),X)=0
FOR
SET X=$ORDER(PXRRCLIN(X))
IF 'X
QUIT
SET ^TMP($JOB,"TVCO")=^TMP($JOB,"TVCO")+$GET(^TMP($JOB,$PIECE(PXRRCLIN(X),U),"ENT"))
EXIT QUIT
SETUP ;_._._.TMP Array_._._.
+1 FOR I="UN","CA","NS","NEW","ESTABLISHED","CONSULT","OTHER","OTHER CPT","ENT","NVCPT","TOT"
SET ^TMP($JOB,PXRRCL,I)=0
+2 QUIT