Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: DGRPC

DGRPC.m

Go to the documentation of this file.
DGRPC ;ALB/MRL,PJR,PHH,EG,BAJ,TDM,LBD,RN,ARF,JDB,JDB - CHECK CONSISTENCY OF PATIENT DATA ;6/29/11 3:50pm
 ;;5.3;Registration;**108,121,314,301,470,489,505,451,568,585,641,653,688,754,797,867,903,952,1027,1045,1081,1098,1111**;Aug 13, 1993;Build 18
 ;Per VHA Directive 6402, this routine should not be modified.
 ;
 ; 315 added to OVER99 local variable by patch DG*5.3*903 which was submitted to OSEHRA
 ; on 04/02/2015 by HP. This update was authored by James Harris 2014-2015 
 ;
 ;line tags in routines correspond to IEN of file 38.6
 ;
 ;variables:  DGVT = 1 if VETERAN? = YES, 0 if NO
 ;    DGSC = 1 if SC? = YES, 0 if NO
 ;    DGCD = 0 node of file EC file (#8)
 ;        DGRPCOLD = old inconsistencies for pt (separated by ,s)
 ;   DGCHK = #s to check (separated by ,s)
 ;   DGLST = next # to check
 ;    DGER = inconsistencies found (separated by ,s)
 ;   DGNCK = 1 if missing key elig data...can't process further
 ;
 N ANYMSE,CONARR,CONCHK,CONERR,CONSPEC,LOC,I5,I6,DGPMSE
 N MSECHK,MSESET,MSERR,MSDATERR,RANGE,RANSET,OVER99
 D ON I $S(('$D(DFN)#2):1,'$D(^DPT(DFN,0)):1,DGER:1,1:0) G KVAR^DGRPCE:DGER
EN ; DG*5.3*1027 Screen 7 changes - call new consistency check
 D VETINDCHG
 S:'$D(DGEDCN)#2 DGEDCN=0 I DGEDCN W !!,"Checking data for consistency..."
 D START:DGEDCN
 F I=0,.13,.141,.121,.122,.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))
 ;Get MSEs from MSE sub-file #2.3216 (DG*5.3*797)
 I '$D(^DPT(DFN,.3216)) D MOVMSE^DGMSEUTL(DFN)
 D GETMSE^DGMSEUTL(DFN,.DGPMSE)
 ;get old inconsistencies
 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_","
 ;find consistencies to check/not check
 ; DG*5.3*653 modified to exclude checks numbered>99  BAJ  10/25/2005
 ; DG*5.3*1081 modified to exclude 15, INEL REASON UNSPECIFIED, ineligibility consistency check
 ;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,I=89:1,'$P(^(0),"^",5):1,1:0),I'=99 S DGCHK=DGCHK_I_","
 ; DG*5.3*1111 modified to remove "always true" conditions for 52, INSURANCE PROMPT UNANSWERED and 53, EMPLOYMENT STATUS UNANSWERED which will both now obey CHECK/DON'T CHECK, Field (#5) 
 ;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,I=89:1,'$P(^(0),"^",5):1,1:0),I'=99,I'=15 S DGCHK=DGCHK_I_","
 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=89:1,'$P(^(0),"^",5):1,1:0),I'=99,I'=15 S DGCHK=DGCHK_I_","
 ; DG*5.3*1098 removed 406: CLAIM FOLDER NUMBER INVALID from consistency check OVER99 variable string since the rule was removed from INCONSISTENT DATA ELEMENT File (#38.6).
 S OVER99=",301,303,304,306,307,308,313,314,315,402,403,407,501,502,503,504,505,506,507,516,517,"
 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
 S DGLST=+$P(DGCHK,",",2) G @DGLST
1        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
 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
 I I1 S X=1 D COMB
 D NEXT I +DGLST'=2 G @DGLST
2        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
 I I1 S X=2 D COMB
 D NEXT I +DGLST>7!('DGLST) G @DGLST
3        ;
4        ;
5        ;
6        ;
7        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_",")
 S DGLST=7 G:DGCHK'[",7," FIND^DGRPC2 D NEXT I +DGLST'=8 G @DGLST
8        S I1=0,DGD=$G(^DPT(DFN,.11)) I '$P(DGD,"^",10) S I1=1,X=8 D COMB,NEXT G @DGLST
 I '$D(^HL(779.004,$P(DGD,"^",10))) S I1=1,X=8 D COMB,NEXT G @DGLST
 N STR8 S STR8="1,4,5,6,7" I $$FORIEN^DGADDUTL($P(DGD,"^",10)) S STR8="1,4"
 F T=1:1:$L(STR8,",") S I=$P(STR8,",",T) Q:I1  I $P(DGD,"^",I)="" S I1=1
 I I1 S X=8 D COMB
 D NEXT I +DGLST'=9 G @DGLST
9        I DGP("VET")="" S X=9,DGNCK=1 D COMB
 D NEXT I +DGLST'=10 G @DGLST
10       I $P(DGP(.3),"^",1)="" S X=10,DGNCK=1 D COMB
 D NEXT I +DGLST'=11 G @DGLST
11       I 'DGVT,DGSC S X=11 D COMB
 D NEXT I +DGLST'=12 G @DGLST
12       I DGSC,DGVT,$P(DGP(.3),"^",2)="" S X=12 D COMB
 D NEXT I +DGLST'=13 G @DGLST
13       I '$D(^DIC(21,+$P(DGP(.32),"^",3),0)) S X=13,DGNCK=1 D COMB
 D NEXT I +DGLST'=14 G @DGLST
14       I $P(DGCD,"^",1)="" S X=14,DGNCK=1 D COMB
 ;
 ;Check Patient Eligibilities multiple if Primary Elig Code defined
 I DGP(.36),'$D(^DPT(DFN,"E",+DGP(.36),0)) D PRI^VADPT60 ;5.3*301
 ;
 D NEXT I +DGLST'=15 G FIND^DGRPC2:+DGLST=35,@DGLST
15       I $P($G(^DPT(DFN,.15)),"^",2)]"",$P(DGP(.3),"^",7)="" S X=15 D COMB
 D NEXT I +DGLST'=16 G FIND^DGRPC2:+DGLST=35,@DGLST
16       D H^DGUTL I +DGP(.35)>DGTIME S X=16 D COMB
 D NEXT I +DGLST'=17 G FIND^DGRPC2:+DGLST=35,@DGLST
17       K DGDATE,DGTIME
 N SDARRAY,SDCLIEN,SDDATE
 S I1=0,DGD=DT
 S SDARRAY("FLDS")=3
 S SDARRAY(4)=DFN
 I +DGP(.35),$$SDAPI^SDAMA301(.SDARRAY) D
 .;if there is data hanging from the 101 subscript,
 .;then this is a valid appointment
 .;otherwise it is an error eg 01/21/2005
 .I $D(^TMP($J,"SDAMA301",101))=1 Q
 .S SDCLIEN=0
 .F  S SDCLIEN=$O(^TMP($J,"SDAMA301",DFN,SDCLIEN)) Q:'SDCLIEN!(I1)  D
 ..S SDDATE=0
 ..F  S SDDATE=$O(^TMP($J,"SDAMA301",DFN,SDCLIEN,SDDATE)) Q:'SDDATE!(I1)  D
 ...S X=$P($P(^TMP($J,"SDAMA301",DFN,SDCLIEN,SDDATE),"^",3),";")
 ...I X=""!(X="I") S I1=1
 K ^TMP($J,"SDAMA301")
 I I1 S X=17 D COMB
 ;
END      ; end of routine...find next check to execute (or goto end)
 S:DGNCK DGLST=35 G:DGCHK'[",35,"&(DGNCK) FIND^DGRPC2 D NEXT G @DGLST
 ;
COMB     ;record inconsistency
 S DGCT=DGCT+1,DGER=DGER_X_",",DGLST=X Q
 Q
 ;
NEXT     ; find the next consistency check to check (goto end if can't process further)
 S I=$F(DGCHK,(","_DGLST_",")),DGLST=+$E(DGCHK,I,999) I +DGLST,DGLST<18 Q
 I +DGLST,DGNCK,+DGLST>17,+DGLST<36 S DGLST=35 Q:DGCHK'[",35,"  G NEXT
 S:'+DGLST DGLST="END^DGRPC3" I +DGLST S DGLST=DGLST_"^DGRPC"_$S(+DGLST<43:1,+DGLST<79:2,1:3)
 Q
 ;
PAT      ;check inconsistencies for a selected patient
 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
 ;
START    ;record start time for checker
 S DGSTART=$H Q
 ;
TIME     ;record end time for checker
 Q:'$D(DGSTART)#2  S DGEND=$H,X=$P(DGSTART,",",2),X1=$P(DGEND,",",2)
 I +DGSTART=+DGEND S DGTIME=X1-X
 E  S DGTIME=(5184000-X)+X1
 I $S(DGCT:0,DGCON=1:1,1:0) G TIMEQ
 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
TIMEQ    K DGSTART,DGEND,DGTIME,X,X1,DGCON Q
 ;
ON       ;check if checker is on
 S DGER=0 I $S('$D(^DG(43,1,0)):1,'$P(^(0),"^",37):1,1:0) S DGER=1
 S:'$D(DGEDCN) DGEDCN=0 W:DGER !!,"CONSISTENCY CHECKER TURNED OFF!!",$C(7) Q
VETINDCHG ; DG*5.3*1027 Vet indicator change
 ; If DO YOU WISH TO ENROLL field in PATIENT (#2) file is YES AND
 ; A record for the patient does not exist in the Patient Enrollment file AND
 ; The patient is unknown to ES Then Incomplete Enrollment.
 ; Supported DBIA #2701:   The supported DBIA is used to access MPI
 ;                         APIs to retrieve ICN, determine if ICN
 ;                         is local and if site is LST. 
 ; Supported ICRs
 ; #3356  -  XQY0          ; Kernel Variable
 ;
 ; Quit if not in specific menu options or if there is a current enrollment
 I ($P($G(XQY0),"^",1)'="DG REGISTER PATIENT"),($P($G(XQY0),"^",1)'="DG LOAD PATIENT DATA"),($P($G(XQY0),"^",1)'="DG ELIGIBILITY VERIFICATION"),($P($G(XQY0),"^",1)'="DGPRE PRE-REGISTER OPTION") QUIT
 I $$FINDCUR^DGENA(DFN) QUIT
 N DGKEY,DGREQNAME,DGENSTAT,DGWSHTOEN,DGRESP,DGVET,DGOVET,DTOUT,DUOUT
 S DGREQNAME="VistAData"
 S DGRESP=0
 S DGKEY=$$GETICN^MPIF001(DFN),DGVET=$$VET^DGENPTA(DFN),DGOVET=$G(^TMP($J,"DGOLDVET",DFN))
 I $P(DGKEY,"^",1)'=-1 S DGRESP=$$EN^DGREGEEWS(DGKEY,DGREQNAME,.DGENSTAT,.DGWSHTOEN)
 I +DGRESP=0,'$G(DGDONE),$P($G(XQY0),"^",1)'="DG REGISTER PATIENT" D
 . W !!,"This patient has not had the Enrollment Request Process completed and this must be done through Register A Patient."
 . S DGDONE=1
 . N DIR,X,Y
 . S DIR(0)="E"
 . D ^DIR K DIR
 I DGOVET'="",$P($G(XQY0),"^",1)="DG REGISTER PATIENT",+DGRESP=0,DGVET'=DGOVET,'$G(DGDONE2) D
 . I DGVET=1 D
 . . W !,"Veteran indicator has been changed. ""Do You Wish To Enroll"" is currently set to NO."
 . . W !!,"Use the Enrollment System if the Veteran wishes to enroll."
 . . N DIR,X,Y
 . . S DIR(0)="E"
 . . D ^DIR
 . I DGVET=0 D
 . . N DGINELIG,DGENPTA
 . . I $$GET^DGENPTA(DFN,.DGENPTA) S DGINELIG=$G(DGENPTA("INELDATE"))
 . . I ($G(DGENRYN)=1),DGINELIG="" D REGORSN     ;self-reported reason prompt
 . . I DGINELIG="" D APPTCHG     ; DG*5.3*1045 - If there is no Ineligible Date, set the Appointment request fields to null
 . S DGDONE2=1
 Q
APPTCHG   ; DG*5.3*1027 Vet indicator change from Yes to No
 ;Remove the Appointment Request information
 N DGIENS,DGRSLT,DGFDA
 S DGRSLT=""
 S DGIENS=DFN_","
 ;APPOINTMENT REQUEST ON 1010EZ 1010.15;9
 S DGFDA(2,DGIENS,1010.159)=DGRSLT ;
 ;APPOINTMENT REQUEST DATE 1010.15;11
 S DGFDA(2,DGIENS,1010.1511)=DGRSLT
 ;ORIGINAL APPOINTMENT REQUEST 1010.15;12
 S DGFDA(2,DGIENS,1010.1512)=DGRSLT
 ;ORIGINAL APPT REQUEST DATE 1010.15;13
 S DGFDA(2,DGIENS,1010.1513)=DGRSLT
 ;ORIG APPT REQUEST CHG DT/TM 1010.15;14
 S DGFDA(2,DGIENS,1010.1514)=DGRSLT
 ;APPT REQUEST 1010EZ CHG DT/TM 1010.15;15
 S DGFDA(2,DGIENS,1010.1515)=DGRSLT
 D FILE^DIE("","DGFDA")
 Q
REGORSN ; DG*5.3*1027 Display prompt for REGISTRATION ONLY REASON
 N DGNOW,DGENRODT,DGENSRCE,DGENRRSN,DIR,X,Y,DUOUT,DTOUT
 F  D  Q:DGENRRSN
 . K DIR
 . S DIR("A")="SELF-REPORTED REGISTRATION ONLY REASON: "
 . S DIR(0)="27.11,.15,AO"
 . D ^DIR Q:$D(DTOUT)!($D(DUOUT))
 . S DGENRRSN=+Y
 . I 'DGENRRSN W !,"This is a required field.",!
 I DGENRRSN S DGNOW=$$NOW^XLFDT(),DGENRODT=DGNOW,DGENSRCE=1 D REGONLY^DGEN(DFN)
 S DGENRYN=0
 Q