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

AGFULAUD.m

Go to the documentation of this file.
AGFULAUD ;IHS/ASDS/TPF - FULL PATIENT FILE AUDIT USING EDIT CHECK ERRORS/WARNINGS CALLS 6/8/2004 9:49:39 AM
 ;;7.1;PATIENT REGISTRATION;**8**;AUG 25,2005
 ;
 ;#90A IHS/SD/TPF 6/8/2004
 ;THIS TASK WAS ADDED FAR INTO PROJECT
 ;TASK #90 WAS COMPLETED BUT WAS NOT THE FUNCTION INTENDED BY THE
 ;REQUEST
 ;
 ;AFTER ADDITONAL SPECIFICATIONS WERE OBTAINED FROM IHS. RUN LASTED 11
 ;MINUTES FOR SITE WITH 27,000 PATIENT ENTRIES
 ;
 ;AG*7.1 IHS/SD/TPF 10/26/2004
ENTER ;
 S AGOPT("VERSION")=$$VERSION^XPDUTL("AG")  ;GET CURRENT VERSION EDIT CHECKS WILL BE PERFORMED DIFFERENTLY ON SOME FIELDS BECAUSE VERSION 7.1 CHANGED THEIR LOCATION
 I AGOPT("VERSION")="" W !,"PATIENT REGISTRATION VERSION CANNOT BE DETERMINED PLEASE CALL THE HELP DESK!!" Q
 W !!,"WARNING THIS TASK COULD TAKE UP TO 10 HOURS TO COMPLETE!!!"
 W !,"THIS TASK SHOULD BE QUEUED VIA TASKMAN TO RUN AFTER HOURS"
 W !,"PREFERABLY ON THE WEEKEND!! MAKE SURE BACKUPS DO NOT SHUTDOWN"
 W !,"THIS TASK BEFORE IT'S FINISHED."
 I AGOPT("VERSION")<7.1 D
 .W !,"YOUR CURRENT VERSION OF IHS PATIENT REGISTRATION IS ",AGOPT("VERSION")
 .W !,"THEREFORE THE AUDIT WILL BE PERFORMED BASED ON PRE 7.1 FILE STRUCTURES."
 K DIR,DTOUT,DUOUT,DIRUT,DIROUT
 S DIR(0)="Y"
 S DIR("A")="ARE YOU SURE YOU WANT TO CONTINUE"
 D ^DIR
 I $D(DTOUT)!($D(DUOUT))!($D(DIROUT)) D EXIT Q
 I 'Y D EXIT Q
 S ERRDT=$O(^AGERRAUD("B",""),-1)
 I ERRDT D  I 'LASTFIN W !!,"THE AUDIT REPORT IS CURRENTLY COMPILING! TRY AGAIN LATER" H 3 D EXIT Q
 .S DTREC=$O(^AGERRAUD("B",ERRDT,""))
 .S LASTFIN=$P($G(^AGERRAUD(DTREC,0)),U,4)
 I $D(^AGERRAUD(1,0)) D SHODAT($P($G(^AGERRAUD(1,0)),U)) D  I $D(DTOUT)!($D(DUOUT))!($D(DIROUT))!('$G(Y)) D EXIT Q
 .K DIR,DTOUT,DUOUT,DIRUT,DIROUT
 .S DIR(0)="Y"
 .S DIR("A")="ARE YOU SURE YOU WANT TO CONTINUE"
 .D ^DIR
 K DIR,DTOUT,DUOUT,DIRUT,DIROUT
 S DIR(0)="S^T:TASK TO TASKMAN;R:RUN IMMEDIATELY"
 S DIR("A")="ACTION"
 D ^DIR
 I $D(DTOUT)!($D(DUOUT))!($D(DIROUT)) D EXIT Q
 I Y="R" W !,"STARTING FULL PATIENT FILE AUDIT....." D START Q
 S ZTRTN="START^AGFULAUD",ZTDESC="Full Patient File audit by Patient Registration"
 S ZTIO=""
 S ZTSAVE("AG*")=""
 D ^%ZTLOAD
 I $D(ZTSK)[0 W !,"Full patient audit canceled!"
 E  W !!?5,"Full patient audit queued as Task # ",ZTSK,"!"
 H 2
 D HOME^%ZIS
 D EXIT
 Q
 ;
SHODAT(DATE) ;EP
 S Y=DATE X ^DD("DD")
 W !!,"THERE IS ALREADY AN AUDIT REPORT FROM ",Y,". IT WILL BE DELETED!"
 Q
START ;EP - ENTER BELOW FROM TASKMAN OPTION
 ;KILL PREVIOUS ENTRIES IF THEY EXIST. THIS IS A SNAPSHOT ONLY. WE
 ;ARE NOT GOING TO ALLOW KEEPING MORE THAN ONE RUN
 S STOPFLAG=0
 D ^AGVAR  ;AG*7.1*8 - Define AGOPT array
 ;
 D CLEAR   ;KILL THE CURRENT ENTRY IN THE AUDIT FILE
 ;IF DATE ENTRY NOT THERE CREATE IT
 I '$D(^AGERRAUD("B",DT)) S DTREC=$$NEWDT(DT)
 I '$G(DTREC) W:'$D(ZTQUEUED) !,"UNABLE TO CREATE DATE ENTRY IN 'ERROR/WARNING AUDIT' FILE!!" H 3 D EXITCAP Q
 E  S DTREC=$O(^AGERRAUD("B",DT,""))
 I 'DTREC W:'$D(ZTQUEUED) !,"TROUBLE CREATING ENTRY IN 'AG ERROR/WARNING AUDIT' FILE CALL HELP DESK!" Q
 ;STORE TASK #
 S DA=DTREC
 S DIE="^AGERRAUD("
 S DR=".06////^S X=$G(ZTSK)"
 D ^DIE
 K MYERRS,MYVARS
 D FETCHERR^AGEDERR("ALL",.MYERRS)
 S MYVARS("FINDCALL")="",MYVARS("SELECTION")=$G(AGSELECT),MYVARS("SITE")=DUZ(2)
 S PDFN=0,SKIP=0,PTTOTAL=0
 S TOTALDFN=$P($G(^AUPNPAT(0)),U,4)
 F  S PDFN=$O(^AUPNPAT(PDFN)) Q:'PDFN  D  Q:STOPFLAG
 .I '$D(ZTQUEUED) W:$P(PDFN/15,".",2)="" "."
 .I '$D(ZTQUEUED) W:$P(PDFN/200,".",2)="" !,$J((PDFN/TOTALDFN)*100,3,0)_" % ESTIMATED COMPLETE"
 .S STOPFLAG=$$S^%ZTLOAD
 .;AG*7.1*8 - Commented out filters - each error already has filters in place and not all errors have the same filters 
 .;I $$DECEASED^AGEDERR2(PDFN) S SKIP=SKIP+1 Q  ;QUIT IF PATIENT DECEASED
 .;I '$$CURRUPD^AGEDERR2(PDFN,1095) S SKIP=SKIP+1 Q  ;QUIT IF LAST UPDATE>3 YEARS
 .;I '$$HASELIG^AGEDERR2(PDFN) S SKIP=SKIP+1 Q  ;QUIT IF PATIENT HAS NO ACTIVE INSURANCE ELIGIBILITY PER ADRIAN E-MAIL 2/3/2005
 .;I '$$PTACTIVE^AGEDERR2(PDFN) S SKIP=SKIP+1 Q  ;QUIT IF PATIENT NOT ACTIVE IN ANY FACILITY
 .S PTTOTAL=PTTOTAL+1  ;TOTAL PATIENTS REVIEWED BY ERROR CHECKS
 .S (MYVARS("AGPATDFN"),MYVARS("DFN"))=PDFN ;AG*7.1*8 - Added MYVARS("AGPATDFN") set
 .D EDITCHEK^AGEDERR(.MYERRS,.MYVARS,0)
 .D CAPTURE^AGERRAUD(.MYERRS,PDFN)
 I '$D(ZTQUEUED) W !,"100% COMPLETED"
 K DIC,DIE
 S DIC(0)="EMQ"
 S DIC="^AGERRAUD("
 S X=DT
 D ^DIC
 Q:Y<0
 S DIE="^AGERRAUD("
 S DA=+Y
 S DR=".02////^S X=SKIP"
 D ^DIE
 D NOW^%DTC
 S ENDTIME=%
 S DIE="^AGERRAUD("
 S DR=".04////^S X=ENDTIME"
 D ^DIE
 S DIE="^AGERRAUD("
 S DR=".05////^S X=STOPFLAG"
 D ^DIE
 S DIE="^AGERRAUD("
 S DR=".08////^S X=PTTOTAL"
 D ^DIE
 S ZTSTOP=STOPFLAG  ;PASS STOP FLAG BACK TO TASKMANAGER
 Q
EXIT ;EP - CLEAN UP VARIABLES
 K DIR,DTOUT,DUOUT,DIRUT,DIROUT,AGOPT("VERSION"),LASTFIN,DTREC,ZTIO,ZTSAVE,Y,ERRDT
 Q
CLEAR ;EP - CLEAR THE AUDIT FILE
 W:'$D(ZTQUEUED) !,"Clearing audit file for new run."
 S DIK="^AGERRAUD("
 S ERRDT=""
 F  S ERRDT=$O(^AGERRAUD("B",ERRDT)) Q:ERRDT=""  D
 .S DA=$O(^AGERRAUD("B",ERRDT,""))
 .D ^DIK
 K ^AGERRAUD("D")
 K ^AGERRAUD("E")
 Q
EXITCAP ;EP
 K DTREC,PDFN,PTREC,ERRREC,ERRCODE,AGOPT("VERSION")
 Q
NEWDT(DT) ;EP
 ;SET STARTIME
 N STARTIME
 D NOW^%DTC
 S STARTIME=%
 ;ADD TOP LEVEL
 K DIC,DIE,DR,DA
 S DIC=9009061.6
 S DIC(0)="L"
 S X=DT
 D ^DIC
 Q:Y<0 0
 S DTREC=+Y
 S DIE="^AGERRAUD("
 S DA=+Y
 S DR=".03////^S X=STARTIME"
 D ^DIE
 Q DTREC