source: FOIAVistA/trunk/r/SCHEDULING-SD-SC/SDSCAPI.m@ 731

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

initial load of FOIAVistA 6/30/08 version

File size: 5.7 KB
Line 
1SDSCAPI ;ALB/JDS/JAM/RBS - Automated Service Connection Designation Review ; 4/16/07 10:39am
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 ; Routine should be called at specified tags only.
7 Q
8SC(SDFN,SDXS,SDENC,SDVST) ; Determine if SC based on DXS codes
9 ; Input:
10 ; SDFN = Patient ien, file #2 [Required, if SDENC or SDVST undefined]
11 ; SDXS = Diagnosis code array [Optional, if SDENC defined]
12 ; SDENC = Encounter ien, file #409.68 [Optional]
13 ; SDVST = Visit ien, field #9000010 [Optional]
14 ;
15 ; Output:
16 ; $$SDFILEOK = (4 piece data string ^ delimited)
17 ; (SC flag^SC description^VBA/ICD9 match^ASCD Review)
18 ; SC flag: 1-SC, 0-NSC, ""-could not be determined
19 ; SC description: SC or NSC
20 ; VBA/ICD9 match: 1-yes, 0-no
21 ; ASCD: 1-send to review, 0-don't send to review
22 ;
23 N SDOE0,SDFILEOK,SDOEDAT,SDKILL
24 S SDENC=+$G(SDENC),SDFILEOK=""
25 I 'SDENC S SDENC=+$O(^SCE("AVSIT",+$G(SDVST),0))
26 I SDENC S SDOE0=$$GETOE^SDOE(SDENC)
27 S SDOEDAT=$S(SDENC:+SDOE0,+$G(SDVST):+$G(^AUPNVSIT(SDVST,0)),1:DT)
28 ; Get patient. If no patient, quit.
29 I '$G(SDFN) S SDFN=$S(SDENC:$P(SDOE0,U,2),+$G(SDVST):$P($G(^AUPNVSIT(SDVST,0)),U,5),1:"")
30 I '$G(SDFN) Q SDFILEOK
31 ; diagnosis codes present
32 I $O(SDXS(0)) D OPT3 Q SDFILEOK
33 I 'SDENC Q SDFILEOK
34 D OPT2 I $D(SDKILL) K SDXS
35 Q SDFILEOK
36 ;
37OPT2 ; enter with no DXS defined; get ICD9 for visit/encounter
38 N SCDXS
39 K SDXS
40 I '+$G(SDENC) Q
41 D GETDX^SDOE(SDENC,"SCDXS")
42 S SDXS=0 F S SDXS=$O(SCDXS(SDXS)) Q:'SDXS S SDXS(+SCDXS(SDXS))=""
43 I $O(SDXS(0))="" Q
44 S SDKILL=1
45OPT3 ; enter with DXS defined
46 N I,SDRD,SDRDIEN,SD31,ICDMCH,SDMCH,FL,SDARR
47 ; Patient has no rated disabilities
48 D RDIS^DGRPDB(SDFN,.SDARR)
49 I '$D(SDARR) S SDFILEOK="1^SC^0^1" Q
50 ; Patient has rated disabilities
51 S (SDRD,FL)=0
52 F S SDRD=$O(SDARR(SDRD)) Q:'SDRD D
53 .S SDRDIEN=$P(SDARR(SDRD),U) Q:SDRDIEN=""
54 .; Get code from eligibility file.
55 .S I=0,SD31=$G(^DIC(31,SDRDIEN,0)) Q:SD31=""
56 .; Get partial or true match on ICD9 code
57 .F S I=$O(SDXS(I)) Q:'I D
58 ..S SDMCH=$$MATCH(SDRDIEN,I,SDOEDAT,SDENC),ICDMCH(SDMCH)=""
59 ; locate entry in the following priority order -
60 F I="1^SC^1^0","1^SC^1^1","0^NSC^0^1","1^SC^0^1" I $D(ICDMCH(I)) S SDFILEOK=I Q
61 Q
62 ;
63STORE ; Save the information for this encounter.
64 N SDSC,SDIEN,SDERR
65 S SDIEN(1)=SDENC
66 S SDSC(409.48,"+1,",.01)=SDENC
67 S SDSC(409.48,"+1,",.04)=DT
68 S SDSC(409.48,"+1,",.07)=+SDOE0
69 S SDSC(409.48,"+1,",.08)=SDPRV
70 S SDSC(409.48,"+1,",.09)=$P(SDFILEOK,U,3)
71 S SDSC(409.48,"+1,",.11)=$P(SDOE0,U,2)
72 S SDSC(409.48,"+1,",.12)=$P(SDOE0,U,11)
73 S SDSC(409.48,"+1,",.05)="N"
74 S SDSC(409.48,"+1,",.13)=SDOSC
75 D UPDATE^DIE("","SDSC","SDIEN","SDERR")
76 I $D(SDERR) S ERR=1
77 Q
78ST(SDENC,SDXS) ;Reviews the diagnosis codes for an encounter and then
79 ;determines whether or not to file, or delete the record from the
80 ;ASCD file, SDSC SERVICE CONNECTED CHANGES (#409.48).
81 ;
82 ; Input: SDENC = Encounter ien, file (#409.68) [Required]
83 ; SDXS = Diagnosis code array [Optional]
84 ;
85 ; Output: $$ST value
86 ; 0 = not filed for additional review
87 ; 1 = filed for additional review
88 ; 2 = deleted from (#409.48) file
89 ;
90 N SDLIST,SDOE0,SDEL,SDOEDAT,SDPRV,SDFN,SDFILEOK,ERR,SCVAL,SDCLIN,SDSTP
91 N SDPAT,SDCST,SDKILL,SDV0,SDOSC,SDOEDT
92 I '$G(SDENC) Q 0
93 S SDOE0=$$GETOE^SDOE(SDENC) I SDOE0="" Q 0
94 ;quit if child encounter
95 I $P(SDOE0,U,6) Q 0
96 S SDV0=$P(SDOE0,U,5),SDOSC=$$GET1^DIQ(9000010,SDV0_",",80001,"I")
97 S SDPRV=$$PRIMVPRV^PXUTL1(SDV0),SDEL=$P(SDOE0,U,13),SCVAL=0
98 S (SDOEDAT,SDOEDT)=+SDOE0,(SDFILEOK,ERR)=0,SDCLIN=$P(SDOE0,U,4)
99 S SDCST=$P(SDOE0,U,3),(SDFN,SDPAT)=$P(SDOE0,U,2)
100 ;no patient
101 I 'SDPAT Q 0
102 ;no clinic
103 I 'SDCLIN Q 0
104 ;no stop code
105 I 'SDCST Q 0
106 ;no visit SC value
107 I SDOSC="" Q 0
108 ;not checked-out
109 I $P(SDOE0,U,12)'=2 Q 0
110 ;check for non-count
111 I $$NCTCL^SDSCUTL(SDCLIN) Q 0
112 ;no eligibility
113 I SDEL="" Q 0
114 ;If eligibility is not service connected, quit.
115 D ELIG I '$D(SDLIST(SDEL)) Q 0
116 ;if non-billable for first and third party, quit
117 I $$NBFP^SDSCUTL(SDENC),$$NBTP^SDSCUTL(SDENC) Q 0
118 D
119 .I $O(SDXS(0)) D OPT3 Q
120 .D OPT2 I $D(SDKILL) K SDXS
121 I SDFILEOK="" Q 0
122 ;File encounter in ASCD if it does not exist
123 I $P(SDFILEOK,U,4),'$D(^SDSC(409.48,SDENC,0)) D STORE Q 'ERR
124 I '$P(SDFILEOK,U,4) D Q SCVAL
125 .;Set for review if Visit SC is different from ASCD
126 .I SDOSC'=$P(SDFILEOK,U) Q:$D(^SDSC(409.48,SDENC,0)) D STORE S SCVAL='ERR Q
127 .;Remove encounter from ASCD if no review needed
128 .N DA,DIK
129 .I $D(^SDSC(409.48,SDENC,0)) S DA=SDENC,DIK="^SDSC(409.48," D ^DIK S SCVAL=2
130 Q 0
131ELIG ;Compile list of service connected eligibility codes
132 N I,J
133 F I=1,3 S J=0 F S J=$O(^DIC(8,"D",I,J)) Q:'J S SDLIST(J)=""
134 Q
135MATCH(SDIEN31,SDXIEN,SDATE,SDENC) ;ICD9 matching code
136 ; - api should be changed to lexicon in next version
137 ; Input:
138 ; SDIEN31 = File #31 [Required]
139 ; SDXIEN = Diagnosis code ien, file #80 [Required]
140 ; SDATE = Encounter date, [Optional] [Required for lexicon]
141 ; SDENC = Encounter ien, file #409.68 [Required]
142 ;
143 ; Output:
144 ; $$SDFILEOK = (4 piece data string ^ delimited)
145 ; (SC flag^SC description^VBA/ICD9 match^ASCD Review)
146 ; SC flag: 1-SC, 0-NSC, ""-could not be determined
147 ; SC description: SC or NSC
148 ; VBA/ICD9 match: 1-yes, 0-no
149 ; ASCD: 1-send to review, 0-don't send to review
150 ;
151 N SDMCH,SDXIEN1,SDXLVL,SDPDX
152 I '$D(^DIC(31,SDIEN31,"ICD")) Q "1^SC^0^1"
153 I '$D(^DIC(31,SDIEN31,"ICD","B",SDXIEN)) Q "0^NSC^0^1"
154 S SDXIEN1=$O(^DIC(31,SDIEN31,"ICD","B",SDXIEN,0))
155 S SDXLVL=$G(^DIC(31,SDIEN31,"ICD",+SDXIEN1,0)),SDMCH=+$P(SDXLVL,U,2)
156 I ('SDXIEN1)!(SDXLVL="") Q "0^NSC^0^1"
157 D GETPDX^SDOERPC(.SDPDX,SDENC)
158 Q $S(SDMCH&(SDPDX=SDXIEN):"1^SC^1^0",1:"1^SC^1^1")
Note: See TracBrowser for help on using the repository browser.