GMRCUTL1 ;SLC/DCM,JFR,MA - General Utilities ;12-Feb-2015 15:20;DU
;;3.0;CONSULT/REQUEST TRACKING;**1,4,12,15,21,17,28,1004,1005**;DEC 27, 1997;Build 2
;
; This routine invokes IA #2876,3121
; Patch #21 added variable GMRCAUDT and moved line tag PRNTAUDT
; to GMRCP5A.
;
ACTM ;;Set correct variables to complete, discontinue, etc. a consult
K GMRCQUT
S:'+$G(GMRCA) GMRCA=$O(^GMR(123.1,"B",GMRCACTM,""))
S GMRCACTM=$P($G(^GMR(123.1,+GMRCA,0)),"^")
S ORSTS=$S(GMRCA:$P(^GMR(123.1,GMRCA,0),"^",2),1:0)
I 'GMRCA S GMRCQUT=1
Q
PRNT(SRVCIFN,GMRCO) ;print form 513 to a printer when new consult is entered
N ORVP,GMRCDEV,GMRCQUED,IOP,%ZIS,POP,ZTDTH,ZTDESC,ZTIO,ZTRTN,ZTSK,GMRCAUDT
I '$G(SRVCIFN) S SRVCIFN=+$P(^GMR(123,GMRCO,0),U,5)
Q:'$D(^GMR(123.5,SRVCIFN,123)) Q:'$P(^GMR(123.5,SRVCIFN,123),"^",9)
S IOP="`"_$P(^GMR(123.5,SRVCIFN,123),"^",9)
S %ZIS="N" D ^%ZIS I POP S %ZIS=0 D HOME^%ZIS Q
S GMRCDEV=ION,GMRCQUED=1,GMRCAUDT=1
S ZTRTN="PRNT^GMRCP5A("_(+GMRCO)_","_(+$G(TIUFLG))_",1,"""_$G(GMRCCPY,"W")_""",0,"_(GMRCAUDT)_")"
S ZTDESC="CONSULT/REQUEST PACKAGE PRINT FORM 513 FOR NEW CONSULT"
S ZTIO=GMRCDEV,ZTDTH=$H
D ^%ZTLOAD
S %ZIS=0 D HOME^%ZIS
K GMRCQUED,GMRCDEV1
Q
END K GMRCDEV,GMRCDEV1,GMRCOREC,GMRCFMT
Q
PROVDX(OI) ;return PROV DX prompting info from 123.5
; Input:
; OI = ref to file 123.5("#;99CON") or file 123.3 (#;99PRC)
;
; Returns: string A^B
; A = O (optional), R (required) or S (suppress)
; B = F (free-text) or L (lexicon)
;
N GMRCFIL
Q:'+$G(OI) "^"
S GMRCFIL=$S(OI["99PRC":123.3,1:123.5)
Q:'$D(^GMR(GMRCFIL,+OI)) "^"
N STRING,NODE,DATA
I GMRCFIL=123.3 S NODE=$P(^GMR(123.3,+OI,0),U,7,8)
I GMRCFIL=123.5 S NODE=$P($G(^GMR(123.5,+OI,1)),U,1,2)
;IHS/MSC/MGH patch 1005 check for parameter being turned off
D GETPAR^CIAVMRPC(.DATA,"BEHOORPA CLINICAL INDICATOR","ALL","CONSULT/REQUEST TRACKING")
I DATA=0 Q "O^F" ;Parameter is not turned on
I NODE="" Q "R^F" ;values not set
S $P(STRING,U)=$S($L($P(NODE,U)):$P(NODE,U),1:"R")
S $P(STRING,U,2)=$S($L($P(NODE,U,2)):$P(NODE,U,2),1:"F")
Q STRING
ORIFN(GMRC123) ;return ORIFN associated with give record in ^GMR(123,
; GMRC123 = ien of consult record in file 123
Q $P($G(^GMR(123,GMRC123,0)),U,3)
GETDT(PROMPT,DEFAULT) ;prompt and return FM date
;Input:
; PROMPT = text of prompt - DIR("A") (optional)
; DEFAULT = default date to prompt - DIR("B") (optional)
;
;Output:
; FM date/time if successfully answered, "^" if exit or timeout
N DIR,DIRUT,DIROUT,DTOUT,DUOUT,X,Y
S DIR(0)="DA^::EPT"
S DIR("?")="Enter the date/time the activity took place."
S DIR("A")=$S($D(PROMPT):PROMPT_" ",1:"Actual Date/Time of Activity: ")
S DIR("B")=$S($D(DEFAULT):DEFAULT,1:"NOW")
D ^DIR
I $D(DUOUT)!($D(DTOUT)) S Y="^"
Q Y
;
DCPRNT(IEN,USER) ;reprint SF-513 on DC?
N SERV,REPR
S SERV=$P(^GMR(123,IEN,0),U,5) I 'SERV Q 0
S REPR=$P($G(^GMR(123.5,SERV,1)),U,5)
I 'REPR Q 1
I REPR=2 Q 0
I REPR=1,'$$VALID^GMRCAU(SERV,IEN,USER) Q 1
Q 0
;
PREREQ(GMRCARR,GMRCSRV,GMRCDFN,UNRESOLV) ; return service pre-requisite
; pre-requisite stored in 125 nodes in file 123.5 or 123.3
; GMRCARR = array to return containing pre-requisite
; GMRCSRV = ref to file 123.5 (ien;99CON) or 123.3 (ien;99PRC)
; GMRCDFN = patient identifier if to return resolved
; UNRESOLV = 1 or 0 ; if UNRESOLV=1 GMRCARR will be returned unresolved
Q:'+GMRCSRV
N GMRCFIL
S GMRCFIL=$S(GMRCSRV["99PRC":123.3,1:123.5)
Q:'$D(^GMR(GMRCFIL,+GMRCSRV,125))
I '$D(GMRCDFN)!($G(UNRESOLV)) D Q
. M @GMRCARR=^GMR(GMRCFIL,+GMRCSRV,125)
D BLRPLT^TIUSRVD(,,GMRCDFN,,$NA(^GMR(GMRCFIL,+GMRCSRV,125)))
I $D(^TMP("TIUBOIL",$J)) M @GMRCARR=^TMP("TIUBOIL",$J)
K ^TMP("TIUBOIL",$J)
Q
;
LOCKREC(GMRCDA) ;attempt to lock a consult record using order or record
; Input:
; GMRCDA = ien of consult record from file 123
;
; Output:
; 1 or 0^reason can't be locked
; 1 = successfully locked
; 0 = couldn't be locked
N GMRCORD,GMRCMSG
S GMRCORD=$P($G(^GMR(123,GMRCDA,0)),U,3)
I $G(GMRCORD) D ;an order associated
. S GMRCMSG=$$LOCK1^ORX2(GMRCORD)
. ; GMRCMSG=1 if locked or 0 if couldn't be locked
I $L($G(GMRCMSG)) Q GMRCMSG
; no order = Inter-facility Consult so lock consult record
L +^GMR(123,GMRCDA):5
I '$T Q "0^Another user is editing this record" ; couldn't lock it
Q 1
;
UNLKREC(GMRCDA) ;unlock a consult record
; Input:
; GMRCDA = ien of consult record from file 123
;
N GMRCORD
S GMRCORD=$P($G(^GMR(123,GMRCDA,0)),U,3)
I $G(GMRCORD) D Q
. D UNLK1^ORX2(GMRCORD)
L -^GMR(123,GMRCDA)
Q
GMRCUTL1 ;SLC/DCM,JFR,MA - General Utilities ;12-Feb-2015 15:20;DU
+1 ;;3.0;CONSULT/REQUEST TRACKING;**1,4,12,15,21,17,28,1004,1005**;DEC 27, 1997;Build 2
+2 ;
+3 ; This routine invokes IA #2876,3121
+4 ; Patch #21 added variable GMRCAUDT and moved line tag PRNTAUDT
+5 ; to GMRCP5A.
+6 ;
ACTM ;;Set correct variables to complete, discontinue, etc. a consult
+1 KILL GMRCQUT
+2 IF '+$GET(GMRCA)
SET GMRCA=$ORDER(^GMR(123.1,"B",GMRCACTM,""))
+3 SET GMRCACTM=$PIECE($GET(^GMR(123.1,+GMRCA,0)),"^")
+4 SET ORSTS=$SELECT(GMRCA:$PIECE(^GMR(123.1,GMRCA,0),"^",2),1:0)
+5 IF 'GMRCA
SET GMRCQUT=1
+6 QUIT
PRNT(SRVCIFN,GMRCO) ;print form 513 to a printer when new consult is entered
+1 NEW ORVP,GMRCDEV,GMRCQUED,IOP,%ZIS,POP,ZTDTH,ZTDESC,ZTIO,ZTRTN,ZTSK,GMRCAUDT
+2 IF '$GET(SRVCIFN)
SET SRVCIFN=+$PIECE(^GMR(123,GMRCO,0),U,5)
+3 IF '$DATA(^GMR(123.5,SRVCIFN,123))
QUIT
IF '$PIECE(^GMR(123.5,SRVCIFN,123),"^",9)
QUIT
+4 SET IOP="`"_$PIECE(^GMR(123.5,SRVCIFN,123),"^",9)
+5 SET %ZIS="N"
DO ^%ZIS
IF POP
SET %ZIS=0
DO HOME^%ZIS
QUIT
+6 SET GMRCDEV=ION
SET GMRCQUED=1
SET GMRCAUDT=1
+7 SET ZTRTN="PRNT^GMRCP5A("_(+GMRCO)_","_(+$GET(TIUFLG))_",1,"""_$GET(GMRCCPY,"W")_""",0,"_(GMRCAUDT)_")"
+8 SET ZTDESC="CONSULT/REQUEST PACKAGE PRINT FORM 513 FOR NEW CONSULT"
+9 SET ZTIO=GMRCDEV
SET ZTDTH=$HOROLOG
+10 DO ^%ZTLOAD
+11 SET %ZIS=0
DO HOME^%ZIS
+12 KILL GMRCQUED,GMRCDEV1
+13 QUIT
END KILL GMRCDEV,GMRCDEV1,GMRCOREC,GMRCFMT
+1 QUIT
PROVDX(OI) ;return PROV DX prompting info from 123.5
+1 ; Input:
+2 ; OI = ref to file 123.5("#;99CON") or file 123.3 (#;99PRC)
+3 ;
+4 ; Returns: string A^B
+5 ; A = O (optional), R (required) or S (suppress)
+6 ; B = F (free-text) or L (lexicon)
+7 ;
+8 NEW GMRCFIL
+9 IF '+$GET(OI)
QUIT "^"
+10 SET GMRCFIL=$SELECT(OI["99PRC":123.3,1:123.5)
+11 IF '$DATA(^GMR(GMRCFIL,+OI))
QUIT "^"
+12 NEW STRING,NODE,DATA
+13 IF GMRCFIL=123.3
SET NODE=$PIECE(^GMR(123.3,+OI,0),U,7,8)
+14 IF GMRCFIL=123.5
SET NODE=$PIECE($GET(^GMR(123.5,+OI,1)),U,1,2)
+15 ;IHS/MSC/MGH patch 1005 check for parameter being turned off
+16 DO GETPAR^CIAVMRPC(.DATA,"BEHOORPA CLINICAL INDICATOR","ALL","CONSULT/REQUEST TRACKING")
+17 ;Parameter is not turned on
IF DATA=0
QUIT "O^F"
+18 ;values not set
IF NODE=""
QUIT "R^F"
+19 SET $PIECE(STRING,U)=$SELECT($LENGTH($PIECE(NODE,U)):$PIECE(NODE,U),1:"R")
+20 SET $PIECE(STRING,U,2)=$SELECT($LENGTH($PIECE(NODE,U,2)):$PIECE(NODE,U,2),1:"F")
+21 QUIT STRING
ORIFN(GMRC123) ;return ORIFN associated with give record in ^GMR(123,
+1 ; GMRC123 = ien of consult record in file 123
+2 QUIT $PIECE($GET(^GMR(123,GMRC123,0)),U,3)
GETDT(PROMPT,DEFAULT) ;prompt and return FM date
+1 ;Input:
+2 ; PROMPT = text of prompt - DIR("A") (optional)
+3 ; DEFAULT = default date to prompt - DIR("B") (optional)
+4 ;
+5 ;Output:
+6 ; FM date/time if successfully answered, "^" if exit or timeout
+7 NEW DIR,DIRUT,DIROUT,DTOUT,DUOUT,X,Y
+8 SET DIR(0)="DA^::EPT"
+9 SET DIR("?")="Enter the date/time the activity took place."
+10 SET DIR("A")=$SELECT($DATA(PROMPT):PROMPT_" ",1:"Actual Date/Time of Activity: ")
+11 SET DIR("B")=$SELECT($DATA(DEFAULT):DEFAULT,1:"NOW")
+12 DO ^DIR
+13 IF $DATA(DUOUT)!($DATA(DTOUT))
SET Y="^"
+14 QUIT Y
+15 ;
DCPRNT(IEN,USER) ;reprint SF-513 on DC?
+1 NEW SERV,REPR
+2 SET SERV=$PIECE(^GMR(123,IEN,0),U,5)
IF 'SERV
QUIT 0
+3 SET REPR=$PIECE($GET(^GMR(123.5,SERV,1)),U,5)
+4 IF 'REPR
QUIT 1
+5 IF REPR=2
QUIT 0
+6 IF REPR=1
IF '$$VALID^GMRCAU(SERV,IEN,USER)
QUIT 1
+7 QUIT 0
+8 ;
PREREQ(GMRCARR,GMRCSRV,GMRCDFN,UNRESOLV) ; return service pre-requisite
+1 ; pre-requisite stored in 125 nodes in file 123.5 or 123.3
+2 ; GMRCARR = array to return containing pre-requisite
+3 ; GMRCSRV = ref to file 123.5 (ien;99CON) or 123.3 (ien;99PRC)
+4 ; GMRCDFN = patient identifier if to return resolved
+5 ; UNRESOLV = 1 or 0 ; if UNRESOLV=1 GMRCARR will be returned unresolved
+6 IF '+GMRCSRV
QUIT
+7 NEW GMRCFIL
+8 SET GMRCFIL=$SELECT(GMRCSRV["99PRC":123.3,1:123.5)
+9 IF '$DATA(^GMR(GMRCFIL,+GMRCSRV,125))
QUIT
+10 IF '$DATA(GMRCDFN)!($GET(UNRESOLV))
Begin DoDot:1
+11 MERGE @GMRCARR=^GMR(GMRCFIL,+GMRCSRV,125)
End DoDot:1
QUIT
+12 DO BLRPLT^TIUSRVD(,,GMRCDFN,,$NAME(^GMR(GMRCFIL,+GMRCSRV,125)))
+13 IF $DATA(^TMP("TIUBOIL",$JOB))
MERGE @GMRCARR=^TMP("TIUBOIL",$JOB)
+14 KILL ^TMP("TIUBOIL",$JOB)
+15 QUIT
+16 ;
LOCKREC(GMRCDA) ;attempt to lock a consult record using order or record
+1 ; Input:
+2 ; GMRCDA = ien of consult record from file 123
+3 ;
+4 ; Output:
+5 ; 1 or 0^reason can't be locked
+6 ; 1 = successfully locked
+7 ; 0 = couldn't be locked
+8 NEW GMRCORD,GMRCMSG
+9 SET GMRCORD=$PIECE($GET(^GMR(123,GMRCDA,0)),U,3)
+10 ;an order associated
IF $GET(GMRCORD)
Begin DoDot:1
+11 SET GMRCMSG=$$LOCK1^ORX2(GMRCORD)
+12 ; GMRCMSG=1 if locked or 0 if couldn't be locked
End DoDot:1
+13 IF $LENGTH($GET(GMRCMSG))
QUIT GMRCMSG
+14 ; no order = Inter-facility Consult so lock consult record
+15 LOCK +^GMR(123,GMRCDA):5
+16 ; couldn't lock it
IF '$TEST
QUIT "0^Another user is editing this record"
+17 QUIT 1
+18 ;
UNLKREC(GMRCDA) ;unlock a consult record
+1 ; Input:
+2 ; GMRCDA = ien of consult record from file 123
+3 ;
+4 NEW GMRCORD
+5 SET GMRCORD=$PIECE($GET(^GMR(123,GMRCDA,0)),U,3)
+6 IF $GET(GMRCORD)
Begin DoDot:1
+7 DO UNLK1^ORX2(GMRCORD)
End DoDot:1
QUIT
+8 LOCK -^GMR(123,GMRCDA)
+9 QUIT