GMRCP5A ;SLC/DCM,RJS,MA - Print Consult form 513 (Gather Data - TIU Results) ;15-Mar-2012 10:40;PLS
;;3.0;CONSULT/REQUEST TRACKING;**4,13,12,15,21,22,1001,53,1003**;Dec 27, 1997;Build 14
; Patch #21 added PRNTAUDT to this routine.
;Modified - IHS/CIA/MGH - 11/29/2005 - Line FORMAT+8 Added code to use HRCN instead of SSN
;
PRNT(GMRCIFN,TIUFLG,GMRCQUED,GMRCCPY,GMRCGUI,GMRCAUDT) ;
;
; Input Arguments:
;
; GMRCIFN: IEN of the Consult/Request in file 123
; TIUFLG: Called from TIU ? 1=yes 0=no
; GMRCQUED: Queued job ? 1=yes 0=no
; GMRCCPY: Chart Copy ? C=Chart Copy W=Working Copy null=Not Applicable
; GMRCGUI: Called from the GUI. (Only produce output in a formatted global.)
; GMRCAUDT: Set to 1 in GMRCUTL1 if NW or DC consult.
; ZTIO: Output device when job is tasked
;
N GMRCSIG,GMRCSDT,GMRCCSIG,GMRCSIGT,GMRCADDS
I '+$G(IOM) S IOM=80
;
I GMRCGUI D Q
. D FORMAT(80)
. D ASSMBL^GMRCP5C(GMRCGUI,80)
. F GMRCX="GMRCTIU","RES","MCAR" K ^TMP("GMRCR",$J,GMRCX)
. K ^TMP("GMRC",$J,"OUTPUT")
. Q
;
I 'TIUFLG,'GMRCQUED W @IOF I '$$CRT^GMRCP5C,$L($G(IO(0))),'(IO=IO(0)) U IO(0) W !,"PRINTING... "
;
D FORMAT(IOM),ASSMBL^GMRCP5C(IOSL,IOM)
U IO
D PRINT^GMRCP5C(IOSL,IOM)
;
I 'TIUFLG,'$$CRT^GMRCP5C U IO(0) D ^%ZISC
;
I $G(GMRCQUED),$G(ZTSK) D KILL^%ZTLOAD
;
F GMRCX="OUTPUT","SF513" K ^TMP("GMRC",$J,GMRCX)
F GMRCX="GMRCTIU","RES","MCAR" K ^TMP("GMRCR",$J,GMRCX)
; If print device (ZTIO) do PRNTAUDT unless there is no GMRCAUDT
; GMRCAUDT=1 means print for NW or DC consult
I $D(ZTIO),$D(GMRCAUDT) D PRNTAUDT(GMRCIFN,ZTIO,GMRCAUDT)
Q
;
PRNTAUDT(GMRCIFN,ZTIO,GMRCAUDT) ; Update the last activity field in 123 and
; Processing Activity multiple
; Update the activity log to reflect "Printed To:" and the printer
; GMRCAUDT=1 indicates the consult is NW or Discontinued
; and it should update the audit trail.
I $G(GMRCAUDT)'=1 K GMRCAUDT Q
N GMRCOM,GMRCORNP,GMRCFF,GMRCPA,GMRCAD,GMRCA,DA,DIE
S GMRCA=22
S GMRCO=GMRCIFN,GMRCDEV=ZTIO
S DIE="^GMR(123,",DA=+GMRCO,DR="9////^S X=GMRCA"
L +^GMR(123,GMRCO):5
D ^DIE
L -^GMR(123,GMRCO)
;Update activity other than HL7 original msg received
D AUDIT^GMRCP
KILL GMRCO,GMRCA,GMRCDEV
Q
;
FORMAT(PAGEWID) ;
;
N %I,CMT,COUNT,D0,DFN,DIC,DIQ2,DR,GLOBAL,GMRC400,GMRCADD,GMRCADDT,GMRCAGE,GMRCCSDT
N GMRCCTIT,GMRCDFN,GMRCDOB,GMRCDVL,GMRCELIG,GMRCEQL,GMRCERR,GMRCFAC,GMRCFP
N GMRCFTR,GMRCIPH,GMRCINO,GMRCIRL,GMRCLAST,GMRCMODE,GMRCND,GMRCNDX,GMRCNT,GMRCPG,GMRCPGR,GMRCPNM,GMRCPRNM
N GMRCPTR,GMRCQSTR,GMRCQSTT,GMRCR0,GMRCR1,GMRCR2,GMRCRB,GMRCRD,GMRCRPT,GMRCSG,GMRCSGAD,GMRCSIGM
N GMRCSN,GMRCSR,GMRCSVC,GMRCTO,GMRCUL,GMRCWARD,GMRCWLI,GMRCX,LN,MCFILE,MCPROC
N ND,ND1,ND2,NDS,ORACTION,SEX,TAB,X,Y
N GMRCHRCN ;IHS/MSC/MGH
;
S GMRCFTR=13,GMRCFP=0,GMRCPG=0
S GMRCRD=$G(^GMR(123,GMRCIFN,0)),(DFN,GMRCDFN)=$P(GMRCRD,U,2)
Q:'(DFN)
D ELIG^VADPT S GMRCELIG=$P(VAEL(6),U,2) K VAEL
S GMRCDVL="",$P(GMRCDVL,"-",PAGEWID+1)=""
S GMRCEQL="",$P(GMRCEQL,"=",PAGEWID+1)=""
S GMRCUL="",$P(GMRCUL,"_",40)=""
S DFN=GMRCDFN D DEM^GMRCU
;
S GMRCFAC=+$P(GMRCRD,U,21)
I 'GMRCFAC S GMRCFAC=+$G(DUZ(2))
I 'GMRCFAC S GMRCFAC=+$$SITE^VASITE()
I +GMRCFAC S GMRCFAC=$$GET1^DIQ(4,+GMRCFAC,.01)
E S GMRCFAC="" Q
;
; get inter-facility consult info
I $P(GMRCRD,U,23) D
.S GMRCINO=$P(GMRCRD,U,22)
.S GMRCRD(12)=$G(^GMR(123,GMRCIFN,12))
.S GMRCRD(13)=$G(^GMR(123,GMRCIFN,13))
.S GMRCIRL=$S($P(GMRCRD(12),U,5)="P":"Requesting facility",$P(GMRCRD(12),U,5)="F":"Consulting facility",1:"")
;Commented out following line to allow TIU doc to print based on ASU
;rules.
;I $P(GMRCRD,U,12)=2!(TIUFLG) D
D PRINT^GMRCTIUP(GMRCIFN,0,0) ;Removed dot structure
;
K GMRCSG I $D(^TMP("GMRCR",$J,"RES")) D
.;
.S GMRCR0=0 F Q:$D(GMRCSG) S GMRCR0=$O(^TMP("GMRCR",$J,"RES",GMRCR0)) Q:'GMRCR0 D
..F GMRCV="GMRCSDT","GMRCSIG","GMRCSIGM","GMRCSIGT" S @GMRCV=$G(^TMP("GMRCR",$J,"RES",GMRCR0,"TEXT",GMRCV))
..Q:'$L($G(GMRCSIG))
..F GMRCV="GMRCSDT","GMRCSIG","GMRCSIGM","GMRCSIGT" S GMRCSG(GMRCV)=@GMRCV
;
D INIT^GMRCP5B(.GMRCSG) ; Build Header, Footer, Request, and Primary Diagnosis Segments
;
I $L($G(GMRCCPY)) D
.D BLD("RES",1,1,0,$$CENTER($S(GMRCCPY="C":"C H A R T C O P Y",1:"W O R K I N G C O P Y")))
I ($P(GMRCRD,U,19)="Y") D
.D BLD("RES",1,1,0,$$CENTER("******* Significant Findings *******"))
I ($P(GMRCRD,U,19)="N") D
.D BLD("RES",1,1,0,$$CENTER("******* No Significant Findings *******"))
I ($P(GMRCRD,U,19)="U") D
.D BLD("RES",1,1,0,$$CENTER("******* Unknown Significant Findings *******"))
;
I $P(GMRCRD,U,12)=1 D
. D BLD("RES",1,2,0,$$CENTER("**** REQUEST CANCELLED REQUEST CANCELLED ****"))
I '$D(^TMP("GMRCR",$J,"RES")),'$D(^("MCAR")) D
.I $L($G(GMRCRPT)) D BLD("RES",1,2,0,$$CENTER(" No Consultation Results for "_GMRCRPT_" available."))
.I '$L($G(GMRCRPT)) D BLD("RES",1,2,0,$$CENTER(" No Consultation Results available."))
;
I $D(^TMP("GMRCR",$J,"RES")) D
.;
.S (GMRCNT,GMRCR0)=0 F S GMRCR0=$O(^TMP("GMRCR",$J,"RES",GMRCR0)) Q:'GMRCR0 D
..N GMRCCSDT,GMRCCSGM,GMRCCSIG,GMRCCTIT,GMRCRPT,GMRCSDT
..N GMRCSIG,GMRCSIGM,GMRCSIGT,GMRCV,GMRCENT,GMRCVIS,GMRCVLOC,GMRCNODT
..;
..F GMRCV="GMRCCSDT","GMRCCSGM","GMRCCSIG","GMRCCTIT","GMRCRPT","GMRCSDT","GMRCSIG","GMRCSIGM","GMRCSIGT","GMRCVIS","GMRCENT","GMRCVLOC","GMRCNODT" D
...S @GMRCV=$G(^TMP("GMRCR",$J,"RES",GMRCR0,"TEXT",GMRCV))
..;
..S GMRCNDX=$O(^TMP("GMRC",$J,"OUTPUT","RES"," "),-1)+1
..I $L($G(GMRCRPT)) D SUB("H","RES",GMRCNDX,"Consultation Results "_$S(GMRCR0=.5:"",1:"#"_GMRCR0_" ")_"for "_GMRCRPT_" continued.")
..I '$L($G(GMRCRPT)) D SUB("H","RES",GMRCNDX,"Consultation Results "_$S(GMRCR0=.5:"",1:"#"_GMRCR0_" ")_"continued.")
..D SUB("H","RES",GMRCNDX," ")
..I $L($G(GMRCSIG)) D
...D SUB("F","RES",GMRCNDX," ")
...I (GMRCSIGM="electronic") S GMRCX=" Results Signature: "_GMRCSIG_" /es/ "_$$EXDT($G(GMRCSDT))
...I '(GMRCSIGM="electronic") S GMRCX=" Results Signature: "_GMRCSIG_" /chart/ " S:$L($G(GMRCSDT)) GMRCX=GMRCX_$$EXDT(GMRCSDT)
...D SUB("F","RES",GMRCNDX,GMRCX)
...D:$L($G(GMRCSIGT)) SUB("F","RES",GMRCNDX," "_GMRCSIGT)
..I $L($G(GMRCCSIG)) D
...D SUB("F","RES",GMRCNDX," ")
...I (GMRCCSGM="electronic") S GMRCX=" Results CoSignature: "_GMRCCSIG_" /es/ "_$$EXDT($G(GMRCCSDT))
...I '(GMRCCSGM="electronic") S GMRCX=" Results CoSignature: "_GMRCCSIG_" /chart/ " S:$L($G(GMRCCSDT)) GMRCX=GMRCX_$$EXDT(GMRCCSDT)
...D SUB("F","RES",GMRCNDX,GMRCX)
...D:$L($G(GMRCCTIT)) SUB("F","RES",GMRCNDX," "_GMRCCTIT)
..;extra signers
.. I $D(^TMP("GMRCR",$J,"RES",GMRCR0,"TEXT","GMRCXTRA")) D
... D SUB("F","RES",GMRCNDX," ")
... D SUB("F","RES",GMRCNDX," Receipt acknowledged by: ")
... N XTRA S XTRA=0 F S XTRA=$O(^TMP("GMRCR",$J,"RES",GMRCR0,"TEXT","GMRCXTRA",XTRA)) Q:'XTRA D
.... D SUB("F","RES",GMRCNDX,^TMP("GMRCR",$J,"RES",GMRCR0,"TEXT","GMRCXTRA",XTRA,0))
.... D SUB("F","RES",GMRCNDX,^TMP("GMRCR",$J,"RES",GMRCR0,"TEXT","GMRCXTRA",XTRA,1))
..;
..D BLD("RES",GMRCNDX,1,0," ")
..I $L($G(GMRCRPT)) D BLD("RES",GMRCNDX,1,0,$$CENTER("CONSULTATION NOTE "_$S(GMRCR0=.5:"",1:"#"_GMRCR0_" ")_"FOR "_GMRCRPT))
..I '$L($G(GMRCRPT)) D BLD("RES",GMRCNDX,1,0,$$CENTER("CONSULTATION NOTE "_$S(GMRCR0=.5:"",1:"#"_GMRCR0)))
..D BLD("RES",GMRCNDX,1,0," ")
..I $L($G(GMRCENT)) D
...S GMRCX=" Entry Date: "_$$EXDT($G(GMRCENT))
...D BLD("RES",GMRCNDX,1,0,GMRCX)
..I $L($G(GMRCNODT)) D
...Q:$$EXDT($G(GMRCNODT))=$$EXDT($G(GMRCENT))
...S GMRCX="Date/Time of result: "_$$EXDT($G(GMRCNODT))
...D BLD("RES",GMRCNDX,1,0,GMRCX)
..I $L($G(GMRCVIS)) D
...S GMRCX=" Visit: "_$$EXDT($G(GMRCVIS))
...I $L($G(GMRCVLOC)) S GMRCX=GMRCX_" "_GMRCVLOC
...D BLD("RES",GMRCNDX,1,0,GMRCX)
..I $L($G(GMRCVLOC)) S GMRCX=GMRCVLOC
..D BLD("RES",GMRCNDX,1,0," ")
..I $D(^TMP("GMRCR",$J,"RES",GMRCR0,"TEXT",0,0)) D I 1
...D BLD("RES",GMRCNDX,1,0,^TMP("GMRCR",$J,"RES",GMRCR0,"TEXT",0,0))
..E I '$O(^TMP("GMRCR",$J,"RES",GMRCR0,"TEXT","")) D
...D BLD("RES",1,1,0,$$CENTER("CONSULTATION NOTE TEXT NOT AVAILABLE"))
..S GMRCR1=0 F S GMRCR1=$O(^TMP("GMRCR",$J,"RES",GMRCR0,"TEXT",GMRCR1)) Q:'GMRCR1 D
...D BLD("RES",GMRCNDX,1,0,^TMP("GMRCR",$J,"RES",GMRCR0,"TEXT",GMRCR1,0))
..;
..; GET ADDENDUMS TO THIS NOTE
..;
..I +$O(^TMP("GMRCR",$J,"RES",GMRCR0,"ADD",0)) D ADDEND^GMRCP5D(GMRCIFN,GMRCR0,GMRCNDX,GMRCRD,PAGEWID)
;
D FORMAT^GMRCP5D(GMRCIFN,GMRCRD,PAGEWID) ; GET SERVICE REPORTS AND COMMENTS
;
Q
;
EXDT(X) ;EXTERNAL DATE FORMAT
;
N DATE,TIME,HR,MN,PD,Y,%DT
Q:'$L(X) ""
I '(X?7N.1".".6N) S %DT="PTS" D ^%DT S X=Y
Q $$FMTE^XLFDT(X,"5PMZ")
;
CENTER(X) ;
;
N TEXT,COL
S COL=35-($L(X)\2) Q:(COL<1) X
S $E(TEXT,COL)=X
Q TEXT
;
BLD(SUB,NDX,LINE,TAB,TEXT,RUNTIME) ;
;
Q:'$L($G(SUB))
N LINECNT
;
F LINECNT=1:1:+LINE S ^TMP("GMRC",$J,"OUTPUT",SUB,NDX,$$LASTLN(SUB,NDX)+1,0)=""
;
S $E(^TMP("GMRC",$J,"OUTPUT",SUB,NDX,$$LASTLN(SUB,NDX),0),TAB+1)=TEXT
I $L($G(RUNTIME)) S ^TMP("GMRC",$J,"OUTPUT",SUB,NDX,$$LASTLN(SUB,NDX),1)=RUNTIME
;
S GMRCLAST=SUB
Q
;
SUB(ZONE,SUB,NDX,TEXT) ;
;
N NEXT
S NEXT=$O(^TMP("GMRC",$J,"OUTPUT",SUB,NDX,ZONE," "),-1)+1
S ^TMP("GMRC",$J,"OUTPUT",SUB,NDX,ZONE,NEXT,0)=TEXT
Q
;
LASTLN(SUB,NDX) ;
Q +$O(^TMP("GMRC",$J,"OUTPUT",SUB,NDX," "),-1)
;
GMRCP5A ;SLC/DCM,RJS,MA - Print Consult form 513 (Gather Data - TIU Results) ;15-Mar-2012 10:40;PLS
+1 ;;3.0;CONSULT/REQUEST TRACKING;**4,13,12,15,21,22,1001,53,1003**;Dec 27, 1997;Build 14
+2 ; Patch #21 added PRNTAUDT to this routine.
+3 ;Modified - IHS/CIA/MGH - 11/29/2005 - Line FORMAT+8 Added code to use HRCN instead of SSN
+4 ;
PRNT(GMRCIFN,TIUFLG,GMRCQUED,GMRCCPY,GMRCGUI,GMRCAUDT) ;
+1 ;
+2 ; Input Arguments:
+3 ;
+4 ; GMRCIFN: IEN of the Consult/Request in file 123
+5 ; TIUFLG: Called from TIU ? 1=yes 0=no
+6 ; GMRCQUED: Queued job ? 1=yes 0=no
+7 ; GMRCCPY: Chart Copy ? C=Chart Copy W=Working Copy null=Not Applicable
+8 ; GMRCGUI: Called from the GUI. (Only produce output in a formatted global.)
+9 ; GMRCAUDT: Set to 1 in GMRCUTL1 if NW or DC consult.
+10 ; ZTIO: Output device when job is tasked
+11 ;
+12 NEW GMRCSIG,GMRCSDT,GMRCCSIG,GMRCSIGT,GMRCADDS
+13 IF '+$GET(IOM)
SET IOM=80
+14 ;
+15 IF GMRCGUI
Begin DoDot:1
+16 DO FORMAT(80)
+17 DO ASSMBL^GMRCP5C(GMRCGUI,80)
+18 FOR GMRCX="GMRCTIU","RES","MCAR"
KILL ^TMP("GMRCR",$JOB,GMRCX)
+19 KILL ^TMP("GMRC",$JOB,"OUTPUT")
+20 QUIT
End DoDot:1
QUIT
+21 ;
+22 IF 'TIUFLG
IF 'GMRCQUED
WRITE @IOF
IF '$$CRT^GMRCP5C
IF $LENGTH($GET(IO(0)))
IF '(IO=IO(0))
USE IO(0)
WRITE !,"PRINTING... "
+23 ;
+24 DO FORMAT(IOM)
DO ASSMBL^GMRCP5C(IOSL,IOM)
+25 USE IO
+26 DO PRINT^GMRCP5C(IOSL,IOM)
+27 ;
+28 IF 'TIUFLG
IF '$$CRT^GMRCP5C
USE IO(0)
DO ^%ZISC
+29 ;
+30 IF $GET(GMRCQUED)
IF $GET(ZTSK)
DO KILL^%ZTLOAD
+31 ;
+32 FOR GMRCX="OUTPUT","SF513"
KILL ^TMP("GMRC",$JOB,GMRCX)
+33 FOR GMRCX="GMRCTIU","RES","MCAR"
KILL ^TMP("GMRCR",$JOB,GMRCX)
+34 ; If print device (ZTIO) do PRNTAUDT unless there is no GMRCAUDT
+35 ; GMRCAUDT=1 means print for NW or DC consult
+36 IF $DATA(ZTIO)
IF $DATA(GMRCAUDT)
DO PRNTAUDT(GMRCIFN,ZTIO,GMRCAUDT)
+37 QUIT
+38 ;
PRNTAUDT(GMRCIFN,ZTIO,GMRCAUDT) ; Update the last activity field in 123 and
+1 ; Processing Activity multiple
+2 ; Update the activity log to reflect "Printed To:" and the printer
+3 ; GMRCAUDT=1 indicates the consult is NW or Discontinued
+4 ; and it should update the audit trail.
+5 IF $GET(GMRCAUDT)'=1
KILL GMRCAUDT
QUIT
+6 NEW GMRCOM,GMRCORNP,GMRCFF,GMRCPA,GMRCAD,GMRCA,DA,DIE
+7 SET GMRCA=22
+8 SET GMRCO=GMRCIFN
SET GMRCDEV=ZTIO
+9 SET DIE="^GMR(123,"
SET DA=+GMRCO
SET DR="9////^S X=GMRCA"
+10 LOCK +^GMR(123,GMRCO):5
+11 DO ^DIE
+12 LOCK -^GMR(123,GMRCO)
+13 ;Update activity other than HL7 original msg received
+14 DO AUDIT^GMRCP
+15 KILL GMRCO,GMRCA,GMRCDEV
+16 QUIT
+17 ;
FORMAT(PAGEWID) ;
+1 ;
+2 NEW %I,CMT,COUNT,D0,DFN,DIC,DIQ2,DR,GLOBAL,GMRC400,GMRCADD,GMRCADDT,GMRCAGE,GMRCCSDT
+3 NEW GMRCCTIT,GMRCDFN,GMRCDOB,GMRCDVL,GMRCELIG,GMRCEQL,GMRCERR,GMRCFAC,GMRCFP
+4 NEW GMRCFTR,GMRCIPH,GMRCINO,GMRCIRL,GMRCLAST,GMRCMODE,GMRCND,GMRCNDX,GMRCNT,GMRCPG,GMRCPGR,GMRCPNM,GMRCPRNM
+5 NEW GMRCPTR,GMRCQSTR,GMRCQSTT,GMRCR0,GMRCR1,GMRCR2,GMRCRB,GMRCRD,GMRCRPT,GMRCSG,GMRCSGAD,GMRCSIGM
+6 NEW GMRCSN,GMRCSR,GMRCSVC,GMRCTO,GMRCUL,GMRCWARD,GMRCWLI,GMRCX,LN,MCFILE,MCPROC
+7 NEW ND,ND1,ND2,NDS,ORACTION,SEX,TAB,X,Y
+8 ;IHS/MSC/MGH
NEW GMRCHRCN
+9 ;
+10 SET GMRCFTR=13
SET GMRCFP=0
SET GMRCPG=0
+11 SET GMRCRD=$GET(^GMR(123,GMRCIFN,0))
SET (DFN,GMRCDFN)=$PIECE(GMRCRD,U,2)
+12 IF '(DFN)
QUIT
+13 DO ELIG^VADPT
SET GMRCELIG=$PIECE(VAEL(6),U,2)
KILL VAEL
+14 SET GMRCDVL=""
SET $PIECE(GMRCDVL,"-",PAGEWID+1)=""
+15 SET GMRCEQL=""
SET $PIECE(GMRCEQL,"=",PAGEWID+1)=""
+16 SET GMRCUL=""
SET $PIECE(GMRCUL,"_",40)=""
+17 SET DFN=GMRCDFN
DO DEM^GMRCU
+18 ;
+19 SET GMRCFAC=+$PIECE(GMRCRD,U,21)
+20 IF 'GMRCFAC
SET GMRCFAC=+$GET(DUZ(2))
+21 IF 'GMRCFAC
SET GMRCFAC=+$$SITE^VASITE()
+22 IF +GMRCFAC
SET GMRCFAC=$$GET1^DIQ(4,+GMRCFAC,.01)
+23 IF '$TEST
SET GMRCFAC=""
QUIT
+24 ;
+25 ; get inter-facility consult info
+26 IF $PIECE(GMRCRD,U,23)
Begin DoDot:1
+27 SET GMRCINO=$PIECE(GMRCRD,U,22)
+28 SET GMRCRD(12)=$GET(^GMR(123,GMRCIFN,12))
+29 SET GMRCRD(13)=$GET(^GMR(123,GMRCIFN,13))
+30 SET GMRCIRL=$SELECT($PIECE(GMRCRD(12),U,5)="P":"Requesting facility",$PIECE(GMRCRD(12),U,5)="F":"Consulting facility",1:"")
End DoDot:1
+31 ;Commented out following line to allow TIU doc to print based on ASU
+32 ;rules.
+33 ;I $P(GMRCRD,U,12)=2!(TIUFLG) D
+34 ;Removed dot structure
DO PRINT^GMRCTIUP(GMRCIFN,0,0)
+35 ;
+36 KILL GMRCSG
IF $DATA(^TMP("GMRCR",$JOB,"RES"))
Begin DoDot:1
+37 ;
+38 SET GMRCR0=0
FOR
IF $DATA(GMRCSG)
QUIT
SET GMRCR0=$ORDER(^TMP("GMRCR",$JOB,"RES",GMRCR0))
IF 'GMRCR0
QUIT
Begin DoDot:2
+39 FOR GMRCV="GMRCSDT","GMRCSIG","GMRCSIGM","GMRCSIGT"
SET @GMRCV=$GET(^TMP("GMRCR",$JOB,"RES",GMRCR0,"TEXT",GMRCV))
+40 IF '$LENGTH($GET(GMRCSIG))
QUIT
+41 FOR GMRCV="GMRCSDT","GMRCSIG","GMRCSIGM","GMRCSIGT"
SET GMRCSG(GMRCV)=@GMRCV
End DoDot:2
End DoDot:1
+42 ;
+43 ; Build Header, Footer, Request, and Primary Diagnosis Segments
DO INIT^GMRCP5B(.GMRCSG)
+44 ;
+45 IF $LENGTH($GET(GMRCCPY))
Begin DoDot:1
+46 DO BLD("RES",1,1,0,$$CENTER($SELECT(GMRCCPY="C":"C H A R T C O P Y",1:"W O R K I N G C O P Y")))
End DoDot:1
+47 IF ($PIECE(GMRCRD,U,19)="Y")
Begin DoDot:1
+48 DO BLD("RES",1,1,0,$$CENTER("******* Significant Findings *******"))
End DoDot:1
+49 IF ($PIECE(GMRCRD,U,19)="N")
Begin DoDot:1
+50 DO BLD("RES",1,1,0,$$CENTER("******* No Significant Findings *******"))
End DoDot:1
+51 IF ($PIECE(GMRCRD,U,19)="U")
Begin DoDot:1
+52 DO BLD("RES",1,1,0,$$CENTER("******* Unknown Significant Findings *******"))
End DoDot:1
+53 ;
+54 IF $PIECE(GMRCRD,U,12)=1
Begin DoDot:1
+55 DO BLD("RES",1,2,0,$$CENTER("**** REQUEST CANCELLED REQUEST CANCELLED ****"))
End DoDot:1
+56 IF '$DATA(^TMP("GMRCR",$JOB,"RES"))
IF '$DATA(^("MCAR"))
Begin DoDot:1
+57 IF $LENGTH($GET(GMRCRPT))
DO BLD("RES",1,2,0,$$CENTER(" No Consultation Results for "_GMRCRPT_" available."))
+58 IF '$LENGTH($GET(GMRCRPT))
DO BLD("RES",1,2,0,$$CENTER(" No Consultation Results available."))
End DoDot:1
+59 ;
+60 IF $DATA(^TMP("GMRCR",$JOB,"RES"))
Begin DoDot:1
+61 ;
+62 SET (GMRCNT,GMRCR0)=0
FOR
SET GMRCR0=$ORDER(^TMP("GMRCR",$JOB,"RES",GMRCR0))
IF 'GMRCR0
QUIT
Begin DoDot:2
+63 NEW GMRCCSDT,GMRCCSGM,GMRCCSIG,GMRCCTIT,GMRCRPT,GMRCSDT
+64 NEW GMRCSIG,GMRCSIGM,GMRCSIGT,GMRCV,GMRCENT,GMRCVIS,GMRCVLOC,GMRCNODT
+65 ;
+66 FOR GMRCV="GMRCCSDT","GMRCCSGM","GMRCCSIG","GMRCCTIT","GMRCRPT","GMRCSDT","GMRCSIG","GMRCSIGM","GMRCSIGT","GMRCVIS","GMRCENT","GMRCVLOC","GMRCNODT"
Begin DoDot:3
+67 SET @GMRCV=$GET(^TMP("GMRCR",$JOB,"RES",GMRCR0,"TEXT",GMRCV))
End DoDot:3
+68 ;
+69 SET GMRCNDX=$ORDER(^TMP("GMRC",$JOB,"OUTPUT","RES"," "),-1)+1
+70 IF $LENGTH($GET(GMRCRPT))
DO SUB("H","RES",GMRCNDX,"Consultation Results "_$SELECT(GMRCR0=.5:"",1:"#"_GMRCR0_" ")_"for "_GMRCRPT_" continued.")
+71 IF '$LENGTH($GET(GMRCRPT))
DO SUB("H","RES",GMRCNDX,"Consultation Results "_$SELECT(GMRCR0=.5:"",1:"#"_GMRCR0_" ")_"continued.")
+72 DO SUB("H","RES",GMRCNDX," ")
+73 IF $LENGTH($GET(GMRCSIG))
Begin DoDot:3
+74 DO SUB("F","RES",GMRCNDX," ")
+75 IF (GMRCSIGM="electronic")
SET GMRCX=" Results Signature: "_GMRCSIG_" /es/ "_$$EXDT($GET(GMRCSDT))
+76 IF '(GMRCSIGM="electronic")
SET GMRCX=" Results Signature: "_GMRCSIG_" /chart/ "
IF $LENGTH($GET(GMRCSDT))
SET GMRCX=GMRCX_$$EXDT(GMRCSDT)
+77 DO SUB("F","RES",GMRCNDX,GMRCX)
+78 IF $LENGTH($GET(GMRCSIGT))
DO SUB("F","RES",GMRCNDX," "_GMRCSIGT)
End DoDot:3
+79 IF $LENGTH($GET(GMRCCSIG))
Begin DoDot:3
+80 DO SUB("F","RES",GMRCNDX," ")
+81 IF (GMRCCSGM="electronic")
SET GMRCX=" Results CoSignature: "_GMRCCSIG_" /es/ "_$$EXDT($GET(GMRCCSDT))
+82 IF '(GMRCCSGM="electronic")
SET GMRCX=" Results CoSignature: "_GMRCCSIG_" /chart/ "
IF $LENGTH($GET(GMRCCSDT))
SET GMRCX=GMRCX_$$EXDT(GMRCCSDT)
+83 DO SUB("F","RES",GMRCNDX,GMRCX)
+84 IF $LENGTH($GET(GMRCCTIT))
DO SUB("F","RES",GMRCNDX," "_GMRCCTIT)
End DoDot:3
+85 ;extra signers
+86 IF $DATA(^TMP("GMRCR",$JOB,"RES",GMRCR0,"TEXT","GMRCXTRA"))
Begin DoDot:3
+87 DO SUB("F","RES",GMRCNDX," ")
+88 DO SUB("F","RES",GMRCNDX," Receipt acknowledged by: ")
+89 NEW XTRA
SET XTRA=0
FOR
SET XTRA=$ORDER(^TMP("GMRCR",$JOB,"RES",GMRCR0,"TEXT","GMRCXTRA",XTRA))
IF 'XTRA
QUIT
Begin DoDot:4
+90 DO SUB("F","RES",GMRCNDX,^TMP("GMRCR",$JOB,"RES",GMRCR0,"TEXT","GMRCXTRA",XTRA,0))
+91 DO SUB("F","RES",GMRCNDX,^TMP("GMRCR",$JOB,"RES",GMRCR0,"TEXT","GMRCXTRA",XTRA,1))
End DoDot:4
End DoDot:3
+92 ;
+93 DO BLD("RES",GMRCNDX,1,0," ")
+94 IF $LENGTH($GET(GMRCRPT))
DO BLD("RES",GMRCNDX,1,0,$$CENTER("CONSULTATION NOTE "_$SELECT(GMRCR0=.5:"",1:"#"_GMRCR0_" ")_"FOR "_GMRCRPT))
+95 IF '$LENGTH($GET(GMRCRPT))
DO BLD("RES",GMRCNDX,1,0,$$CENTER("CONSULTATION NOTE "_$SELECT(GMRCR0=.5:"",1:"#"_GMRCR0)))
+96 DO BLD("RES",GMRCNDX,1,0," ")
+97 IF $LENGTH($GET(GMRCENT))
Begin DoDot:3
+98 SET GMRCX=" Entry Date: "_$$EXDT($GET(GMRCENT))
+99 DO BLD("RES",GMRCNDX,1,0,GMRCX)
End DoDot:3
+100 IF $LENGTH($GET(GMRCNODT))
Begin DoDot:3
+101 IF $$EXDT($GET(GMRCNODT))=$$EXDT($GET(GMRCENT))
QUIT
+102 SET GMRCX="Date/Time of result: "_$$EXDT($GET(GMRCNODT))
+103 DO BLD("RES",GMRCNDX,1,0,GMRCX)
End DoDot:3
+104 IF $LENGTH($GET(GMRCVIS))
Begin DoDot:3
+105 SET GMRCX=" Visit: "_$$EXDT($GET(GMRCVIS))
+106 IF $LENGTH($GET(GMRCVLOC))
SET GMRCX=GMRCX_" "_GMRCVLOC
+107 DO BLD("RES",GMRCNDX,1,0,GMRCX)
End DoDot:3
+108 IF $LENGTH($GET(GMRCVLOC))
SET GMRCX=GMRCVLOC
+109 DO BLD("RES",GMRCNDX,1,0," ")
+110 IF $DATA(^TMP("GMRCR",$JOB,"RES",GMRCR0,"TEXT",0,0))
Begin DoDot:3
+111 DO BLD("RES",GMRCNDX,1,0,^TMP("GMRCR",$JOB,"RES",GMRCR0,"TEXT",0,0))
End DoDot:3
IF 1
+112 IF '$TEST
IF '$ORDER(^TMP("GMRCR",$JOB,"RES",GMRCR0,"TEXT",""))
Begin DoDot:3
+113 DO BLD("RES",1,1,0,$$CENTER("CONSULTATION NOTE TEXT NOT AVAILABLE"))
End DoDot:3
+114 SET GMRCR1=0
FOR
SET GMRCR1=$ORDER(^TMP("GMRCR",$JOB,"RES",GMRCR0,"TEXT",GMRCR1))
IF 'GMRCR1
QUIT
Begin DoDot:3
+115 DO BLD("RES",GMRCNDX,1,0,^TMP("GMRCR",$JOB,"RES",GMRCR0,"TEXT",GMRCR1,0))
End DoDot:3
+116 ;
+117 ; GET ADDENDUMS TO THIS NOTE
+118 ;
+119 IF +$ORDER(^TMP("GMRCR",$JOB,"RES",GMRCR0,"ADD",0))
DO ADDEND^GMRCP5D(GMRCIFN,GMRCR0,GMRCNDX,GMRCRD,PAGEWID)
End DoDot:2
End DoDot:1
+120 ;
+121 ; GET SERVICE REPORTS AND COMMENTS
DO FORMAT^GMRCP5D(GMRCIFN,GMRCRD,PAGEWID)
+122 ;
+123 QUIT
+124 ;
EXDT(X) ;EXTERNAL DATE FORMAT
+1 ;
+2 NEW DATE,TIME,HR,MN,PD,Y,%DT
+3 IF '$LENGTH(X)
QUIT ""
+4 IF '(X?7N.1".".6N)
SET %DT="PTS"
DO ^%DT
SET X=Y
+5 QUIT $$FMTE^XLFDT(X,"5PMZ")
+6 ;
CENTER(X) ;
+1 ;
+2 NEW TEXT,COL
+3 SET COL=35-($LENGTH(X)\2)
IF (COL<1)
QUIT X
+4 SET $EXTRACT(TEXT,COL)=X
+5 QUIT TEXT
+6 ;
BLD(SUB,NDX,LINE,TAB,TEXT,RUNTIME) ;
+1 ;
+2 IF '$LENGTH($GET(SUB))
QUIT
+3 NEW LINECNT
+4 ;
+5 FOR LINECNT=1:1:+LINE
SET ^TMP("GMRC",$JOB,"OUTPUT",SUB,NDX,$$LASTLN(SUB,NDX)+1,0)=""
+6 ;
+7 SET $EXTRACT(^TMP("GMRC",$JOB,"OUTPUT",SUB,NDX,$$LASTLN(SUB,NDX),0),TAB+1)=TEXT
+8 IF $LENGTH($GET(RUNTIME))
SET ^TMP("GMRC",$JOB,"OUTPUT",SUB,NDX,$$LASTLN(SUB,NDX),1)=RUNTIME
+9 ;
+10 SET GMRCLAST=SUB
+11 QUIT
+12 ;
SUB(ZONE,SUB,NDX,TEXT) ;
+1 ;
+2 NEW NEXT
+3 SET NEXT=$ORDER(^TMP("GMRC",$JOB,"OUTPUT",SUB,NDX,ZONE," "),-1)+1
+4 SET ^TMP("GMRC",$JOB,"OUTPUT",SUB,NDX,ZONE,NEXT,0)=TEXT
+5 QUIT
+6 ;
LASTLN(SUB,NDX) ;
+1 QUIT +$ORDER(^TMP("GMRC",$JOB,"OUTPUT",SUB,NDX," "),-1)
+2 ;