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

DG737PST.m

Go to the documentation of this file.
  1. DG737PST ;BAY/JAT ;file #45 cleanup
  1. ;;5.3;Registration;**737,1015**;Aug 13, 1993;Build 21
  1. Q
  1. ; loosely based on PXRMINDD routine released in PX*2*4
  1. CHECK ;Driver for making index date checks & stripping trailing zeros
  1. N GBL,LIST,ROUTINE
  1. W !,"Queue the Clinical Reminders Index date check and update."
  1. S GBL(4)=45
  1. S LIST="4,"
  1. S ROUTINE(45)="CNTPTF^DG737PST"
  1. D TASKIT(LIST,.GBL,.ROUTINE)
  1. Q
  1. ;
  1. CNTPTF(FILENUM,NSD) ;Check for string dates for PTF indexes where the
  1. ;date is at subscript 7. Works for file numbers:
  1. ;45
  1. K ^TMP($J,"SDATE"),^TMP("PXRMXMZ",$J)
  1. N DAS,DATE,DFN,IND,ITEM,NODE,TYPE
  1. I '$D(ZTQUEUED) W !,"Checking file number "_FILENUM
  1. S IND=0
  1. ; only procedure codes affected (file 80.1) therefore only
  1. ; sub-file 45.01 or 45.05 are involved
  1. F TYPE="ICD0" D
  1. . S DFN=""
  1. . F S DFN=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN)) Q:DFN="" D
  1. .. S IND=IND+1
  1. .. I '$D(ZTQUEUED),(IND#10000=0) W "."
  1. .. S NODE=""
  1. .. F S NODE=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE)) Q:NODE="" D
  1. ... S ITEM=""
  1. ... F S ITEM=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM)) Q:ITEM="" D
  1. .... S DATE=""
  1. .... F S DATE=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM,DATE)) Q:DATE="" D
  1. ..... I +DATE=DATE Q
  1. ..... S DAS=""
  1. ..... F S DAS=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM,DATE,DAS)) Q:DAS="" D
  1. ...... S NSD=NSD+1
  1. ...... S ^TMP($J,"SDATE",NSD)="^PXRMINDX("_FILENUM_","_TYPE_",""PNI"","_DFN_","_NODE_","_ITEM_","""_DATE_""","_DAS_")"
  1. ...... D UPDATE
  1. Q
  1. ;
  1. UPDATE ; strip trailing zeros from date,e.g., 3031005.1340 or 3010816.134050
  1. N DGNEWDT,DGFILE,DGDA,DGIENS,FDA
  1. S DGNEWDT=+DATE
  1. S DGFILE=$P(DAS,";",2)
  1. I DGFILE'="P"&(DGFILE'="S") Q
  1. I DGFILE="P" S DGFILE=45.05
  1. I DGFILE="S" S DGFILE=45.01
  1. ; below patterned after UPD^DGENDBS
  1. S DGDA=$P(DAS,";",3)
  1. S DGDA(1)=+DAS
  1. S DGIENS=$$IENS^DILF(.DGDA)
  1. S FDA(DGFILE,DGIENS,.01)=DGNEWDT
  1. D FILE^DIE("K","FDA")
  1. Q
  1. ;
  1. ;========================================================
  1. MESSAGE(FILENUM,NSD,START,END) ;Build the MailMan message giving the
  1. ;list of entries with string dates.
  1. N IND,NAME,NL,TEXT,XMSUB
  1. K ^TMP("PXRMXMZ",$J)
  1. S XMSUB="CR Index string date check for file #"_FILENUM
  1. S NAME=$$GET1^DID(FILENUM,"","","NAME")_", file #"_FILENUM
  1. I NSD=0 S TEXT="No string dates were found for "_NAME_"."
  1. I NSD>0 S TEXT="A total of "_NSD_" string dates were found for "_NAME_"."
  1. S ^TMP("PXRMXMZ",$J,1,0)=TEXT
  1. S ^TMP("PXRMXMZ",$J,2,0)="Check finished at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
  1. S ^TMP("PXRMXMZ",$J,3,0)=$$ETIME^DG737PST(START,END)
  1. S ^TMP("PXRMXMZ",$J,4,0)=" "
  1. I NSD=0,'$D(^PXRMINDX(FILENUM)) D
  1. . S ^TMP("PXRMXMZ",$J,5,0)="The index for file number "_FILENUM_" does not exist."
  1. . S ^TMP("PXRMXMZ",$J,6,0)=" "
  1. I NSD>0 D
  1. . S ^TMP("PXRMXMZ",$J,5,0)="The following entries with string dates were found:"
  1. . S NL=5
  1. . F IND=1:1:NSD D
  1. .. S NL=NL+1
  1. .. S ^TMP("PXRMXMZ",$J,NL,0)=" "_^TMP($J,"SDATE",IND)
  1. . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=" "
  1. D SEND^DG737PST(XMSUB,DUZ)
  1. ;K ^TMP($J,"SDATE"),^TMP("PXRMXMZ",$J)
  1. Q
  1. ;
  1. ;===============================================================
  1. RUNNOW(LIST,GBL) ;Run the routine now.
  1. N END,FN,IND,LI,NSD,NUM,ROUTINE,RTN,START,TOTAL
  1. K ^TMP($J,"SDATE")
  1. S ROUTINE(45)="CNTPTF^DG737PST"
  1. S NUM=$L(LIST,",")-1
  1. F IND=1:1:NUM D
  1. . S LI=$P(LIST,",",IND)
  1. . S NSD=0
  1. . S FN=GBL(LI)
  1. . S RTN=ROUTINE(FN)
  1. . S RTN=RTN_"("_FN_",.NSD)"
  1. . S START=$H
  1. . I $D(^PXRMINDX(FN)) D @RTN
  1. . S END=$H
  1. . D MESSAGE(FN,NSD,START,END)
  1. Q
  1. ;
  1. ;===============================================================
  1. TASKIT(LIST,GBL,ROUTINE) ;Check the indexes as a tasked job.
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,MINDT,SDTIME,X,Y
  1. S MINDT=$$NOW^XLFDT
  1. S DIR("A",1)="Enter the date and time you want the job to start."
  1. S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
  1. S DIR("A")="Start the task at: "
  1. S DIR(0)="DAU"_U_MINDT_"::RSX"
  1. D ^DIR
  1. I $D(DIROUT)!$D(DIRUT) Q
  1. I $D(DTOUT)!$D(DUOUT) Q
  1. S SDTIME=Y
  1. K DIR
  1. ;Put the task into the queue.
  1. K ZTSAVE
  1. S ZTSAVE("LIST")=""
  1. S ZTSAVE("GBL(")=""
  1. S ZTRTN="TASKJOB^DG737PST"
  1. S ZTDESC="Clinical Reminders Index string date check and update"
  1. S ZTDTH=SDTIME
  1. S ZTIO=""
  1. D ^%ZTLOAD
  1. W !,"Task number ",ZTSK," queued."
  1. Q
  1. ;
  1. ;===============================================================
  1. TASKJOB ;Execute as tasked job. LIST and GBL come through ZTSAVE.
  1. N IND,LI,NUM
  1. S ZTREQ="@"
  1. S ZTSTOP=0
  1. S NUM=$L(LIST,",")-1
  1. F IND=1:1:NUM D
  1. .;Check to see if the task has had a stop request
  1. . I $$S^%ZTLOAD S ZTSTOP=1,IND=NUM Q
  1. . S LI=$P(LIST,",",IND)_","
  1. . D RUNNOW^DG737PST(LI,.GBL)
  1. Q
  1. ;
  1. ETIME(START,END) ;Calculate and format the elapsed time.
  1. ;START and END are $H times.
  1. N ETIME,TEXT
  1. S ETIME=$$HDIFF^XLFDT(END,START,2)
  1. I ETIME>90 D
  1. . S ETIME=$$HDIFF^XLFDT(END,START,3)
  1. . S TEXT="Elapsed time: "_ETIME
  1. E S TEXT="Elapsed time: "_ETIME_" secs"
  1. Q TEXT
  1. SEND(XMSUB,USER) ;Send a MailMan message to the user. The text of the message is in
  1. ;^TMP("PXRMXMZ",$J,N,0), where there are N lines of text. The subject
  1. ;is the string XMSUB.
  1. N MGIEN,MGROUP,NL,REF,XMDUZ,XMY,XMZ
  1. ;If this is a test run write out the message.
  1. ;I $G(PXRMDEBG) D
  1. ;. S REF="^TMP(""PXRMXMZ"",$J)"
  1. ;. D AWRITE^PXRMUTIL(REF)
  1. ;Make sure the subject does not exceed 64 characters.
  1. S XMSUB=$E(XMSUB,1,64)
  1. ;Make the sender the Postmaster.
  1. S XMDUZ=0.5
  1. RETRY ;Get the message number.
  1. D XMZ^XMA2
  1. I XMZ<1 G RETRY
  1. ;Load the message
  1. M ^XMB(3.9,XMZ,2)=^TMP("PXRMXMZ",$J)
  1. K ^TMP("PXRMXMZ",$J)
  1. S NL=$O(^XMB(3.9,XMZ,2,""),-1)
  1. S ^XMB(3.9,XMZ,2,0)="^3.92^"_+NL_U_+NL_U_DT
  1. ;Send message to requestor if USER is defined
  1. I $G(USER)'="" S XMY(DUZ)="" D ENT1^XMD Q
  1. ;Send the message to the site defined mail group or the user if
  1. ;there is no mail group.
  1. ;S MGIEN=$G(^PXRM(800,1,"MGFE"))
  1. ;I MGIEN'="" D
  1. ;. S MGROUP="G."_$$GET1^DIQ(3.8,MGIEN,.01)
  1. ;. S XMY(MGROUP)=""
  1. ;E S XMY(DUZ)=""
  1. ;D ENT1^XMD
  1. Q