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

KMPDUTL2.m

Go to the documentation of this file.
  1. KMPDUTL2 ;OAK/RAK - CM Tools Utility ;6/21/05 10:18
  1. ;;3.0;KMPD;;Jan 22, 2009;Build 42
  1. ;
  1. DATERNG(KMPUY,KMPUSTR,KMPUEND) ;-- date range
  1. ;---------------------------------------------------------------------
  1. ; KMPUY..... Value returned in four pieces:
  1. ; fmstartdate^fmenddate^ouputstartdate^outputenddate
  1. ;
  1. ; Piece one and two are the date ranges in fileman format.
  1. ; Piece three and four are the same dates in output format:
  1. ; dy-Mon-yr
  1. ;
  1. ; ********
  1. ; * NOTE *
  1. ; ********
  1. ; - The first piece will always be the earliest date entered.
  1. ;
  1. ; Optional Parameters:
  1. ;
  1. ; KMPUSTR... If defined, the earliest date that may be selected.
  1. ; (must be in fileman format)
  1. ;
  1. ; KMPUEND... If defined, the latest date that may be selected.
  1. ; (must be in fileman format)
  1. ;-----------------------------------------------------------------------
  1. ;
  1. N DATE1,DATE2,DIR,DIRUT,LINE,X,Y
  1. ;
  1. S KMPUY="",KMPUSTR=$G(KMPUSTR),KMPUEND=$G(KMPUEND)
  1. ;
  1. RANGE ;-- Ask date ranges
  1. S DIR(0)="DOA^"_$S(KMPUSTR:KMPUSTR,1:"")_":"_$S(KMPUEND:KMPUEND,1:"")_":ET)"
  1. S DIR("A")="Start with Date: "
  1. S:KMPUSTR DIR("B")=$$FMTE^XLFDT(KMPUSTR,2)
  1. S DIR("?")=" "
  1. S DIR("?",1)="Enter the starting date.",LINE=2
  1. ; if starting date.
  1. I KMPUSTR D
  1. .S DIR("?",LINE)="Date must not precede "_$$FMTE^XLFDT(KMPUSTR)
  1. .S LINE=LINE+1
  1. ; if ending date.
  1. I KMPUEND S DIR("?",LINE)="Date must not follow "_$$FMTE^XLFDT(KMPUEND)
  1. W ! D ^DIR I $D(DIRUT) S KMPUY="" Q
  1. S DATE1=Y
  1. S DIR("A")=" End with Date: "
  1. S:KMPUEND DIR("B")=$$FMTE^XLFDT(KMPUEND,2)
  1. S DIR("?",1)="Enter the ending date."
  1. D ^DIR G:Y="" RANGE I Y="^" S KMPUY="" Q
  1. S DATE2=Y
  1. ; Set earliest date into first piece.
  1. S KMPUY=$S(DATE2<DATE1:DATE2,1:DATE1)_U_$S(DATE2>DATE1:DATE2,1:DATE1)
  1. S $P(KMPUY,U,3)=$$FMTE^XLFDT($P(KMPUY,U))
  1. S $P(KMPUY,U,4)=$$FMTE^XLFDT($P(KMPUY,U,2))
  1. Q
  1. ;
  1. EMAIL(KMPDSUBJ,KMPDTEXT,KMPDTO) ; check and process errors.
  1. ;-----------------------------------------------------------------------
  1. ; KMPDSUBJ... Free text - to be included in subject
  1. ; KMPDTEXT(). Array containing message text. This must be in a format
  1. ; accepted by XMTEXT - TEXT(
  1. ; ^TMP($J,"TEXT",
  1. ; KMPDTO..... Address for email recipient:
  1. ; G.KMP2-RUM@FO-ALBANY.DOMAIN.EXT
  1. ; G.KMP4-CMTOOLS@FO-ALBANY.DOMAIN.EXT
  1. ; G.CAPACITY,MANAGEMENT@FO-ALBANY.MED.GOV
  1. ; If no value is passed the default will be
  1. ; G.KMP4-CMTOOLS@FO-ALBANY.DOMAIN.EXT
  1. ;
  1. ;-----------------------------------------------------------------------
  1. ;
  1. Q:$G(KMPDTEXT)=""
  1. S KMPDSUBJ=$S($G(KMPDSUBJ)="":"CM Error",1:KMPDSUBJ)
  1. S KMPDTO=$S($G(KMPDTO)="":"G.KMP4-CMTOOLS@FO-ALBANY.DOMAIN.EXT",1:KMPDTO)
  1. ;
  1. N H,I,LN,N,O,SITE,TEXT,TL,XMSUB,X,XMTEXT,XMY,XMZ,Y,Z
  1. ;
  1. S TL=$$TESTLAB^KMPDUT1
  1. S SITE=$$SITE^VASITE
  1. S XMSUB=KMPDSUBJ_" at site "_$P(TL,U,2)_$P(SITE,U,3)_" on "_$$FMTE^XLFDT($$DT^XLFDT)
  1. S XMTEXT=KMPDTEXT
  1. S XMY(KMPDTO)=""
  1. D ^XMD
  1. W:'$D(ZTQUEUED) !,"Message #"_$G(XMZ)_" sent..."
  1. ;
  1. Q
  1. ;
  1. STRSTP(KMPDAPP,KMPDDW,KMPDBP,KMPDSTM) ;-- record start/stop times
  1. ;-----------------------------------------------------------------------
  1. ; KMPDAPP.... CP application:
  1. ; 1 - sagg
  1. ; 2 - rum
  1. ; 3 - hl7
  1. ; 4 - timing
  1. ; KMPDDW..... Daily or Weekly
  1. ; 1 - daily
  1. ; 2 - weekly
  1. ; KMPDBP.... Background or Purge
  1. ; 1 - background
  1. ; 2 - purge
  1. ; KMPDSTM.... Start Time in internal fileman format
  1. ;
  1. ; This api will calculate END time and DELTA time (END-KMPDSTM) and
  1. ; store the results in:
  1. ; ^XTMP("KMPD","BACKGROUND",KMPDAPP,KMPDDW,KMPDBP,...)
  1. ;-----------------------------------------------------------------------
  1. Q:'$G(KMPDAPP)
  1. Q:KMPDAPP<1!(KMPDAPP>4)
  1. Q:'$G(KMPDDW)
  1. Q:KMPDDW<1!(KMPDDW>2)
  1. Q:'$G(KMPDBP)
  1. Q:KMPDBP<1!(KMPDBP>2)
  1. Q:'$G(KMPDSTM)
  1. ;
  1. N END,ERROR,FDA,FIELD S END=$$NOW^XLFDT
  1. ;
  1. ; starting field for daily or background
  1. S FIELD=KMPDAPP+($S(KMPDDW=1:5,1:8)*.01)
  1. ; if purge
  1. S:KMPDBP=2 FIELD=FIELD+.07
  1. ;
  1. ; store start time, end time, and delta
  1. S FDA($J,8973,"1,",FIELD)=KMPDSTM
  1. S FDA($J,8973,"1,",FIELD+.01)=END
  1. S FDA($J,8973,"1,",FIELD+.02)=$$FMDIFF^XLFDT(END,KMPDSTM,3)
  1. ;
  1. D FILE^DIE("","FDA($J)","ERROR")
  1. ;
  1. Q