GMTSYTQS ;SLC/JMH & ALB/ASF - MHA SCORE ; 10/3/07 12:05pm
;;2.7;Health Summary;**77,91**;Oct 20, 1995;Build 1
;
; External References
; DBIA 10035 ^DPT(
; DBIA 10103 $$FMTE^XLFDT
;
Q
EN ; MHA SCOREIT
N GMTS1,GMTS2,GMTSAI,GMTSAJ,GMTSCC,GMTSCOR,GMTSCS,GMTSCW,GMTSDATA
N GMTSDAY,GMTSDTM,GMTSGIV,GMTSI,GMTSJ,GMTSLO,GMTSLOC,GMTSLPG,GMTSNN,GMTSNPG,GMTSOR,GMTSQIT,GMTSRAW,GMTSSCL,GMTSTITL,GMTSTN,GMTSTRA,GMTSX,MAX,N
K ^TMP("GMTSYTQS",$J),^TMP("GMTSYTQSEG",$J)
S MAX=$S(+($G(GMTSNDM))>0:+($G(GMTSNDM)),1:9999999)
S:+($G(GMTSBEG))'>2700101 GMTSBEG=$$FMADD^XLFDT($P($$NOW^XLFDT,".",1),-1095,0,0,1),GMTSEND=$$FMADD^XLFDT($P($$NOW^XLFDT,".",1),1,0,0,1),GMTS2=9999999-GMTSBEG,GMTS1=9999999-GMTSEND
S:'$L($P(GMTSBEG,".",2)) GMTSBEG=$$FMADD^XLFDT(GMTSBEG,0,0,0,1)
S:+($G(GMTSEND))'>2700101!(+($G(GMTSEND))>+($$FMADD^XLFDT($P($$NOW^XLFDT,".",1),+1,0,0,2))) GMTSEND=$$FMADD^XLFDT($P($$NOW^XLFDT,".",1),1,0,0,1),GMTS1=9999999-GMTSEND
S:'$L($P(GMTSEND,".",2)) GMTSEND=$$FMADD^XLFDT(GMTSEND,0,0,0,1)
S:+($G(GMTSEND))>0&(+($G(GMTS1))=0) GMTS1=9999999-GMTSEND S:+($G(GMTSBEG))>0&(+($G(GMTS2))=0) GMTS2=9999999-GMTSBEG
S GMTSLO=+($G(GMTSLO)) S:GMTSLO=0 GMTSLO=3 S GMTSLPG=+($G(GMTSLPG)),GMTSDTM=$G(GMTSDTM) S:'$L(GMTSDTM) GMTSDTM=$$DTM
S:'$D(GMTSTITL)!('$L($G(GMTSTITL))) GMTSTITL="MHA Administrations"
S DFN=+($G(DFN)) Q:'$L($P($G(^DPT(DFN,0)),"^",1))
S GMTSCW(0)=+($G(IOM)) S:GMTSCW(0)=0 GMTSCW(0)=80
S GMTSCW(1)=5,GMTSCW(2)=10,GMTSCW(3)=20,GMTSCW(4)=GMTSCW(0)-(GMTSCW(1)+GMTSCW(2)+GMTSCW(3)+8)
S GMTSCW("L")=(GMTSCW(1)+GMTSCW(2)+GMTSCW(3)+GMTSCW(4)+6)
S GMTSCS(1)=1,GMTSCS(2)=GMTSCS(1)+GMTSCW(1)+2,GMTSCS(3)=GMTSCS(2)+GMTSCW(2)+2,GMTSCS(4)=GMTSCS(3)+GMTSCW(3)+2
D GET Q:'$D(^TMP("GMTSYTQS",$J)) D OUT
Q
OUT ; Output
N GMTSI,GMTSJ,GMTSNN
S GMTSNN=1
D HDR
S GMTSGIV="" F S GMTSGIV=$O(^TMP("GMTSYTQS",$J,GMTSGIV)) Q:GMTSGIV'>0!(GMTSNN>MAX) S GMTSTN="" F S GMTSTN=$O(^TMP("GMTSYTQS",$J,GMTSGIV,GMTSTN)) Q:GMTSTN="" D
. S GMTSJ=$G(^TMP("GMTSYTQS",$J,GMTSGIV,GMTSTN))
. S GMTSDAY=$$ITM(GMTSGIV)
. S GMTSOR=$P(GMTSJ,U,5) S:GMTSOR?1N.N GMTSOR=$$EXTERNAL^DILFD(601.84,5,,GMTSOR)
. S GMTSLOC=$P(GMTSJ,U,14) S:GMTSLOC?1N.N GMTSLOC=$$EXTERNAL^DILFD(601.84,13,,GMTSLOC)
. S GMTSNN=GMTSNN+1
. D LINE
. D:GMTSTN="GAF" GAFSCORE
. D:GMTSTN="ASI" ASISCORE
. D:(GMTSTN'="GAF")&(GMTSTN'="ASI") SCORE
K ^TMP("GMTSYTQS",$J),^TMP("GMTSYTQSEG",$J)
Q
SCORE ;
K GMTSX S:+GMTSJ GMTSX("AD")=+GMTSJ S:'(+GMTSJ) GMTSX("DFN")=DFN,GMTSX("CODE")=GMTSTN,GMTSX("ADATE")=9999999.999999-GMTSGIV
D GETSCORE^YTQAPI8(.GMTSDATA,.GMTSX)
Q:^TMP($J,"YSCOR",1)'="[DATA]"
S N=1 F S N=$O(^TMP($J,"YSCOR",N)) Q:N'>0 D
. S GMTSCOR=^TMP($J,"YSCOR",N)
. S GMTSSCL=$P(GMTSCOR,"=")
. S:$L(GMTSSCL)>15 GMTSSCL=$E(GMTSSCL,1,15)_"*"
. S GMTSRAW=$P(GMTSCOR,"=",2),GMTSRAW=$P(GMTSRAW,U)
. S GMTSTRA=$P(GMTSCOR,"=",2),GMTSTRA=$P(GMTSTRA,U,2)
. D CKP^GMTSUP Q:$D(GMTSQIT)
. D:GMTSNPG=1 HDR
. W ?42,$J(GMTSRAW,5)," ",$J(GMTSTRA,8)," ",GMTSSCL,!
Q
GAFSCORE ;
W $J($P(GMTSJ,U,2),5),!
Q
ASISCORE ;
N IFN
S IFN=+GMTSJ
W ?42,$J($$GET1^DIQ(604,IFN_",",8.12),5),$J($$GET1^DIQ(604,IFN_",",.61),8)," Medical",!
W ?42,$J($$GET1^DIQ(604,IFN_",",9.34),5),$J($$GET1^DIQ(604,IFN_",",.62),5)," Employment",!
W ?42,$J($$GET1^DIQ(604,IFN_",",11.18),5),$J($$GET1^DIQ(604,IFN_",",.63),5)," Alcohol",!
W ?42,$J($$GET1^DIQ(604,IFN_",",11.185),5),$J($$GET1^DIQ(604,IFN_",",.635),5)," Drug",!
W ?42,$J($$GET1^DIQ(604,IFN_",",14.34),5),$J($$GET1^DIQ(604,IFN_",",.64),5)," Legal",!
W ?42,$J($$GET1^DIQ(604,IFN_",",18.29),5),$J($$GET1^DIQ(604,IFN_",",.65),5)," Family",!
W ?42,$J($$GET1^DIQ(604,IFN_",",19.33),5),$J($$GET1^DIQ(604,IFN_",",.66),5)," Psychiatric",!
Q
LINE ; Output One Line
D CKP^GMTSUP Q:$D(GMTSQIT)
D:GMTSNPG=1 HDR
W GMTSDAY,?20,$J($E(GMTSTN,1,20)_$S($L(GMTSTN)>20:"* ",1:" "),22)
Q
HDR ; Header
N GMTSI S GMTSI="",$P(GMTSI,"-",+($G(GMTSCW("L"))))="-"
D CKP^GMTSUP Q:$D(GMTSQIT) G:GMTSNPG=1 HDR W "Date",?31,"Instrument Raw Trans Scale",!
Q
GET ; Get and Format Data
N %DT,X,Y,GMTSNN,GMTSGIV,GMTSTN
K ^TMP("GMTSYTQSEG",$J)
;selctions
S GMTSCC=0 F S GMTSCC=$O(GMTSEG(GMTSCC)) Q:GMTSCC'>0 Q:$D(GMTSEG($G(GMTSCC,0),601.71)) ;ASF 7/6/07
Q:GMTSCC'>0 ;must have a selection
S GMTSAI=0 F S GMTSAI=$O(GMTSEG(GMTSCC,601.71,GMTSAI)) Q:GMTSAI'>0 S GMTSAJ=GMTSEG(GMTSCC,601.71,GMTSAI),^TMP("GMTSYTQSEG",$J,$P(^YTT(601.71,GMTSAJ,0),U))=""
;
S GMTSNN=0
K GMTSX
S GMTSX("DFN")=DFN,GMTSX("COMPLETE")="Y" D ADMINS^YTQAPI5(.GMTSDATA,.GMTSX)
Q:'$D(GMTSDATA(3))
S N=2 F S N=$O(GMTSDATA(N)) Q:N'>0!(GMTSNN>MAX) D
. S GMTSTN=$P(GMTSDATA(N),U,2) Q:GMTSTN=""
. Q:'$D(^TMP("GMTSYTQSEG",$J,GMTSTN))
. S GMTSGIV=$P($G(GMTSDATA(N)),U,3) Q:GMTSGIV'?7N.E
. Q:GMTSGIV<GMTSBEG
. Q:GMTSGIV>GMTSEND
. S GMTSNN=GMTSNN+1
. F Q:'$D(^TMP("GMTSYTQS",$J,9999999.999999-GMTSGIV,GMTSTN)) S GMTSGIV=GMTSGIV+.00000001 ; 2/3/09 *91 - VM/RJT
. S ^TMP("GMTSYTQS",$J,9999999.999999-GMTSGIV,GMTSTN)=GMTSDATA(N)
K GMTSDATA
D:$D(^TMP("GMTSYTQSEG",$J,"GAF")) GAFGET
K GMTSDATA
D:$D(^TMP("GMTSYTQSEG",$J,"ASI")) ASIGET
Q
ASIGET ;
N G,GMTSIEN,GMTSNN,GMTSELS
S GMTSNN=0
S GMTSIEN=0
F S GMTSIEN=$O(^YSTX(604,"C",DFN,GMTSIEN)) Q:GMTSIEN'>0 D
. S G=^YSTX(604,GMTSIEN,0)
. S GMTSGIV=$P(G,U,12)
. S GMTSELS=$P($G(^YSTX(604,GMTSIEN,.5)),U)
. Q:GMTSELS'=1
. Q:GMTSGIV<GMTSBEG
. Q:GMTSGIV>GMTSEND
. S GMTSNN=GMTSNN+1
. S ^TMP("GMTSYTQS",$J,9999999.999999-GMTSGIV,"ASI")=GMTSIEN
Q
GAFGET ;get axis5
N G,N,GMTSNN
S GMTSNN=0
S GMTSX("DFN")=DFN D GAFRET^YTQAPI6(.GMTSDATA,.GMTSX)
Q:'$D(GMTSDATA(2))
S N=1 F S N=$O(GMTSDATA(N)) Q:N'>0!(GMTSNN>MAX) D
. S G=GMTSDATA(N)
. S GMTSGIV=$P(^YSD(627.8,+G,0),U)
. Q:GMTSGIV<GMTSBEG
. Q:GMTSGIV>GMTSEND
. S GMTSNN=GMTSNN+1
. S ^TMP("GMTSYTQS",$J,9999999.999999-GMTSGIV,"GAF")=+G_U_$P(G,U,2)
Q
ITM(X) ; Inverse date to Mental Health formats
S X=+($G(X)) Q:X=0 "" S X=9999999.999999-X D REGDTM4^GMTSU Q X
DTM(X) ; Current Date and Time (External)
S X=$$NOW^XLFDT D REGDTM4^GMTSU Q X
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMTSYTQS 6106 printed Dec 13, 2024@02:01:20 Page 2
GMTSYTQS ;SLC/JMH & ALB/ASF - MHA SCORE ; 10/3/07 12:05pm
+1 ;;2.7;Health Summary;**77,91**;Oct 20, 1995;Build 1
+2 ;
+3 ; External References
+4 ; DBIA 10035 ^DPT(
+5 ; DBIA 10103 $$FMTE^XLFDT
+6 ;
+7 QUIT
EN ; MHA SCOREIT
+1 NEW GMTS1,GMTS2,GMTSAI,GMTSAJ,GMTSCC,GMTSCOR,GMTSCS,GMTSCW,GMTSDATA
+2 NEW GMTSDAY,GMTSDTM,GMTSGIV,GMTSI,GMTSJ,GMTSLO,GMTSLOC,GMTSLPG,GMTSNN,GMTSNPG,GMTSOR,GMTSQIT,GMTSRAW,GMTSSCL,GMTSTITL,GMTSTN,GMTSTRA,GMTSX,MAX,N
+3 KILL ^TMP("GMTSYTQS",$JOB),^TMP("GMTSYTQSEG",$JOB)
+4 SET MAX=$SELECT(+($GET(GMTSNDM))>0:+($GET(GMTSNDM)),1:9999999)
+5 if +($GET(GMTSBEG))'>2700101
SET GMTSBEG=$$FMADD^XLFDT($PIECE($$NOW^XLFDT,".",1),-1095,0,0,1)
SET GMTSEND=$$FMADD^XLFDT($PIECE($$NOW^XLFDT,".",1),1,0,0,1)
SET GMTS2=9999999-GMTSBEG
SET GMTS1=9999999-GMTSEND
+6 if '$LENGTH($PIECE(GMTSBEG,".",2))
SET GMTSBEG=$$FMADD^XLFDT(GMTSBEG,0,0,0,1)
+7 if +($GET(GMTSEND))'>2700101!(+($GET(GMTSEND))>+($$FMADD^XLFDT($PIECE($$NOW^XLFDT,".",1),+1,0,0,2)))
SET GMTSEND=$$FMADD^XLFDT($PIECE($$NOW^XLFDT,".",1),1,0,0,1)
SET GMTS1=9999999-GMTSEND
+8 if '$LENGTH($PIECE(GMTSEND,".",2))
SET GMTSEND=$$FMADD^XLFDT(GMTSEND,0,0,0,1)
+9 if +($GET(GMTSEND))>0&(+($GET(GMTS1))=0)
SET GMTS1=9999999-GMTSEND
if +($GET(GMTSBEG))>0&(+($GET(GMTS2))=0)
SET GMTS2=9999999-GMTSBEG
+10 SET GMTSLO=+($GET(GMTSLO))
if GMTSLO=0
SET GMTSLO=3
SET GMTSLPG=+($GET(GMTSLPG))
SET GMTSDTM=$GET(GMTSDTM)
if '$LENGTH(GMTSDTM)
SET GMTSDTM=$$DTM
+11 if '$DATA(GMTSTITL)!('$LENGTH($GET(GMTSTITL)))
SET GMTSTITL="MHA Administrations"
+12 SET DFN=+($GET(DFN))
if '$LENGTH($PIECE($GET(^DPT(DFN,0)),"^",1))
QUIT
+13 SET GMTSCW(0)=+($GET(IOM))
if GMTSCW(0)=0
SET GMTSCW(0)=80
+14 SET GMTSCW(1)=5
SET GMTSCW(2)=10
SET GMTSCW(3)=20
SET GMTSCW(4)=GMTSCW(0)-(GMTSCW(1)+GMTSCW(2)+GMTSCW(3)+8)
+15 SET GMTSCW("L")=(GMTSCW(1)+GMTSCW(2)+GMTSCW(3)+GMTSCW(4)+6)
+16 SET GMTSCS(1)=1
SET GMTSCS(2)=GMTSCS(1)+GMTSCW(1)+2
SET GMTSCS(3)=GMTSCS(2)+GMTSCW(2)+2
SET GMTSCS(4)=GMTSCS(3)+GMTSCW(3)+2
+17 DO GET
if '$DATA(^TMP("GMTSYTQS",$JOB))
QUIT
DO OUT
+18 QUIT
OUT ; Output
+1 NEW GMTSI,GMTSJ,GMTSNN
+2 SET GMTSNN=1
+3 DO HDR
+4 SET GMTSGIV=""
FOR
SET GMTSGIV=$ORDER(^TMP("GMTSYTQS",$JOB,GMTSGIV))
if GMTSGIV'>0!(GMTSNN>MAX)
QUIT
SET GMTSTN=""
FOR
SET GMTSTN=$ORDER(^TMP("GMTSYTQS",$JOB,GMTSGIV,GMTSTN))
if GMTSTN=""
QUIT
Begin DoDot:1
+5 SET GMTSJ=$GET(^TMP("GMTSYTQS",$JOB,GMTSGIV,GMTSTN))
+6 SET GMTSDAY=$$ITM(GMTSGIV)
+7 SET GMTSOR=$PIECE(GMTSJ,U,5)
if GMTSOR?1N.N
SET GMTSOR=$$EXTERNAL^DILFD(601.84,5,,GMTSOR)
+8 SET GMTSLOC=$PIECE(GMTSJ,U,14)
if GMTSLOC?1N.N
SET GMTSLOC=$$EXTERNAL^DILFD(601.84,13,,GMTSLOC)
+9 SET GMTSNN=GMTSNN+1
+10 DO LINE
+11 if GMTSTN="GAF"
DO GAFSCORE
+12 if GMTSTN="ASI"
DO ASISCORE
+13 if (GMTSTN'="GAF")&(GMTSTN'="ASI")
DO SCORE
End DoDot:1
+14 KILL ^TMP("GMTSYTQS",$JOB),^TMP("GMTSYTQSEG",$JOB)
+15 QUIT
SCORE ;
+1 KILL GMTSX
if +GMTSJ
SET GMTSX("AD")=+GMTSJ
if '(+GMTSJ)
SET GMTSX("DFN")=DFN
SET GMTSX("CODE")=GMTSTN
SET GMTSX("ADATE")=9999999.999999-GMTSGIV
+2 DO GETSCORE^YTQAPI8(.GMTSDATA,.GMTSX)
+3 if ^TMP($JOB,"YSCOR",1)'="[DATA]"
QUIT
+4 SET N=1
FOR
SET N=$ORDER(^TMP($JOB,"YSCOR",N))
if N'>0
QUIT
Begin DoDot:1
+5 SET GMTSCOR=^TMP($JOB,"YSCOR",N)
+6 SET GMTSSCL=$PIECE(GMTSCOR,"=")
+7 if $LENGTH(GMTSSCL)>15
SET GMTSSCL=$EXTRACT(GMTSSCL,1,15)_"*"
+8 SET GMTSRAW=$PIECE(GMTSCOR,"=",2)
SET GMTSRAW=$PIECE(GMTSRAW,U)
+9 SET GMTSTRA=$PIECE(GMTSCOR,"=",2)
SET GMTSTRA=$PIECE(GMTSTRA,U,2)
+10 DO CKP^GMTSUP
if $DATA(GMTSQIT)
QUIT
+11 if GMTSNPG=1
DO HDR
+12 WRITE ?42,$JUSTIFY(GMTSRAW,5)," ",$JUSTIFY(GMTSTRA,8)," ",GMTSSCL,!
End DoDot:1
+13 QUIT
GAFSCORE ;
+1 WRITE $JUSTIFY($PIECE(GMTSJ,U,2),5),!
+2 QUIT
ASISCORE ;
+1 NEW IFN
+2 SET IFN=+GMTSJ
+3 WRITE ?42,$JUSTIFY($$GET1^DIQ(604,IFN_",",8.12),5),$JUSTIFY($$GET1^DIQ(604,IFN_",",.61),8)," Medical",!
+4 WRITE ?42,$JUSTIFY($$GET1^DIQ(604,IFN_",",9.34),5),$JUSTIFY($$GET1^DIQ(604,IFN_",",.62),5)," Employment",!
+5 WRITE ?42,$JUSTIFY($$GET1^DIQ(604,IFN_",",11.18),5),$JUSTIFY($$GET1^DIQ(604,IFN_",",.63),5)," Alcohol",!
+6 WRITE ?42,$JUSTIFY($$GET1^DIQ(604,IFN_",",11.185),5),$JUSTIFY($$GET1^DIQ(604,IFN_",",.635),5)," Drug",!
+7 WRITE ?42,$JUSTIFY($$GET1^DIQ(604,IFN_",",14.34),5),$JUSTIFY($$GET1^DIQ(604,IFN_",",.64),5)," Legal",!
+8 WRITE ?42,$JUSTIFY($$GET1^DIQ(604,IFN_",",18.29),5),$JUSTIFY($$GET1^DIQ(604,IFN_",",.65),5)," Family",!
+9 WRITE ?42,$JUSTIFY($$GET1^DIQ(604,IFN_",",19.33),5),$JUSTIFY($$GET1^DIQ(604,IFN_",",.66),5)," Psychiatric",!
+10 QUIT
LINE ; Output One Line
+1 DO CKP^GMTSUP
if $DATA(GMTSQIT)
QUIT
+2 if GMTSNPG=1
DO HDR
+3 WRITE GMTSDAY,?20,$JUSTIFY($EXTRACT(GMTSTN,1,20)_$SELECT($LENGTH(GMTSTN)>20:"* ",1:" "),22)
+4 QUIT
HDR ; Header
+1 NEW GMTSI
SET GMTSI=""
SET $PIECE(GMTSI,"-",+($GET(GMTSCW("L"))))="-"
+2 DO CKP^GMTSUP
if $DATA(GMTSQIT)
QUIT
if GMTSNPG=1
GOTO HDR
WRITE "Date",?31,"Instrument Raw Trans Scale",!
+3 QUIT
GET ; Get and Format Data
+1 NEW %DT,X,Y,GMTSNN,GMTSGIV,GMTSTN
+2 KILL ^TMP("GMTSYTQSEG",$JOB)
+3 ;selctions
+4 ;ASF 7/6/07
SET GMTSCC=0
FOR
SET GMTSCC=$ORDER(GMTSEG(GMTSCC))
if GMTSCC'>0
QUIT
if $DATA(GMTSEG($GET(GMTSCC,0),601.71))
QUIT
+5 ;must have a selection
if GMTSCC'>0
QUIT
+6 SET GMTSAI=0
FOR
SET GMTSAI=$ORDER(GMTSEG(GMTSCC,601.71,GMTSAI))
if GMTSAI'>0
QUIT
SET GMTSAJ=GMTSEG(GMTSCC,601.71,GMTSAI)
SET ^TMP("GMTSYTQSEG",$JOB,$PIECE(^YTT(601.71,GMTSAJ,0),U))=""
+7 ;
+8 SET GMTSNN=0
+9 KILL GMTSX
+10 SET GMTSX("DFN")=DFN
SET GMTSX("COMPLETE")="Y"
DO ADMINS^YTQAPI5(.GMTSDATA,.GMTSX)
+11 if '$DATA(GMTSDATA(3))
QUIT
+12 SET N=2
FOR
SET N=$ORDER(GMTSDATA(N))
if N'>0!(GMTSNN>MAX)
QUIT
Begin DoDot:1
+13 SET GMTSTN=$PIECE(GMTSDATA(N),U,2)
if GMTSTN=""
QUIT
+14 if '$DATA(^TMP("GMTSYTQSEG",$JOB,GMTSTN))
QUIT
+15 SET GMTSGIV=$PIECE($GET(GMTSDATA(N)),U,3)
if GMTSGIV'?7N.E
QUIT
+16 if GMTSGIV<GMTSBEG
QUIT
+17 if GMTSGIV>GMTSEND
QUIT
+18 SET GMTSNN=GMTSNN+1
+19 ; 2/3/09 *91 - VM/RJT
FOR
if '$DATA(^TMP("GMTSYTQS",$JOB,9999999.999999-GMTSGIV,GMTSTN))
QUIT
SET GMTSGIV=GMTSGIV+.00000001
+20 SET ^TMP("GMTSYTQS",$JOB,9999999.999999-GMTSGIV,GMTSTN)=GMTSDATA(N)
End DoDot:1
+21 KILL GMTSDATA
+22 if $DATA(^TMP("GMTSYTQSEG",$JOB,"GAF"))
DO GAFGET
+23 KILL GMTSDATA
+24 if $DATA(^TMP("GMTSYTQSEG",$JOB,"ASI"))
DO ASIGET
+25 QUIT
ASIGET ;
+1 NEW G,GMTSIEN,GMTSNN,GMTSELS
+2 SET GMTSNN=0
+3 SET GMTSIEN=0
+4 FOR
SET GMTSIEN=$ORDER(^YSTX(604,"C",DFN,GMTSIEN))
if GMTSIEN'>0
QUIT
Begin DoDot:1
+5 SET G=^YSTX(604,GMTSIEN,0)
+6 SET GMTSGIV=$PIECE(G,U,12)
+7 SET GMTSELS=$PIECE($GET(^YSTX(604,GMTSIEN,.5)),U)
+8 if GMTSELS'=1
QUIT
+9 if GMTSGIV<GMTSBEG
QUIT
+10 if GMTSGIV>GMTSEND
QUIT
+11 SET GMTSNN=GMTSNN+1
+12 SET ^TMP("GMTSYTQS",$JOB,9999999.999999-GMTSGIV,"ASI")=GMTSIEN
End DoDot:1
+13 QUIT
GAFGET ;get axis5
+1 NEW G,N,GMTSNN
+2 SET GMTSNN=0
+3 SET GMTSX("DFN")=DFN
DO GAFRET^YTQAPI6(.GMTSDATA,.GMTSX)
+4 if '$DATA(GMTSDATA(2))
QUIT
+5 SET N=1
FOR
SET N=$ORDER(GMTSDATA(N))
if N'>0!(GMTSNN>MAX)
QUIT
Begin DoDot:1
+6 SET G=GMTSDATA(N)
+7 SET GMTSGIV=$PIECE(^YSD(627.8,+G,0),U)
+8 if GMTSGIV<GMTSBEG
QUIT
+9 if GMTSGIV>GMTSEND
QUIT
+10 SET GMTSNN=GMTSNN+1
+11 SET ^TMP("GMTSYTQS",$JOB,9999999.999999-GMTSGIV,"GAF")=+G_U_$PIECE(G,U,2)
End DoDot:1
+12 QUIT
ITM(X) ; Inverse date to Mental Health formats
+1 SET X=+($GET(X))
if X=0
QUIT ""
SET X=9999999.999999-X
DO REGDTM4^GMTSU
QUIT X
DTM(X) ; Current Date and Time (External)
+1 SET X=$$NOW^XLFDT
DO REGDTM4^GMTSU
QUIT X