DG53P641 ;BAY/JAT - Patient File Updat; 6/7/04 7:13pm ; 1/4/05 5:06pm
;;5.3;Registration;**641,1015**;Aug 13,1993;Build 21
Q
;
CLEANUP ;This entry point will do the update.
;
N DGENSKIP
S DGENSKIP=0
W !,"This is a one-time update of the Patient File."
W !,"It will set the 'ATEST' cross-reference as needed."
N X1,X2
K ^XTMP("DG53P641",$J)
S X1=DT,X2=90 D C^%DTC
S ^XTMP("DG53P641",$J,0)=X_"^"_DT_"^Patient File update"
I $$DEVICE() D ENTER
Q
;
REPORT ;This entry point was provided for testing, so that before
;patient records are updated the site can have a list of
;the DFN's that would be affected.
;
;Use this entry point to report on what the update would do.
;No changes will be made to the database.
;
N DGENSKIP
S DGENSKIP=1
W !,"This is a preliminary report by DFN of the Patient file"
W !,"records which would be affected by the update."
N X1,X2
K ^XTMP("DG53P641",$J)
S X1=DT,X2=90 D C^%DTC
S ^XTMP("DG53P641",$J,0)=X_"^"_DT_"^Patient File update"
I $$DEVICE() D ENTER
Q
;
ENTER ;
;
D UPDATE(DGENSKIP)
D:(DGENSKIP) ^%ZISC
I $D(ZTQUEUED) S ZTREQ="@"
Q
DEVICE() ;
;Description: allows the user to select a device.
;
;Output:
; Function Value - Returns 0 if the user decides not to print or to
; queue the report, 1 otherwise.
;
N OK,IOP,POP,%ZIS
S OK=1
S %ZIS="MQ"
D ^%ZIS
S:POP OK=0
D:OK&$D(IO("Q"))
.N ZTRTN,ZTDESC,ZTSKM,ZTREQ,ZTSTOP
.S ZTRTN="ENTER^DG53P641",ZTDESC=$S(DGENSKIP:"Report",1:"Update")_" of Patient Records"
.S ZTSAVE("DGENSKIP")=""
.D ^%ZTLOAD
.W !,$S($D(ZTSK):"REQUEST QUEUED TASK="_ZTSK,1:"REQUEST CANCELLED")
.D HOME^%ZIS
.S OK=0
Q OK
;
UPDATE(DGENSKIP) ;
;This will update patient records --
;
;Input: If DGENSKIP=1, the records will not be updated,
;just reported.
;
N DFN,COUNT,DGSSN,DGS,DGFLG,DGXREF,DGVAL,DGFDA,DGERR
S (COUNT,DFN)=0
F S DFN=$O(^DPT(DFN)) Q:'DFN D
.; merged record
.I $D(^DPT(DFN,-9)) Q
.; in process of being merged
.I $P($G(^DPT(DFN,0)),U)["MERGING INTO" Q
.I $D(^DPT(DFN,0)) D
..S DGSSN=$P($G(^DPT(DFN,0)),U,9)
..Q:'DGSSN
..Q:$E(DGSSN,1,5)'="00000"
..Q:$D(^DPT("ATEST",DFN))
..D UPDR
;
D PRINT
Q
;
UPDR ;
S COUNT=COUNT+1
S ^XTMP("DG53P641",$J,DFN)=DGSSN
I 'DGENSKIP D
.N DA,DIK
.S DA=DFN,DIK="^DPT(",DIK(1)=".09^ATP"
.D EN1^DIK
Q
PRINT ;
U IO
N DGDDT,DGQUIT,DGPG
S DGDDT=$$FMTE^XLFDT($$NOW^XLFDT,"D")
S (DGQUIT,DGPG)=0
D HEAD
I '$G(COUNT) D Q
.W !!!,?20,"*** No records to report ***"
W !!,"*** COUNT OF BAD PATIENT RECORDS"_$S(DGENSKIP:"",1:" UPDATED")_": ",COUNT," ***",!!
S DFN=0
F S DFN=$O(^XTMP("DG53P641",$J,DFN)) Q:'DFN D Q:DGQUIT
.I $Y>(IOSL-4) D HEAD
.S DGSSN=$P($G(^XTMP("DG53P641",$J,DFN)),U)
.W ?2,DFN,?15,DGSSN,!
;
I DGQUIT W:$D(ZTQUEUED) !!,"Report stopped at user's request" Q
I $G(DGPG)>0,$E(IOST)="C" K DIR S DIR(0)="E" D ^DIR K DIR S:+Y=0 DGQUIT=1
I $D(ZTQUEUED) S ZTREQ="@"
Q
;
HEAD ;
I $D(ZTQUEUED),$$S^%ZTLOAD S (ZTSTOP,DGQUIT)=1 Q
I $G(DGPG)>0,$E(IOST)="C" K DIR S DIR(0)="E" D ^DIR K DIR S:+Y=0 DGQUIT=1
Q:DGQUIT
S DGPG=$G(DGPG)+1
W @IOF,!,DGDDT,?15,"DG*5.3*641 Patient File Update Utility",?70,"Page:",$J(DGPG,5),! K X S $P(X,"-",81)="" W X,!
W !
W !,?2,"DFN",?15,"SSN",!
S $P(X,"-",81)="" W X,!
Q
DG53P641 ;BAY/JAT - Patient File Updat; 6/7/04 7:13pm ; 1/4/05 5:06pm
+1 ;;5.3;Registration;**641,1015**;Aug 13,1993;Build 21
+2 QUIT
+3 ;
CLEANUP ;This entry point will do the update.
+1 ;
+2 NEW DGENSKIP
+3 SET DGENSKIP=0
+4 WRITE !,"This is a one-time update of the Patient File."
+5 WRITE !,"It will set the 'ATEST' cross-reference as needed."
+6 NEW X1,X2
+7 KILL ^XTMP("DG53P641",$JOB)
+8 SET X1=DT
SET X2=90
DO C^%DTC
+9 SET ^XTMP("DG53P641",$JOB,0)=X_"^"_DT_"^Patient File update"
+10 IF $$DEVICE()
DO ENTER
+11 QUIT
+12 ;
REPORT ;This entry point was provided for testing, so that before
+1 ;patient records are updated the site can have a list of
+2 ;the DFN's that would be affected.
+3 ;
+4 ;Use this entry point to report on what the update would do.
+5 ;No changes will be made to the database.
+6 ;
+7 NEW DGENSKIP
+8 SET DGENSKIP=1
+9 WRITE !,"This is a preliminary report by DFN of the Patient file"
+10 WRITE !,"records which would be affected by the update."
+11 NEW X1,X2
+12 KILL ^XTMP("DG53P641",$JOB)
+13 SET X1=DT
SET X2=90
DO C^%DTC
+14 SET ^XTMP("DG53P641",$JOB,0)=X_"^"_DT_"^Patient File update"
+15 IF $$DEVICE()
DO ENTER
+16 QUIT
+17 ;
ENTER ;
+1 ;
+2 DO UPDATE(DGENSKIP)
+3 IF (DGENSKIP)
DO ^%ZISC
+4 IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+5 QUIT
DEVICE() ;
+1 ;Description: allows the user to select a device.
+2 ;
+3 ;Output:
+4 ; Function Value - Returns 0 if the user decides not to print or to
+5 ; queue the report, 1 otherwise.
+6 ;
+7 NEW OK,IOP,POP,%ZIS
+8 SET OK=1
+9 SET %ZIS="MQ"
+10 DO ^%ZIS
+11 IF POP
SET OK=0
+12 IF OK&$DATA(IO("Q"))
Begin DoDot:1
+13 NEW ZTRTN,ZTDESC,ZTSKM,ZTREQ,ZTSTOP
+14 SET ZTRTN="ENTER^DG53P641"
SET ZTDESC=$SELECT(DGENSKIP:"Report",1:"Update")_" of Patient Records"
+15 SET ZTSAVE("DGENSKIP")=""
+16 DO ^%ZTLOAD
+17 WRITE !,$SELECT($DATA(ZTSK):"REQUEST QUEUED TASK="_ZTSK,1:"REQUEST CANCELLED")
+18 DO HOME^%ZIS
+19 SET OK=0
End DoDot:1
+20 QUIT OK
+21 ;
UPDATE(DGENSKIP) ;
+1 ;This will update patient records --
+2 ;
+3 ;Input: If DGENSKIP=1, the records will not be updated,
+4 ;just reported.
+5 ;
+6 NEW DFN,COUNT,DGSSN,DGS,DGFLG,DGXREF,DGVAL,DGFDA,DGERR
+7 SET (COUNT,DFN)=0
+8 FOR
SET DFN=$ORDER(^DPT(DFN))
IF 'DFN
QUIT
Begin DoDot:1
+9 ; merged record
+10 IF $DATA(^DPT(DFN,-9))
QUIT
+11 ; in process of being merged
+12 IF $PIECE($GET(^DPT(DFN,0)),U)["MERGING INTO"
QUIT
+13 IF $DATA(^DPT(DFN,0))
Begin DoDot:2
+14 SET DGSSN=$PIECE($GET(^DPT(DFN,0)),U,9)
+15 IF 'DGSSN
QUIT
+16 IF $EXTRACT(DGSSN,1,5)'="00000"
QUIT
+17 IF $DATA(^DPT("ATEST",DFN))
QUIT
+18 DO UPDR
End DoDot:2
End DoDot:1
+19 ;
+20 DO PRINT
+21 QUIT
+22 ;
UPDR ;
+1 SET COUNT=COUNT+1
+2 SET ^XTMP("DG53P641",$JOB,DFN)=DGSSN
+3 IF 'DGENSKIP
Begin DoDot:1
+4 NEW DA,DIK
+5 SET DA=DFN
SET DIK="^DPT("
SET DIK(1)=".09^ATP"
+6 DO EN1^DIK
End DoDot:1
+7 QUIT
PRINT ;
+1 USE IO
+2 NEW DGDDT,DGQUIT,DGPG
+3 SET DGDDT=$$FMTE^XLFDT($$NOW^XLFDT,"D")
+4 SET (DGQUIT,DGPG)=0
+5 DO HEAD
+6 IF '$GET(COUNT)
Begin DoDot:1
+7 WRITE !!!,?20,"*** No records to report ***"
End DoDot:1
QUIT
+8 WRITE !!,"*** COUNT OF BAD PATIENT RECORDS"_$SELECT(DGENSKIP:"",1:" UPDATED")_": ",COUNT," ***",!!
+9 SET DFN=0
+10 FOR
SET DFN=$ORDER(^XTMP("DG53P641",$JOB,DFN))
IF 'DFN
QUIT
Begin DoDot:1
+11 IF $Y>(IOSL-4)
DO HEAD
+12 SET DGSSN=$PIECE($GET(^XTMP("DG53P641",$JOB,DFN)),U)
+13 WRITE ?2,DFN,?15,DGSSN,!
End DoDot:1
IF DGQUIT
QUIT
+14 ;
+15 IF DGQUIT
IF $DATA(ZTQUEUED)
WRITE !!,"Report stopped at user's request"
QUIT
+16 IF $GET(DGPG)>0
IF $EXTRACT(IOST)="C"
KILL DIR
SET DIR(0)="E"
DO ^DIR
KILL DIR
IF +Y=0
SET DGQUIT=1
+17 IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+18 QUIT
+19 ;
HEAD ;
+1 IF $DATA(ZTQUEUED)
IF $$S^%ZTLOAD
SET (ZTSTOP,DGQUIT)=1
QUIT
+2 IF $GET(DGPG)>0
IF $EXTRACT(IOST)="C"
KILL DIR
SET DIR(0)="E"
DO ^DIR
KILL DIR
IF +Y=0
SET DGQUIT=1
+3 IF DGQUIT
QUIT
+4 SET DGPG=$GET(DGPG)+1
+5 WRITE @IOF,!,DGDDT,?15,"DG*5.3*641 Patient File Update Utility",?70,"Page:",$JUSTIFY(DGPG,5),!
KILL X
SET $PIECE(X,"-",81)=""
WRITE X,!
+6 WRITE !
+7 WRITE !,?2,"DFN",?15,"SSN",!
+8 SET $PIECE(X,"-",81)=""
WRITE X,!
+9 QUIT