APCDFDEC ; IHS/CMI/LAB - FIX DEPENDENT ENTRY COUNT ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
S U="^"
S X="LOW",X1="FIRST" W !,"ENTER A ""^"" TO HALT"
GETHILO ; Get the HI and LO DFN's
W !,"Enter the ",X," DFN: ",X1,"//" R @X G:@X="^" XIT I @X'?1N.N&(@X]"") W !,"Enter the ",X," DFN, must be a number greater than 0." G GETHILO
I X="LOW" S X="HIGH",X1="LAST" G GETHILO
PROCESS ;
W !,"<PLEASE WAIT>" S (APCDVT,APCDVCNT,APCDCDEC,APCDNDEC,APCDNC)=0 S:LOW="" LOW=1 S APCDDFN=LOW-1
F APCDL=0:0 S APCDDFN=$O(^AUPNVSIT(APCDDFN)) Q:APCDDFN'=+APCDDFN!(HIGH]""&(APCDDFN>HIGH)) I $D(^AUPNVSIT(APCDDFN,0)) S APCDVCNT=APCDVCNT+1,APCDVT=APCDVT+1 W:APCDVCNT>50 "." S:APCDVCNT>50 APCDVCNT=0 D PROC2
D TOTALS
G XIT
PROC2 ;
Q:$P(^AUPNVSIT(APCDDFN,0),U,7)="H"
S APCDCDEC=$P(^AUPNVSIT(APCDDFN,0),U,9) D CALDEC
I +APCDNDEC'=+APCDCDEC W !,APCDDFN," OLD Dependent Entry Count=",APCDCDEC," NEW Dependent Entry Count=",APCDNDEC," " S APCDNC=APCDNC+1,$P(^AUPNVSIT(APCDDFN,0),U,9)=APCDNDEC
I APCDNDEC>0,$P(^AUPNVSIT(APCDDFN,0),U,11)=1 S $P(^(0),U,11)="" S DA=APCDDFN,DIK="^AUPNVSIT(" D IX^DIK K DIK,DA,DR W "RE-XREF"," ",APCDDFN
I APCDNDEC=0,'$P(^AUPNVSIT(APCDDFN,0),U,11) S AUPNVSIT=APCDDFN D DEL^AUPNVSIT W !,"DELETED: ",APCDDFN K AUPNVSIT
Q
CALDEC ;
S APCDNDEC=0
S APCDVFLE=9000010 F APCDFL=0:0 S APCDVFLE=$O(^DIC(APCDVFLE)) Q:APCDVFLE>9000010.99!(APCDVFLE'=+APCDVFLE) D CALDEC2
Q
CALDEC2 ;
S APCDVDG=^DIC(APCDVFLE,0,"GL"),APCDVIGR=APCDVDG_"""AD"",APCDDFN,APCDEDFN)"
S APCDEDFN="" F APCDEL=1:1 S APCDEDFN=$O(@APCDVIGR) Q:APCDEDFN'=+APCDEDFN S APCDNDEC=APCDNDEC+1
Q
TOTALS ;
W !!,"Total Visits Checked: ",APCDVT
W !,"Total Number Dependent Entry Counts Changed: ",APCDNC
Q
XIT K APCDDFN,APCDCDEC,APCDERR,APCDFILE,APCDNC,APCDNDEC,APCDVCNT,APCDVT,HIGH,LOW,X1,APCDVIGR,APCDVDG,APCDEDFN,APCDEL,APCDVL,APCDVFLE
Q
;
DOC ; This routine checks the dependent entry count of the VISIT file for
; accuracy. If it is not correct it is replaced with a correct count
; The count is determined by scanning each of the VISIT related
; files for entries that point to that VISIT. A count is incremented
; each time a "hit" is made.
; The user can enter a LO and HIGH DFN or hit return to default to
; first and last.
APCDFDEC ; IHS/CMI/LAB - FIX DEPENDENT ENTRY COUNT ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 SET U="^"
+3 SET X="LOW"
SET X1="FIRST"
WRITE !,"ENTER A ""^"" TO HALT"
GETHILO ; Get the HI and LO DFN's
+1 WRITE !,"Enter the ",X," DFN: ",X1,"//"
READ @X
IF @X="^"
GOTO XIT
IF @X'?1N.N&(@X]"")
WRITE !,"Enter the ",X," DFN, must be a number greater than 0."
GOTO GETHILO
+2 IF X="LOW"
SET X="HIGH"
SET X1="LAST"
GOTO GETHILO
PROCESS ;
+1 WRITE !,"<PLEASE WAIT>"
SET (APCDVT,APCDVCNT,APCDCDEC,APCDNDEC,APCDNC)=0
IF LOW=""
SET LOW=1
SET APCDDFN=LOW-1
+2 FOR APCDL=0:0
SET APCDDFN=$ORDER(^AUPNVSIT(APCDDFN))
IF APCDDFN'=+APCDDFN!(HIGH]""&(APCDDFN>HIGH))
QUIT
IF $DATA(^AUPNVSIT(APCDDFN,0))
SET APCDVCNT=APCDVCNT+1
SET APCDVT=APCDVT+1
IF APCDVCNT>50
WRITE "."
IF APCDVCNT>50
SET APCDVCNT=0
DO PROC2
+3 DO TOTALS
+4 GOTO XIT
PROC2 ;
+1 IF $PIECE(^AUPNVSIT(APCDDFN,0),U,7)="H"
QUIT
+2 SET APCDCDEC=$PIECE(^AUPNVSIT(APCDDFN,0),U,9)
DO CALDEC
+3 IF +APCDNDEC'=+APCDCDEC
WRITE !,APCDDFN," OLD Dependent Entry Count=",APCDCDEC," NEW Dependent Entry Count=",APCDNDEC," "
SET APCDNC=APCDNC+1
SET $PIECE(^AUPNVSIT(APCDDFN,0),U,9)=APCDNDEC
+4 IF APCDNDEC>0
IF $PIECE(^AUPNVSIT(APCDDFN,0),U,11)=1
SET $PIECE(^(0),U,11)=""
SET DA=APCDDFN
SET DIK="^AUPNVSIT("
DO IX^DIK
KILL DIK,DA,DR
WRITE "RE-XREF"," ",APCDDFN
+5 IF APCDNDEC=0
IF '$PIECE(^AUPNVSIT(APCDDFN,0),U,11)
SET AUPNVSIT=APCDDFN
DO DEL^AUPNVSIT
WRITE !,"DELETED: ",APCDDFN
KILL AUPNVSIT
+6 QUIT
CALDEC ;
+1 SET APCDNDEC=0
+2 SET APCDVFLE=9000010
FOR APCDFL=0:0
SET APCDVFLE=$ORDER(^DIC(APCDVFLE))
IF APCDVFLE>9000010.99!(APCDVFLE'=+APCDVFLE)
QUIT
DO CALDEC2
+3 QUIT
CALDEC2 ;
+1 SET APCDVDG=^DIC(APCDVFLE,0,"GL")
SET APCDVIGR=APCDVDG_"""AD"",APCDDFN,APCDEDFN)"
+2 SET APCDEDFN=""
FOR APCDEL=1:1
SET APCDEDFN=$ORDER(@APCDVIGR)
IF APCDEDFN'=+APCDEDFN
QUIT
SET APCDNDEC=APCDNDEC+1
+3 QUIT
TOTALS ;
+1 WRITE !!,"Total Visits Checked: ",APCDVT
+2 WRITE !,"Total Number Dependent Entry Counts Changed: ",APCDNC
+3 QUIT
XIT KILL APCDDFN,APCDCDEC,APCDERR,APCDFILE,APCDNC,APCDNDEC,APCDVCNT,APCDVT,HIGH,LOW,X1,APCDVIGR,APCDVDG,APCDEDFN,APCDEL,APCDVL,APCDVFLE
+1 QUIT
+2 ;
DOC ; This routine checks the dependent entry count of the VISIT file for
+1 ; accuracy. If it is not correct it is replaced with a correct count
+2 ; The count is determined by scanning each of the VISIT related
+3 ; files for entries that point to that VISIT. A count is incremented
+4 ; each time a "hit" is made.
+5 ; The user can enter a LO and HIGH DFN or hit return to default to
+6 ; first and last.