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

APCDFDEC.m

Go to the documentation of this file.
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.