MDRPCNT1 ; HOIFO/NCA - Object RPCs (TMDNOTE) Continued 2;10/29/04 12:20 ;2/25/09 16:08
;;1.0;CLINICAL PROCEDURES;**6,21**;Apr 01, 2004;Build 30
; Integration Agreements:
; IA# 2693 [Subscription] TIU Extractions.
; IA# 3535 [Subscription] Calls to TIUSRVP.
; IA# 4795 [Subscription] Calls to TIUSRVP2.
; IA# 5407 [Subscription] Call to GETDCOS^ORWTPN
ADDMSG ; [Procedure] Add message to transaction
N MDIEN,MDIENS,MDRET
Q:'$G(DATA("TRANSACTION"))
Q:$G(DATA("MESSAGE"))=""
S MDIEN=+DATA("TRANSACTION"),MDIENS="+1,"_MDIEN_","
D NOW^%DTC S DATA("DATE")=%
S MDFDA(702.091,MDIENS,.01)=+$O(^MDD(702,+MDIEN,.091,"A"),-1)+1
S MDFDA(702.091,MDIENS,.02)=DATA("DATE")
S MDFDA(702.091,MDIENS,.03)=$G(DATA("PKG"),"UNKNOWN")
S MDFDA(702.091,MDIENS,.09)=DATA("MESSAGE")
D UPDATE^DIE("","MDFDA","MDRET")
Q
;
FILEMSG(STUDY,MDPKG,MDSTAT,MDMSG) ; [Procedure] File Study Status and Message.
S DATA("TRANSACTION")=STUDY,DATA("PKG")=MDPKG
S DATA("MESSAGE")=$P(MDMSG,"^",2)
D STATUS(STUDY_",",MDSTAT,$P(MDMSG,"^",2)),ADDMSG
Q
;
STATUS(MDIENS,MDSTAT,MDMSG) ; [Procedure] Update transaction status
S MDFDA(702,MDIENS,.08)=$G(MDMSG)
S MDFDA(702,MDIENS,.09)=MDSTAT
D FILE^DIE("","MDFDA")
Q
;
SUBMIT(MDDATA,MDDT,MDAU,MDESIG,MDNTL,MDG1) ; [Procedure] Process the Image(s) Submission.
; Input: MDDATA - Study ID
; MDDT-Date/Time of Document
; MDA - Author
; MDESIG - Electronic Signature
; MDNTL - Note title
; MDG1 - ^TMP global with the text of the report
; Output: -1^Error Message or
; 1^Successful Message
N MDANS,MDRESUL,MDSTUDY,MDG2,RES,MDN
S MDSTUDY=+MDDATA,(RES,MDRESUL)=""
; Create New TIU Document
S (MDN,MDRESUL)=$$NEWTIUN(MDSTUDY,MDDT,MDAU,MDNTL)
; File TIU Error messages
I +MDRESUL<0 D Q RES
.D FILEMSG(MDSTUDY,"TIU",2,MDRESUL)
.S RES=MDRESUL
S MDANS=+MDRESUL
; Update the text of the TIU document
S MDG2=@($NA(MDG1))
I +$O(@MDG2@(""),-1) D Q:RES'="" RES
.S MDRESUL=$$UPDATE(MDSTUDY,MDANS,MDESIG,MDG2)
.I +MDRESUL<0 D Q
..D FILEMSG(MDSTUDY,"TIU",2,MDRESUL)
..S RES=MDRESUL
S RES=MDANS
N XX S XX="",XX=$$UPDCONS^MDRPCOT1(+$P($G(^MDD(702,+MDSTUDY,0)),U,5),+MDN)
Q RES
;
GETDATA(STUDY) ; [Function] Return the Necessary data for creating a TIU note.
; Return: Patient DFN_"^"_TIU title_"^"_Hospital Location_"^"_TIU Note
; IEN_"^"_Consult #_"^"_CP Definition IEN_"^"_Visit String_"^"
; New Visit Flag
; or
; -1^Error Message
N DFN,MDCON,MDFN,MDIEN,MDIENS,MDLOC,MDNEWV,MDNOTE,MDNVST,MDPROC,MDVSTR,MDTITL,MDX,MDTST
S MDIEN=+STUDY,MDIENS=MDIEN_",",MDNVST=0
I $$GET1^DIQ(702,MDIENS,.01)="" Q "-1^No such study entry."
; Get DFN
S DFN=$$GET1^DIQ(702,MDIEN,.01,"I")
I 'DFN Q "-1^No DFN."
; Get CP Def
S MDPROC=$$GET1^DIQ(702,MDIEN,.04,"I")
I 'MDPROC Q "-1^No CP Def."
; Get Consult
S MDCON=$$GET1^DIQ(702,MDIEN,.05,"I")
I 'MDCON Q "-1^No Consult #."
; Get TIU Note Title
S MDTITL=$$GET1^DIQ(702.01,+MDPROC_",",.04,"I")
I 'MDTITL Q "-1^No TIU Note Title."
S MDVSTR=$$GET1^DIQ(702,MDIEN,.07)
I MDVSTR="" Q "-1^No Visit String."
I $L(MDVSTR,";")=1 S MDNVST=1,MDVSTR=";"_MDVSTR ; If new visit is selected
; MDLOC is Hospital Location
I MDVSTR'="" D
.S MDVSTR=$$GETVSTR^MDRPCOT1(DFN,MDVSTR,MDPROC,$$GET1^DIQ(702,MDIEN,.02,"I"))
.S MDLOC=$P(MDVSTR,";",1)
; Does TIU doc already exist?
;I $$GET1^DIQ(702,MDIEN,.06,"I") Q DFN_"^"_MDTITL_"^"_MDLOC_"^"_+$$GET1^DIQ(702,MDIEN,.06,"I")_"^"_MDCON_"^"_MDPROC_"^"_MDVSTR_"^"_MDNVST
; Does TIU doc exist for previous transaction of this consult?
;I MDCON S MDNOTE=$$PREV(MDCON,MDIEN)
S MDNOTE=""
Q DFN_"^"_MDTITL_"^"_MDLOC_"^"_+MDNOTE_"^"_MDCON_"^"_MDPROC_"^"_MDVSTR_"^"_MDNVST
;
NEWTIUN(STUDY,MDDT,MDA,MDNT) ; [Function] Create a new TIU for transaction
; Input: STUDY - IENS of CP study entry
; MDDT - Date of Note
; MDA - Author
; MDNT - Note Title
; Return: TIU Document IEN
N CTR,DFN,MDCON,MDFDA,MDGST,MDL,MDLOC,MDNOTE,MDPDT,MDPROC,MDPT,MDRESU,MDDTTL,MDTITL,MDTSTR,MDVST,MDVSTR,MDWP S CTR=0,MDGST=+STUDY,MDRESU="" N MDFIL S MDFIL=8925.1
; Get data for TIU Note Creation
S (MDTSTR,MDRESU)=$$GETDATA(MDGST),MDDTTL=0
; File Error message
I +MDRESU<0 D FILEMSG(MDGST,"CP",2,MDRESU) Q MDRESU
I $G(MDTSTR)="" Q "-1^No Data to Create TIU Document"
F MDL="DFN","MDTITL","MDLOC","MDNOTE","MDCON","MDPROC","MDVSTR","MDNVST" D
.S CTR=CTR+1,@MDL=$P(MDTSTR,"^",CTR)
S (MDVST,MDRESU)=""
; If previous TIU document exists, quit
;I MDNOTE Q MDNOTE
I 'MDLOC Q "-1^No Hospital Location."
; Create new visit, if no vstring
S MDDTTL=+$$FIND1^DIC(MDFIL,"","BOX",MDNT,"B","","MDERR")
S MDTITL=$S(+MDDTTL>0:+MDDTTL,1:MDTITL)
S MDPDT=$$PDT^MDRPCOT1(MDGST)
I 'MDPDT S MDPT=$O(^MDD(703.1,"ASTUDYID",+MDGST,0)),MDPDT=$P($G(^MDD(703.1,+MDPT,0)),U,3)
S:'MDPDT MDPDT=$P(MDVSTR,";",2) ; If No D/T Performed grab visit D/T
; Build variables for TIU Call
S MDWP(.05)=1 ; Undicated Status
S MDWP(1201)=MDDT ; Date/Time Note Created
S MDWP(1202)=MDA ; Author of Note
S MDWP(1302)=MDA ; Entered By
S MDWP(1405)=+MDCON_";GMR(123," ; Package Reference
S MDWP(70201)=5 ; Default Procedure Summary Code "Machine Resulted"
I MDPDT S MDWP(70202)=MDPDT ; Date/Time Performed
; File PCE Error message
I MDNVST S MDRESU=$$EN1^MDPCE(MDGST,MDPDT,MDPROC,$P(MDVSTR,";",3),"P") I +MDRESU S MDVST=+MDRESU,MDVSTR=$P(MDRESU,"^",2)
I +MDRESU<0 D FILEMSG(MDGST,"PCE",2,$P(MDRESU,"^",2)) Q MDRESU
; Create the TIU note stub
I MDVST="" S MDVST=+$G(^MDD(702,MDGST,1))
S MDNOTE="" D MAKE^TIUSRVP(.MDNOTE,DFN,MDTITL,$P(MDVSTR,";",2),MDLOC,$S(MDVST:MDVST,1:""),.MDWP,MDVSTR,1,1)
I '(+MDNOTE) S $P(MDNOTE,"^")=-1 Q MDNOTE
;S MDFDA(702,STUDY_",",.06)=+MDNOTE
S MDFDA(702,STUDY_",",.08)=""
D FILE^DIE("","MDFDA")
D UPD^MDKUTLR(STUDY,+MDNOTE)
Q MDNOTE
;
UPDATE(STUDY,MDA,SIGN,MDGLB) ; Update the TIU document with the text
N MDK,MDNOTE,MDPPR,MDRESU,MDS,MDTI,MDTIUER,MDWP,MDV,MDV1,MDVAU S (MDNOTE,MDTIUER)="" K MDWP,^TMP("MDTIUST",$J)
F MDK=0:0 S MDK=$O(@MDGLB@(MDK)) Q:'MDK S MDWP("TEXT",MDK,0)=$G(@MDGLB@(MDK))
S MDTI=MDA
S MDWP(.05)=5
D GETDCOS^ORWTPN(.MDVAU,DUZ)
I +MDVAU S MDWP(1506)=1,MDWP(1208)=+MDVAU
D UPDATE^TIUSRVP(.MDNOTE,+MDTI,.MDWP,1)
I '+MDNOTE S MDNOTE="-1^"_$P(MDNOTE,"^",2) Q MDNOTE
; Sign TIU Document
S MDS=$$SIGN(MDTI,SIGN) I MDS<0 Q MDS
Q 1
SIGN(MDTIUIN,MDSIGN) ; Sign the TIU Document
; [Function] TIU SIGN RECORD
;Input Parameters:
; 1. TIUIEN [Literal/Required] TIU internal Entry Number
; 2. MDSIGN [Literal/Required] User Signature
N MDSRES,X
S MDSRES=""
D SIGN^TIUSRVP2(.MDSRES,MDTIUIN,MDSIGN)
I +MDSRES>0 Q "-1^"_$P(MDSRES,"^",2)
Q 1
;
PREV(MDC,MDS) ; [Function] Return the Previous TIU document.
N MDNEWV,MDDOC,MDTRAN,MDTIUER,MDTST
S (MDDOC,MDNEWV,MDTRAN,MDTIUER,MDTST)="" K ^TMP("MDTIUST",$J)
F S MDTRAN=$O(^MDD(702,"ACON",MDC,MDTRAN)) Q:'MDTRAN D Q:'MDTRAN
.I $P(^MDD(702,MDTRAN,0),U,6) D
..D EXTRACT^TIULQ($P(^MDD(702,MDTRAN,0),U,6),"^TMP(""MDTIUST"",$J)",MDTIUER,".01;.05;1406") Q:+MDTIUER
..S MDTST=$G(^TMP("MDTIUST",$J,$P(^MDD(702,MDTRAN,0),U,6),.05,"E"))
..I MDTST'="UNDICTATED"&(MDTST'="UNSIGNED") K ^TMP("MDTIUST",$J) Q
..I MDTST="UNSIGNED"&'($G(^TMP("MDTIUST",$J,$P(^MDD(702,MDTRAN,0),U,6),1406,"I"))) K ^TMP("MDTIUST",$J) Q
..S MDDOC=$P(^MDD(702,MDTRAN,0),U,6),MDNEWV=$P(^MDD(702,MDTRAN,0),U,7)
..Q:'MDS
..S MDFDA(702,MDS_",",.06)=MDDOC
..S MDFDA(702,MDS_",",.07)=MDNEWV
..D FILE^DIE("","MDFDA")
..S MDTRAN=""
Q MDDOC
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMDRPCNT1 7571 printed Nov 22, 2024@16:54:10 Page 2
MDRPCNT1 ; HOIFO/NCA - Object RPCs (TMDNOTE) Continued 2;10/29/04 12:20 ;2/25/09 16:08
+1 ;;1.0;CLINICAL PROCEDURES;**6,21**;Apr 01, 2004;Build 30
+2 ; Integration Agreements:
+3 ; IA# 2693 [Subscription] TIU Extractions.
+4 ; IA# 3535 [Subscription] Calls to TIUSRVP.
+5 ; IA# 4795 [Subscription] Calls to TIUSRVP2.
+6 ; IA# 5407 [Subscription] Call to GETDCOS^ORWTPN
ADDMSG ; [Procedure] Add message to transaction
+1 NEW MDIEN,MDIENS,MDRET
+2 if '$GET(DATA("TRANSACTION"))
QUIT
+3 if $GET(DATA("MESSAGE"))=""
QUIT
+4 SET MDIEN=+DATA("TRANSACTION")
SET MDIENS="+1,"_MDIEN_","
+5 DO NOW^%DTC
SET DATA("DATE")=%
+6 SET MDFDA(702.091,MDIENS,.01)=+$ORDER(^MDD(702,+MDIEN,.091,"A"),-1)+1
+7 SET MDFDA(702.091,MDIENS,.02)=DATA("DATE")
+8 SET MDFDA(702.091,MDIENS,.03)=$GET(DATA("PKG"),"UNKNOWN")
+9 SET MDFDA(702.091,MDIENS,.09)=DATA("MESSAGE")
+10 DO UPDATE^DIE("","MDFDA","MDRET")
+11 QUIT
+12 ;
FILEMSG(STUDY,MDPKG,MDSTAT,MDMSG) ; [Procedure] File Study Status and Message.
+1 SET DATA("TRANSACTION")=STUDY
SET DATA("PKG")=MDPKG
+2 SET DATA("MESSAGE")=$PIECE(MDMSG,"^",2)
+3 DO STATUS(STUDY_",",MDSTAT,$PIECE(MDMSG,"^",2))
DO ADDMSG
+4 QUIT
+5 ;
STATUS(MDIENS,MDSTAT,MDMSG) ; [Procedure] Update transaction status
+1 SET MDFDA(702,MDIENS,.08)=$GET(MDMSG)
+2 SET MDFDA(702,MDIENS,.09)=MDSTAT
+3 DO FILE^DIE("","MDFDA")
+4 QUIT
+5 ;
SUBMIT(MDDATA,MDDT,MDAU,MDESIG,MDNTL,MDG1) ; [Procedure] Process the Image(s) Submission.
+1 ; Input: MDDATA - Study ID
+2 ; MDDT-Date/Time of Document
+3 ; MDA - Author
+4 ; MDESIG - Electronic Signature
+5 ; MDNTL - Note title
+6 ; MDG1 - ^TMP global with the text of the report
+7 ; Output: -1^Error Message or
+8 ; 1^Successful Message
+9 NEW MDANS,MDRESUL,MDSTUDY,MDG2,RES,MDN
+10 SET MDSTUDY=+MDDATA
SET (RES,MDRESUL)=""
+11 ; Create New TIU Document
+12 SET (MDN,MDRESUL)=$$NEWTIUN(MDSTUDY,MDDT,MDAU,MDNTL)
+13 ; File TIU Error messages
+14 IF +MDRESUL<0
Begin DoDot:1
+15 DO FILEMSG(MDSTUDY,"TIU",2,MDRESUL)
+16 SET RES=MDRESUL
End DoDot:1
QUIT RES
+17 SET MDANS=+MDRESUL
+18 ; Update the text of the TIU document
+19 SET MDG2=@($NAME(MDG1))
+20 IF +$ORDER(@MDG2@(""),-1)
Begin DoDot:1
+21 SET MDRESUL=$$UPDATE(MDSTUDY,MDANS,MDESIG,MDG2)
+22 IF +MDRESUL<0
Begin DoDot:2
+23 DO FILEMSG(MDSTUDY,"TIU",2,MDRESUL)
+24 SET RES=MDRESUL
End DoDot:2
QUIT
End DoDot:1
if RES'=""
QUIT RES
+25 SET RES=MDANS
+26 NEW XX
SET XX=""
SET XX=$$UPDCONS^MDRPCOT1(+$PIECE($GET(^MDD(702,+MDSTUDY,0)),U,5),+MDN)
+27 QUIT RES
+28 ;
GETDATA(STUDY) ; [Function] Return the Necessary data for creating a TIU note.
+1 ; Return: Patient DFN_"^"_TIU title_"^"_Hospital Location_"^"_TIU Note
+2 ; IEN_"^"_Consult #_"^"_CP Definition IEN_"^"_Visit String_"^"
+3 ; New Visit Flag
+4 ; or
+5 ; -1^Error Message
+6 NEW DFN,MDCON,MDFN,MDIEN,MDIENS,MDLOC,MDNEWV,MDNOTE,MDNVST,MDPROC,MDVSTR,MDTITL,MDX,MDTST
+7 SET MDIEN=+STUDY
SET MDIENS=MDIEN_","
SET MDNVST=0
+8 IF $$GET1^DIQ(702,MDIENS,.01)=""
QUIT "-1^No such study entry."
+9 ; Get DFN
+10 SET DFN=$$GET1^DIQ(702,MDIEN,.01,"I")
+11 IF 'DFN
QUIT "-1^No DFN."
+12 ; Get CP Def
+13 SET MDPROC=$$GET1^DIQ(702,MDIEN,.04,"I")
+14 IF 'MDPROC
QUIT "-1^No CP Def."
+15 ; Get Consult
+16 SET MDCON=$$GET1^DIQ(702,MDIEN,.05,"I")
+17 IF 'MDCON
QUIT "-1^No Consult #."
+18 ; Get TIU Note Title
+19 SET MDTITL=$$GET1^DIQ(702.01,+MDPROC_",",.04,"I")
+20 IF 'MDTITL
QUIT "-1^No TIU Note Title."
+21 SET MDVSTR=$$GET1^DIQ(702,MDIEN,.07)
+22 IF MDVSTR=""
QUIT "-1^No Visit String."
+23 ; If new visit is selected
IF $LENGTH(MDVSTR,";")=1
SET MDNVST=1
SET MDVSTR=";"_MDVSTR
+24 ; MDLOC is Hospital Location
+25 IF MDVSTR'=""
Begin DoDot:1
+26 SET MDVSTR=$$GETVSTR^MDRPCOT1(DFN,MDVSTR,MDPROC,$$GET1^DIQ(702,MDIEN,.02,"I"))
+27 SET MDLOC=$PIECE(MDVSTR,";",1)
End DoDot:1
+28 ; Does TIU doc already exist?
+29 ;I $$GET1^DIQ(702,MDIEN,.06,"I") Q DFN_"^"_MDTITL_"^"_MDLOC_"^"_+$$GET1^DIQ(702,MDIEN,.06,"I")_"^"_MDCON_"^"_MDPROC_"^"_MDVSTR_"^"_MDNVST
+30 ; Does TIU doc exist for previous transaction of this consult?
+31 ;I MDCON S MDNOTE=$$PREV(MDCON,MDIEN)
+32 SET MDNOTE=""
+33 QUIT DFN_"^"_MDTITL_"^"_MDLOC_"^"_+MDNOTE_"^"_MDCON_"^"_MDPROC_"^"_MDVSTR_"^"_MDNVST
+34 ;
NEWTIUN(STUDY,MDDT,MDA,MDNT) ; [Function] Create a new TIU for transaction
+1 ; Input: STUDY - IENS of CP study entry
+2 ; MDDT - Date of Note
+3 ; MDA - Author
+4 ; MDNT - Note Title
+5 ; Return: TIU Document IEN
+6 NEW CTR,DFN,MDCON,MDFDA,MDGST,MDL,MDLOC,MDNOTE,MDPDT,MDPROC,MDPT,MDRESU,MDDTTL,MDTITL,MDTSTR,MDVST,MDVSTR,MDWP
SET CTR=0
SET MDGST=+STUDY
SET MDRESU=""
NEW MDFIL
SET MDFIL=8925.1
+7 ; Get data for TIU Note Creation
+8 SET (MDTSTR,MDRESU)=$$GETDATA(MDGST)
SET MDDTTL=0
+9 ; File Error message
+10 IF +MDRESU<0
DO FILEMSG(MDGST,"CP",2,MDRESU)
QUIT MDRESU
+11 IF $GET(MDTSTR)=""
QUIT "-1^No Data to Create TIU Document"
+12 FOR MDL="DFN","MDTITL","MDLOC","MDNOTE","MDCON","MDPROC","MDVSTR","MDNVST"
Begin DoDot:1
+13 SET CTR=CTR+1
SET @MDL=$PIECE(MDTSTR,"^",CTR)
End DoDot:1
+14 SET (MDVST,MDRESU)=""
+15 ; If previous TIU document exists, quit
+16 ;I MDNOTE Q MDNOTE
+17 IF 'MDLOC
QUIT "-1^No Hospital Location."
+18 ; Create new visit, if no vstring
+19 SET MDDTTL=+$$FIND1^DIC(MDFIL,"","BOX",MDNT,"B","","MDERR")
+20 SET MDTITL=$SELECT(+MDDTTL>0:+MDDTTL,1:MDTITL)
+21 SET MDPDT=$$PDT^MDRPCOT1(MDGST)
+22 IF 'MDPDT
SET MDPT=$ORDER(^MDD(703.1,"ASTUDYID",+MDGST,0))
SET MDPDT=$PIECE($GET(^MDD(703.1,+MDPT,0)),U,3)
+23 ; If No D/T Performed grab visit D/T
if 'MDPDT
SET MDPDT=$PIECE(MDVSTR,";",2)
+24 ; Build variables for TIU Call
+25 ; Undicated Status
SET MDWP(.05)=1
+26 ; Date/Time Note Created
SET MDWP(1201)=MDDT
+27 ; Author of Note
SET MDWP(1202)=MDA
+28 ; Entered By
SET MDWP(1302)=MDA
+29 ; Package Reference
SET MDWP(1405)=+MDCON_";GMR(123,"
+30 ; Default Procedure Summary Code "Machine Resulted"
SET MDWP(70201)=5
+31 ; Date/Time Performed
IF MDPDT
SET MDWP(70202)=MDPDT
+32 ; File PCE Error message
+33 IF MDNVST
SET MDRESU=$$EN1^MDPCE(MDGST,MDPDT,MDPROC,$PIECE(MDVSTR,";",3),"P")
IF +MDRESU
SET MDVST=+MDRESU
SET MDVSTR=$PIECE(MDRESU,"^",2)
+34 IF +MDRESU<0
DO FILEMSG(MDGST,"PCE",2,$PIECE(MDRESU,"^",2))
QUIT MDRESU
+35 ; Create the TIU note stub
+36 IF MDVST=""
SET MDVST=+$GET(^MDD(702,MDGST,1))
+37 SET MDNOTE=""
DO MAKE^TIUSRVP(.MDNOTE,DFN,MDTITL,$PIECE(MDVSTR,";",2),MDLOC,$SELECT(MDVST:MDVST,1:""),.MDWP,MDVSTR,1,1)
+38 IF '(+MDNOTE)
SET $PIECE(MDNOTE,"^")=-1
QUIT MDNOTE
+39 ;S MDFDA(702,STUDY_",",.06)=+MDNOTE
+40 SET MDFDA(702,STUDY_",",.08)=""
+41 DO FILE^DIE("","MDFDA")
+42 DO UPD^MDKUTLR(STUDY,+MDNOTE)
+43 QUIT MDNOTE
+44 ;
UPDATE(STUDY,MDA,SIGN,MDGLB) ; Update the TIU document with the text
+1 NEW MDK,MDNOTE,MDPPR,MDRESU,MDS,MDTI,MDTIUER,MDWP,MDV,MDV1,MDVAU
SET (MDNOTE,MDTIUER)=""
KILL MDWP,^TMP("MDTIUST",$JOB)
+2 FOR MDK=0:0
SET MDK=$ORDER(@MDGLB@(MDK))
if 'MDK
QUIT
SET MDWP("TEXT",MDK,0)=$GET(@MDGLB@(MDK))
+3 SET MDTI=MDA
+4 SET MDWP(.05)=5
+5 DO GETDCOS^ORWTPN(.MDVAU,DUZ)
+6 IF +MDVAU
SET MDWP(1506)=1
SET MDWP(1208)=+MDVAU
+7 DO UPDATE^TIUSRVP(.MDNOTE,+MDTI,.MDWP,1)
+8 IF '+MDNOTE
SET MDNOTE="-1^"_$PIECE(MDNOTE,"^",2)
QUIT MDNOTE
+9 ; Sign TIU Document
+10 SET MDS=$$SIGN(MDTI,SIGN)
IF MDS<0
QUIT MDS
+11 QUIT 1
SIGN(MDTIUIN,MDSIGN) ; Sign the TIU Document
+1 ; [Function] TIU SIGN RECORD
+2 ;Input Parameters:
+3 ; 1. TIUIEN [Literal/Required] TIU internal Entry Number
+4 ; 2. MDSIGN [Literal/Required] User Signature
+5 NEW MDSRES,X
+6 SET MDSRES=""
+7 DO SIGN^TIUSRVP2(.MDSRES,MDTIUIN,MDSIGN)
+8 IF +MDSRES>0
QUIT "-1^"_$PIECE(MDSRES,"^",2)
+9 QUIT 1
+10 ;
PREV(MDC,MDS) ; [Function] Return the Previous TIU document.
+1 NEW MDNEWV,MDDOC,MDTRAN,MDTIUER,MDTST
+2 SET (MDDOC,MDNEWV,MDTRAN,MDTIUER,MDTST)=""
KILL ^TMP("MDTIUST",$JOB)
+3 FOR
SET MDTRAN=$ORDER(^MDD(702,"ACON",MDC,MDTRAN))
if 'MDTRAN
QUIT
Begin DoDot:1
+4 IF $PIECE(^MDD(702,MDTRAN,0),U,6)
Begin DoDot:2
+5 DO EXTRACT^TIULQ($PIECE(^MDD(702,MDTRAN,0),U,6),"^TMP(""MDTIUST"",$J)",MDTIUER,".01;.05;1406")
if +MDTIUER
QUIT
+6 SET MDTST=$GET(^TMP("MDTIUST",$JOB,$PIECE(^MDD(702,MDTRAN,0),U,6),.05,"E"))
+7 IF MDTST'="UNDICTATED"&(MDTST'="UNSIGNED")
KILL ^TMP("MDTIUST",$JOB)
QUIT
+8 IF MDTST="UNSIGNED"&'($GET(^TMP("MDTIUST",$JOB,$PIECE(^MDD(702,MDTRAN,0),U,6),1406,"I")))
KILL ^TMP("MDTIUST",$JOB)
QUIT
+9 SET MDDOC=$PIECE(^MDD(702,MDTRAN,0),U,6)
SET MDNEWV=$PIECE(^MDD(702,MDTRAN,0),U,7)
+10 if 'MDS
QUIT
+11 SET MDFDA(702,MDS_",",.06)=MDDOC
+12 SET MDFDA(702,MDS_",",.07)=MDNEWV
+13 DO FILE^DIE("","MDFDA")
+14 SET MDTRAN=""
End DoDot:2
End DoDot:1
if 'MDTRAN
QUIT
+15 QUIT MDDOC