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

RGVCCMR1.m

Go to the documentation of this file.
  1. RGVCCMR1 ;GAI/TMG-CMOR ACTIVITY SCORE GENERATOR (PART 1) ;01/15/98
  1. ;;1.0;CLINICAL INFO RESOURCE NETWORK;**2,19**;30 Apr 99
  1. ;Reference to ^DPT("ACMORS" and ^DPT(0 supported by IA #2070
  1. ;
  1. EN ; this routine contains entry points to start/restart the batch cmor
  1. ; score initialization, flag a running
  1. ; initialization to stop, calculate and file an activity score for an
  1. ; individual patient, and display the status of the cmor initialization
  1. START ; entry point to start or restart the cmor activity score initialization
  1. N RGY
  1. S U="^"
  1. S NODE=$G(^RGSITE(991.8,1,"CMOR"))
  1. I '(+$P(NODE,U)) D G QUIT
  1. .W !!,"This is the initial run of the CMOR patient activity score generator."
  1. .S RUNTYPE="I",RGDFN=0 D TASK
  1. S STATUS=$P(NODE,U,7)
  1. I STATUS="R" D I RUN G QUIT
  1. .S RUN=0
  1. .S ZTSK=+$P(NODE,U,9)
  1. .I 'ZTSK D INT Q
  1. .D STAT^%ZTLOAD
  1. .I ZTSK(1)=0!(ZTSK(1)=3)!(ZTSK(1)=4) D INT Q
  1. .I ZTSK(1)=1 W !!,"CMOR Patient Activity Score queued task #",ZTSK,!,"is waiting to run. Do not start another job at this time." S RUN=1 Q
  1. .I ZTSK(1)=2 W !!,"CMOR Patient Activity Score queued task #",ZTSK,!,"is currently running. Do not start another job at this time." S RUN=1 Q
  1. .I ZTSK(1)=5 W !!,"CMOR Patient Activity Score queued task #",ZTSK,!,"was interrupted abnormally, possibly from a system error." D INT
  1. I STATUS="SN" D
  1. .S STOPDT=$P(NODE,U,3) I +STOPDT D
  1. ..S STOPDT=$$FMTE^XLFDT(STOPDT,"1P")
  1. ..W !!,"The CMOR patient activity score generator",!,"completed successfully on ",STOPDT,"."
  1. .W !
  1. .S DIR(0)="Y",DIR("A")="Would you like to reset all patient activity scores",DIR("B")="N" D ^DIR S RGY=Y
  1. .I RGY=1 S DIR(0)="Y",DIR("A")="This will take quite a while. Are you sure",DIR("B")="N" D ^DIR S RGY=Y
  1. .I RGY=1 S RUNTYPE="R",RGDFN=0 D TASK
  1. I STATUS="SM"!(STATUS="INT") D
  1. .S STOPDT=$P(NODE,U,3) D
  1. ..I +STOPDT S STOPDT=$$FMTE^XLFDT(STOPDT,"1P")
  1. ..W !!,"The CMOR patient activity score generator was "
  1. ..W:STATUS="SM" ! W $S(STATUS="SM":"STOPPED MANUALLY",1:"INTERRUPTED ABNORMALLY.") I STATUS="SM" W " on ",STOPDT,"."
  1. .I +$P(NODE,U) D
  1. ..S LASTDFN=$P(NODE,U),LASTPT=$P($G(^DPT(+LASTDFN,0)),U),LASTSSN=$P(^(0),U,9)
  1. ..W !,"The last patient processed was ",LASTPT," SSN: ",LASTSSN,!?31,"[RECORD# ",LASTDFN,"]"
  1. .W ! S DIR(0)="Y",DIR("A")="Would you like to start with this patient and continue",DIR("B")="N" D ^DIR S RGY=Y
  1. .W ! I RGY=1 D
  1. ..S DIR(0)="Y",DIR("A")="This will take quite a while. Are you sure"
  1. ..S DIR("B")="N" D ^DIR I Y=1 S RUNTYPE="RS",RGDFN=LASTDFN D TASK
  1. .W ! I RGY=0 D
  1. ..S DIR(0)="Y",DIR("A")="Would you like to rerun the CMOR calculation for all patients"
  1. ..S DIR("B")="N" D ^DIR I Y=1 D
  1. ...W ! S DIR(0)="Y",DIR("A")="This will take quite a while. Are you sure",DIR("B")="N" D ^DIR I Y=1 S RUNTYPE="RS",RGDFN=0 D TASK
  1. G QUIT
  1. STOP ; entry point to flag a running cmor score initialization to stop
  1. S U="^"
  1. S NODE=$G(^RGSITE(991.8,1,"CMOR"))
  1. I $P(NODE,U,7)'="R" W !,"The CMOR activity score generation is NOT running." G QUIT
  1. W !,"This option will stop the CMOR patient activity score generation"
  1. W !,"after it has completed calculating and filing the score for the current"
  1. W !,"patient."
  1. W ! S DIR("A")="Are you sure you want to do this",DIR("B")="N",DIR(0)="Y" D ^DIR K DIR S RGY=Y
  1. W ! S DIR("A")="Stop patient activity score generation after the current patient",DIR("B")="N",DIR(0)="Y" D ^DIR S RGY=Y
  1. ;I RGY=1 S DA=1,DIE="^RGSITE(991.8,",DR="21////Y;24////SM" D ^DIE
  1. I RGY=1 D
  1. .S $P(^RGSITE(991.8,1,"CMOR"),U,4)="Y"
  1. .W !!,"CMOR patient activity generation is flagged to stop after"
  1. .W !,"it has completed the current patient. This may take a short time."
  1. .W !,"Please check the status later."
  1. G QUIT
  1. INDIV ; entry point to allow a cmor score for an individual patient to be
  1. ; calculated and filed
  1. N MNODE
  1. S U="^"
  1. S DIC="^DPT(",DIC(0)="AEQMNZ" D ^DIC K DIC Q:+Y<0 S RGDFN=+Y
  1. S PTNAM=$P(Y(0),"^"),SSN=$P(Y(0),"^",9),FILE=1
  1. S MNODE=$$MPINODE^MPIFAPI(RGDFN)
  1. I $P($G(MNODE),U,7)'="" D
  1. .S FILE=0
  1. .S SCOREDT=$$FMTE^XLFDT($P(MNODE,U,7),"1P")
  1. .S CURSCORE=$P(MNODE,U,6) W !!,"This patient has an existing CMOR score of ",+CURSCORE," calculated on ",SCOREDT,".",!
  1. .S DIR(0)="Y",DIR("A")="Do you want to calculate and file a new score for this patient",DIR("B")="NO" D ^DIR I Y=1 S FILE=1
  1. I FILE=1 D
  1. .W !!,"Working. Please standby..." S FILEFLG=0 D CALCI^RGVCCMR2
  1. .I 'FILEFLG W !!,"No Patient Activity in the Past Three Years - No Score Filed!" Q
  1. .W !!,"CMOR Activity Score: ",SCORE," filed for ",PTNAM," SSN: ",SSN,"."
  1. G QUIT
  1. DISPLAY ; displays the status of the background cmor score initialization
  1. W !,"The CMOR Activity Score Generator",!
  1. ;count number of CMOR scores"
  1. W !,"..one moment please...",!
  1. S (SCORE,CNT)=0
  1. F S SCORE=$O(^DPT("ACMORS",SCORE)) Q:'SCORE D
  1. .S RGDFN=0 F S RGDFN=$O(^DPT("ACMORS",SCORE,RGDFN)) Q:'RGDFN D
  1. ..S CNT=CNT+1
  1. W !,"There are ",$P(^DPT(0),U,4)," records in your PATIENT file."
  1. W !,"The last record number is ",$P(^DPT(0),U,3),"."
  1. I $P($G(^RGSITE(991.8,1,"CMOR")),U)'="" D CHKSTAT
  1. I $P($G(^RGSITE(991.8,1,"CMOR")),U)="" D
  1. . W !,"The CMOR Calculation has NEVER been run on your system."
  1. G QUIT
  1. CHKSTAT S NODE=$G(^RGSITE(991.8,1,"CMOR"))
  1. S PTNAM="-Unknown-",SSN="---"
  1. S RGDFN=+NODE I RGDFN,$D(^DPT(RGDFN,0)) D
  1. .S PTNAM=$P(^(0),U),SSN=$P(^(0),U,9)
  1. S OSTARTED="UNSPECIFIED" I $P(NODE,U,2)'="" D
  1. .S OSTARTED=$$FMTE^XLFDT($P(NODE,U,2),"1P")
  1. S OSTOPPED="UNSPECIFIED" I $P(NODE,U,3)'="" D
  1. .S OSTOPPED=$$FMTE^XLFDT($P(NODE,U,3),"1P")
  1. S ORESTART=$G(^XTMP("RGVCCMR","@@@@","RESTARTED"))
  1. I +ORESTART S ORESTART=$$FMTE^XLFDT(ORESTART,"1P")
  1. S ODFNCT=""
  1. I $D(^XTMP("RGVCCMR","@@@@","DFNCOUNT")) S ODFNCT=^XTMP("RGVCCMR","@@@@","DFNCOUNT")
  1. STATUS S ST=$P(NODE,U,7)
  1. ;if status is RUNNING, check to see if task errored out
  1. I ST="R" D
  1. .S ZTSK=$P(NODE,U,9) I $D(ZTSK) D
  1. ..D STAT^%ZTLOAD
  1. ..I ZTSK(1)=5 D INT S ST="INT"
  1. S STATUS=$S(ST="R":"RUNNING.",ST="SM":"STOPPED MANUALLY",ST="SN":"SUCCESSFULLY COMPLETED",ST="INT":"INTERRUPTED ABNORMALLY.",1:"- NO STATUS LISTED -")
  1. ;S PERCOMP=((ODFNCT/$P(^DPT(0),U,4))*100),PERCOMP=$P(PERCOMP,".")_"."_$E($P(PERCOMP,".",2),1,2)
  1. W !,"Last Patient Processed: ",PTNAM," SSN: ",SSN," [RECORD# ",RGDFN,"]"
  1. W !!,"The CMOR score initialization last started on ",OSTARTED,"."
  1. I ORESTART]"" W !,"Job was restarted on ",ORESTART,"."
  1. I +ODFNCT W !,ODFNCT," patient records have been processed."
  1. W !,"Status: ",STATUS I ST'="R"&(ST'="INT") W " on ",OSTOPPED,"."
  1. W !,"CMOR Score Count: ",CNT
  1. ;
  1. G QUIT
  1. ;
  1. INT ;Set status to INTERRUPTED for abnormally stopped jobs
  1. S $P(^RGSITE(991.8,1,"CMOR"),"^",7)="INT"
  1. S STATUS="INT"
  1. Q
  1. TASK S ZTIO="",ZTRTN="^RGVCCMR2",ZTDESC="BACKGROUND CMOR SCORE CALCULATOR"
  1. S (ZTSAVE("RUNTYPE"),ZTSAVE("RGDFN"))=""
  1. ; change ztsave("*")="" to specific variables when done
  1. D ^%ZTLOAD
  1. I $D(ZTSK) W " Task#, ",ZTSK," queued" S $P(^RGSITE(991.8,1,"CMOR"),U,9)=ZTSK
  1. D ^%ZISC
  1. Q
  1. QUIT K RGDFN,DIC,DIR,FILE,LASTDFN,LASTPT,LASTSSN,ODFNCT,ORESTART,OSTARTED
  1. K OSTOPPED,PTNAM,RUNTYPE,SCORE,SSN,ST,STATUS,X,Y,%DT,ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTSK
  1. K CURSCORE,SCOREDT,NODE,STOPDT,FILEFLG,SCORE,CNT,RGDFN,RUN
  1. ;kill variables leftover from the CALI^RGVCCMR2 entry point
  1. K LRCODE,DA,DR,DIE,APSTDT,LRCODE,LRSCORE,NXPC,NXPTF,NXSCE,NXRX,NXXR,PCCODE,PSOVER,PTF0,RXDT,STDT,XRCODE,XRSTDT,YR
  1. Q