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

YSGAFTR.m

Go to the documentation of this file.
  1. YSGAFTR ;DALOI/MJE/MJD-GAF INT ENTRY BUILD ROUTINE ;09/01/98 16:17
  1. ;;5.01;MENTAL HEALTH;**43,49,59**;Dec 30, 1994
  1. ;
  1. ;This routine will be executed from option YS GAF TRANSMISSION.
  1. ;This routine will transmit GAF data for the dates entered. This
  1. ;routine will also be used to re-transmit GAF data as needed.
  1. ;It will only transmit GAF records containing all necessary
  1. ;pieces of information. A MAILMAN message for each GAF score
  1. ;transmitted will be sent to users enrolled in mail group
  1. ;YS GAF TRANSMISSION ACK.
  1. ;
  1. ;
  1. Q
  1. START ;
  1. ; Date range will be from no less than 10-01-1997 to any time
  1. ; in the future.
  1. I '$D(DUZ) D Q
  1. .W !!,$C(7),"ERROR: DUZ is not defined. Use ^XUP or ask your "
  1. .W !,"IRM why you don't have a DUZ variable defined.",!!
  1. .D CLNUP
  1. ;
  1. S YSGFDATE=""
  1. D DTRANGE Q:+Y<1
  1. K ^TMP("YSGAFTR",$J)
  1. S ZTRTN="GEN^YSGAFTR"
  1. ;
  1. ;VARIABLES TO BE SAVED IN ZTSAVE
  1. S ZTSAVE("*")=""
  1. ;
  1. S ZTDESC="MENTAL HEALTH - GAF TRANSMISSION"
  1. S ZTIO=""
  1. D ^%ZTLOAD
  1. I '$D(ZTSK) QUIT ;-->
  1. W !!,"The Mental Health GAF Transmission has been Tasked, job# "
  1. W ZTSK,"...",!
  1. Q
  1. ;
  1. DTRANGE ;
  1. W !
  1. S (YSSTD,YSSPD)=0
  1. S %DT("A")="Enter the Start date: ",%DT="AEQ",%DT(0)=2971001
  1. D ^%DT K %DT
  1. Q:+Y<1
  1. S YSSTD=+Y
  1. W !
  1. S %DT("A")="Enter the End date: ",%DT="AEQ"
  1. D ^%DT K %DT
  1. Q:+Y<1
  1. S YSSPD=+Y
  1. I YSSPD<YSSTD D G DTRANGE
  1. .W !?5,"... Start date is after the Ending date ..."
  1. .W !?5,"... Please re-enter both the Start and Ending Dates ..."
  1. .H 2 W $C(7)
  1. Q
  1. ;
  1. GEN ;
  1. I $D(ZTQUEUED) S ZTREQ="@" K ZTSK
  1. S (YSIEN,YSTOT,YSINC,YSTRMT,YSSUBT)=0
  1. F YSJ="I","O" D
  1. .S (YSTOT(YSJ),YSTRMT(YSJ),YSINC(YSJ))=0
  1. F S YSIEN=$O(^YSD(627.8,YSIEN)) Q:YSIEN=""!('YSIEN) D
  1. .S YSGFDATE=$P($P($G(^YSD(627.8,YSIEN,0)),"^",1),".",1)
  1. .S YSO=$G(^YSD(627.8,YSIEN,0))
  1. .S YSPATID=$P(YSO,U,2) ; Patient ID
  1. .S YSGAFDT=$P(YSO,U,3) ; Date/time of diagnosis
  1. .Q:YSGAFDT=""
  1. .S YSGFDATE=$P($P(YSO,U,3),".",1)
  1. .I (YSGFDATE>(YSSTD-1))&(YSGFDATE<(YSSPD+1)) D
  1. ..S YSTOT=YSTOT+1 ; Count total records found in this date range
  1. ..S YSP=$G(^YSD(627.8,YSIEN,60)),YSPATYPE=$P(YSP,U,4)
  1. ..I YSPATYPE="" D Q:YSPATYPE=""
  1. ...Q:YSPATID=""
  1. ...S DFN=YSPATID
  1. ...D PATSTAT^YSDX3B
  1. ...I '$D(DFN) D QUIT ;--->
  1. ....D EN^YSGAFOBX(YSIEN)
  1. ...S YSPATYPE=YSSTAT
  1. ..S YSTOT(YSPATYPE)=YSTOT(YSPATYPE)+1
  1. ..S YSAX5=$P(YSP,U,3),YSPROV=$P(YSO,U,4)
  1. ..I YSAX5=""!(YSPROV="") D Q
  1. ...S YSINC=YSINC+1
  1. ...S YSINC(YSPATYPE)=YSINC(YSPATYPE)+1
  1. ..S YSTRMT=YSTRMT+1
  1. ..S YSTRMT(YSPATYPE)=YSTRMT(YSPATYPE)+1
  1. ..D EN^YSGAFOBX(YSIEN)
  1. D REPORT,MAILIT,CLNUP
  1. Q
  1. REPORT ;
  1. S YSSUBT=YSINC+YSTRMT,YSLN=0
  1. S XTMP="GAF TRANSMISSION TOTALS" D YSLN,SPC
  1. S XTMP="Total GAF Records:" D YSLN,SPC
  1. F YSJ="I","O" D
  1. .S XTMP=$J(+YSTOT(YSJ),8)_" "
  1. .S XTMP=XTMP_$S(YSJ="I":"In",1:"Out")_"-patient" D YSLN
  1. S XTMP=$J(YSTOT,8)_" Total GAF Records"
  1. D YSLN,DSH,DSH,SPC
  1. S XTMP="GAF Records Transmitted:" D YSLN,SPC
  1. F YSJ="I","O" D
  1. .S XTMP=$J(+YSTRMT(YSJ),8)_" "
  1. .S XTMP=XTMP_$S(YSJ="I":"In",1:"Out")_"-patient" D YSLN
  1. S XTMP=$J(YSTRMT,8)_" GAF Record(s) transmitted" D YSLN,SPC
  1. S XTMP="GAF Records Not Transmitted:" D YSLN,SPC
  1. F YSJ="I","O" D
  1. .S XTMP=$J(+YSINC(YSJ),8)_" "
  1. .S XTMP=XTMP_$S(YSJ="I":"In",1:"Out")_"-patient" D YSLN
  1. S XTMP=$J(YSINC,8)_" GAF Record(s) not transmitted" D YSLN,DSH,SPC
  1. S XTMP=$J(YSSUBT,8)_" Total GAF Records" D YSLN,DSH,DSH,SPC
  1. S XTMP=$J((YSTOT-YSSUBT),8)_" Difference" D YSLN
  1. Q
  1. SPC ;
  1. S XTMP=" " D YSLN
  1. Q
  1. DSH ;
  1. S XTMP="--------" D YSLN
  1. Q
  1. YSLN ;Store to ^TMP for MAILMAN message
  1. S YSLN=YSLN+1
  1. S ^TMP("YSGAFTR",$J,YSLN)=XTMP
  1. Q
  1. MAILIT ; Mail totals
  1. S DTIME=600
  1. S XMSUB="GAF Transmission"
  1. S XMTEXT="^TMP(""YSGAFTR"",$J,"
  1. S XMY(DUZ)=""
  1. S XMY("YOUNG,TIM@ISC-DALLAS.DOMAIN.EXT")=""
  1. S XMY("DEVLIN,MARK@ISC-DALLAS.DOMAIN.EXT")=""
  1. S XMDUZ="AUTOMATED MESSAGE"
  1. D ^XMD
  1. S DTIME=$$DTIME^XUP(DUZ)
  1. Q
  1. CLNUP ;This section for clean up of variables
  1. K X,Y,YSDIROUT,YSDIRUT,YSDUOUT,YSDTOUT,YSGFDATE,YSIEN,YSSPD,YSSTD
  1. K YSANIMA,YSHH,YSSTAT,YSAX5,YSGAFDT,YSINC,YSLN,YSO,YSP,YSPATID
  1. K YSPATYPE,YSPROV,YSSUBT,YSTOT,YSTRMT,ZTDESC,ZTIO,ZTRTN,ZTSAVE
  1. K XTMP,XMDUZ,XMSUB,XMTEXT,XMSUB,XMY,XCNP,XMZ,YSYEAR,YSJ,YSI
  1. K ^TMP("YSGAFTR",$J)
  1. Q