source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SDSCCHK.m@ 767

Last change on this file since 767 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 6.4 KB
Line 
1SDSCCHK ;ALB/JAM/RBS - Check Encounters for Inclusion in ASCD ; 4/30/07 4:46pm
2 ;;5.3;Scheduling;**495**;Aug 13, 1993;Build 50
3 ;;MODIFIED FOR NATIONAL RELEASE from a Class III software product
4 ;;known as Service Connected Automated Monitoring (SCAM).
5 ;
6 Q
7EN ; Entry point
8 N SDSCBDT,SDSCITE,SDSCDAY,ZTQUEUED,POP,ZTRTN,ZTDTH,ZTDESC,ZTSAVE
9 ; Initialize system variables if not already set
10 D HOME^%ZIS
11 ; Get start and end date for compile.
12 S (SDSCBDT,SDSCEDT,SDSCDAY)=""
13 S SDSCITE=$P($$SITE^VASITE(),U,1)
14 S SDSCDAY=$$GET^XPAR((+SDSCITE)_";DIC(4,","SDSC SITE PARAMETER")
15 ; set default start date based on site parameter (30 days max)
16 I SDSCDAY="" S SDSCDAY=30
17 S SDSCBDT=$$FMADD^XLFDT(DT,-SDSCDAY),SDSCEDT=DT
18 D GETDATE1^SDSCOMP I SDSCTDT="" G EXIT
19 S DIR(0)="S^S:Summary Report;D:Detailed Report",DIR("B")="S"
20 D ^DIR K DIR
21 I $G(DTOUT)!($G(DUOUT)) G EXIT
22 S SDANS=Y
23 K %ZIS,IOP,IOC,ZTIO S %ZIS="MQ" D ^%ZIS G:POP EXIT
24 I $D(IO("Q")) D G EXIT
25 . S ZTRTN="PRT^SDSCCHK",ZTDTH=$H,ZTDESC="ASCD Compile Results Report"
26 . S ZTSAVE("SDANS")="",ZTSAVE("SDSCTDT")="",ZTSAVE("SDEDT")=""
27 . K IO("Q") D ^%ZTLOAD W !,"REQUEST QUEUED"
28 ;
29PRT ; Print results
30 N SDCT,SDDCT,SDOEDT,SDOE,P,L,SDTXT,TOTAL,SDOANS
31 K ^TMP("SDSCCHK",$J)
32 D ELIG^SDSCOMP
33 S SDOEDT=SDSCTDT,(SDCT,SDDCT)=0
34 F S SDOEDT=$O(^SCE("B",SDOEDT)) Q:(SDOEDT\1)>SDEDT Q:SDOEDT="" D
35 . S SDOE=0
36 . F S SDOE=$O(^SCE("B",SDOEDT,SDOE)) Q:'SDOE D FND
37 ;
38BEG ; Begin report
39 S (P,L,SDABRT,TOTAL,SDOANS)=0
40 S SDOANS=SDANS S:SDANS="D" SDANS="S"
41 D HDR
42 ;
43 U IO
44 D G EXIT:$G(SDABRT)=1
45 . S SDTXT=""
46 . F S SDTXT=$O(^TMP("SDSCCHK",$J,"TOTAL",SDTXT)) Q:SDTXT="" D Q:$G(SDABRT)=1
47 .. W !,$J(^TMP("SDSCCHK",$J,"TOTAL",SDTXT),8),?10,SDTXT S L=L+1
48 .. F I=" TP "," MT " W:SDTXT[I " *"
49 .. S TOTAL=TOTAL+^TMP("SDSCCHK",$J,"TOTAL",SDTXT)
50 .. I L+3>IOSL D HDR Q:$G(SDABRT)=1
51 . W ! F I=1:1:79 W "-"
52 . W !,$J(TOTAL,8),?10,"TOTAL Encounters"
53 . W !!,"* Third Party=TP; Means Test=MT",!
54 ;
55 I SDOANS="D" S SDANS="D" D HDR D G EXIT:$G(SDABRT)=1
56 . S SDTXT=""
57 . F S SDTXT=$O(^TMP("SDSCCHK",$J,"DX",SDTXT)) Q:'SDTXT D Q:$G(SDABRT)=1
58 .. S SDDATA=^TMP("SDSCCHK",$J,"DX",SDTXT)
59 .. W !,$P(SDDATA,U,1),?12,$P(SDDATA,U,2),?24,$E($P(SDDATA,U,3),1,19),?44,$E($P(SDDATA,U,4),1,16)
60 .. W ?62,$E($P(^TMP("SDSCCHK",$J,"DX",SDTXT),U,5),1,18),!,?10,$P($P(^TMP("SDSCCHK",$J,"DX",SDTXT),U,6),"(",1)
61 .. S L=L+2
62 .. I L+3>IOSL D HDR Q:$G(SDABRT)=1
63 D RPTEND^SDSCRPT1
64EXIT ;
65 K SDABRT,SDANS,SDCLIN,SDEDT,SDFPTX,SDHDR,SDLIST,SDNWPV,SDOEX,SDPOV
66 K SDSCEDT,SDSCTDT,SDSCTXT,I,X,Y,QUE,POP,DFN,SDDATA
67 K ^TMP("SDSCCHK",$J),DTOUT,DUOUT
68 Q
69 ;
70FND ; Find errors with encounters
71 N SDOEDAT,SDCLIN,SDPAT,SDEC,DFN,SDCST,SDV0,SDPNAM,SDFILEOK
72 ; If this encounter has already been compiled for review, quit.
73 I $D(^SDSC(409.48,SDOE,0)) Q
74 ;
75 S SDOEDAT=$$GETOE^SDOE(SDOE) I SDOEDAT="" S SDSCTXT="No Encounter zero node" D STORE Q
76 ; If child encounter, quit
77 I $P(SDOEDAT,U,6) Q
78 S SDCLIN=$P(SDOEDAT,U,4)
79 ; Get patient. If no patient, quit.
80 S SDPAT=$P(SDOEDAT,U,2) I SDPAT="" S SDSCTXT="No Patient Pointer for this encounter" D STORE Q
81 N VADM S DFN=SDPAT D DEM^VADPT S SDPNAM=VADM(1)
82 ; Get visit file entry. If no visit, quit.
83 S SDV0=$P(SDOEDAT,U,5) I SDV0="" S SDSCTXT="No Visit Pointer for this encounter" D STORE Q
84 ; Get eligibility. If no eligibility, quit.
85 S SDEC=$P(SDOEDAT,U,13) I SDEC="" S SDSCTXT="Encounter eligibility is blank." D STORE Q
86 ; If eligibility is not service connected, quit.
87 I '$D(SDLIST(SDEC)) S SDSCTXT="Eligibility is not service connected" D STORE Q
88 ; Get clinic. If no clinic, quit.
89 I SDCLIN="" S SDSCTXT="No Clinic Pointer for this encounter" D STORE Q
90 ; Get clinic stop code. If no clinic stop code, quit.
91 S SDCST=$P(SDOEDAT,U,3) I SDCST="" S SDSCTXT="Clinic "_$P(^SC(SDCLIN,0),U,1)_" has no defined clinic stop code" D STORE Q
92 ; If clinic is non-count, quit.
93 I $$NCTCL^SDSCUTL(SDCLIN) S SDSCTXT="Clinic "_$P(^SC(SDCLIN,0),U,1)_" is non-count" D STORE Q
94 ; If encounter is non-billable for first and third party, quit.
95 I $$NBFP(),$$NBTP() S SDSCTXT="Non-billable because "_SDFPTX D STORE Q
96 ; Get and evaluate all ICD9 entries for the specified visit.
97 S SDFILEOK=$$SC^SDSCAPI(DFN,,SDOE)
98 ;no ICDs were found for this encounter SDFILEOK=""
99 I SDFILEOK="" S SDSCTXT="No Diagnoses for this encounter" D STORED Q
100 ;checks if ICD match found
101 I +SDFILEOK D Q
102 .I '$P(SDFILEOK,"^",4) S SDSCTXT="A diagnosis fully matched a rated disability condition" D STORED Q
103 .S SDSCTXT="A diagnosis partially matched a rated disability condition" D STORED
104 ; ICDs that were found as non-service connected
105 S SDSCTXT="No Diagnoses identified as service connected" D STORED
106 Q
107 ;
108HDR ; Header
109 ; Do not ask 'RETURN' before first page on CRT.
110 I $E(IOST,1,2)="C-",P N DIR S DIR(0)="E" D ^DIR I 'Y S SDABRT=1 Q
111 ; Do not print a form feed before first page on printer. Top of form is set at end of previous report.
112 I $E(IOST,1,2)="C-"!P W @IOF
113 S P=P+1,L=5
114 S SDHDR="Compile Results Report"_" - "_$S(SDANS="S":"Summary",1:"Detail")
115 U IO
116 S SDNWPV=1
117 W SDHDR,?67,"PAGE: ",P
118 W !,?5,"For Encounters Dated ",$$FMTE^XLFDT(SDSCTDT,2)," THRU ",$$FMTE^XLFDT(SDEDT,2)
119 I SDANS="S" W !,?2,"# Enc",?10,"Reason"
120 I SDANS="D" D
121 . W !!,"Note: The Detail report will ONLY list additional encounter information ",!," for the Diagnosis code related Reasons.",!
122 . W !,"Enc #",?12,"Visit #",?24,"Clinic",?42,"Encounter Date/Time",?62,"Patient Name",!,?10,"Reason"
123 W ! F I=1:1:79 W "-"
124 Q
125 ;
126STORE ; Store the encounter for later use.
127 S SDCT=SDCT+1
128 I SDOEDAT="" S ^TMP("SDSCCHK",$J,SDCT)="Encounter IEN "_SDOE_" "_SDSCTXT Q
129 I SDPAT="" S ^TMP("SDSCCHK",$J,SDCT)="Encounter IEN "_SDOE_" "_SDSCTXT Q
130 S ^TMP("SDSCCHK",$J,SDCT)=$P(^SC(SDCLIN,0),U,1)_"^"_$$FMTE^XLFDT($P(SDOEDAT,U,1),"5Z")_"^"_SDPNAM_"^"_SDSCTXT
131 S ^TMP("SDSCCHK",$J,"TOTAL",SDSCTXT)=$G(^TMP("SDSCCHK",$J,"TOTAL",SDSCTXT))+1
132 Q
133 ;
134STORED ; Store the diagnosis encounter for detail
135 N DFN,SDPNAM
136 S SDDCT=SDDCT+1
137 S DFN=SDPAT D DEM^VADPT S SDPNAM=VADM(1) D KVA^VADPT
138 S ^TMP("SDSCCHK",$J,"DX",SDDCT)=SDOE_"^"_SDV0_"^"_$P(^SC(SDCLIN,0),U,1)_"^"_$$FMTE^XLFDT($P(SDOEDAT,U,1),"5Z")_"^"_SDPNAM_"^"_SDSCTXT
139 S ^TMP("SDSCCHK",$J,"TOTAL",SDSCTXT)=$G(^TMP("SDSCCHK",$J,"TOTAL",SDSCTXT))+1
140 Q
141 ;
142NBFP() ; Is first-party non-billable based on either clinic, stop code, or patient?
143 S SDFPTX="",SDFPTX=$P($$FIRST^IBRSUTL(SDOE),U,2) I SDFPTX'="" Q 1
144 Q 0
145 ;
146NBTP() ; Is third-party non-billable based on either clinic, stop code, or patient?
147 S SDFPTX="",SDFPTX=$P($$THIRD^IBRSUTL(SDOE),U,2) I SDFPTX'="" Q 1
148 I '+$$INSUR^IBBAPI(SDPAT,SDOEDT) S SDFPTX="patient is not insured" Q 1
149 Q 0
Note: See TracBrowser for help on using the repository browser.