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

SDECXML.m

Go to the documentation of this file.
SDECXML ;ALB/JCH - SCHEDULING ENHANCEMENTS 3 ;11/03/14 10:59am
 ;;5.3;Scheduling;**628**;Aug 13, 1993;Build 371
 ; 
GETFLT(RESULT,ALL,SDEBUG)  ; RPC - Filter Data only
 N SDRPTYP,SDDT,I,SDPC,DTAGAB,SDFLTFLG,DTRANGE,SDLCNT,NODATA,SDSTAT
 S SDEBUG=$G(SDEBUG),NODATA=0
 S SDSTAT=$$ISLOCKED^SDCED()
 ; If the background job is running then return NODATA with error text
 I +SDSTAT D NODATA^SDECXUTL(.RESULT,$P(SDSTAT,U,2)) Q
 I '$D(^XTMP("SDVSE","FLTXML")) D  Q:NODATA
 .I $D(^XTMP("SDVSE","DT")),SDSTAT=0 D START("MPS","YQMWD","","",1,"","","FLTXML") Q
 .D NODATA^SDECXUTL(.RESULT) S NODATA=1
 S RESULT=$NAME(^TMP($J,"FLTXML"))
 M ^TMP($J,"FLTXML")=^XTMP("SDVSE","FLTXML")
 Q
 ;
REPORT(RESULT,SDRPTLST,SDBEGRNG,SDENDRNG,SDEBUG)  ; RPC - Report Data
 N SDRPTYP,SDDT,I,SDPC,DTAGAB,SDUR,SDACTDT1,SDWEEKS,SDLCNT,DATE,SDINTDT,XMLNODE
 K ^TMP($J,"SDECXML")
 S RESULT=$NAME(^TMP($J,"SDECXML"))
 S SDEBUG=$G(SDEBUG),XMLNODE="SDECXML"
 S SDACTDT1=$O(^XTMP("SDVSE","DT","")) S:'SDACTDT1 SDACTDT1=$P($$NOW^XLFDT,".")
 I $G(SDRPTLST)="" S SDRPTLST="MPS"
 S SDBEGRNG=$G(SDBEGRNG),SDENDRNG=$G(SDENDRNG)
 I SDBEGRNG,(SDBEGRNG'?7N.E) S SDBEGRNG=$$SDETFM(SDBEGRNG)
 I SDENDRNG,(SDENDRNG'?7N.E) S SDENDRNG=$$SDETFM(SDENDRNG)
 I ",Y,Q,M,W,D,"[(","_SDBEGRNG_",") D
 .S SDUR=$S(SDBEGRNG="Y":"Year",SDBEGRNG="Q":"Quarter",SDBEGRNG="M":"Month",SDBEGRNG="W":"Week",1:"Date")
 .I SDUR="Year" D  Q
 ..S SDBEGRNG=$$FMADD^XLFDT(SDACTDT1,-365),SDENDRNG=SDACTDT1
 .I SDUR'="Year" D  Q
 ..N SDDATE,ACTDT1,ACTDT2
 ..S SDBEGRNG=SDENDRNG
 ..I SDUR="Week" D
 ...D WEEKS^SDCED1(SDENDRNG,.SDWEEKS)
 ...S SDBEGRNG=$$GETWEEK^SDCED1(SDBEGRNG,.SDWEEKS)
 ..S SDDATE=SDBEGRNG
 ..D BEGEND^SDECXUTL(SDDATE,.ACTDT1,.ACTDT2,$E(SDUR),SDDATE)
 ..I '($G(ACTDT1)?7N.E) S SDBEGRNG=$$SDETFM(ACTDT1)
 ..I '($G(ACTDT2)?7N.E) S SDENDRNG=$$SDETFM(ACTDT2)
 I $G(SDUR)="" S SDUR=$$FMDIFF^XLFDT(SDENDRNG,SDBEGRNG) D
 .S SDUR=$S(SDUR>93:"Year",SDUR>31:"Quarter",SDUR>7:"Month",SDUR>1:"Week",1:"Date")
 ; If this is a Year report request and if Yearly report already exists then return without recompiling XML report data
 I SDUR="Year",$D(^XTMP("SDVSE","YRPTXML-"_SDRPTLST)) M ^TMP($J,"SDECXML")=^XTMP("SDVSE","YRPTXML-"_SDRPTLST) Q
 S SDDTINC="D"
 D START(SDRPTLST,.SDDTINC,SDBEGRNG,SDENDRNG,,SDUR,SDEBUG,XMLNODE)
 M ^TMP($J,"SDECXML")=^XTMP("SDVSE",XMLNODE)
 K ^XTMP("SDVSE",XMLNODE)
 Q
 ;
START(SDRPTLST,SDDTINC,SDBEGRNG,SDENDRNG,SDFLTFLG,SDUR,SDEBUG,XMLNODE) ; Begin building report data from ^XTMP("SDVSE","DT"
 N DT,SDDT,SDBEGDT,SDENDDT,SDFACNUM,SDFACNAM,SDFILT,SDFAC,DTNAMAR,SDDTCNT,SDRPTCNT,DTRANGE,SDNODE,SDRPTAR
 N CLNTAG,DIVTAG,GRPFLG,SDACTDT,DTNAM,SDRPT
 I $G(XMLNODE)="" S XMLNODE=$S($G(SDFLTFLG)=1:"FLTXML",1:"SDECXML")
 K ^XTMP("SDVSE",XMLNODE)
 F SDRPT="M","P","S" S SDRPTAR(SDRPT)=""
 S (SDACTDT,DT)=$O(^XTMP("SDVSE","DT","")) Q:'SDACTDT
 S SDBEGDT=$S($G(SDBEGRNG):$$SDETFM(SDBEGRNG),1:"")
 S SDENDDT=$S($G(SDENDRNG)&$G(SDBEGDT):$$SDETFM(SDENDRNG),1:"")
 I '$G(SDFLTFLG),$G(SDBEGDT)&$G(SDENDDT) S DTRANGE=SDBEGDT_"-"_SDENDDT
 S SDNODE=$S($G(DTRANGE):$J_",SDCEX",1:"SDCEX")
 I $G(DTRANGE) D
 .D EN^SDCED1(.SDRPTAR,SDBEGRNG,SDENDRNG,SDNODE)
 ;
 S SDLCNT=0,SDFACNAM=$$SITE^VASITE,SDFACNUM=+SDFACNAM,SDFACNAM=$P(SDFACNAM,"^",2)
 F DTNAM="Year","Quarter","Month","Week","Date" S DTNAMAR($E(DTNAM))=DTNAM
 S SDFAC=$$SITE^VASITE
 D OUTPUT^SDECXUTL("<?xml version=""1.0"" encoding=""UTF-8""?>",0,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE) ; Generic Set/Output
 S SDFILT=$$FAC(SDFAC) D SETFILT(.SDLCNT,SDFILT,2)
 F SDRPTCNT=1:1:$L(SDRPTLST) S SDRPT=$E(SDRPTLST,SDRPTCNT) D
 .S SDFILT=$$RPT(SDRPT) D SETFILT(.SDLCNT,SDFILT,4)
 .F SDDTCNT=1:1:$L(SDDTINC) S SDTINC=$E(SDDTINC,SDDTCNT) D
 ..Q:'$D(DTNAMAR(SDTINC))  S SDTINC=$G(DTNAMAR(SDTINC))
 ..Q:SDTINC=""
 ..D DATINC(.SDLCNT,SDBEGDT,SDENDDT,SDRPT,SDTINC,$G(DTRANGE),SDNODE,SDEBUG,XMLNODE)
 .D OUTPUT^SDECXUTL("</ReportType>",4,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
 I '$G(SDFLTFLG) D SETSDREC^SDECXUTL(.SDLCNT,$E(SDRPTLST),,XMLNODE)
 D OUTPUT^SDECXUTL("</VAFacility>",2,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
 I $G(SDNODE)["," K ^XTMP(SDNODE)
 Q
 ;
DATINC(SDLCNT,SDBEGDT,SDENDDT,SDRPTYP,DATINC,DTRANGE,SDNODE,SDEBUG,XMLNODE) ; Get Year, Quarter, Month, Week, and Date data for Division, Group, Clinic, Provider
 N SDPRV,SDCLN,SDDGRP,SDIV,SDFAC,SDII,SDDATE,SDRPT,SDTINC,IC,SDALL,SDDIV
 N CLNTAG,GRPFLG,DIVTAG,STRING
 I '$G(SDBEGDT) S SDBEGDT=$$FMADD^XLFDT($$NOW^XLFDT,-365)
 I '$G(SDENDDT) S SDENDDT=$P($$FMADD^XLFDT($$NOW^XLFDT,1),".")
 S SDDATE=$S($G(DTRANGE):"",1:$$FMADD^XLFDT(SDBEGDT,,-1))
 I DATINC="Year",'$G(DTRANGE) S SDDATE=$O(^XTMP(SDNODE,DATINC,SDRPTYP,""))
 S SDDATE="",SDCALL="",SDGALL=""
 I $G(SDFLTFLG),DATINC="Date" S SDDATE=$$FMADD^XLFDT(SDACTDT,,,1)
 I $G(SDFLTFLG),DATINC="Week" I $O(^XTMP(SDNODE,DATINC,SDRPTYP,""),-1)>$$FMADD^XLFDT(SDACTDT,6) S SDDATE=$$FMADD^XLFDT(SDACTDT,6)
 F SDII=0:1 S SDDATE=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE),-1) Q:SDDATE=""!($G(DTRANGE)&(SDDATE<SDBEGDT))  D
 .I SDII=0 D OUTPUT^SDECXUTL("<DateAggregate DateAgg="""_$S(($G(SDUR)]""):SDUR,1:DATINC)_""">",6,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
 .D OUTPUT^SDECXUTL($$DATE(SDDATE,$E(DATINC),SDACTDT,$G(DTRANGE)),8,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
 .S SDFAC="" F  S SDFAC=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC)) Q:SDFAC=""!(SDFAC="APP")  D
 ..Q:$G(SDFLTFLG)
 ..Q:$G(XMLNODE)="FLTXML"
 ..N SDALLALL,SDVGRCL,SDGALL,SDCALL
 ..S SDVGRCL="",SDALL=0,SDGALL=0,SDCALL=0
 ..S SDDIV="" F DIVCOUNT=0:1 S SDDIV=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC,SDDIV)) Q:'SDDIV  D
 ...;Q:(SDDIV="APP")
 ...D DIVISION(.SDLCNT,SDRPTYP,SDDATE,SDFAC,SDDIV,$E(DATINC),DIVCOUNT,XMLNODE)
 ...N SDSINGRP S SDSINGRP=0
 ...S SDGALL=0
 ...S SDDGRP=0 F IG=1:1 S SDDGRP=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP)) Q:SDDGRP=""  D
 ....Q:(SDDGRP="APP")
 ....D GROUP(.SDLCNT,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,$E(DATINC),IG)
 ....Q:((SDDGRP=0)&$G(SDSINGRP))
 ....S SDGALL=$G(SDGALL)+1
 ....S SDCALL=0
 ....S SDCLN="" F IC=1:1  S SDCLN=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,SDCLN)) Q:SDCLN=""  D
 .....Q:(SDCLN="APP")!(SDCLN="STAT")
 .....D CLINIC^SDECXML2(.SDLCNT,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,SDCLN,$E(DATINC),SDNODE,.CLNTAG,SDCALL,.GRPFLG,SDEBUG,XMLNODE)
 .....S SDCALL=$G(SDCALL)+1
 .....S SDPRV="" F  S SDPRV=$O(^XTMP(SDNODE,DATINC,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,SDCLN,SDPRV)) Q:SDPRV=""  D
 ......Q:'(SDPRV["^")
 ......D PROVIDER^SDECXML2(.SDLCNT,SDRPTYP,SDDATE,SDFAC,SDDIV,SDDGRP,SDCLN,SDPRV,DATINC,.CLNTAG,.GRPFLG,SDCALL,DTNAM,SDGALL,SDNODE)
 .....I $G(CLNTAG) D OUTPUT^SDECXUTL("</Rs>",13,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
 ....I $G(GRPFLG) D OUTPUT^SDECXUTL("</Rg>",12,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
 ...I $G(DIVTAG) D OUTPUT^SDECXUTL("</Division>",10,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
 .D OUTPUT^SDECXUTL("</Date>",8,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
 Q:'SDII
 D OUTPUT^SDECXUTL("</DateAggregate>",6,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
 Q
 ;
DIVISION(SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,DTINC,DIVCOUNT,XMLNODE) ; Division
 N SDFILT,DTNAM
 S DTNAM=$G(DTNAMAR(DTINC))
 I '$G(DIVCOUNT) D DIVALL^SDECXML3(.SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,DTINC,SDEBUG,SDGALL,SDCALL,SDNODE,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE) ; All divisions -
 ;
 S SDFILT=$$DIV(SDIV) D SETTMPF(.SDLCNT,SDFILT,11)
 Q
 ;
GROUP(SDLCNT,SDRPTYP,SDAT,SDFAC,SDIV,SDGRP,DTINC,IG) ; Group
 N SDFILT,SDDATA,DTNAM,SDFILT,SDGRPRV
 Q:$G(SDIV)=""
 S DTNAM=$G(DTNAMAR(DTINC))
 I '$G(SDGALL) D GRPALL^SDECXML3(SDRPTYP,SDAT,SDFAC,SDIV,"",SDEBUG,SDGALL,SDCALL,SDNODE,.CLNTAG,.GRPFLG,.DIVTAG,XMLNODE)
 ;
 I SDGRP D
 .I $G(GRPFLG) D OUTPUT^SDECXUTL("</Rg>",12,.SDLCNT,SDEBUG,.CLNTAG,.GRPFLG,.DIVTAG,$G(XMLNODE))
 .S SDFILT=$$GRP(SDGRP) D SETTMPF(.SDLCNT,SDFILT,15) S GRPFLG=1
 Q
 ;
RPT(RPT) ; Report Type
 S RPT=$S(RPT="S":"Specialty Care",RPT="M":"Mental Health",RPT="P":"Primary Care",1:"")
 S STRING="ReportType ReportType="""_RPT_""""
 Q STRING
FAC(SDFAC,XTYP) ; Return formatted Facility
 N SDFACDAT S SDFACDAT=$$SITE^VASITE()
 S STRING="VAFacility Name="""_$$SYMENC^MXMLUTL($P(SDFACDAT,"^",2))_""" ID="""_+SDFACDAT_"""" Q STRING
DIV(DIV,XTYP) ; Return formatted Division
 S DIVTAG=1
 S STRING="Division Name="""_$$DIVNAME^SDECXUTL(DIV)_"""" Q STRING
GRP(GRP,XTYP) ; Return Clinic Group
 N GRPNAM
 S GRPNAM=$$GRPNAM(GRP)
 I $G(XTYP)="M" S STRING="Rg="""_$S(GRPNAM]"":GRPNAM,1:"")_"""" Q STRING
 S STRING="Rg Rg="""_$S(GRPNAM]"":GRPNAM,1:"")_"""" Q STRING
GRPNAM(GRP) ; Get Group Name
 N DIC,DR,DA,DIQ S GRPNAM=""
 I GRP="All" S GRPNAM=GRP
 I ($G(GRPNAM)'="All") D
 .S GRPNAM=$P(GRP,"^",2)
 .I GRPNAM="" S GRPNAM="UNKNOWN" Q
 .S GRPNAM="("_+GRP_") "_GRPNAM
 Q $$SYMENC^MXMLUTL(GRPNAM)
CLIN(CLIN,FILT) ; Return formatted Clinic
 N CLNAM I CLIN["^" S CLIN=$P(CLIN,"^",2)
 S CLNAM=$S($G(CLIN):$P($G(^SC(+CLIN,0)),"^"),1:CLIN),CLNTAG=1
 S STRING="" I $G(FILT) S STRING="Rs "
 S STRING=STRING_"Rn="""_$$SYMENC^MXMLUTL(CLNAM)_"""" Q STRING
PROV(PROV) ; Return formatted Provider
 N PRVNAM S PRVNAM=""
 I $P(PROV,"^",2) S PRVNAM=$P(PROV,"^")
 I PRVNAM="" S PRVNAM=$S($G(PROV):$P($G(^VA(200,PROV,0)),"^"),1:PROV)
 I PRVNAM["^" S PRVNAM=$P(PRVNAM,"^") D
 .I PRVNAM=" None" S PRVNAM="N/A"
 S STRING="Pr="""_$$SYMENC^MXMLUTL(PRVNAM)_"""" Q STRING
DATE(DATE,DTFMT,SDACTDT,DTRANGE) ; Return formatted Date
 N BEGDT,ENDDT,RANGE,RANGEX,DTNAMEX
 S STRING="",RANGEX=""
 I $G(DTRANGE) S RANGE=$$XDATE^SDECXUTL($P(DTRANGE,"-"))_"-"_$$XDATE^SDECXUTL($P(DTRANGE,"-",2)) D
 .;S RANGEX=" DateRange="""_DTRANGE_""""
 .S DTNAMEX=" DateName="""_$P(RANGE,"^")_""""
 I '$G(DTRANGE) D BEGEND^SDECXUTL(DATE,.BEGDT,.ENDDT,DTFMT,SDACTDT) D
 .S RANGEX=" DateRange="""_BEGDT_"-"_ENDDT_""""
 .S DTNAMEX=" DateName="""_BEGDT_""""
 I DTFMT="Y"!(DTFMT="W") S STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_BEGDT_""" EndDate="""_ENDDT_""""_DTNAMEX_">"
 I DTFMT="Q" D
 .S DTNAMEX=" DateName="""_$P(DATE,"-",2)_"-"_$P(DATE,"-")_""""
 .S STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_BEGDT_""" EndDate="""_ENDDT_""""_DTNAMEX_">"
 I DTFMT="M" D
 .N X,Y,DTNAMEX,%DT S %DT="I" S DTNAMEX=" DateName="""_$$FMTE^XLFDT(DATE)_""""
 .S STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_BEGDT_""" EndDate="""_ENDDT_""""_DTNAMEX_">"
 I DTFMT="D" D
 .I '$G(DTRANGE) S STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_BEGDT_""" EndDate="""_ENDDT_""""_DTNAMEX_">" Q
 .S STRING="<Date ActivityDate="""_$$XDATE^SDECXUTL(SDACTDT)_""" BeginDate="""_$P(RANGE,"-")_""" EndDate="""_$P(RANGE,"-",2)_""""_DTNAMEX_">"
 Q STRING
ENC(ENC,TEL,NEW,EST) ; Return formatted number of encounters
 S STRING="Mn=""Encounters"" Vt=""Actual"" Vl="""_ENC_""""
 Q STRING
TEL(TEL) ; Return formatted telephone encounters
 S STRING="Mn=""Encounters"" Vt=""Telephone Encounters"" Vl="""_TEL_"""" Q STRING
NEW(NEW) ; Return new patients
 S STRING="Mn=""Encounters"" Vt=""New Patients"" Vl="""_NEW_"""" Q STRING
EST(EST) ; Return established patients
 S STRING="Mn=""Encounters"" Vt=""Established Patients"" Vl="""_EST_"""" Q STRING
RCAOVR(OVR) ; Appointment 
 S STRING="Mn=""Appointments"" Vt=""Overbooks"" Vl="""_OVR_""""
 Q STRING
RCADEM(DEM) ; Demand
 S DEM=DEM/60
 S STRING="Mn=""Total Demand"" Vt=""Actual"" Vl="""_$FN(DEM,",",2)_""""
 Q STRING
RCADEMA(DEM) ; Demand
 S DEM=DEM/60
 S STRING="Mn=""Adjusted Demand"" Vt=""Actual"" Vl="""_$FN(DEM,",",2)_""""
 Q STRING
RCASUP(SUP) ; Supply
 S STRING="Mn=""Total Supply"" Vt=""Actual"" Vl="""_$FN(SUP,",",2)_""""
 Q STRING
SETTMPF(SDLCNT,SDFILT,INDENTF,SDMEAS) ; Set/Write filter
 D SETFILT(.SDLCNT,SDFILT,$G(INDENTF))
 Q
 ;
SETFILT(SDLCNT,SDFILT,INDENT) ; Set ^XTMP  or Write
 Q:SDFILT=""  S SDLCNT=SDLCNT+1
 I $G(XMLNODE)="" S XMLNODE=$S($G(SDFLTFLG):"FLTXML",1:"SDECXML")
 I $G(INDENT) N PAD S $P(PAD," ",INDENT)=""
 I $G(SDEBUG) U IO W !,$G(PAD)_"<"_SDFILT_">"
 S ^XTMP("SDVSE",XMLNODE,SDLCNT)="<"_SDFILT_">"
 I $E(SDFILT,1,5)="Rg Rg" S GRPFLG=1
 I $E(SDFILT,1,8)="Division" S DIVTAG=1
 I $E(SDFILT,1,5)="Rs Rn" S CLNTAG=1
 Q
 ;
SETREC(SDLCNT,SDDATA,INDENT) ; Set/Write Record
 ;I SDDATA["Pr=""N/A""" Q
 N TMPREC,NEWDATA,TMPDATA
 I SDDATA["'" S SDDATA=$$PARSE(SDDATA,"'","'")
 S SDLCNT=$G(SDLCNT)+1
 S TMPREC="<Rc "_SDDATA_"/>"
 I $G(SDEBUG) U IO W !,?($G(INDENT)+1),TMPREC
 S ^XTMP("SDVSE",XMLNODE,SDLCNT)=TMPREC
 Q
 ;
 ; Pull out data and aggregate it
PARSE(STRING,CHAR,SUBS)  ; Aggregate pieces of node
 N NEWDATA,TMPDATA S NEWDATA="",TMPDATA=""
 I STRING[CHAR F I=1:1:$L(STRING,"'") D
 .S TMPDATA=$P(STRING,"'",I) S NEWDATA=NEWDATA_TMPDATA_$S(I=$L(STRING,CHAR):"",1:SUBS)
 Q NEWDATA
 ;
SDETFM(DATE) ; Convert external date to FM
 N X,Y,DATNAM
 S SDINTDT=""
 I ($G(DATE)?7N)!($G(DATE)?7N1"."1.N) Q DATE
 S X=DATE D ^%DT I Y>0 S SDINTDT=+Y
 Q $S($G(SDINTDT):SDINTDT,1:DATE)