source: WorldVistAEHR/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGRPC.m@ 1365

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

initial load of WorldVistAEHR

File size: 5.2 KB
RevLine 
[613]1DGRPC ;ALB/MRL/PJR/PHH/EG/BAJ - CHECK CONSISTENCY OF PATIENT DATA ; 11/8/05 8:37am
2 ;;5.3;Registration;**108,121,314,301,470,489,505,451,568,585,641,653**;Aug 13, 1993;Build 2
3 ;
4 ;linetags in routines correspond to IEN of file 38.6
5 ;
6 ;variables: DGVT = 1 if VETERAN? = YES, 0 if NO
7 ; DGSC = 1 if SC? = YES, 0 if NO
8 ; DGCD = 0 node of file EC file (#8)
9 ; DGRPCOLD = old inconsistencies for pt (separated by ,s)
10 ; DGCHK = #s to check (separated by ,s)
11 ; DGLST = next # to check
12 ; DGER = inconsistencies found (separated by ,s)
13 ; DGNCK = 1 if missing key elig data...can't process further
14 ;
15 N ANYMSE,CONARR,CONCHK,CONERR,CONSPEC,LOC,I5,I6
16 N MSECHK,MSESET,MSERR,MSDATERR,RANGE,RANSET
17 D ON I $S(('$D(DFN)#2):1,'$D(^DPT(DFN,0)):1,DGER:1,1:0) G KVAR^DGRPCE:DGER
18EN S:'$D(DGEDCN)#2 DGEDCN=0 I DGEDCN W !!,"Checking data for consistency..."
19 D START:DGEDCN
20 F I=0,.13,.141,.22,.24,.3,.31,.311,.32,.321,.322,.33,.35,.36,.362,.38,.39,.52,.53,"TYPE","VET" S DGP(I)=$G(^DPT(DFN,I))
21 ;get old inconsistencies
22 S DGRPCOLD="," I $D(^DGIN(38.5,DFN)) F I=0:0 S I=$O(^DGIN(38.5,DFN,"I",I)) Q:'I S DGRPCOLD=DGRPCOLD_I_","
23 ;find consistencies to check/not check
24 ; DG*5.3*653 modified to exclude checks numbered>99 BAJ 10/25/2005
25 S DGCHK="," F I=0:0 S I=$O(^DGIN(38.6,I)) Q:'I!(I=99) I $D(^(I,0)),$S(I=2:0,I=51:0,I=9:1,I=10:1,I=13:1,I=14:1,I=22:1,I=52:1,I=53:1,'$P(^(0),"^",5):1,1:0),I'=99 S DGCHK=DGCHK_I_","
26 S DGVT=$S(DGP("VET")="Y":1,1:0),DGSC=$S($P(DGP(.3),"^",1)="Y":1,1:0),DGCD=$S($D(^DIC(8,+DGP(.36),0)):^(0),1:""),(DGCT,DGER,DGNCK)="" I 'DGVT,$D(^DG(391,+DGP("TYPE"),0)),$P(^(0),"^",2) S DGVT=2
27 S DGLST=+$P(DGCHK,",",2) G @DGLST
281 S DGD=$P(DGP(0),"^",1) I DGD?1L.E!(DGD?.E1L.E)!(DGD="") S X=1 D COMB,NEXT I +DGLST'=2 G @DGLST
29 S I1=0 F I=1:1:$L(DGD) Q:I1 S J=$E(DGD,I) I J?1NP,$A(J)>32,J'=",",J'="-",J'=".",J'="'" S I1=1
30 I I1 S X=1 D COMB
31 D NEXT I +DGLST'=2 G @DGLST
322 S I1=0 F I=0:0 S I=$O(^DPT(DFN,.01,I)) Q:'I!(I1) I $P(^(I,0),"^",1)'?1A.E S I1=1
33 I I1 S X=2 D COMB
34 D NEXT I +DGLST>7!('DGLST) G @DGLST
353 ;
364 ;
375 ;
386 ;
397 F I=2,3,5,8,9 I $P(DGP(0),"^",I)="" S X=$S(I=2:3,I=3:4,I=5:5,I=8:6,1:7) D COMB:DGCHK[(","_X_",")
40 S DGLST=7 G:DGCHK'[",7," FIND^DGRPC2 D NEXT I +DGLST'=8 G @DGLST
418 S I1=0,DGD=$G(^DPT(DFN,.11)) F I=1,4,5,6,7 Q:I1 I $P(DGD,"^",I)="" S I1=1
42 I I1 S X=8 D COMB
43 D NEXT I +DGLST'=9 G @DGLST
449 I DGP("VET")="" S X=9,DGNCK=1 D COMB
45 D NEXT I +DGLST'=10 G @DGLST
4610 I $P(DGP(.3),"^",1)="" S X=10,DGNCK=1 D COMB
47 D NEXT I +DGLST'=11 G @DGLST
4811 I 'DGVT,DGSC S X=11 D COMB
49 D NEXT I +DGLST'=12 G @DGLST
5012 I DGSC,DGVT,$P(DGP(.3),"^",2)="" S X=12 D COMB
51 D NEXT I +DGLST'=13 G @DGLST
5213 I '$D(^DIC(21,+$P(DGP(.32),"^",3),0)) S X=13,DGNCK=1 D COMB
53 D NEXT I +DGLST'=14 G @DGLST
5414 I $P(DGCD,"^",1)="" S X=14,DGNCK=1 D COMB
55 ;
56 ;Check Patient Eligibilities multiple if Primary Elig Code defined
57 I DGP(.36),'$D(^DPT(DFN,"E",+DGP(.36),0)) D PRI^VADPT60 ;5.3*301
58 ;
59 D NEXT I +DGLST'=15 G FIND^DGRPC2:+DGLST=35,@DGLST
6015 I $P($G(^DPT(DFN,.15)),"^",2)]"",$P(DGP(.3),"^",7)="" S X=15 D COMB
61 D NEXT I +DGLST'=16 G FIND^DGRPC2:+DGLST=35,@DGLST
6216 D H^DGUTL I +DGP(.35)>DGTIME S X=16 D COMB
63 D NEXT I +DGLST'=17 G FIND^DGRPC2:+DGLST=35,@DGLST
6417 K DGDATE,DGTIME
65 N SDARRAY,SDCLIEN,SDDATE
66 S I1=0,DGD=DT
67 S SDARRAY("FLDS")=3
68 S SDARRAY(4)=DFN
69 I +DGP(.35),$$SDAPI^SDAMA301(.SDARRAY) D
70 .;if there is data hanging from the 101 subscript,
71 .;then this is a valid appointment
72 .;otherwise it is an error eg 01/21/2005
73 .I $D(^TMP($J,"SDAMA301",101))=1 Q
74 .S SDCLIEN=0
75 .F S SDCLIEN=$O(^TMP($J,"SDAMA301",DFN,SDCLIEN)) Q:'SDCLIEN!(I1) D
76 ..S SDDATE=0
77 ..F S SDDATE=$O(^TMP($J,"SDAMA301",DFN,SDCLIEN,SDDATE)) Q:'SDDATE!(I1) D
78 ...S X=$P($P(^TMP($J,"SDAMA301",DFN,SDCLIEN,SDDATE),"^",3),";")
79 ...I X=""!(X="I") S I1=1
80 K ^TMP($J,"SDAMA301")
81 I I1 S X=17 D COMB
82 ;
83END ; end of routine...find next check to execute (or goto end)
84 S:DGNCK DGLST=35 G:DGCHK'[",35,"&(DGNCK) FIND^DGRPC2 D NEXT G @DGLST
85 ;
86COMB ;record inconsistency
87 S DGCT=DGCT+1,DGER=DGER_X_",",DGLST=X Q
88 Q
89 ;
90NEXT ; find the next consistency check to check (goto end if can't process further)
91 S I=$F(DGCHK,(","_DGLST_",")),DGLST=+$E(DGCHK,I,999) I +DGLST,DGLST<18 Q
92 I +DGLST,DGNCK,+DGLST>17,+DGLST<36 S DGLST=35 Q:DGCHK'[",35," G NEXT
93 S:'+DGLST DGLST="END^DGRPC3" I +DGLST S DGLST=DGLST_"^DGRPC"_$S(+DGLST<43:1,+DGLST<79:2,1:3)
94 Q
95 ;
96PAT ;check inconsistencies for a selected patient
97 D ON G KVAR^DGRPCE:DGER W !! S DIC="^DPT(",DIC(0)="AEQMZ",DIC("A")="Check consistency for which PATIENT: " D ^DIC K DIC G KVAR^DGRPCE:Y'>0 S DFN=+Y,DGEDCN=1 D DGRPC G PAT
98 ;
99START ;record start time for checker
100 S DGSTART=$H Q
101 ;
102TIME ;record end time for checker
103 Q:'$D(DGSTART)#2 S DGEND=$H,X=$P(DGSTART,",",2),X1=$P(DGEND,",",2)
104 I +DGSTART=+DGEND S DGTIME=X1-X
105 E S DGTIME=(5184000-X)+X1
106 I $S(DGCT:0,DGCON=1:1,1:0) G TIMEQ
107 W !!,"===> ",$S(DGCT:DGCT,DGCON<2:"No",1:"All")," inconsistenc",$S(DGCT=1:"y",1:"ies")," ",$S('DGCON:"found",DGCON=1:"filed",1:"removed")," in ",DGTIME," second",$S(DGTIME=1:"",1:"s"),"..." H 1
108TIMEQ K DGSTART,DGEND,DGTIME,X,X1,DGCON Q
109 ;
110ON ;check if checker is on
111 S DGER=0 I $S('$D(^DG(43,1,0)):1,'$P(^(0),"^",37):1,1:0) S DGER=1
112 S:'$D(DGEDCN) DGEDCN=0 W:DGER !!,"CONSISTENCY CHECKER TURNED OFF!!",$C(7) Q
Note: See TracBrowser for help on using the repository browser.