VistA-WorldVistAEHR/r/SURGERY-SR/SROARPT.m

135 lines
6.7 KiB
Mathematica

SROARPT ;B'HAM ISC/MAM,ADM - ANESTHESIA REPORT ;10/21/04
;;3.0; Surgery ;**100,134**;24 Jun 93
;** NOTICE: This routine is part of an implementation of a nationally
;** controlled procedure. Local modifications to this routine
;** are prohibited.
;
; Reference to UPDATE^TIUSRVP supported by DBIA #3535
; Reference to ES^TIUSROI supported by DBIA #3537
;
I '$D(SRSITE) D ^SROVAR G:'$D(SRSITE) END S SRSITE("KILL")=1
I '$D(SRTN) K SRNEWOP D ^SROPS G:'$D(SRTN) END S SRTN("KILL")=1
N SRDIV,SRDO,SRFUNCT,SRHDR,SRINUSE,SRLEAVE,SRLOC,SRPARAM,SRPRINT,SRSEL,SRSINED,SRDTITL,SRTIU,SRXX
S SRDTITL="Anesthesia Report"
S (SRFUNCT,SRLEAVE,SRSINED)=0,SRTIU=$P($G(^SRF(SRTN,"TIU")),"^",4)
I SRTIU,$$STATUS^SROESUTL(SRTIU)=7 S SRSINED=1
D:SRSINED FUNCT D:'SRSINED EN
ENF I 'SRLEAVE,SRFUNCT S SRSEL="" D FUNCT
D END
Q
DISPLY I SRSINED S SRTIU=$P($G(^SRF(SRTN,"TIU")),"^",4) I SRTIU D PRNT^SROESPR(SRTN,SRTIU,SRDTITL) S SRLEAVE=1 Q
K %ZIS,IO("Q") S %ZIS="Q" D ^%ZIS I POP S SRLEAVE=1 Q
I $D(IO("Q")) K IO("Q") N ZTRTN,ZTDESC,ZTSAVE,ZTQUEUED S ZTRTN="PRNT^SROARPT",ZTDESC=SRDTITL,(ZTSAVE("SRTN"),ZTSAVE("SRSITE*"))="" D ^%ZTLOAD,^%ZISC Q
EN D RPT^SROANR(SRTN) S DFN=$P(^SRF(SRTN,0),"^"),VAINDT=$P(^SRF(SRTN,0),"^",9)
S Y=$E(VAINDT,1,7) D D^DIQ S SRSDATE=Y D OERR^VADPT
S SRHDR=" "_VADM(1)_" ("_VA("PID")_") Case #"_SRTN_" - "_SRSDATE
S Y=$E($$NOW^XLFDT,1,12) D DD^%DT S SRPRINT="Printed: "_Y
S SRLOC=" Pt Loc: "_$P(VAIN(4),"^",2)_" "_VAIN(5)
S SRAGE="",Z=$P(VADM(3),"^") I Z S X=$E($P(^SRF(SRTN,0),"^",9),1,12),Y=$E(X,1,7),SRAGE=$E(Y,1,3)-$E(Z,1,3)-($E(Y,4,7)<$E(Z,4,7))
S SRPARAM=$$SITE^SROUTL0(SRTN) I SRPARAM S X=$P(^SRO(133,SRPARAM,0),"^"),SRDIV=$$EXTERNAL^DILFD(133,.01,"",X)
S SRDIV=$S(SRDIV'="":SRDIV,1:SRSITE("SITE"))
S SRINUSE=$P($G(^SRO(133,SRPARAM,.1)),"^",4)
U IO S (SRPAGE,SRSOUT)=0,$P(SRLINE,"-",80)="" D HDR
S SRI=0 F S SRI=$O(^TMP("SRANE",$J,SRTN,SRI)) Q:'SRI D Q:SRSOUT
.I $E(IOST)="P",$Y+11>IOSL D FOOT Q:SRSOUT D HDR
.I $E(IOST)'="P",$Y+4>IOSL D FOOT Q:SRSOUT D HDR
.W !,^TMP("SRANE",$J,SRTN,SRI)
I SRSOUT D ^%ZISC Q
D FOOT D D ^%ZISC
.I $D(SRALRT) S SRFUNCT=1 Q
.I '$G(SRFUNCT) S SRLEAVE=1
Q
SRHDR S DFN=$P(^SRF(SRTN,0),"^") D DEM^VADPT
S Y=$E($P(^SRF(SRTN,0),"^",9),1,7) D D^DIQ S SRSDATE=Y
S SRHDR=" "_VADM(1)_" ("_VA("PID")_") Case #"_SRTN_" - "_SRSDATE
Q
PRNT N SRDIV,SRFUNCT,SRLEAVE D EN
END K ^TMP("SRANE",$J)
W @IOF I $D(ZTQUEUED) Q:$G(ZTSTOP) S ZTREQ="@" Q
D ^SRSKILL K VAIN,VAINDT I $D(SRSITE("KILL")) K SRSITE
I $D(SRTN("KILL")) K SRTN
Q
PAGE I 'SRINUSE!'$D(^XUSEC("SROANES",DUZ)) D LAST Q
S (SRFUNCT,SRSOUT)=0
W ! K DIR S DIR(0)="FOA",DIR("A",1)=" Press <return> to continue, 'A' to access Anesthesia Report functions",DIR("A")=" or '^' to exit: " D ^DIR K DIR I $D(DTOUT)!$D(DUOUT) S (SRLEAVE,SRSOUT)=1 Q
I X="A"!(X="a") S (SRFUNCT,SRSOUT)=1
Q
LAST W ! K DIR S DIR(0)="E" D ^DIR K DIR I $D(DTOUT)!$D(DUOUT) S SRSOUT=1
Q
FOOT ; print footer
Q:SRSOUT I $E(IOST)'="P" D PAGE Q
I IOSL-9>$Y F X=$Y:1:(IOSL-10) W !
W !,SRLINE,!,VADM(1),?50,SRPRINT,!,VA("PID")_" Age: "_SRAGE,?50,SRLOC,!,SRDIV,?59,"Vice SF 509",!,SRLINE
Q
HDR ; heading
I $D(ZTQUEUED) D ^SROSTOP I SRHALT S SRSOUT=1 Q
S SRPAGE=SRPAGE+1 I $Y'=0 W @IOF
I $E(IOST)'="P",SRPAGE=1 S DFN=$P(^SRF(SRTN,0),"^") D DEM^VADPT S SRXX=VADM(1)_" ("_VA("PID")_")" W !,?(80-$L(SRXX)\2),SRXX
W:$E(IOST)="P" !!!!,SRLINE W !,?4,"MEDICAL RECORD ANESTHESIA REPORT - CASE #"_SRTN,?(79-$L("PAGE "_SRPAGE)),"PAGE "_SRPAGE,!
W:$E(IOST)="P" SRLINE,!
Q
FUNCT ; anethesia report functions
D:'$D(SRHDR) SRHDR S SRSOUT=0,SRTIU=$P($G(^SRF(SRTN,"TIU")),"^",4)
I 'SRSINED,SRTIU,$$STATUS^SROESUTL(SRTIU)=7 S SRSINED=1
W:$Y>0 @IOF W !,SRHDR I SRSINED W !!," * * The Anesthesia Report has been electronically signed. * *"
W !!," Anesthesia Report Functions:",!
S DIR("A",1)=" 1. Edit report information",DIR("A",2)=" 2. Print/View report from beginning"
S DIR("A",3)=$S('SRTIU:"",'SRSINED:" 3. Sign the report electronically",1:"") I SRTIU,'SRSINED S DIR("A",4)=""
S DIR("A")="Select number: ",DIR("B")=2,DIR(0)="SAM^1:Edit report information;2:Print/View report from beginning"_$S(('SRSINED&SRTIU):";3:Sign the report electronically",1:"")
D ^DIR K DIR I $D(DTOUT)!$D(DUOUT) S (SRLEAVE,SRSOUT)=1 D END Q
S SRSEL=Y,SRDO=$S(SRSEL=1:"EDIT",SRSEL=3:"SIGN",1:"DISPLY")
D @SRDO D UNLOCK^SROUTL(SRTN)
S SRSOUT=0,SRFUNCT=1 D ENF
Q
EDIT ; edit report data fields
D CHECK^SROES I SRSOUT Q
N SROLOCK,SRX,SRZ D ^SROLOCK I SROLOCK S Q3("VIEW")=""
N SRLCK S SRLCK=$$LOCK^SROUTL(SRTN) I 'SRLCK Q
K DA,DR,DIE S SRDTIME=DTIME,DTIME=3600,DIE=130,DA=SRTN,DR="[SROARPT]",ST="ANESTHESIA REPORT"_$S(SROLOCK:" **LOCKED",1:"") D EN2^SROVAR,^SRCUSS S DTIME=SRDTIME K Q3("VIEW")
I '$P(^SRF(SRTN,0),"^",20) D ^SROPCE1
I $D(SRODR) D ^SROCON1
S SROERR=SRTN D ^SROERR0
D EXIT^SROES
Q
SIGN ; sign report if appropriate user
N SRTIU S SRTIU=$P($G(^SRF(SRTN,"TIU")),"^",4) I SRTIU,$$STATUS^SROESUTL(SRTIU)=7 W !!,"This report is already signed." H 2 Q
N SRLCK,SRESIG S SRESIG=1,SRLCK=$$LOCK^SROUTL(SRTN) I 'SRLCK Q
N SRA,SRMISS,SROK,X,Y S SROK=0,X=$G(^SRF(SRTN,.3)) F Y=1,2,3,4 I $P(X,"^",Y)=DUZ S SROK=1 Q
I 'SROK W !!,"Sorry, you are not authorized to sign this report." H 2 Q
S SRMISS=0 D ALLIN Q:SRSOUT!SRMISS
ES D RPT^SROANR(SRTN)
N SRAY,SRERR,SRI,SRP,SRSIG,X1
S SRTIU=$P($G(^SRF(SRTN,"TIU")),"^",4)
D SIG^XUSESIG I X1="" W !!,"Signature failed." H 2 Q
F I=1:1 Q:'$D(^TMP("SRANE",$J,SRTN,I)) S SRAY("TEXT",I,0)=^TMP("SRANE",$J,SRTN,I)
S SRAY(.05)=5 D UPDATE^TIUSRVP(.SRERR,SRTIU,.SRAY,1) K SRAY
I +SRERR S SRSINED=1 D
.D ES^TIUSROI(SRTIU,DUZ)
.S XQAID="SRAR-"_SRTN,XQAKILL=0 D DELETEA^XQALERT
W ! K DIR S DIR(0)="FOA",DIR("A")="Press RETURN to continue... " D ^DIR K DIR
Q
ALLIN N SRFLD,SRI,SRP,SRX,SRY,SRZ
K DA,DIC,DIQ,DR S (SREDIT,SRMISS,SRSOUT)=0
S DIC="^SRF(",DA=SRTN,DIQ="SRY",DIQ(0)="I",DR=".21;.24;1.13;.46;.31" D EN^DIQ1 K DA,DIC,DIQ,DR D LIST
K SRY,SRZ D TECH^SROPRIN I SRTECH="NOT ENTERED" D
.I $O(^SRF(SRTN,6,0)) S SRX(.37)="PRINCIPAL ANESTHESIA TECHNIQUE NOT SELECTED" Q
.S SRX(.37)="ANESTHESIA TECHNIQUE"
S SRZ=0 F S SRZ=$O(SRX(SRZ)) Q:'SRZ S SRMISS=1 Q
I SRMISS D MESS Q:SRSOUT D:SREDIT EDIT
Q
MESS ; display list of missing items
W @IOF,!,"The following information is required before this report may be signed:",!
S SRZ=0 F S SRZ=$O(SRX(SRZ)) Q:'SRZ W !,?5,SRX(SRZ)
W ! K DIR S DIR("A")="Do you want to enter this information",DIR("B")="YES",DIR(0)="Y" D ^DIR K DIR,SRX I $D(DTOUT)!$D(DUOUT) S SRSOUT=1 Q
I Y S SREDIT=1
Q
LIST S SRZ=0 F S SRZ=$O(SRY(130,SRTN,SRZ)) Q:'SRZ I SRY(130,SRTN,SRZ,"I")="" D TR S X=$T(@SRP),SRFLD=$P(X,";;",2),SRX(SRZ)=$P(SRFLD,"^",2)
Q
TR S SRP=SRZ,SRP=$TR(SRP,"1234567890.","ABCDEFGHIJP")
Q
PBA ;;.21^ANES CARE START TIME
PBD ;;.24^ANES CARE END TIME
APAC ;;1.13^ASA CLASS
PDF ;;.46^OP DISPOSITION
PCA ;;.31^PRINC ANESTHETIST