ORRCTIU ; SLC/JER - TIU data for CM ; 7/18/05 10:38
;;1.0;CARE MANAGEMENT;**2**;Jul 15, 2003
;
; This routine invokes IAs: 2322,2323,2834,2937,2944,2960,4175,4733
;
GETPTUNS(ORRCY,AUDUZ) ; Get pts w/documents that need user's signature
; Returns @ORRCY@(DFN,"DOC:"_TIUDA)=""
; [from ORRCDPT]
N TITLE,GVN,ORT,TIUDA,ORDFN,ITR,ORRCASIG
S TITLE=0,GVN=$NA(^TIU(8925,"AAU")),ORRCY=$NA(^TMP($J,"ORRCTIU")) K @ORRCY
F S TITLE=$O(@GVN@(AUDUZ,TITLE)) Q:+TITLE'>0 D
. S ORT=0 F S ORT=$O(@GVN@(AUDUZ,TITLE,5,ORT)) Q:+ORT'>0 D
.. S TIUDA=0
.. F S TIUDA=$O(@GVN@(AUDUZ,TITLE,5,ORT,TIUDA)) Q:+TIUDA'>0 D
... S ORDFN=$P($G(^TIU(8925,TIUDA,0)),U,2) Q:+ORDFN'>0
... I $D(^TMP($J,"ORRCLST")),'$D(^TMP($J,"ORRCY",ORDFN)) Q ;not on list
... I '+$$CANDO^TIULP(TIUDA,"SIGNATURE",AUDUZ) Q ; user may not sign
... S @ORRCY@(ORDFN,"DOC:"_TIUDA)=""
S TITLE=0,GVN=$NA(^TIU(8925,"ASUP"))
F S TITLE=$O(@GVN@(AUDUZ,TITLE)) Q:+TITLE'>0 D
. N STATUS F STATUS=5,6 D
.. S ORT=0 F S ORT=$O(@GVN@(AUDUZ,TITLE,STATUS,ORT)) Q:+ORT'>0 D
... S TIUDA=0
... F S TIUDA=$O(@GVN@(AUDUZ,TITLE,STATUS,ORT,TIUDA)) Q:+TIUDA'>0 D
.... S ORDFN=$P($G(^TIU(8925,TIUDA,0)),U,2) Q:+ORDFN'>0
.... I $D(^TMP($J,"ORRCLST")),'$D(^TMP($J,"ORRCY",ORDFN)) Q ;not on list
.... I '+$$CANDO^TIULP(TIUDA,$S(STATUS=5:"SIGNATURE",1:"COSIGNATURE"),AUDUZ) Q ; user may not Sign/Cosign
.... S @ORRCY@(ORDFN,"DOC:"_TIUDA)=""
; capture addl signer docs
K ^TMP("TIUSIGN",$J),^TMP("ORRCASIG",$J)
S ORRCASIG="",ITR=0
D NEEDSIG^TIULX(.ORRCASIG,AUDUZ)
Q:'$D(@ORRCASIG)
M ^TMP("ORRCASIG",$J)=@ORRCASIG
F S ITR=$O(^TMP("ORRCASIG",$J,ITR)) Q:'ITR D
. S TIUDA=^TMP("ORRCASIG",$J,ITR)
. S ORDFN=$P($G(^TIU(8925,TIUDA,0)),U,2) Q:+ORDFN'>0
. I $D(^TMP($J,"ORRCLST")),'$D(^TMP($J,"ORRCY",ORDFN)) Q ;not on list?
. I '+$$CANDO^TIULP(TIUDA,"SIGNATURE",AUDUZ) Q ; user may not sign
. S @ORRCY@(ORDFN,"DOC:"_TIUDA)=""
K ^TMP("TIUSIGN",$J),^TMP("ORRCASIG",$J)
Q
;
LISTUNS(ORY,ORUSR,ORPAT) ; -- Get list of unsigned documents for ORPAT by ORUSR
;
Q
;
TEXT(ORY,DOC) ; -- Return text of DOCs in
; @ORY@(#) = Item=ID^Title^Date IN HL7 format
; = Text=line of document text
N ORN,ORI,ORRCY,TIUDA,TIUY,TIUI,TIUX
S ORN=0,ORY=$NA(^TMP($J,"ORRCDOC")) K @ORY
S ORI="" F S ORI=$O(DOC(ORI)) Q:ORI="" D
. S TIUDA=+$P(DOC(ORI),":",2) D TGET^TIUSRVR1(.ORRCY,TIUDA)
. M TIUY=ORRCY
. S TIUX=$$RESOLVE^TIUSRVLO(TIUDA)
. S ORN=ORN+1,@ORY@(ORN)="Item=DOC:"_TIUDA_U_$P(TIUX,U)_U_$P($$FMTHL7^XLFDT($P(TIUX,U,2)),"-")_U_$$REQENC(TIUDA)
. S TIUI=0 F S TIUI=$O(@TIUY@(TIUI)) Q:TIUI<1 S ORN=ORN+1,@ORY@(ORN)="Text="_@TIUY@(TIUI)
Q
;
REQENC(TIUDA) ; -- Determine whether encounter data is needed
N ORRD0,ORRD12,ORSVC,ORRY,ORRDP,ORRCSA,ORASK,ORRPRIMD,DATANEED,ORROPT,LST,ORRPRIME,ORRCLST,ORRCDP,ORRCASK
S ORRD0=$G(^TIU(8925,TIUDA,0)),ORRD12=$G(^(12)),ORRY="false"
S (ORROPT,DATANEED)=0
; Load existing encounter info
D PCE4NOTE^ORWPCE3(.ORRCLST,TIUDA,+$P(ORRD0,U,2))
; identify primary provider
S ORRPRIMD=$$GETPRIMD(TIUDA,ORRD12,.ORRCLST)
M LST=ORRCLST
; determine whether "Data Needed"
; 1. if encdt > today quit false
I +$P(ORRD0,U,7)>(DT_".235959") G CHKASK
; 2. if service category '= "A", "I", or "T" quit false
S ORSVC=$P(ORRD0,U,13)
I '$S(ORSVC="A":1,ORSVC="I":1,ORSVC="T":1,1:0) G CHKASK
S ORROPT=1
; if TIU doc param SUPPRESS DX/CPT ON ENTRY is true, quit false
D DOCPRM^TIULC1(+ORRD0,.ORRCDP)
M ORRDP=ORRCDP
I +$P(ORRDP(0),U,14) G CHKASK
; if stand-alone visit, quit true
D HASVISIT^ORWPCE(.ORRCSA,TIUDA,+$P(ORRD0,U,2),+$P(ORRD12,U,11),+$P(ORRD0,U,7))
I ORRCSA<1 S DATANEED=1 G CHKASK
; if TIU doc param ASK DX/CPT ON ALL OPT VISITS is true, quit true
I +$P(ORRDP(0),U,16) S DATANEED=1 G CHKASK
CHKASK I +DATANEED S DATANEED=$$CHKPCE(TIUDA,.ORRCLST,$P(ORRD0,U,2),$P(ORRD12,U,11))
M LST=ORRCLST
D ASKPCE^ORWPCE2(.ORRCASK,DUZ,+$P(ORRD12,U,11))
M ORASK=ORRCASK
; if Never or Disable, quit false
I $S(ORASK=6:1,ORASK=7:1,1:0) S ORRY="false" G REQENCX
; if Always, quit true
I ORASK=5 S ORRY="true" G REQENCX
; if Data Needed, quit true
I ORASK=3,+DATANEED S ORRY="true" G REQENCX
; if Outpatient, quit true
I ORASK=4,+ORROPT S ORRY="true" G REQENCX
; If we don't know who the primary encounter provider is, and we need to know, we
; must go to the chart to sign the note - so we treat it the same as if they are primary
I ORRPRIMD=0 S ORRPRIME=1
E S ORRPRIME=+(DUZ=ORRPRIMD)
; if Primary/Data Needed, quit true
I ORASK=0,ORRPRIME,+DATANEED S ORRY="true" G REQENCX
; if Primary/Outpatient, quit true
I ORASK=1,ORRPRIME,+ORROPT S ORRY="true" G REQENCX
; if Primary Always, quit true
I ORASK=2,ORRPRIME S ORRY="true" G REQENCX
REQENCX Q ORRY
;
CHKPCE(TIUDA,LST,PTNT,LOC) ; Look for existing PCE data
N ENCDT,ORI,CPT,COUNT,MAX,ICD,CODE,SUB,EXPNEED,EXP,RESULT,SCREQ,DOCPARM
N ORRCSREQ,ORRCDOCP
S (CPT,ICD,ORI,EXPNEED,EXP,RESULT,COUNT)=0
S MAX=2
S ENCDT=$P($P(LST(1),U,4),";",2)
D SCSEL^ORWPCE(.ORRCSREQ,PTNT,ENCDT,LOC,"")
M SCREQ=ORRCSREQ
D DOCPARM^TIUSRVP1(.ORRCDOCP,TIUDA,0)
M DOCPARM=ORRCDOCP
I +$P(DOCPARM(0),U,15)=1 S EXPNEED=1,MAX=8
F S ORI=$O(LST(ORI)) Q:+ORI'>0 D Q:(COUNT'<MAX)
. S CODE=$P(LST(ORI),U)
. I CODE="POV",'ICD S ICD=1,COUNT=COUNT+1
. I CODE="CPT",'CPT S CPT=1,COUNT=COUNT+1
. I EXPNEED,CODE="VST" D
. . N VAL,IDX
. . S SUB=$P(LST(ORI),U,2),VAL=$P(LST(ORI),U,3)
. . S IDX=$S(SUB="SC":1,SUB="AO":2,SUB="IR":3,SUB="EC":4,SUB="MST":5,SUB="HNC":6,1:0)
. . I IDX>0 S COUNT=COUNT+1 I VAL'="" S $P(SCREQ,";",IDX)=0
I 'ICD Q 1
I 'CPT Q 1
F ORI=1:1:6 D Q:RESULT=1
. I $P($P(SCREQ,";",ORI),U,1) S RESULT=1
Q RESULT
GETPRIMD(TIUDA,ORRD12,LST) ; Get the Primary Provider
N ORRY,ORI,ORMDEF,TIUSPRM,ORRCSPRM
S (ORI,ORRY)=0
D SITEPARM^TIUSRVP1(.ORRCSPRM) M TIUSPRM=ORRCSPRM
; 1. Check for the provider in the encounter, if it exists.
F S ORI=$O(LST(ORI)) Q:+ORI'>0 D Q:+ORRY
. I $P(LST(ORI),U)="PRV",+$P(LST(ORI),U,6) S ORRY=$P(LST(ORI),U,2)
; 2. check for the default primary as specified in TIU
I 'ORRY D ;DEFDOC^TIUSRVP1(.ORMDEF,$P(ORRD12,U,11),DUZ,$P(ORRD0,U,7),TIUDA) S ORRY=+ORMDEF
. I +$P(TIUSPRM,U,8)=1 S ORRY=$$DFLTDOC^TIUPXAPI($P(ORRD12,U,11)) I +ORRY'=DUZ S ORRY=0
Q ORRY
SIGN(ORY,LIST) ; -- Apply signature to documents in LIST(#)=DOC:##
; RPC = ORRC UNSIGNED DOCS SIGN
Q
ORRCTIU ; SLC/JER - TIU data for CM ; 7/18/05 10:38
+1 ;;1.0;CARE MANAGEMENT;**2**;Jul 15, 2003
+2 ;
+3 ; This routine invokes IAs: 2322,2323,2834,2937,2944,2960,4175,4733
+4 ;
GETPTUNS(ORRCY,AUDUZ) ; Get pts w/documents that need user's signature
+1 ; Returns @ORRCY@(DFN,"DOC:"_TIUDA)=""
+2 ; [from ORRCDPT]
+3 NEW TITLE,GVN,ORT,TIUDA,ORDFN,ITR,ORRCASIG
+4 SET TITLE=0
SET GVN=$NAME(^TIU(8925,"AAU"))
SET ORRCY=$NAME(^TMP($JOB,"ORRCTIU"))
KILL @ORRCY
+5 FOR
SET TITLE=$ORDER(@GVN@(AUDUZ,TITLE))
IF +TITLE'>0
QUIT
Begin DoDot:1
+6 SET ORT=0
FOR
SET ORT=$ORDER(@GVN@(AUDUZ,TITLE,5,ORT))
IF +ORT'>0
QUIT
Begin DoDot:2
+7 SET TIUDA=0
+8 FOR
SET TIUDA=$ORDER(@GVN@(AUDUZ,TITLE,5,ORT,TIUDA))
IF +TIUDA'>0
QUIT
Begin DoDot:3
+9 SET ORDFN=$PIECE($GET(^TIU(8925,TIUDA,0)),U,2)
IF +ORDFN'>0
QUIT
+10 ;not on list
IF $DATA(^TMP($JOB,"ORRCLST"))
IF '$DATA(^TMP($JOB,"ORRCY",ORDFN))
QUIT
+11 ; user may not sign
IF '+$$CANDO^TIULP(TIUDA,"SIGNATURE",AUDUZ)
QUIT
+12 SET @ORRCY@(ORDFN,"DOC:"_TIUDA)=""
End DoDot:3
End DoDot:2
End DoDot:1
+13 SET TITLE=0
SET GVN=$NAME(^TIU(8925,"ASUP"))
+14 FOR
SET TITLE=$ORDER(@GVN@(AUDUZ,TITLE))
IF +TITLE'>0
QUIT
Begin DoDot:1
+15 NEW STATUS
FOR STATUS=5,6
Begin DoDot:2
+16 SET ORT=0
FOR
SET ORT=$ORDER(@GVN@(AUDUZ,TITLE,STATUS,ORT))
IF +ORT'>0
QUIT
Begin DoDot:3
+17 SET TIUDA=0
+18 FOR
SET TIUDA=$ORDER(@GVN@(AUDUZ,TITLE,STATUS,ORT,TIUDA))
IF +TIUDA'>0
QUIT
Begin DoDot:4
+19 SET ORDFN=$PIECE($GET(^TIU(8925,TIUDA,0)),U,2)
IF +ORDFN'>0
QUIT
+20 ;not on list
IF $DATA(^TMP($JOB,"ORRCLST"))
IF '$DATA(^TMP($JOB,"ORRCY",ORDFN))
QUIT
+21 ; user may not Sign/Cosign
IF '+$$CANDO^TIULP(TIUDA,$SELECT(STATUS=5:"SIGNATURE",1:"COSIGNATURE"),AUDUZ)
QUIT
+22 SET @ORRCY@(ORDFN,"DOC:"_TIUDA)=""
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+23 ; capture addl signer docs
+24 KILL ^TMP("TIUSIGN",$JOB),^TMP("ORRCASIG",$JOB)
+25 SET ORRCASIG=""
SET ITR=0
+26 DO NEEDSIG^TIULX(.ORRCASIG,AUDUZ)
+27 IF '$DATA(@ORRCASIG)
QUIT
+28 MERGE ^TMP("ORRCASIG",$JOB)=@ORRCASIG
+29 FOR
SET ITR=$ORDER(^TMP("ORRCASIG",$JOB,ITR))
IF 'ITR
QUIT
Begin DoDot:1
+30 SET TIUDA=^TMP("ORRCASIG",$JOB,ITR)
+31 SET ORDFN=$PIECE($GET(^TIU(8925,TIUDA,0)),U,2)
IF +ORDFN'>0
QUIT
+32 ;not on list?
IF $DATA(^TMP($JOB,"ORRCLST"))
IF '$DATA(^TMP($JOB,"ORRCY",ORDFN))
QUIT
+33 ; user may not sign
IF '+$$CANDO^TIULP(TIUDA,"SIGNATURE",AUDUZ)
QUIT
+34 SET @ORRCY@(ORDFN,"DOC:"_TIUDA)=""
End DoDot:1
+35 KILL ^TMP("TIUSIGN",$JOB),^TMP("ORRCASIG",$JOB)
+36 QUIT
+37 ;
LISTUNS(ORY,ORUSR,ORPAT) ; -- Get list of unsigned documents for ORPAT by ORUSR
+1 ;
+2 QUIT
+3 ;
TEXT(ORY,DOC) ; -- Return text of DOCs in
+1 ; @ORY@(#) = Item=ID^Title^Date IN HL7 format
+2 ; = Text=line of document text
+3 NEW ORN,ORI,ORRCY,TIUDA,TIUY,TIUI,TIUX
+4 SET ORN=0
SET ORY=$NAME(^TMP($JOB,"ORRCDOC"))
KILL @ORY
+5 SET ORI=""
FOR
SET ORI=$ORDER(DOC(ORI))
IF ORI=""
QUIT
Begin DoDot:1
+6 SET TIUDA=+$PIECE(DOC(ORI),":",2)
DO TGET^TIUSRVR1(.ORRCY,TIUDA)
+7 MERGE TIUY=ORRCY
+8 SET TIUX=$$RESOLVE^TIUSRVLO(TIUDA)
+9 SET ORN=ORN+1
SET @ORY@(ORN)="Item=DOC:"_TIUDA_U_$PIECE(TIUX,U)_U_$PIECE($$FMTHL7^XLFDT($PIECE(TIUX,U,2)),"-")_U_$$REQENC(TIUDA)
+10 SET TIUI=0
FOR
SET TIUI=$ORDER(@TIUY@(TIUI))
IF TIUI<1
QUIT
SET ORN=ORN+1
SET @ORY@(ORN)="Text="_@TIUY@(TIUI)
End DoDot:1
+11 QUIT
+12 ;
REQENC(TIUDA) ; -- Determine whether encounter data is needed
+1 NEW ORRD0,ORRD12,ORSVC,ORRY,ORRDP,ORRCSA,ORASK,ORRPRIMD,DATANEED,ORROPT,LST,ORRPRIME,ORRCLST,ORRCDP,ORRCASK
+2 SET ORRD0=$GET(^TIU(8925,TIUDA,0))
SET ORRD12=$GET(^(12))
SET ORRY="false"
+3 SET (ORROPT,DATANEED)=0
+4 ; Load existing encounter info
+5 DO PCE4NOTE^ORWPCE3(.ORRCLST,TIUDA,+$PIECE(ORRD0,U,2))
+6 ; identify primary provider
+7 SET ORRPRIMD=$$GETPRIMD(TIUDA,ORRD12,.ORRCLST)
+8 MERGE LST=ORRCLST
+9 ; determine whether "Data Needed"
+10 ; 1. if encdt > today quit false
+11 IF +$PIECE(ORRD0,U,7)>(DT_".235959")
GOTO CHKASK
+12 ; 2. if service category '= "A", "I", or "T" quit false
+13 SET ORSVC=$PIECE(ORRD0,U,13)
+14 IF '$SELECT(ORSVC="A":1,ORSVC="I":1,ORSVC="T":1,1:0)
GOTO CHKASK
+15 SET ORROPT=1
+16 ; if TIU doc param SUPPRESS DX/CPT ON ENTRY is true, quit false
+17 DO DOCPRM^TIULC1(+ORRD0,.ORRCDP)
+18 MERGE ORRDP=ORRCDP
+19 IF +$PIECE(ORRDP(0),U,14)
GOTO CHKASK
+20 ; if stand-alone visit, quit true
+21 DO HASVISIT^ORWPCE(.ORRCSA,TIUDA,+$PIECE(ORRD0,U,2),+$PIECE(ORRD12,U,11),+$PIECE(ORRD0,U,7))
+22 IF ORRCSA<1
SET DATANEED=1
GOTO CHKASK
+23 ; if TIU doc param ASK DX/CPT ON ALL OPT VISITS is true, quit true
+24 IF +$PIECE(ORRDP(0),U,16)
SET DATANEED=1
GOTO CHKASK
CHKASK IF +DATANEED
SET DATANEED=$$CHKPCE(TIUDA,.ORRCLST,$PIECE(ORRD0,U,2),$PIECE(ORRD12,U,11))
+1 MERGE LST=ORRCLST
+2 DO ASKPCE^ORWPCE2(.ORRCASK,DUZ,+$PIECE(ORRD12,U,11))
+3 MERGE ORASK=ORRCASK
+4 ; if Never or Disable, quit false
+5 IF $SELECT(ORASK=6:1,ORASK=7:1,1:0)
SET ORRY="false"
GOTO REQENCX
+6 ; if Always, quit true
+7 IF ORASK=5
SET ORRY="true"
GOTO REQENCX
+8 ; if Data Needed, quit true
+9 IF ORASK=3
IF +DATANEED
SET ORRY="true"
GOTO REQENCX
+10 ; if Outpatient, quit true
+11 IF ORASK=4
IF +ORROPT
SET ORRY="true"
GOTO REQENCX
+12 ; If we don't know who the primary encounter provider is, and we need to know, we
+13 ; must go to the chart to sign the note - so we treat it the same as if they are primary
+14 IF ORRPRIMD=0
SET ORRPRIME=1
+15 IF '$TEST
SET ORRPRIME=+(DUZ=ORRPRIMD)
+16 ; if Primary/Data Needed, quit true
+17 IF ORASK=0
IF ORRPRIME
IF +DATANEED
SET ORRY="true"
GOTO REQENCX
+18 ; if Primary/Outpatient, quit true
+19 IF ORASK=1
IF ORRPRIME
IF +ORROPT
SET ORRY="true"
GOTO REQENCX
+20 ; if Primary Always, quit true
+21 IF ORASK=2
IF ORRPRIME
SET ORRY="true"
GOTO REQENCX
REQENCX QUIT ORRY
+1 ;
CHKPCE(TIUDA,LST,PTNT,LOC) ; Look for existing PCE data
+1 NEW ENCDT,ORI,CPT,COUNT,MAX,ICD,CODE,SUB,EXPNEED,EXP,RESULT,SCREQ,DOCPARM
+2 NEW ORRCSREQ,ORRCDOCP
+3 SET (CPT,ICD,ORI,EXPNEED,EXP,RESULT,COUNT)=0
+4 SET MAX=2
+5 SET ENCDT=$PIECE($PIECE(LST(1),U,4),";",2)
+6 DO SCSEL^ORWPCE(.ORRCSREQ,PTNT,ENCDT,LOC,"")
+7 MERGE SCREQ=ORRCSREQ
+8 DO DOCPARM^TIUSRVP1(.ORRCDOCP,TIUDA,0)
+9 MERGE DOCPARM=ORRCDOCP
+10 IF +$PIECE(DOCPARM(0),U,15)=1
SET EXPNEED=1
SET MAX=8
+11 FOR
SET ORI=$ORDER(LST(ORI))
IF +ORI'>0
QUIT
Begin DoDot:1
+12 SET CODE=$PIECE(LST(ORI),U)
+13 IF CODE="POV"
IF 'ICD
SET ICD=1
SET COUNT=COUNT+1
+14 IF CODE="CPT"
IF 'CPT
SET CPT=1
SET COUNT=COUNT+1
+15 IF EXPNEED
IF CODE="VST"
Begin DoDot:2
+16 NEW VAL,IDX
+17 SET SUB=$PIECE(LST(ORI),U,2)
SET VAL=$PIECE(LST(ORI),U,3)
+18 SET IDX=$SELECT(SUB="SC":1,SUB="AO":2,SUB="IR":3,SUB="EC":4,SUB="MST":5,SUB="HNC":6,1:0)
+19 IF IDX>0
SET COUNT=COUNT+1
IF VAL'=""
SET $PIECE(SCREQ,";",IDX)=0
End DoDot:2
End DoDot:1
IF (COUNT'<MAX)
QUIT
+20 IF 'ICD
QUIT 1
+21 IF 'CPT
QUIT 1
+22 FOR ORI=1:1:6
Begin DoDot:1
+23 IF $PIECE($PIECE(SCREQ,";",ORI),U,1)
SET RESULT=1
End DoDot:1
IF RESULT=1
QUIT
+24 QUIT RESULT
GETPRIMD(TIUDA,ORRD12,LST) ; Get the Primary Provider
+1 NEW ORRY,ORI,ORMDEF,TIUSPRM,ORRCSPRM
+2 SET (ORI,ORRY)=0
+3 DO SITEPARM^TIUSRVP1(.ORRCSPRM)
MERGE TIUSPRM=ORRCSPRM
+4 ; 1. Check for the provider in the encounter, if it exists.
+5 FOR
SET ORI=$ORDER(LST(ORI))
IF +ORI'>0
QUIT
Begin DoDot:1
+6 IF $PIECE(LST(ORI),U)="PRV"
IF +$PIECE(LST(ORI),U,6)
SET ORRY=$PIECE(LST(ORI),U,2)
End DoDot:1
IF +ORRY
QUIT
+7 ; 2. check for the default primary as specified in TIU
+8 ;DEFDOC^TIUSRVP1(.ORMDEF,$P(ORRD12,U,11),DUZ,$P(ORRD0,U,7),TIUDA) S ORRY=+ORMDEF
IF 'ORRY
Begin DoDot:1
+9 IF +$PIECE(TIUSPRM,U,8)=1
SET ORRY=$$DFLTDOC^TIUPXAPI($PIECE(ORRD12,U,11))
IF +ORRY'=DUZ
SET ORRY=0
End DoDot:1
+10 QUIT ORRY
SIGN(ORY,LIST) ; -- Apply signature to documents in LIST(#)=DOC:##
+1 ; RPC = ORRC UNSIGNED DOCS SIGN
+2 QUIT