SDSCOMP ;ALB/JAM/RBS - ASCD Compile list of encounters for Service Connection Review ; 3/12/07 4:36pm
;;5.3;Scheduling;**495,1015**;Aug 13, 1993;Build 21
;;MODIFIED FOR NATIONAL RELEASE from a Class III software product
;;known as Service Connected Automated Monitoring (SCAM).
;
; Routine should be called at specified tags only.
Q
;
AUTODT ; Called by option "SDSC NIGHTLY COMPILE"
; - Compile ASCD Encounters on a Nightly Basis
; (Rated Disabilities/ICDs for Prior Day Encounters)
;
N SDSCTDT,SDEDT,DIC,DA
; nightly compile is for previous day only
S SDSCTDT=$$FMADD^XLFDT(DT,-1)
; Set variable 'SDEDT' (loop end point) to same date
S SDEDT=SDSCTDT
; Setup list of service connected eligibility codes.
D ELIG
G TASK1
;
GETDATE ; Entry point for edit or report - Get START and END dates
S SDSCBDT=$O(^SDSC(409.48,"AE",""))\1,SDSCEDT=DT
; If no records currently available, display message.
I SDSCBDT=0 D EN^DDIOL("NO RECORDS ON FILE - RUN COMPILE",,"!!?10") HANG 3 S (SDSCTDT,SDEDT)="" Q
;
GETDATE1 ; Entry point for SDSC COMPILE option - Get START and END dates
; Output:
; Set var 'SDSCTDT' (loop start point) to a user selected date.
N DIR,X,Y,X1,X2
S DIR(0)="DA^"_SDSCBDT_":"_DT_":EX"
S DIR("A")="Please enter START date: "
;S DIR("B")=$$FMTE^XLFDT(SDSCBDT,"1Z")
S DIR("?")="This START date cannot precede "_$$FMTE^XLFDT(SDSCBDT,"1Z")
;
; This check works for the "SDSC COMPILE" only.
; - Compile does not setup SDSCEDT var
I SDSCBDT]"",SDSCEDT']"" D
. S DIR("B")=$$FMTE^XLFDT(SDSCBDT,"1Z")
. S DIR("?")="This START date cannot precede the default SDSC SITE PARAMETER days"
;
D ^DIR
I $D(DTOUT)!$D(DUOUT) S (SDSCTDT,SDEDT)="" Q
S:Y>0 SDSCTDT=Y
; check if start date has changed
I SDSCTDT'=SDSCBDT S SDSCBDT=SDSCTDT
; Set variable 'SDEDT' (loop end point) to a user selected date.
K DIR
S DIR(0)="DA^"_SDSCBDT_":"_DT_":EX"
S DIR("A")="Please enter END date: "
S DIR("B")=$$FMTE^XLFDT($S(SDSCEDT]"":SDSCEDT,1:DT),"1Z")
S DIR("?")="This END date cannot precede the START date or exceed today's date"
D ^DIR
I $D(DTOUT)!$D(DUOUT) S (SDSCTDT,SDEDT)="" Q
S:Y>0 SDEDT=Y
Q
;
ELIG ; Compile list of service connected eligibility codes.
N I,J
K SDLIST
; loop "D" x-ref of ELIGIBILITY CODE (#8) file
; Entries 1 and 3 are the service connected entries in this file.
F I=1,3 S J=0 F S J=$O(^DIC(8,"D",I,J)) Q:'J S SDLIST(J)=""
Q
;
COMPILE ; Called by option "SDSC COMPILE"
; - Compile ASCD Encounters by Date Range
; (Rated Disabilities/ICDs for Encounters)
N DIR,X,Y,SDSCBDT,SDSCEDT,ZTIO,ZTDESC,ZTRTN,ZTSAVE
N SDSCITE,SDSCDAY
D HOME^%ZIS
; Get start and end date for compile.
S (SDSCBDT,SDSCEDT,SDSCDAY)=""
S SDSCITE=$P($$SITE^VASITE(),U,1)
S SDSCDAY=$$GET^XPAR((+SDSCITE)_";DIC(4,","SDSC SITE PARAMETER")
; set default start date based on site parameter (30 days max)
I SDSCDAY="" S SDSCDAY=30
S SDSCBDT=$$FMADD^XLFDT(DT,-SDSCDAY)
;
D GETDATE1 I SDSCTDT="" G END
; Setup list of service connected eligibility codes.
D ELIG
; Ask user if compile should be in background and handle queuing if requested.
K DIR
S DIR(0)="YA",DIR("B")="YES"
S DIR("A")="Do you wish to schedule the compile? "
S DIR("?")="Enter 'YES' to schedule compile using TaskMan or 'NO' to compile immediately."
D ^DIR
I $D(DTOUT)!$D(DUOUT) D EN^DDIOL("<Compile Aborted> ",,"!!?10") G END
I Y D G END
. S ZTIO="NULL",ZTDESC="COMPARE RATED DISABILITY/ICDs PER ENCOUNTER (COMPILE)",ZTRTN="TASK^SDSCOMP",ZTSAVE("*")=""
. D ^%ZTLOAD
. I $G(ZTSK)]"" D EN^DDIOL("Extract's TaskMan ID is "_ZTSK,"","!!?10")
. K ZTSK
. Q
D EN^DDIOL("Comparing Rated Disabilities and Diagnosis Code per Encounter ...",,"!!?10")
;
TASK ; Start compile (one-time compile - remove from queue when complete)
D OPT
I $D(ZTQUEUED) S ZTREQ="@"
G END
;
TASK1 ; Start compile (scheduled compile - don't remove from queue)
D OPT
G END
;
OPT ; Loop through all outpatient encounters for the specified dates.
N SDSCTOT,SDSCSVC,SDSCNSC,SDSCBAD,SDSCNCT,SDSCEXS,SDSCNDX,SDSCNBL
N SDSCMAP1,SDSCMAP2,SDSCINS,SDOEDT,SDOE
S (SDSCTOT,SDSCSVC,SDSCNSC,SDSCBAD,SDSCNCT,SDSCEXS,SDSCNDX,SDSCNBL,SDSCMAP1,SDSCMAP2,SDSCINS)=0
S SDOEDT=SDSCTDT F S SDOEDT=$O(^SCE("B",SDOEDT)) Q:(SDOEDT\1)>SDEDT Q:SDOEDT="" D
. S SDOE=0 F S SDOE=$O(^SCE("B",SDOEDT,SDOE)) Q:'SDOE D OPT1
. Q
;
; Check for newly identified insurance
D EN^SDSCINS(.SDSCINS,.SDSCSVC)
;
; Send mail message with counts of records
D MMSG
;
; Check for encounters in ASCD that were deleted from (#409.68)
D EN^SDSCPRG
Q
;
OPT1 ; Check the service connected info for one encounter.
N SDOEDAT,SDEC,SDPAT,SDCLIN,SDCST,SDV0,SDFILEOK,SDPRV,SDOSC
S SDSCTOT=SDSCTOT+1
; If this encounter has already been compiled for review, quit.
I $D(^SDSC(409.48,SDOE,0)) S SDSCEXS=SDSCEXS+1 Q
; Get encounter data. If no encounter data, quit.
; Replace all ^SCE calls with new variable.
S SDOEDAT=$$GETOE^SDOE(SDOE)
I SDOEDAT="" S SDSCBAD=SDSCBAD+1 Q
; if child encounter, reduce count and quit
I $P(SDOEDAT,U,6) S SDSCTOT=SDSCTOT-1 Q
; if not Check-out, quit
I $P(SDOEDAT,U,12)'=2 S SDSCNBL=SDSCNBL+1 Q
; Get eligibility. If no eligibility, quit.
S SDEC=$P(SDOEDAT,U,13) I SDEC="" S SDSCBAD=SDSCBAD+1 Q
; If eligibility is not service connected, quit.
I '$D(SDLIST(SDEC)) S SDSCNSC=SDSCNSC+1 Q
; Get patient. If no patient, quit.
S SDPAT=$P(SDOEDAT,U,2) I SDPAT="" S SDSCBAD=SDSCBAD+1 Q
; Checks for clinic and stop code.
; Get clinic. If no clinic, quit.
S SDCLIN=$P(SDOEDAT,U,4) I SDCLIN="" S SDSCBAD=SDSCBAD+1 Q
; Get clinic stop code. If no clinic stop code, quit.
S SDCST=$P(SDOEDAT,U,3) I SDCST="" S SDSCBAD=SDSCBAD+1 Q
; If clinic is non-count, quit.
I $$NCTCL^SDSCUTL(SDCLIN) S SDSCNCT=SDSCNCT+1 Q
; If encounter is non-billable for first and third party, quit.
I $$NBFP^SDSCUTL(SDOE),$$NBTP^SDSCUTL(SDOE) S SDSCNBL=SDSCNBL+1 Q
; Get visit file entry. If no visit, quit.
S SDV0=$P(SDOEDAT,U,5) I SDV0="" S SDSCBAD=SDSCBAD+1 Q
S SDOSC=$$GET1^DIQ(9000010,SDV0_",",80001,"I")
I SDOSC="" S SDSCNBL=SDSCNBL+1 Q
; Get and evaluate all ICD9 entries for the specified visit.
S SDFILEOK=$$SC^SDSCAPI(SDPAT,,SDOE)
;no ICDs were found for this encounter SDFILEOK=""
I SDFILEOK="" S SDSCNDX=SDSCNDX+1 Q
;checks if ICD match found
I +SDFILEOK D
.I '$P(SDFILEOK,"^",4) S SDSCMAP1=SDSCMAP1+1 Q
.S SDSCMAP2=SDSCMAP2+1
I '+SDFILEOK S SDSCNSC=SDSCNSC+1
; Get Primary Provider for the specified visit.
S SDPRV=$$PRIMVPRV^PXUTL1(SDV0) I SDPRV=0 S SDPRV=""
; Store the encounter for later use.
S SDSCSVC=SDSCSVC+1
I $P(SDFILEOK,U,4) Q:$D(^SDSC(409.48,SDOE,0)) D STORE Q
I SDOSC'=$P(SDFILEOK,U) D STORE
Q
;
STORE ; Save the information for the found encounter.
N SDERR,SDIEN,SDSC
S SDIEN(1)=SDOE
S SDSC(409.48,"+1,",.01)=SDOE
S SDSC(409.48,"+1,",.04)=DT
S SDSC(409.48,"+1,",.07)=SDOEDT
S SDSC(409.48,"+1,",.08)=SDPRV
S SDSC(409.48,"+1,",.09)=$P(SDFILEOK,U,3)
S SDSC(409.48,"+1,",.11)=SDPAT
S SDSC(409.48,"+1,",.12)=$P(SDOEDAT,U,11)
S SDSC(409.48,"+1,",.05)="N"
S SDSC(409.48,"+1,",.13)=SDOSC
D UPDATE^DIE("","SDSC","SDIEN","SDERR")
Q
;
MMSG ; Send Mail Message
N SDCNT,SDTEXT,DIFROM,XMY,XMDUZ,XMTEXT,XMSUB,XMZ,XMDUN
S SDTEXT(1)="Date Range (Compile) - From: "_$$FMTE^XLFDT(SDSCTDT,1)_" Thru: "_$$FMTE^XLFDT(SDEDT,1)
S SDTEXT(2)="Date Range (Late Ins.) - "
I '$D(SDSCBDT),'$D(SDSCEDT) S SDTEXT(2)=SDTEXT(2)_"None"
E S SDTEXT(2)=SDTEXT(2)_"From: "_$$FMTE^XLFDT(SDSCBDT,1)_" Thru: "_$$FMTE^XLFDT(SDSCEDT,1)
S SDTEXT(3)=" "
S SDTEXT(4)="Number of encounters Service Connected (Compile) : "_$J(SDSCSVC-SDSCINS,7)
S SDTEXT(5)="Number of encounters Service Connected (Late Ins.) : "_$J(SDSCINS,7)
S SDTEXT(6)=" (Number SvcConn with a True Map) : "_$J(SDSCMAP1,7)
S SDTEXT(6.5)=" (Number SvcConn with a Partial Map) : "_$J(SDSCMAP2,7)
S SDTEXT(7)=" (Number SvcConn that don't Map to VBA) : "_$J(SDSCSVC-SDSCMAP1-SDSCMAP2,7)
S SDTEXT(8)="Number of encounters Not Service Connected : "_$J(SDSCNSC,7)
S SDTEXT(9)="Number of encounters that are Non-billable : "_$J(SDSCNBL,7)
S SDTEXT(10)="Number of encounters with Non-count Clinics : "_$J(SDSCNCT,7)
S SDTEXT(11)="Number of encounters with no diagnoses : "_$J(SDSCNDX,7)
S SDTEXT(12)="Number of encounters with other errors : "_$J(SDSCBAD,7)
S SDTEXT(13)="Number of encounters already evaluated : "_$J(SDSCEXS,7)
S SDTEXT(14)="---------------------------------------------------------------------------"
S SDTEXT(15)="Total Encounters Checked: "_$J(SDSCTOT,7)
S SDCNT=15
D AUDIT^SDSCINS(.SDTEXT,.SDCNT)
I $G(DUZ)="" S XMZ(.5)=""
S XMZ(DUZ)="",XMDUZ="ASCD Compile",XMY("G.SDSC NIGHTLY TALLY")=""
S XMTEXT="SDTEXT(",XMSUB="ASCD Compile Numbers"
D ^XMD
Q
;
END ; Clear all variables before exiting.
K SDSCTDT,SDEDT,SDOEX,SDRD,SDRDIEN,SDSCBDT,SDSCEDT,SDIEN,SDERR,SDSC
K SDVBA,SDVBAI,SDLIST,P,L,SDABRT,X,Y,DTOUT,DUOUT
Q
SDSCOMP ;ALB/JAM/RBS - ASCD Compile list of encounters for Service Connection Review ; 3/12/07 4:36pm
+1 ;;5.3;Scheduling;**495,1015**;Aug 13, 1993;Build 21
+2 ;;MODIFIED FOR NATIONAL RELEASE from a Class III software product
+3 ;;known as Service Connected Automated Monitoring (SCAM).
+4 ;
+5 ; Routine should be called at specified tags only.
+6 QUIT
+7 ;
AUTODT ; Called by option "SDSC NIGHTLY COMPILE"
+1 ; - Compile ASCD Encounters on a Nightly Basis
+2 ; (Rated Disabilities/ICDs for Prior Day Encounters)
+3 ;
+4 NEW SDSCTDT,SDEDT,DIC,DA
+5 ; nightly compile is for previous day only
+6 SET SDSCTDT=$$FMADD^XLFDT(DT,-1)
+7 ; Set variable 'SDEDT' (loop end point) to same date
+8 SET SDEDT=SDSCTDT
+9 ; Setup list of service connected eligibility codes.
+10 DO ELIG
+11 GOTO TASK1
+12 ;
GETDATE ; Entry point for edit or report - Get START and END dates
+1 SET SDSCBDT=$ORDER(^SDSC(409.48,"AE",""))\1
SET SDSCEDT=DT
+2 ; If no records currently available, display message.
+3 IF SDSCBDT=0
DO EN^DDIOL("NO RECORDS ON FILE - RUN COMPILE",,"!!?10")
HANG 3
SET (SDSCTDT,SDEDT)=""
QUIT
+4 ;
GETDATE1 ; Entry point for SDSC COMPILE option - Get START and END dates
+1 ; Output:
+2 ; Set var 'SDSCTDT' (loop start point) to a user selected date.
+3 NEW DIR,X,Y,X1,X2
+4 SET DIR(0)="DA^"_SDSCBDT_":"_DT_":EX"
+5 SET DIR("A")="Please enter START date: "
+6 ;S DIR("B")=$$FMTE^XLFDT(SDSCBDT,"1Z")
+7 SET DIR("?")="This START date cannot precede "_$$FMTE^XLFDT(SDSCBDT,"1Z")
+8 ;
+9 ; This check works for the "SDSC COMPILE" only.
+10 ; - Compile does not setup SDSCEDT var
+11 IF SDSCBDT]""
IF SDSCEDT']""
Begin DoDot:1
+12 SET DIR("B")=$$FMTE^XLFDT(SDSCBDT,"1Z")
+13 SET DIR("?")="This START date cannot precede the default SDSC SITE PARAMETER days"
End DoDot:1
+14 ;
+15 DO ^DIR
+16 IF $DATA(DTOUT)!$DATA(DUOUT)
SET (SDSCTDT,SDEDT)=""
QUIT
+17 IF Y>0
SET SDSCTDT=Y
+18 ; check if start date has changed
+19 IF SDSCTDT'=SDSCBDT
SET SDSCBDT=SDSCTDT
+20 ; Set variable 'SDEDT' (loop end point) to a user selected date.
+21 KILL DIR
+22 SET DIR(0)="DA^"_SDSCBDT_":"_DT_":EX"
+23 SET DIR("A")="Please enter END date: "
+24 SET DIR("B")=$$FMTE^XLFDT($SELECT(SDSCEDT]"":SDSCEDT,1:DT),"1Z")
+25 SET DIR("?")="This END date cannot precede the START date or exceed today's date"
+26 DO ^DIR
+27 IF $DATA(DTOUT)!$DATA(DUOUT)
SET (SDSCTDT,SDEDT)=""
QUIT
+28 IF Y>0
SET SDEDT=Y
+29 QUIT
+30 ;
ELIG ; Compile list of service connected eligibility codes.
+1 NEW I,J
+2 KILL SDLIST
+3 ; loop "D" x-ref of ELIGIBILITY CODE (#8) file
+4 ; Entries 1 and 3 are the service connected entries in this file.
+5 FOR I=1,3
SET J=0
FOR
SET J=$ORDER(^DIC(8,"D",I,J))
IF 'J
QUIT
SET SDLIST(J)=""
+6 QUIT
+7 ;
COMPILE ; Called by option "SDSC COMPILE"
+1 ; - Compile ASCD Encounters by Date Range
+2 ; (Rated Disabilities/ICDs for Encounters)
+3 NEW DIR,X,Y,SDSCBDT,SDSCEDT,ZTIO,ZTDESC,ZTRTN,ZTSAVE
+4 NEW SDSCITE,SDSCDAY
+5 DO HOME^%ZIS
+6 ; Get start and end date for compile.
+7 SET (SDSCBDT,SDSCEDT,SDSCDAY)=""
+8 SET SDSCITE=$PIECE($$SITE^VASITE(),U,1)
+9 SET SDSCDAY=$$GET^XPAR((+SDSCITE)_";DIC(4,","SDSC SITE PARAMETER")
+10 ; set default start date based on site parameter (30 days max)
+11 IF SDSCDAY=""
SET SDSCDAY=30
+12 SET SDSCBDT=$$FMADD^XLFDT(DT,-SDSCDAY)
+13 ;
+14 DO GETDATE1
IF SDSCTDT=""
GOTO END
+15 ; Setup list of service connected eligibility codes.
+16 DO ELIG
+17 ; Ask user if compile should be in background and handle queuing if requested.
+18 KILL DIR
+19 SET DIR(0)="YA"
SET DIR("B")="YES"
+20 SET DIR("A")="Do you wish to schedule the compile? "
+21 SET DIR("?")="Enter 'YES' to schedule compile using TaskMan or 'NO' to compile immediately."
+22 DO ^DIR
+23 IF $DATA(DTOUT)!$DATA(DUOUT)
DO EN^DDIOL("<Compile Aborted> ",,"!!?10")
GOTO END
+24 IF Y
Begin DoDot:1
+25 SET ZTIO="NULL"
SET ZTDESC="COMPARE RATED DISABILITY/ICDs PER ENCOUNTER (COMPILE)"
SET ZTRTN="TASK^SDSCOMP"
SET ZTSAVE("*")=""
+26 DO ^%ZTLOAD
+27 IF $GET(ZTSK)]""
DO EN^DDIOL("Extract's TaskMan ID is "_ZTSK,"","!!?10")
+28 KILL ZTSK
+29 QUIT
End DoDot:1
GOTO END
+30 DO EN^DDIOL("Comparing Rated Disabilities and Diagnosis Code per Encounter ...",,"!!?10")
+31 ;
TASK ; Start compile (one-time compile - remove from queue when complete)
+1 DO OPT
+2 IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+3 GOTO END
+4 ;
TASK1 ; Start compile (scheduled compile - don't remove from queue)
+1 DO OPT
+2 GOTO END
+3 ;
OPT ; Loop through all outpatient encounters for the specified dates.
+1 NEW SDSCTOT,SDSCSVC,SDSCNSC,SDSCBAD,SDSCNCT,SDSCEXS,SDSCNDX,SDSCNBL
+2 NEW SDSCMAP1,SDSCMAP2,SDSCINS,SDOEDT,SDOE
+3 SET (SDSCTOT,SDSCSVC,SDSCNSC,SDSCBAD,SDSCNCT,SDSCEXS,SDSCNDX,SDSCNBL,SDSCMAP1,SDSCMAP2,SDSCINS)=0
+4 SET SDOEDT=SDSCTDT
FOR
SET SDOEDT=$ORDER(^SCE("B",SDOEDT))
IF (SDOEDT\1)>SDEDT
QUIT
IF SDOEDT=""
QUIT
Begin DoDot:1
+5 SET SDOE=0
FOR
SET SDOE=$ORDER(^SCE("B",SDOEDT,SDOE))
IF 'SDOE
QUIT
DO OPT1
+6 QUIT
End DoDot:1
+7 ;
+8 ; Check for newly identified insurance
+9 DO EN^SDSCINS(.SDSCINS,.SDSCSVC)
+10 ;
+11 ; Send mail message with counts of records
+12 DO MMSG
+13 ;
+14 ; Check for encounters in ASCD that were deleted from (#409.68)
+15 DO EN^SDSCPRG
+16 QUIT
+17 ;
OPT1 ; Check the service connected info for one encounter.
+1 NEW SDOEDAT,SDEC,SDPAT,SDCLIN,SDCST,SDV0,SDFILEOK,SDPRV,SDOSC
+2 SET SDSCTOT=SDSCTOT+1
+3 ; If this encounter has already been compiled for review, quit.
+4 IF $DATA(^SDSC(409.48,SDOE,0))
SET SDSCEXS=SDSCEXS+1
QUIT
+5 ; Get encounter data. If no encounter data, quit.
+6 ; Replace all ^SCE calls with new variable.
+7 SET SDOEDAT=$$GETOE^SDOE(SDOE)
+8 IF SDOEDAT=""
SET SDSCBAD=SDSCBAD+1
QUIT
+9 ; if child encounter, reduce count and quit
+10 IF $PIECE(SDOEDAT,U,6)
SET SDSCTOT=SDSCTOT-1
QUIT
+11 ; if not Check-out, quit
+12 IF $PIECE(SDOEDAT,U,12)'=2
SET SDSCNBL=SDSCNBL+1
QUIT
+13 ; Get eligibility. If no eligibility, quit.
+14 SET SDEC=$PIECE(SDOEDAT,U,13)
IF SDEC=""
SET SDSCBAD=SDSCBAD+1
QUIT
+15 ; If eligibility is not service connected, quit.
+16 IF '$DATA(SDLIST(SDEC))
SET SDSCNSC=SDSCNSC+1
QUIT
+17 ; Get patient. If no patient, quit.
+18 SET SDPAT=$PIECE(SDOEDAT,U,2)
IF SDPAT=""
SET SDSCBAD=SDSCBAD+1
QUIT
+19 ; Checks for clinic and stop code.
+20 ; Get clinic. If no clinic, quit.
+21 SET SDCLIN=$PIECE(SDOEDAT,U,4)
IF SDCLIN=""
SET SDSCBAD=SDSCBAD+1
QUIT
+22 ; Get clinic stop code. If no clinic stop code, quit.
+23 SET SDCST=$PIECE(SDOEDAT,U,3)
IF SDCST=""
SET SDSCBAD=SDSCBAD+1
QUIT
+24 ; If clinic is non-count, quit.
+25 IF $$NCTCL^SDSCUTL(SDCLIN)
SET SDSCNCT=SDSCNCT+1
QUIT
+26 ; If encounter is non-billable for first and third party, quit.
+27 IF $$NBFP^SDSCUTL(SDOE)
IF $$NBTP^SDSCUTL(SDOE)
SET SDSCNBL=SDSCNBL+1
QUIT
+28 ; Get visit file entry. If no visit, quit.
+29 SET SDV0=$PIECE(SDOEDAT,U,5)
IF SDV0=""
SET SDSCBAD=SDSCBAD+1
QUIT
+30 SET SDOSC=$$GET1^DIQ(9000010,SDV0_",",80001,"I")
+31 IF SDOSC=""
SET SDSCNBL=SDSCNBL+1
QUIT
+32 ; Get and evaluate all ICD9 entries for the specified visit.
+33 SET SDFILEOK=$$SC^SDSCAPI(SDPAT,,SDOE)
+34 ;no ICDs were found for this encounter SDFILEOK=""
+35 IF SDFILEOK=""
SET SDSCNDX=SDSCNDX+1
QUIT
+36 ;checks if ICD match found
+37 IF +SDFILEOK
Begin DoDot:1
+38 IF '$PIECE(SDFILEOK,"^",4)
SET SDSCMAP1=SDSCMAP1+1
QUIT
+39 SET SDSCMAP2=SDSCMAP2+1
End DoDot:1
+40 IF '+SDFILEOK
SET SDSCNSC=SDSCNSC+1
+41 ; Get Primary Provider for the specified visit.
+42 SET SDPRV=$$PRIMVPRV^PXUTL1(SDV0)
IF SDPRV=0
SET SDPRV=""
+43 ; Store the encounter for later use.
+44 SET SDSCSVC=SDSCSVC+1
+45 IF $PIECE(SDFILEOK,U,4)
IF $DATA(^SDSC(409.48,SDOE,0))
QUIT
DO STORE
QUIT
+46 IF SDOSC'=$PIECE(SDFILEOK,U)
DO STORE
+47 QUIT
+48 ;
STORE ; Save the information for the found encounter.
+1 NEW SDERR,SDIEN,SDSC
+2 SET SDIEN(1)=SDOE
+3 SET SDSC(409.48,"+1,",.01)=SDOE
+4 SET SDSC(409.48,"+1,",.04)=DT
+5 SET SDSC(409.48,"+1,",.07)=SDOEDT
+6 SET SDSC(409.48,"+1,",.08)=SDPRV
+7 SET SDSC(409.48,"+1,",.09)=$PIECE(SDFILEOK,U,3)
+8 SET SDSC(409.48,"+1,",.11)=SDPAT
+9 SET SDSC(409.48,"+1,",.12)=$PIECE(SDOEDAT,U,11)
+10 SET SDSC(409.48,"+1,",.05)="N"
+11 SET SDSC(409.48,"+1,",.13)=SDOSC
+12 DO UPDATE^DIE("","SDSC","SDIEN","SDERR")
+13 QUIT
+14 ;
MMSG ; Send Mail Message
+1 NEW SDCNT,SDTEXT,DIFROM,XMY,XMDUZ,XMTEXT,XMSUB,XMZ,XMDUN
+2 SET SDTEXT(1)="Date Range (Compile) - From: "_$$FMTE^XLFDT(SDSCTDT,1)_" Thru: "_$$FMTE^XLFDT(SDEDT,1)
+3 SET SDTEXT(2)="Date Range (Late Ins.) - "
+4 IF '$DATA(SDSCBDT)
IF '$DATA(SDSCEDT)
SET SDTEXT(2)=SDTEXT(2)_"None"
+5 IF '$TEST
SET SDTEXT(2)=SDTEXT(2)_"From: "_$$FMTE^XLFDT(SDSCBDT,1)_" Thru: "_$$FMTE^XLFDT(SDSCEDT,1)
+6 SET SDTEXT(3)=" "
+7 SET SDTEXT(4)="Number of encounters Service Connected (Compile) : "_$JUSTIFY(SDSCSVC-SDSCINS,7)
+8 SET SDTEXT(5)="Number of encounters Service Connected (Late Ins.) : "_$JUSTIFY(SDSCINS,7)
+9 SET SDTEXT(6)=" (Number SvcConn with a True Map) : "_$JUSTIFY(SDSCMAP1,7)
+10 SET SDTEXT(6.5)=" (Number SvcConn with a Partial Map) : "_$JUSTIFY(SDSCMAP2,7)
+11 SET SDTEXT(7)=" (Number SvcConn that don't Map to VBA) : "_$JUSTIFY(SDSCSVC-SDSCMAP1-SDSCMAP2,7)
+12 SET SDTEXT(8)="Number of encounters Not Service Connected : "_$JUSTIFY(SDSCNSC,7)
+13 SET SDTEXT(9)="Number of encounters that are Non-billable : "_$JUSTIFY(SDSCNBL,7)
+14 SET SDTEXT(10)="Number of encounters with Non-count Clinics : "_$JUSTIFY(SDSCNCT,7)
+15 SET SDTEXT(11)="Number of encounters with no diagnoses : "_$JUSTIFY(SDSCNDX,7)
+16 SET SDTEXT(12)="Number of encounters with other errors : "_$JUSTIFY(SDSCBAD,7)
+17 SET SDTEXT(13)="Number of encounters already evaluated : "_$JUSTIFY(SDSCEXS,7)
+18 SET SDTEXT(14)="---------------------------------------------------------------------------"
+19 SET SDTEXT(15)="Total Encounters Checked: "_$JUSTIFY(SDSCTOT,7)
+20 SET SDCNT=15
+21 DO AUDIT^SDSCINS(.SDTEXT,.SDCNT)
+22 IF $GET(DUZ)=""
SET XMZ(.5)=""
+23 SET XMZ(DUZ)=""
SET XMDUZ="ASCD Compile"
SET XMY("G.SDSC NIGHTLY TALLY")=""
+24 SET XMTEXT="SDTEXT("
SET XMSUB="ASCD Compile Numbers"
+25 DO ^XMD
+26 QUIT
+27 ;
END ; Clear all variables before exiting.
+1 KILL SDSCTDT,SDEDT,SDOEX,SDRD,SDRDIEN,SDSCBDT,SDSCEDT,SDIEN,SDERR,SDSC
+2 KILL SDVBA,SDVBAI,SDLIST,P,L,SDABRT,X,Y,DTOUT,DUOUT
+3 QUIT