GMRCGUIB ;SLC/DCM,JFR,MA - GUI actions for consults ;19-Nov-2014 09:52;DU
;;3.0;CONSULT/REQUEST TRACKING;**4,12,18,20,17,22,29,30,35,45,53,55,1005**;DEC 27, 1997;Build 2
; This routine invokes IA #2980
; IHS/MSC/MGH added an unlock when exiting
;
SETDA() ;set DA of where audit actions are to be filed
S:'$D(^GMR(123,+GMRCO,40,0)) ^GMR(123,GMRCO,40,0)="^123.02DA^^"
S DA=$S($P(^GMR(123,+GMRCO,40,0),"^",3):$P(^(0),"^",3)+1,1:1)
S $P(^GMR(123,+GMRCO,40,0),"^",3,4)=DA_"^"_DA
Q DA
REASON(GMRCFN,GMRCRQ,GMRCDT) ;Load the reason for the request into ^GMR(123,GMRCO,20
;GMRCFN=File 123 IFN; GMRCRQ=Array containing Reason For Request
;GMRCDT=Date time of entry
S ^GMR(123,GMRCFN,20,0)="^^^"_GMRCDT_"^"
S L=0,LN=1 F S L=$O(GMRCRQ(L)) Q:L="" S ^GMR(123,GMRCFN,20,LN,0)=GMRCRQ(L),LN=LN+1
S LN=LN-1,$P(^GMR(123,GMRCFN,20,0),"^",3)=LN
K LN,L
Q
SETCOM(COMMENT,WHO) ;Set comment array into tracking actions
N GMRCNOW,DR,DIE
S GMRCNOW=$$NOW^XLFDT
S DIE="^GMR(123,GMRCO,40,",DA(1)=GMRCO,DR=".01////^S X=GMRCNOW;1////^S X=GMRCA;2////^S X=GMRCAD;3////^S X=$G(GMRCORNP);4////^S X=$S($G(WHO):WHO,1:DUZ);6////^S X=$G(GMRCFR);8////^S X=$G(GMRCFF)"
D ^DIE
S ^GMR(123,GMRCO,40,DA,1,0)="^^^^"_GMRCAD_"^"
S (GMRCND,GMRCND1)=0 F S GMRCND1=$O(COMMENT(GMRCND1)) Q:GMRCND1="" S GMRCND=GMRCND+1,^GMR(123,GMRCO,40,DA,1,GMRCND,0)=COMMENT(GMRCND)
S $P(^GMR(123,GMRCO,40,DA,1,0),"^",3)=GMRCND,$P(^(0),"^",4)=GMRCND,^GMR(123,GMRCO,40,"B",GMRCNOW,DA)=""
;
; if an IFC, call event handler to generate a msg to remote site
I $D(^GMR(123,+GMRCO,12)),$D(^(40,DA)) D TRIGR^GMRCIEVT(GMRCO,DA)
;
K GMRCND,GMRCND1
Q
CMT(GMRCO,GMRCOM,GMRCADUZ,GMRCWHN,GMRCWHO) ;add comment to consult
; GMRCO = IEN from file 123
; GMRCOM = array of comments in format GMRCOM(1)="xxxx", GMRCOM(2)="xxx"
; GMRCADUZ = array of alert recipients as GMRCADUZ(DUZ)="" (optional)
; GMRCWHO = IEN from file 200 who's responsible activity (optional)
; GMRCWHN = date time of activity in FM format
;
N DA,GMRCA,GMRCAD,GMRCORTX,GMRCDFN,GMRCTM,GMRCRP,GMRCUPD
S DA=$$SETDA ; get next activity tracking entry
S GMRCA=20,GMRCAD=GMRCWHN S:$G(GMRCWHO) GMRCORNP=GMRCWHO
D SETCOM(.GMRCOM,$G(GMRCWHO))
D ;update LAST ACTION field even though no status change
. N GMRCDR,GMRCSTS
. S GMRCSTS="",GMRCDR="9////20"
. D STATUS^GMRCP
S GMRCDFN=$P(^GMR(123,+GMRCO,0),"^",2)
S GMRCORTX="Comment Added to Consult "
I $P($G(^GMR(123,GMRCO,12)),U,5)="P" D
. S GMRCORTX="Comment Added to remote consult "
S GMRCORTX=GMRCORTX_$$ORTX^GMRCAU(+GMRCO)
S GMRCRP=+$P(^GMR(123,GMRCO,0),U,14)
S GMRCUPD=$$VALID^GMRCAU($P(^GMR(123,+GMRCO,0),U,5),GMRCO,DUZ)
I GMRCRP=DUZ D ;alert team if ord. prov. takes the action
. S GMRCTM=1
I GMRCUPD>1,GMRCRP'=DUZ D ; alert ord. prov if update users takes action
. S GMRCADUZ(GMRCRP)=""
I '$G(GMRCTM),GMRCUPD<2 D ;alert both if not ord. prov or update user
. S GMRCTM=1,GMRCADUZ(GMRCRP)=""
D MSG^GMRCP(GMRCDFN,GMRCORTX,+GMRCO,63,.GMRCADUZ,$G(GMRCTM))
Q
SFILE(GMRCO,GMRCA,GMRCSF,GMRCORNP,GMRCDUZ,GMRCOM,GMRCALF,GMRCATO,GMRCAD) ;Process various file update functions from the GUI for a consult
; ADMIN COMPLETE or SIGNIFICANT FINDINGS
;Input variables:
;GMRCO=File 123 IEN of the consult record
;GMRCA=pointer to REQUEST ACTION TYPES (#123.1) 10=complete, 4=Sig find.
;GMRCSF=Significant Findings flag: 'Y'= significant finding
; : 'N'= no significant finding
; : 'U'=unknown significant finding
;GMRCORNP=Provider Responsible for action
;GMRCDUZ=Person actually doing the action
;GMRCOM=An array of comments by reference ARRAY(1)="xxx",ARRAY(2)="xxx"
;GMRCALF=Flag to signal that alerts are to be sent; 'N'=NO, 'Y'=YES
;GMRCATO=Who alerts are to be sent to; a comma delimited string of DUZ's
;GMRCAD =FM date/time of activity
;
;Output:
; GMRCERR=Error Flag: 0 if no error, 1 if error occurred
; GMRCERMS - Error message or null
; returned as GMRCERR^GMRCERMS
;
N GMRCERR,GMRCERMS
L +^GMR(123,GMRCO):5 I '$T S GMRCERR=1,GMRCERMS="Record Locked. File Update Not Accomplished." Q GMRCERR_"^"_GMRCERMS
S GMRCERR=0,GMRCERMS="",DR="",GMRCORTX=""
N GMRCADUZ S GMRCADUZ=""
S GMRCNOW=$$NOW^XLFDT,GMRCSTS=$P(^GMR(123,+GMRCO,0),"^",12),GMRCDFN=$P(^(0),"^",2)
I '$G(GMRCDUZ) S GMRCDUZ=DUZ
I '$G(GMRCAD) S GMRCAD=GMRCNOW
;Insure comment array contains text for Complete action.
;IHS/MSC/MGH Added an unlock before exiting
I GMRCA=10 D I GMRCERR=1 L -^GMR(123,GMRCO) S GMRCERMS="Comment field must contain a text value!" Q GMRCERR_"^"_GMRCERMS
. S GMRCERR=1
. I '$D(GMRCOM) Q
. N GMRCOM1 S GMRCOM1=""
. F S GMRCOM1=$O(GMRCOM(GMRCOM1)) Q:(GMRCOM1=""!(GMRCERR=0)) D
.. I $TR($G(GMRCOM(GMRCOM1))," ","")'="" S GMRCERR=0 Q
I +$G(GMRCA),GMRCA=10 D
.S GMRCSF=$G(GMRCSF,"")
.S GMRCSTS=2
.S DR="8////^S X=GMRCSTS;9////^S X=GMRCA;15////^S X=GMRCSF"
.S GMRCORTX="Completed Consult "_$$ORTX^GMRCAU(+GMRCO)_$S(GMRCSF="Y":" with Sig Findings",GMRCSF="N":" with no Sig Findings",1:"")
.I $P($G(^GMR(123,+GMRCO,0)),U,14) S GMRCADUZ($P($G(^(0)),U,14))=""
.Q
I $G(GMRCALF)=1 D
.N I
.F I=1:1 S X=$P(GMRCATO,";",I) Q:X="" S GMRCADUZ(X)=""
.Q
I $L(GMRCA),GMRCA=4 S DR=DR_$S($L(DR):";",1:"")_"9////^S X=GMRCA;15////^S X=GMRCSF" D
.S GMRCORTX=$S(GMRCSF="Y":"Sig Findings ",GMRCSF="N":"No Sig Findings ",1:"Unknown Sig Findings ")_"for consult "_$$ORTX^GMRCAU(GMRCO)
.I $P($G(^GMR(123,+GMRCO,0)),U,14) S GMRCADUZ($P($G(^(0)),U,14))=""
.Q
I $L(DR) S DIE="^GMR(123,",DA=GMRCO D ^DIE K DIE,DR
I '$O(GMRCOM(0)) D AUDIT^GMRCP
I $D(GMRCOM),$O(GMRCOM(0)) D
.N DA
.S DA=$$SETDA()
.D SETCOM(.GMRCOM,GMRCDUZ)
.Q
L -^GMR(123,GMRCO)
;
D MSG^GMRCP(GMRCDFN,GMRCORTX,+GMRCO,$S(GMRCA=20:63,1:23),.GMRCADUZ,0)
;
I $S(GMRCA=10:1,(GMRCA=4&($P(^GMR(123,GMRCO,0),U,12)=2)):1,1:0) D
. D EN^GMRCHL7($P(^GMR(123,GMRCO,0),"^",2),GMRCO,$G(GMRCTYPE),$G(GMRCRB),"RE",GMRCORNP,$G(GMRCVSIT),.GMRCOM,,GMRCAD)
K DIE,DR,DA,GMRCDT,GMRCNOW,GMRCAD,GMRCORNP,GMRCDUZ,GMRCRSLT,GMRCSTS,GMRCADUZ,GMRCORTX,GMRCDFN
Q GMRCERR_"^"_GMRCERMS
;
SCH(GMRCO,GMRCORNP,GMRCAD,GMRCADUZ,GMRCMT) ;schedule a consult API
; Input variables:
;GMRCO - The internal file number of the consult from File 123
;GMRCORNP - Name of the person who actually 'Received' the consult
;GMRCAD - Actual date time that consult was received into the service.
;GMRCADUZ - array of alert recipients as chosen by user (by reference)
; ARRAY(DUZ)=""
;GMRCMT - array of comments if entered (by reference)
; ARRAY(1)="FIRST LINE OF COMMENT"
; ARRAY(2)="SECOND LINE OF COMMENT"
;
;Output:
;GMRCERR - Error Condition Code: 0 = NO error, 1=error
;GMRCERMS - Error message or null
; returned as GMRCERR^GMRCERMS
;
N DFN,GMRCSTS,GMRCNOW,GMRCERR,GMRCERMS
S GMRCERR=0,GMRCERMS="",GMRCNOW=$$NOW^XLFDT
S:$G(GMRCAD)="" GMRCAD=GMRCNOW
S:'$G(GMRCDUZ) GMRCDUZ=DUZ
S DFN=$P($G(^GMR(123,GMRCO,0)),"^",2) I DFN="" D Q GMRCERR_"^"_GMRCERMS
. S GMRCERR="1",GMRCERMS="Not A Valid Consult - File Not Found."
. D EXIT^GMRCGUIA
S GMRCSTS=8,GMRCA=8
D STATUS^GMRCP I $D(GMRCQUT) D EXIT^GMRCGUIA Q GMRCERR_"^"_GMRCERMS
I '$O(GMRCMT(0)) D AUDIT^GMRCP
I $O(GMRCMT(0)) D
. S DA=$$SETDA
. D SETCOM(.GMRCMT,GMRCDUZ)
D EN^GMRCHL7(DFN,GMRCO,"","","SC",GMRCORNP,"","","",GMRCAD)
D ;send alerts
. N TXT
. S TXT="Scheduled Consult: "_$$ORTX^GMRCAU(GMRCO)
. I $P(^GMR(123,+GMRCO,0),U,14) S GMRCADUZ($P(^(0),U,14))=""
. D MSG^GMRCP(DFN,TXT,GMRCO,63,.GMRCADUZ,0)
D EXIT^GMRCGUIA
Q GMRCERR_"^"_GMRCERMS
DOCLIST(GMRCAR,GMRCDA,GMRCMED) ;return list of linked results
; Input:
; GMRCAR - array to return list, passed by reference
; GMRCDA - ien from file 123
; GMRCMED- 1 = include med results; 0 = only TIU docs
;
; Output:
; GMRCAR - array in format
; GMRCAR(0)=zero node of record
; GMRCAR(50,1)="ien;global ref," e.g. 5;TIU(8925, or 3;MCAR(691,
; GMRCAR(50,2)="ien;global ref,"
;
I '$D(^GMR(123,GMRCDA,0)) Q
S GMRCAR(0)=^GMR(123,GMRCDA,0),$P(GMRCAR(0),U,20)=""
N RES,CNT S RES="",CNT=1
F S RES=$O(^GMR(123,GMRCDA,50,"B",RES)) Q:RES="" D
. I '$G(GMRCMED) Q:RES'["TIU(8925"
. S GMRCAR(50,CNT)=RES
. I RES["MCAR" D
.. N ARR,STR
.. D MEDLKUP^MCARUTL3(.ARR,+$P(RES,"MCAR(",2),+RES)
.. I '+ARR K GMRCAR(50,CNT) Q
.. S STR=$P(ARR,U,9)_U_$P(ARR,U,6)_$S($P(ARR,U,10):"^^^^^^^^1",1:"")
.. S GMRCAR(50,CNT)=GMRCAR(50,CNT)_U_STR
. S CNT=CNT+1
Q
GMRCGUIB ;SLC/DCM,JFR,MA - GUI actions for consults ;19-Nov-2014 09:52;DU
+1 ;;3.0;CONSULT/REQUEST TRACKING;**4,12,18,20,17,22,29,30,35,45,53,55,1005**;DEC 27, 1997;Build 2
+2 ; This routine invokes IA #2980
+3 ; IHS/MSC/MGH added an unlock when exiting
+4 ;
SETDA() ;set DA of where audit actions are to be filed
+1 IF '$DATA(^GMR(123,+GMRCO,40,0))
SET ^GMR(123,GMRCO,40,0)="^123.02DA^^"
+2 SET DA=$SELECT($PIECE(^GMR(123,+GMRCO,40,0),"^",3):$PIECE(^(0),"^",3)+1,1:1)
+3 SET $PIECE(^GMR(123,+GMRCO,40,0),"^",3,4)=DA_"^"_DA
+4 QUIT DA
REASON(GMRCFN,GMRCRQ,GMRCDT) ;Load the reason for the request into ^GMR(123,GMRCO,20
+1 ;GMRCFN=File 123 IFN; GMRCRQ=Array containing Reason For Request
+2 ;GMRCDT=Date time of entry
+3 SET ^GMR(123,GMRCFN,20,0)="^^^"_GMRCDT_"^"
+4 SET L=0
SET LN=1
FOR
SET L=$ORDER(GMRCRQ(L))
IF L=""
QUIT
SET ^GMR(123,GMRCFN,20,LN,0)=GMRCRQ(L)
SET LN=LN+1
+5 SET LN=LN-1
SET $PIECE(^GMR(123,GMRCFN,20,0),"^",3)=LN
+6 KILL LN,L
+7 QUIT
SETCOM(COMMENT,WHO) ;Set comment array into tracking actions
+1 NEW GMRCNOW,DR,DIE
+2 SET GMRCNOW=$$NOW^XLFDT
+3 SET DIE="^GMR(123,GMRCO,40,"
SET DA(1)=GMRCO
SET DR=".01////^S X=GMRCNOW;1////^S X=GMRCA;2////^S X=GMRCAD;3////^S X=$G(GMRCORNP);4////^S X=$S($G(WHO):WHO,1:DUZ);6////^S X=$G(GMRCFR);8////^S X=$G(GMRCFF)"
+4 DO ^DIE
+5 SET ^GMR(123,GMRCO,40,DA,1,0)="^^^^"_GMRCAD_"^"
+6 SET (GMRCND,GMRCND1)=0
FOR
SET GMRCND1=$ORDER(COMMENT(GMRCND1))
IF GMRCND1=""
QUIT
SET GMRCND=GMRCND+1
SET ^GMR(123,GMRCO,40,DA,1,GMRCND,0)=COMMENT(GMRCND)
+7 SET $PIECE(^GMR(123,GMRCO,40,DA,1,0),"^",3)=GMRCND
SET $PIECE(^(0),"^",4)=GMRCND
SET ^GMR(123,GMRCO,40,"B",GMRCNOW,DA)=""
+8 ;
+9 ; if an IFC, call event handler to generate a msg to remote site
+10 IF $DATA(^GMR(123,+GMRCO,12))
IF $DATA(^(40,DA))
DO TRIGR^GMRCIEVT(GMRCO,DA)
+11 ;
+12 KILL GMRCND,GMRCND1
+13 QUIT
CMT(GMRCO,GMRCOM,GMRCADUZ,GMRCWHN,GMRCWHO) ;add comment to consult
+1 ; GMRCO = IEN from file 123
+2 ; GMRCOM = array of comments in format GMRCOM(1)="xxxx", GMRCOM(2)="xxx"
+3 ; GMRCADUZ = array of alert recipients as GMRCADUZ(DUZ)="" (optional)
+4 ; GMRCWHO = IEN from file 200 who's responsible activity (optional)
+5 ; GMRCWHN = date time of activity in FM format
+6 ;
+7 NEW DA,GMRCA,GMRCAD,GMRCORTX,GMRCDFN,GMRCTM,GMRCRP,GMRCUPD
+8 ; get next activity tracking entry
SET DA=$$SETDA
+9 SET GMRCA=20
SET GMRCAD=GMRCWHN
IF $GET(GMRCWHO)
SET GMRCORNP=GMRCWHO
+10 DO SETCOM(.GMRCOM,$GET(GMRCWHO))
+11 ;update LAST ACTION field even though no status change
Begin DoDot:1
+12 NEW GMRCDR,GMRCSTS
+13 SET GMRCSTS=""
SET GMRCDR="9////20"
+14 DO STATUS^GMRCP
End DoDot:1
+15 SET GMRCDFN=$PIECE(^GMR(123,+GMRCO,0),"^",2)
+16 SET GMRCORTX="Comment Added to Consult "
+17 IF $PIECE($GET(^GMR(123,GMRCO,12)),U,5)="P"
Begin DoDot:1
+18 SET GMRCORTX="Comment Added to remote consult "
End DoDot:1
+19 SET GMRCORTX=GMRCORTX_$$ORTX^GMRCAU(+GMRCO)
+20 SET GMRCRP=+$PIECE(^GMR(123,GMRCO,0),U,14)
+21 SET GMRCUPD=$$VALID^GMRCAU($PIECE(^GMR(123,+GMRCO,0),U,5),GMRCO,DUZ)
+22 ;alert team if ord. prov. takes the action
IF GMRCRP=DUZ
Begin DoDot:1
+23 SET GMRCTM=1
End DoDot:1
+24 ; alert ord. prov if update users takes action
IF GMRCUPD>1
IF GMRCRP'=DUZ
Begin DoDot:1
+25 SET GMRCADUZ(GMRCRP)=""
End DoDot:1
+26 ;alert both if not ord. prov or update user
IF '$GET(GMRCTM)
IF GMRCUPD<2
Begin DoDot:1
+27 SET GMRCTM=1
SET GMRCADUZ(GMRCRP)=""
End DoDot:1
+28 DO MSG^GMRCP(GMRCDFN,GMRCORTX,+GMRCO,63,.GMRCADUZ,$GET(GMRCTM))
+29 QUIT
SFILE(GMRCO,GMRCA,GMRCSF,GMRCORNP,GMRCDUZ,GMRCOM,GMRCALF,GMRCATO,GMRCAD) ;Process various file update functions from the GUI for a consult
+1 ; ADMIN COMPLETE or SIGNIFICANT FINDINGS
+2 ;Input variables:
+3 ;GMRCO=File 123 IEN of the consult record
+4 ;GMRCA=pointer to REQUEST ACTION TYPES (#123.1) 10=complete, 4=Sig find.
+5 ;GMRCSF=Significant Findings flag: 'Y'= significant finding
+6 ; : 'N'= no significant finding
+7 ; : 'U'=unknown significant finding
+8 ;GMRCORNP=Provider Responsible for action
+9 ;GMRCDUZ=Person actually doing the action
+10 ;GMRCOM=An array of comments by reference ARRAY(1)="xxx",ARRAY(2)="xxx"
+11 ;GMRCALF=Flag to signal that alerts are to be sent; 'N'=NO, 'Y'=YES
+12 ;GMRCATO=Who alerts are to be sent to; a comma delimited string of DUZ's
+13 ;GMRCAD =FM date/time of activity
+14 ;
+15 ;Output:
+16 ; GMRCERR=Error Flag: 0 if no error, 1 if error occurred
+17 ; GMRCERMS - Error message or null
+18 ; returned as GMRCERR^GMRCERMS
+19 ;
+20 NEW GMRCERR,GMRCERMS
+21 LOCK +^GMR(123,GMRCO):5
IF '$TEST
SET GMRCERR=1
SET GMRCERMS="Record Locked. File Update Not Accomplished."
QUIT GMRCERR_"^"_GMRCERMS
+22 SET GMRCERR=0
SET GMRCERMS=""
SET DR=""
SET GMRCORTX=""
+23 NEW GMRCADUZ
SET GMRCADUZ=""
+24 SET GMRCNOW=$$NOW^XLFDT
SET GMRCSTS=$PIECE(^GMR(123,+GMRCO,0),"^",12)
SET GMRCDFN=$PIECE(^(0),"^",2)
+25 IF '$GET(GMRCDUZ)
SET GMRCDUZ=DUZ
+26 IF '$GET(GMRCAD)
SET GMRCAD=GMRCNOW
+27 ;Insure comment array contains text for Complete action.
+28 ;IHS/MSC/MGH Added an unlock before exiting
+29 IF GMRCA=10
Begin DoDot:1
+30 SET GMRCERR=1
+31 IF '$DATA(GMRCOM)
QUIT
+32 NEW GMRCOM1
SET GMRCOM1=""
+33 FOR
SET GMRCOM1=$ORDER(GMRCOM(GMRCOM1))
IF (GMRCOM1=""!(GMRCERR=0))
QUIT
Begin DoDot:2
+34 IF $TRANSLATE($GET(GMRCOM(GMRCOM1))," ","")'=""
SET GMRCERR=0
QUIT
End DoDot:2
End DoDot:1
IF GMRCERR=1
LOCK -^GMR(123,GMRCO)
SET GMRCERMS="Comment field must contain a text value!"
QUIT GMRCERR_"^"_GMRCERMS
+35 IF +$GET(GMRCA)
IF GMRCA=10
Begin DoDot:1
+36 SET GMRCSF=$GET(GMRCSF,"")
+37 SET GMRCSTS=2
+38 SET DR="8////^S X=GMRCSTS;9////^S X=GMRCA;15////^S X=GMRCSF"
+39 SET GMRCORTX="Completed Consult "_$$ORTX^GMRCAU(+GMRCO)_$SELECT(GMRCSF="Y":" with Sig Findings",GMRCSF="N":" with no Sig Findings",1:"")
+40 IF $PIECE($GET(^GMR(123,+GMRCO,0)),U,14)
SET GMRCADUZ($PIECE($GET(^(0)),U,14))=""
+41 QUIT
End DoDot:1
+42 IF $GET(GMRCALF)=1
Begin DoDot:1
+43 NEW I
+44 FOR I=1:1
SET X=$PIECE(GMRCATO,";",I)
IF X=""
QUIT
SET GMRCADUZ(X)=""
+45 QUIT
End DoDot:1
+46 IF $LENGTH(GMRCA)
IF GMRCA=4
SET DR=DR_$SELECT($LENGTH(DR):";",1:"")_"9////^S X=GMRCA;15////^S X=GMRCSF"
Begin DoDot:1
+47 SET GMRCORTX=$SELECT(GMRCSF="Y":"Sig Findings ",GMRCSF="N":"No Sig Findings ",1:"Unknown Sig Findings ")_"for consult "_$$ORTX^GMRCAU(GMRCO)
+48 IF $PIECE($GET(^GMR(123,+GMRCO,0)),U,14)
SET GMRCADUZ($PIECE($GET(^(0)),U,14))=""
+49 QUIT
End DoDot:1
+50 IF $LENGTH(DR)
SET DIE="^GMR(123,"
SET DA=GMRCO
DO ^DIE
KILL DIE,DR
+51 IF '$ORDER(GMRCOM(0))
DO AUDIT^GMRCP
+52 IF $DATA(GMRCOM)
IF $ORDER(GMRCOM(0))
Begin DoDot:1
+53 NEW DA
+54 SET DA=$$SETDA()
+55 DO SETCOM(.GMRCOM,GMRCDUZ)
+56 QUIT
End DoDot:1
+57 LOCK -^GMR(123,GMRCO)
+58 ;
+59 DO MSG^GMRCP(GMRCDFN,GMRCORTX,+GMRCO,$SELECT(GMRCA=20:63,1:23),.GMRCADUZ,0)
+60 ;
+61 IF $SELECT(GMRCA=10:1,(GMRCA=4&($PIECE(^GMR(123,GMRCO,0),U,12)=2)):1,1:0)
Begin DoDot:1
+62 DO EN^GMRCHL7($PIECE(^GMR(123,GMRCO,0),"^",2),GMRCO,$GET(GMRCTYPE),$GET(GMRCRB),"RE",GMRCORNP,$GET(GMRCVSIT),.GMRCOM,,GMRCAD)
End DoDot:1
+63 KILL DIE,DR,DA,GMRCDT,GMRCNOW,GMRCAD,GMRCORNP,GMRCDUZ,GMRCRSLT,GMRCSTS,GMRCADUZ,GMRCORTX,GMRCDFN
+64 QUIT GMRCERR_"^"_GMRCERMS
+65 ;
SCH(GMRCO,GMRCORNP,GMRCAD,GMRCADUZ,GMRCMT) ;schedule a consult API
+1 ; Input variables:
+2 ;GMRCO - The internal file number of the consult from File 123
+3 ;GMRCORNP - Name of the person who actually 'Received' the consult
+4 ;GMRCAD - Actual date time that consult was received into the service.
+5 ;GMRCADUZ - array of alert recipients as chosen by user (by reference)
+6 ; ARRAY(DUZ)=""
+7 ;GMRCMT - array of comments if entered (by reference)
+8 ; ARRAY(1)="FIRST LINE OF COMMENT"
+9 ; ARRAY(2)="SECOND LINE OF COMMENT"
+10 ;
+11 ;Output:
+12 ;GMRCERR - Error Condition Code: 0 = NO error, 1=error
+13 ;GMRCERMS - Error message or null
+14 ; returned as GMRCERR^GMRCERMS
+15 ;
+16 NEW DFN,GMRCSTS,GMRCNOW,GMRCERR,GMRCERMS
+17 SET GMRCERR=0
SET GMRCERMS=""
SET GMRCNOW=$$NOW^XLFDT
+18 IF $GET(GMRCAD)=""
SET GMRCAD=GMRCNOW
+19 IF '$GET(GMRCDUZ)
SET GMRCDUZ=DUZ
+20 SET DFN=$PIECE($GET(^GMR(123,GMRCO,0)),"^",2)
IF DFN=""
Begin DoDot:1
+21 SET GMRCERR="1"
SET GMRCERMS="Not A Valid Consult - File Not Found."
+22 DO EXIT^GMRCGUIA
End DoDot:1
QUIT GMRCERR_"^"_GMRCERMS
+23 SET GMRCSTS=8
SET GMRCA=8
+24 DO STATUS^GMRCP
IF $DATA(GMRCQUT)
DO EXIT^GMRCGUIA
QUIT GMRCERR_"^"_GMRCERMS
+25 IF '$ORDER(GMRCMT(0))
DO AUDIT^GMRCP
+26 IF $ORDER(GMRCMT(0))
Begin DoDot:1
+27 SET DA=$$SETDA
+28 DO SETCOM(.GMRCMT,GMRCDUZ)
End DoDot:1
+29 DO EN^GMRCHL7(DFN,GMRCO,"","","SC",GMRCORNP,"","","",GMRCAD)
+30 ;send alerts
Begin DoDot:1
+31 NEW TXT
+32 SET TXT="Scheduled Consult: "_$$ORTX^GMRCAU(GMRCO)
+33 IF $PIECE(^GMR(123,+GMRCO,0),U,14)
SET GMRCADUZ($PIECE(^(0),U,14))=""
+34 DO MSG^GMRCP(DFN,TXT,GMRCO,63,.GMRCADUZ,0)
End DoDot:1
+35 DO EXIT^GMRCGUIA
+36 QUIT GMRCERR_"^"_GMRCERMS
DOCLIST(GMRCAR,GMRCDA,GMRCMED) ;return list of linked results
+1 ; Input:
+2 ; GMRCAR - array to return list, passed by reference
+3 ; GMRCDA - ien from file 123
+4 ; GMRCMED- 1 = include med results; 0 = only TIU docs
+5 ;
+6 ; Output:
+7 ; GMRCAR - array in format
+8 ; GMRCAR(0)=zero node of record
+9 ; GMRCAR(50,1)="ien;global ref," e.g. 5;TIU(8925, or 3;MCAR(691,
+10 ; GMRCAR(50,2)="ien;global ref,"
+11 ;
+12 IF '$DATA(^GMR(123,GMRCDA,0))
QUIT
+13 SET GMRCAR(0)=^GMR(123,GMRCDA,0)
SET $PIECE(GMRCAR(0),U,20)=""
+14 NEW RES,CNT
SET RES=""
SET CNT=1
+15 FOR
SET RES=$ORDER(^GMR(123,GMRCDA,50,"B",RES))
IF RES=""
QUIT
Begin DoDot:1
+16 IF '$GET(GMRCMED)
IF RES'["TIU(8925"
QUIT
+17 SET GMRCAR(50,CNT)=RES
+18 IF RES["MCAR"
Begin DoDot:2
+19 NEW ARR,STR
+20 DO MEDLKUP^MCARUTL3(.ARR,+$PIECE(RES,"MCAR(",2),+RES)
+21 IF '+ARR
KILL GMRCAR(50,CNT)
QUIT
+22 SET STR=$PIECE(ARR,U,9)_U_$PIECE(ARR,U,6)_$SELECT($PIECE(ARR,U,10):"^^^^^^^^1",1:"")
+23 SET GMRCAR(50,CNT)=GMRCAR(50,CNT)_U_STR
End DoDot:2
+24 SET CNT=CNT+1
End DoDot:1
+25 QUIT