APCDDVE ; IHS/CMI/LAB - AUTO MERGE E VISITS ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;
START ;EP - called from option
W:$D(IOF) @IOF
W !!,"This option will go through the visit file, find all instances where there",!,"are 2 'E - Historical Event' visits on the same day to the same location",!,"and AUTOMATICALLY merge them together.",!
W !,"You will be asked for a date range for which to run this report.",!,"It takes a long time to process so you may want to queue it to run after hours."
W !,"You may optionally receive a report detailing which visits where merged ",!,"together.",!!
RDPV ; Determine to run by Posting date or Visit date
S APCDBEEP=$C(7)_$C(7),APCDSITE="" S:$D(DUZ(2)) APCDSITE=DUZ(2)
I '$D(DUZ(2)) S APCDSITE=+^AUTTSITE(1,0)
S DIR(0)="S^1:Posting Date;2:Visit Date",DIR("A")="Run Report by",DIR("B")="P" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
I $D(DIRUT) G XIT
S Y=$E(Y),APCDPROC=$S(Y=1:"P",Y=2:"V",1:Y)
GETDATES ;
BD ;get beginning date
W ! S DIR(0)="D^:DT:EP",DIR("A")="Enter beginning "_$S(APCDPROC="P":"Posting",APCDPROC="V":"Visit",1:"Posting")_" Date for Search" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
I $D(DIRUT) G XIT
S APCDBD=Y
ED ;get ending date
W ! S DIR(0)="DA^"_APCDBD_":DT:EP",DIR("A")="Enter ending "_$S(APCDPROC="P":"Posting",APCDPROC="V":"Visit",1:"Posting")_" Date for Search: " S Y=APCDBD D DD^%DT S DIR("B")=Y,Y="" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
I $D(DIRUT) G BD
S APCDED=Y
S X1=APCDBD,X2=-1 D C^%DTC S APCDSD=X
;
REPORT ;
S APCDRPT=""
S DIR(0)="Y",DIR("A")="Would you like a report of those visits that were merged?",DIR("B")="Y" K DA D ^DIR K DIR
G:$D(DIRUT) GETDATES
S APCDRPT=Y
ZIS ;call xbdbque
S XBRC="DRIVER^APCDDVE",XBRP="PRINT^APCDDVE",XBRX="XIT^APCDDVE",XBNS="APCD"
D ^XBDBQUE
D XIT
Q
DRIVER ;EP entry point for taskman
S APCDBT=$H,APCDJOB=$J,APCDC=0
K ^XTMP("APCDDVE",APCDJOB,APCDBT)
I APCDRPT S:'$D(^XTMP("APCDDVE",0)) ^XTMP("APCDDVE",0)="" S $P(^XTMP("APCDDVE",0),U)=$$FMADD^XLFDT(DT,7),$P(^XTMP("APCDDVE",0),U,2)=DT,$P(^XTMP("APCDDVE",0),U,3)="PCC E VISIT AUTO MERGE"
D PROCESS
S APCDET=$H
Q
PRINT ;EP
S APCDQUIT=0,APCDPG=0
G:'APCDRPT DONE
D @("HEAD"_(2-($E(IOST,1,2)="C-")))
I '$D(^XTMP("APCDDVE",APCDJOB,APCDBT)) W !!,"NO Event Visits in the date range were auto merged.",! G DONE
S APCDC=0 F S APCDC=$O(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC)) Q:APCDC'=+APCDC!(APCDQUIT) D PRN1
DONE ;
I 'APCDQUIT,$E(IOST)="C",IO=IO(0) S DIR(0)="E" D ^DIR K DIR
W:$D(IOF) @IOF
K ^XTMP("APCDDVE",APCDJOB,APCDBT)
D XIT
Q
PRN1 ;print each set of visits
I $Y>(IOSL-5) D HEAD Q:APCDQUIT
S F=^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"FROM")
S T=^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"TO")
W !!,"FROM VISIT: ",?14,$$FMTE^XLFDT($P($P(F,U),"."),"5D"),?26,$$HRN^AUPNPAT($P(F,U,4),DUZ(2),2),?41,$P(^AUTTLOC($P(F,U,5),0),U,7),?47,$P(F,U,6),?65,$P(F,U,7)
F X=8:1:1 Q:$P(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"FROM"),U,X)="" W !,?65,$P(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"FROM"),U,X)
W !," TO VISIT: ",?14,$$FMTE^XLFDT($P(T,U),"5D"),?26,$$HRN^AUPNPAT($P(T,U,4),DUZ(2),2),?41,$P(^AUTTLOC($P(T,U,5),0),U,7),?47,$P(T,U,6),?65,$P(T,U,7)
F X=8:1:1 Q:$P(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"TO"),U,X)="" W !,?65,$P(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"TO"),U,X)
Q
XIT ;EP
K APCDVSIT,APCDV,APCDPG,APCDQUIT,APCDODAT,APCDED,APCDSD,APCDBD,APCDBT,APCDJOB,APCDVREC,APCDC,APCDP,APCDBDFN,APCDBEEP,APCDET,APCDPROC,APCDRPT,APCDSITE,DFN
K X,X1,X2,IO("Q"),%DT,%ZIS,%,DUOUT,DLOUT,Y
Q
PROCESS ;process report
D @APCDPROC
Q
P ; Run by Posting date
S APCDBDFN=$O(^AUPNVSIT("AMRG",APCDSD)) Q:APCDBDFN="" S APCDBDFN=$O(^AUPNVSIT("AMRG",APCDBDFN,""))
S APCDVSIT=APCDBDFN-1 F S APCDVSIT=$O(^AUPNVSIT(APCDVSIT)) Q:APCDVSIT'=+APCDVSIT Q:$P(^AUPNVSIT(APCDVSIT,0),U,2)>APCDED D PROC
Q
PV ;
S APCDVSIT="" F S APCDVSIT=$O(^AUPNVSIT("ADWO",APCDODAT,APCDVSIT)) Q:APCDVSIT'=+APCDVSIT D PROC
Q
V ; Run by visit date
S APCDODAT=$O(^AUPNVSIT("B",APCDSD)) Q:APCDODAT=""
S APCDODAT=APCDSD_".9999" F S APCDODAT=$O(^AUPNVSIT("B",APCDODAT)) Q:APCDODAT=""!((APCDODAT\1)>APCDED) D V1
Q
V1 ;
S APCDVSIT="" F S APCDVSIT=$O(^AUPNVSIT("B",APCDODAT,APCDVSIT)) Q:APCDVSIT'=+APCDVSIT I $D(^AUPNVSIT(APCDVSIT,0)) D PROC
Q
PROC ;
Q:'$P(^AUPNVSIT(APCDVSIT,0),U,9) ;no dependent entry count
Q:$P(^AUPNVSIT(APCDVSIT,0),U,2)="" ;no posting date
Q:$P(^AUPNVSIT(APCDVSIT,0),U,11) ;deleted visit
Q:$P(^AUPNVSIT(APCDVSIT,0),U,7)'="E" ;only process service category of E
S APCDVREC=^AUPNVSIT(APCDVSIT,0),DFN=$P(APCDVREC,U,5)
D MRG
Q
MRG ;find all visits that could be merged to visit in APCDVSIT
S APCDV=0 F S APCDV=$O(^AUPNVSIT("AC",DFN,APCDV)) Q:APCDV="" D
.Q:$P(^AUPNVSIT(APCDV,0),U,11) ;deleted
.Q:$P(^AUPNVSIT(APCDV,0),U,7)'="E" ;not E
.Q:'$P(^AUPNVSIT(APCDV,0),U,9) ;0 entries
.Q:APCDV=APCDVSIT ;don't merge to self
.I $$VD^APCLV(APCDV,"I")'=$$VD^APCLV(APCDVSIT,"I") Q ;not same date
.Q:$P(^AUPNVSIT(APCDV,0),U,3)'=$P(APCDVREC,U,3)
.Q:$P(^AUPNVSIT(APCDV,0),U,5)'=$P(APCDVREC,U,5)
.Q:$P(^AUPNVSIT(APCDV,0),U,6)'=$P(APCDVREC,U,6)
.S X=$P($G(^AUPNVSIT(APCDV,21)),U),Y=$P($G(^AUPNVSIT(APCDVSIT,21)),U) I X'=Y Q ;outside locations not the same
. D SETTMP
. D MRG1
Q
MRG1 ;call visit merge utility
S APCDVMT=APCDVSIT,APCDVMF=APCDV D ^APCDVM2
S $P(^AUPNVSIT(APCDVMF,22),U)="AUTO EVENT VISIT MERGE"
D UPDLOG^APCDVDEL(APCDVMF,APCDVMT)
S AUPNVSIT=APCDVMF D DEL^AUPNVSIT
K APCDVMT,APCDVMF,AUPNVSIT
Q
SETTMP ;set tmp for report
Q:'APCDRPT
S APCDC=APCDC+1,%1=0,^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"TO")="" F %=.01,.02,.03,.05,.06,2101 S %1=%1+1,$P(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"TO"),U,%1)=$$VALI^XBDIQ1(9000010,APCDVSIT,%)
S APCDP=6,APCDVFLE=9000010,APCDVIST=APCDVSIT F S APCDVFLE=$O(^DIC(APCDVFLE)) Q:APCDVFLE>9000010.99!(APCDVFLE'=+APCDVFLE) D DE2
S %1=0,^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"FROM")="" F %=.01,.02,.03,.05,.06,2101 S %1=%1+1,$P(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"FROM"),U,%1)=$$VALI^XBDIQ1(9000010,APCDVSIT,%)
S APCDP=6,APCDVFLE=9000010,APCDVIST=APCDV F S APCDVFLE=$O(^DIC(APCDVFLE)) Q:APCDVFLE>9000010.99!(APCDVFLE'=+APCDVFLE) D DE2
Q
;
DE2 ;
S APCDVDG=^DIC(APCDVFLE,0,"GL"),APCDVIGR=APCDVDG_"""AD"",APCDVIST,APCDVDFN)"
S APCDVDFN="" I $O(@APCDVIGR)]"" S APCDP=APCDP+1,$P(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"FROM"),U,APCDP)=$P($P(^DIC(APCDVFLE,0),U),"V ",2)
Q
;
HEAD ;
I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S APCDQUIT="" Q
HEAD1 ;
W:$D(IOF) @IOF
HEAD2 ;
S APCDPG=APCDPG+1
W !,$P(^VA(200,DUZ,0),U,2),?50,$$FMTE^XLFDT(DT),?72,"Page ",APCDPG,!
W !?29,"PCC Data Entry Module"
W !?23,"*********************************"
W !?23,"* VISIT REVIEW ERROR REPORT *"
W !?23,"*********************************"
S X="PCC DATA ENTRY AUTO MERGE EVENT VISIT REPORT"
W !?((80-$L(X))/2),X
W !!,"Report of Visits Merged for ",$S(APCDPROC="P":"Posting",APCDPROC="V":"VISIT",1:"Posting")," Date Range: ",$$FMTE^XLFDT(APCDBD,"5D")," through ",$$FMTE^XLFDT(APCDED,"5D")
W !,$TR($J(" ",80)," ","-")
Q
APCDDVE ; IHS/CMI/LAB - AUTO MERGE E VISITS ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;
START ;EP - called from option
+1 IF $DATA(IOF)
WRITE @IOF
+2 WRITE !!,"This option will go through the visit file, find all instances where there",!,"are 2 'E - Historical Event' visits on the same day to the same location",!,"and AUTOMATICALLY merge them together.",!
+3 WRITE !,"You will be asked for a date range for which to run this report.",!,"It takes a long time to process so you may want to queue it to run after hours."
+4 WRITE !,"You may optionally receive a report detailing which visits where merged ",!,"together.",!!
RDPV ; Determine to run by Posting date or Visit date
+1 SET APCDBEEP=$CHAR(7)_$CHAR(7)
SET APCDSITE=""
IF $DATA(DUZ(2))
SET APCDSITE=DUZ(2)
+2 IF '$DATA(DUZ(2))
SET APCDSITE=+^AUTTSITE(1,0)
+3 SET DIR(0)="S^1:Posting Date;2:Visit Date"
SET DIR("A")="Run Report by"
SET DIR("B")="P"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+4 IF $DATA(DIRUT)
GOTO XIT
+5 SET Y=$EXTRACT(Y)
SET APCDPROC=$SELECT(Y=1:"P",Y=2:"V",1:Y)
GETDATES ;
BD ;get beginning date
+1 WRITE !
SET DIR(0)="D^:DT:EP"
SET DIR("A")="Enter beginning "_$SELECT(APCDPROC="P":"Posting",APCDPROC="V":"Visit",1:"Posting")_" Date for Search"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+2 IF $DATA(DIRUT)
GOTO XIT
+3 SET APCDBD=Y
ED ;get ending date
+1 WRITE !
SET DIR(0)="DA^"_APCDBD_":DT:EP"
SET DIR("A")="Enter ending "_$SELECT(APCDPROC="P":"Posting",APCDPROC="V":"Visit",1:"Posting")_" Date for Search: "
SET Y=APCDBD
DO DD^%DT
SET DIR("B")=Y
SET Y=""
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+2 IF $DATA(DIRUT)
GOTO BD
+3 SET APCDED=Y
+4 SET X1=APCDBD
SET X2=-1
DO C^%DTC
SET APCDSD=X
+5 ;
REPORT ;
+1 SET APCDRPT=""
+2 SET DIR(0)="Y"
SET DIR("A")="Would you like a report of those visits that were merged?"
SET DIR("B")="Y"
KILL DA
DO ^DIR
KILL DIR
+3 IF $DATA(DIRUT)
GOTO GETDATES
+4 SET APCDRPT=Y
ZIS ;call xbdbque
+1 SET XBRC="DRIVER^APCDDVE"
SET XBRP="PRINT^APCDDVE"
SET XBRX="XIT^APCDDVE"
SET XBNS="APCD"
+2 DO ^XBDBQUE
+3 DO XIT
+4 QUIT
DRIVER ;EP entry point for taskman
+1 SET APCDBT=$HOROLOG
SET APCDJOB=$JOB
SET APCDC=0
+2 KILL ^XTMP("APCDDVE",APCDJOB,APCDBT)
+3 IF APCDRPT
IF '$DATA(^XTMP("APCDDVE",0))
SET ^XTMP("APCDDVE",0)=""
SET $PIECE(^XTMP("APCDDVE",0),U)=$$FMADD^XLFDT(DT,7)
SET $PIECE(^XTMP("APCDDVE",0),U,2)=DT
SET $PIECE(^XTMP("APCDDVE",0),U,3)="PCC E VISIT AUTO MERGE"
+4 DO PROCESS
+5 SET APCDET=$HOROLOG
+6 QUIT
PRINT ;EP
+1 SET APCDQUIT=0
SET APCDPG=0
+2 IF 'APCDRPT
GOTO DONE
+3 DO @("HEAD"_(2-($EXTRACT(IOST,1,2)="C-")))
+4 IF '$DATA(^XTMP("APCDDVE",APCDJOB,APCDBT))
WRITE !!,"NO Event Visits in the date range were auto merged.",!
GOTO DONE
+5 SET APCDC=0
FOR
SET APCDC=$ORDER(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC))
IF APCDC'=+APCDC!(APCDQUIT)
QUIT
DO PRN1
DONE ;
+1 IF 'APCDQUIT
IF $EXTRACT(IOST)="C"
IF IO=IO(0)
SET DIR(0)="E"
DO ^DIR
KILL DIR
+2 IF $DATA(IOF)
WRITE @IOF
+3 KILL ^XTMP("APCDDVE",APCDJOB,APCDBT)
+4 DO XIT
+5 QUIT
PRN1 ;print each set of visits
+1 IF $Y>(IOSL-5)
DO HEAD
IF APCDQUIT
QUIT
+2 SET F=^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"FROM")
+3 SET T=^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"TO")
+4 WRITE !!,"FROM VISIT: ",?14,$$FMTE^XLFDT($PIECE($PIECE(F,U),"."),"5D"),?26,$$HRN^AUPNPAT($PIECE(F,U,4),DUZ(2),2),?41,$PIECE(^AUTTLOC($PIECE(F,U,5),0),U,7),?47,$PIECE(F,U,6),?65,$PIECE(F,U,7)
+5 FOR X=8:1:1
IF $PIECE(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"FROM"),U,X)=""
QUIT
WRITE !,?65,$PIECE(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"FROM"),U,X)
+6 WRITE !," TO VISIT: ",?14,$$FMTE^XLFDT($PIECE(T,U),"5D"),?26,$$HRN^AUPNPAT($PIECE(T,U,4),DUZ(2),2),?41,$PIECE(^AUTTLOC($PIECE(T,U,5),0),U,7),?47,$PIECE(T,U,6),?65,$PIECE(T,U,7)
+7 FOR X=8:1:1
IF $PIECE(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"TO"),U,X)=""
QUIT
WRITE !,?65,$PIECE(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"TO"),U,X)
+8 QUIT
XIT ;EP
+1 KILL APCDVSIT,APCDV,APCDPG,APCDQUIT,APCDODAT,APCDED,APCDSD,APCDBD,APCDBT,APCDJOB,APCDVREC,APCDC,APCDP,APCDBDFN,APCDBEEP,APCDET,APCDPROC,APCDRPT,APCDSITE,DFN
+2 KILL X,X1,X2,IO("Q"),%DT,%ZIS,%,DUOUT,DLOUT,Y
+3 QUIT
PROCESS ;process report
+1 DO @APCDPROC
+2 QUIT
P ; Run by Posting date
+1 SET APCDBDFN=$ORDER(^AUPNVSIT("AMRG",APCDSD))
IF APCDBDFN=""
QUIT
SET APCDBDFN=$ORDER(^AUPNVSIT("AMRG",APCDBDFN,""))
+2 SET APCDVSIT=APCDBDFN-1
FOR
SET APCDVSIT=$ORDER(^AUPNVSIT(APCDVSIT))
IF APCDVSIT'=+APCDVSIT
QUIT
IF $PIECE(^AUPNVSIT(APCDVSIT,0),U,2)>APCDED
QUIT
DO PROC
+3 QUIT
PV ;
+1 SET APCDVSIT=""
FOR
SET APCDVSIT=$ORDER(^AUPNVSIT("ADWO",APCDODAT,APCDVSIT))
IF APCDVSIT'=+APCDVSIT
QUIT
DO PROC
+2 QUIT
V ; Run by visit date
+1 SET APCDODAT=$ORDER(^AUPNVSIT("B",APCDSD))
IF APCDODAT=""
QUIT
+2 SET APCDODAT=APCDSD_".9999"
FOR
SET APCDODAT=$ORDER(^AUPNVSIT("B",APCDODAT))
IF APCDODAT=""!((APCDODAT\1)>APCDED)
QUIT
DO V1
+3 QUIT
V1 ;
+1 SET APCDVSIT=""
FOR
SET APCDVSIT=$ORDER(^AUPNVSIT("B",APCDODAT,APCDVSIT))
IF APCDVSIT'=+APCDVSIT
QUIT
IF $DATA(^AUPNVSIT(APCDVSIT,0))
DO PROC
+2 QUIT
PROC ;
+1 ;no dependent entry count
IF '$PIECE(^AUPNVSIT(APCDVSIT,0),U,9)
QUIT
+2 ;no posting date
IF $PIECE(^AUPNVSIT(APCDVSIT,0),U,2)=""
QUIT
+3 ;deleted visit
IF $PIECE(^AUPNVSIT(APCDVSIT,0),U,11)
QUIT
+4 ;only process service category of E
IF $PIECE(^AUPNVSIT(APCDVSIT,0),U,7)'="E"
QUIT
+5 SET APCDVREC=^AUPNVSIT(APCDVSIT,0)
SET DFN=$PIECE(APCDVREC,U,5)
+6 DO MRG
+7 QUIT
MRG ;find all visits that could be merged to visit in APCDVSIT
+1 SET APCDV=0
FOR
SET APCDV=$ORDER(^AUPNVSIT("AC",DFN,APCDV))
IF APCDV=""
QUIT
Begin DoDot:1
+2 ;deleted
IF $PIECE(^AUPNVSIT(APCDV,0),U,11)
QUIT
+3 ;not E
IF $PIECE(^AUPNVSIT(APCDV,0),U,7)'="E"
QUIT
+4 ;0 entries
IF '$PIECE(^AUPNVSIT(APCDV,0),U,9)
QUIT
+5 ;don't merge to self
IF APCDV=APCDVSIT
QUIT
+6 ;not same date
IF $$VD^APCLV(APCDV,"I")'=$$VD^APCLV(APCDVSIT,"I")
QUIT
+7 IF $PIECE(^AUPNVSIT(APCDV,0),U,3)'=$PIECE(APCDVREC,U,3)
QUIT
+8 IF $PIECE(^AUPNVSIT(APCDV,0),U,5)'=$PIECE(APCDVREC,U,5)
QUIT
+9 IF $PIECE(^AUPNVSIT(APCDV,0),U,6)'=$PIECE(APCDVREC,U,6)
QUIT
+10 ;outside locations not the same
SET X=$PIECE($GET(^AUPNVSIT(APCDV,21)),U)
SET Y=$PIECE($GET(^AUPNVSIT(APCDVSIT,21)),U)
IF X'=Y
QUIT
+11 DO SETTMP
+12 DO MRG1
End DoDot:1
+13 QUIT
MRG1 ;call visit merge utility
+1 SET APCDVMT=APCDVSIT
SET APCDVMF=APCDV
DO ^APCDVM2
+2 SET $PIECE(^AUPNVSIT(APCDVMF,22),U)="AUTO EVENT VISIT MERGE"
+3 DO UPDLOG^APCDVDEL(APCDVMF,APCDVMT)
+4 SET AUPNVSIT=APCDVMF
DO DEL^AUPNVSIT
+5 KILL APCDVMT,APCDVMF,AUPNVSIT
+6 QUIT
SETTMP ;set tmp for report
+1 IF 'APCDRPT
QUIT
+2 SET APCDC=APCDC+1
SET %1=0
SET ^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"TO")=""
FOR %=.01,.02,.03,.05,.06,2101
SET %1=%1+1
SET $PIECE(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"TO"),U,%1)=$$VALI^XBDIQ1(9000010,APCDVSIT,%)
+3 SET APCDP=6
SET APCDVFLE=9000010
SET APCDVIST=APCDVSIT
FOR
SET APCDVFLE=$ORDER(^DIC(APCDVFLE))
IF APCDVFLE>9000010.99!(APCDVFLE'=+APCDVFLE)
QUIT
DO DE2
+4 SET %1=0
SET ^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"FROM")=""
FOR %=.01,.02,.03,.05,.06,2101
SET %1=%1+1
SET $PIECE(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"FROM"),U,%1)=$$VALI^XBDIQ1(9000010,APCDVSIT,%)
+5 SET APCDP=6
SET APCDVFLE=9000010
SET APCDVIST=APCDV
FOR
SET APCDVFLE=$ORDER(^DIC(APCDVFLE))
IF APCDVFLE>9000010.99!(APCDVFLE'=+APCDVFLE)
QUIT
DO DE2
+6 QUIT
+7 ;
DE2 ;
+1 SET APCDVDG=^DIC(APCDVFLE,0,"GL")
SET APCDVIGR=APCDVDG_"""AD"",APCDVIST,APCDVDFN)"
+2 SET APCDVDFN=""
IF $ORDER(@APCDVIGR)]""
SET APCDP=APCDP+1
SET $PIECE(^XTMP("APCDDVE",APCDJOB,APCDBT,"E MERGE",APCDC,"FROM"),U,APCDP)=$PIECE($PIECE(^DIC(APCDVFLE,0),U),"V ",2)
+3 QUIT
+4 ;
HEAD ;
+1 IF $EXTRACT(IOST)="C"
IF IO=IO(0)
WRITE !
SET DIR(0)="EO"
DO ^DIR
KILL DIR
IF Y=0!(Y="^")!($DATA(DTOUT))
SET APCDQUIT=""
QUIT
HEAD1 ;
+1 IF $DATA(IOF)
WRITE @IOF
HEAD2 ;
+1 SET APCDPG=APCDPG+1
+2 WRITE !,$PIECE(^VA(200,DUZ,0),U,2),?50,$$FMTE^XLFDT(DT),?72,"Page ",APCDPG,!
+3 WRITE !?29,"PCC Data Entry Module"
+4 WRITE !?23,"*********************************"
+5 WRITE !?23,"* VISIT REVIEW ERROR REPORT *"
+6 WRITE !?23,"*********************************"
+7 SET X="PCC DATA ENTRY AUTO MERGE EVENT VISIT REPORT"
+8 WRITE !?((80-$LENGTH(X))/2),X
+9 WRITE !!,"Report of Visits Merged for ",$SELECT(APCDPROC="P":"Posting",APCDPROC="V":"VISIT",1:"Posting")," Date Range: ",$$FMTE^XLFDT(APCDBD,"5D")," through ",$$FMTE^XLFDT(APCDED,"5D")
+10 WRITE !,$TRANSLATE($JUSTIFY(" ",80)," ","-")
+11 QUIT