SROANEST ;BIR/TJH - ANESTHESIA ENTRY ;01 Jun 2003
;;3.0;Surgery;**119,150,152**;24 Jun 93
SINPUT ;
N SRSTART
S Z=$E($P(^SRF($S($D(SRTN):SRTN,1:DA(1)),0),"^",9),1,7),X=$S(X?1.4N.A!(X?1.2N1":"2N.A):Z_"@"_X,1:X) K %DT,Z S %DT="RTX" D ^%DT S X=Y K:Y<1 X
I '$D(X),$G(SRFLAG)=1 D K SRFLAG Q
.W !!,"Check date format.",!," Examples of Valid Dates:",!," JAN 20 1957 or 20 JAN 57 or 1/20/57 or 012057",!," T (for TODAY), T+1 (for TOMORROW), T+2, T+7, etc."
.W !," T-1 (for YESTERDAY), T-3W (for 3 WEEKS AGO), etc.",!," If the year is omitted, the computer uses CURRENT YEAR. Two digit year"
.W !," assumes no more than 20 years in the future, or 80 years in the past.",!," If only the time is entered, the current date is assumed."
.W !," Follow the date with a time, such as JAN 20@10, T@10AM, 10:30, etc.",!," You may enter a time, such as NOON, MIDNIGHT or NOW."
.W !," You may enter NOW+3' (for current date and time Plus 3 minutes",!," *Note--the Apostrophe following the number of minutes)"
.W !," Time is REQUIRED in this response.",!," Enter the time a member of the Anesthesia staff begins preparing the",!," patient for surgery in the O.R. suite or if the care is interrupted, the"
.W !," time the care resumes."
Q:'$D(X)
S SRSTART=$P($G(^SRF($S($D(SRTN):SRTN,1:DA(1)),.2)),"^",15)
I SRSTART="" K SRFLAG Q
I X<SRSTART W !!,"The time entered is before the 'TIME PAT IN HOLD AREA'. Please check the",!,"DATE/TIME entered for this field." H 2
K SRFLAG
Q
STIME ;
I '$D(X) Q
N SRSPREC,SRPET,SRTIME,SRCRET
S SRCRET=$$GET1^DIQ(130.213,DA(2)_","_DA(1)_",",1,"I")
I SRCRET,(X>SRCRET) W !!,"Start time is after current end time. Please correct." K X Q
S SRSPREC=$O(^SRF(DA(1),50,DA(2)),-1)
I SRSPREC'=0 D
.S SRPET=$$GET1^DIQ(130.213,SRSPREC_","_DA(1)_",",1,"I")
.I SRPET="" W !!,"New start time entry not permitted until previous end time is entered." K X Q
.I SRPET>X W !!,"Start time is prior to previous end time. Please correct." K X
I $D(X),(DA(2)=1) S SRTIME(130,DA(1)_",",.21)=X D FILE^DIE("","SRTIME","^TMP(""SR"",$J)")
Q
FINALT ;
N SRCST,SRLET,SRYN,SRSNREC,SRFDA,SRTIME,SRLREC,SRCON
I $D(^SRF(DA(1),"CON")),$P(^("CON"),"^") S SRCON=$P(^SRF(DA(1),"CON"),"^")
S SRCST=$$GET1^DIQ(130.213,DA(2)_","_DA(1)_",",.01,"I")
I X<SRCST W !!,"End time prior to start time. Please correct." K X Q
S SRSNREC=$O(^SRF(DA(1),50,DA(2)))
I SRSNREC'="B" Q
ASK W !!,"Does this entry complete all start and end times for this case? (Y/N)// " R SRYN:DTIME I '$T!(SRYN["^") S SRYN="N" Q
S SRYN=$E(SRYN) I "YyNn?"'[SRYN W !,"Invalid response, please enter Yes or No. Use ? for help." G ASK
I "?"[SRYN D HELP G ASK
I ("Nn"[SRYN) S SRFDA(130,DA(1)_",",.214)="@" D FILE^DIE("","SRFDA","^TMP(""SR"",$J)") K SRFDA Q
D CHKTIME
I SRAFLAG=1 K SRAFLAG Q
S SRLREC=$O(^SRF(DA(1),50,"B"),-1)
I SRLREC'=DA(2) S SRLET=$$GET1^DIQ(130.213,SRLREC_","_DA(1)_",",1,"I")
I SRLREC=DA(2) S SRLET=X
S SRTIME(130,DA(1)_",",.24)=SRLET,SRTIME(130,DA(1)_",",.214)="1" D FILE^DIE("","SRTIME","^TMP(""SR"",$J)")
K SRAFLAG
Q:'$D(SRCON)
ASK2 ;
W !,"Does this entry complete all start and end times for the concurrent",!,"case? (Y/N)// " R SRYN:DTIME I '$T!(SRYN["^") S SRYN="N" Q
I "?"[SRYN D HELP^SROCON D HELP G ASK2
S SRYN=$E(SRYN) I "YyNn"'[SRYN W !,"Invalid response, please enter Yes or No. Use ? for help." G ASK2
I ("Nn"[SRYN),(($P(^SRF(SRCON,.2),"^",17)=1)) S SRFDA(130,SRCON_",",.214)="@" D FILE^DIE("","SRFDA","^TMP(""SR"",$J)") K SRFDA Q
S SRTIME(130,SRCON_",",.214)="1" D FILE^DIE("","SRTIME","^TMP(""SR"",$J)")
Q
CHKTIME ; verify blocks of time are valid
N SRSREC,SRCST,SRCET,SRAFLAG1,SRSNREC,SRNST,SRLREC
S SRAFLAG=0,SRSREC=0,SRAFLAG1=0
F S SRSREC=$O(^SRF(DA(1),50,SRSREC)) Q:'SRSREC!(SRAFLAG1=1) D
.S SRCST=$$GET1^DIQ(130.213,SRSREC_","_DA(1)_",",.01,"I"),SRCET=$$GET1^DIQ(130.213,SRSREC_","_DA(1)_",",1,"I")
.S SRLREC=$O(^SRF(DA(1),50,"B"),-1)
.I (SRCET=""),(SRSREC'=SRLREC) W !!,"One or more time entries missing end time. Please correct." S SRAFLAG=1,SRAFLAG1=1 Q
.S SRSNREC=$O(^SRF(DA(1),50,SRSREC))
.I SRSNREC="B" S SRAFLAG1=1 Q
.S SRNST=$$GET1^DIQ(130.213,SRSNREC_","_DA(1)_",",.01,"I")
.I SRNST<SRCET W !!,"Some time entries overlap. Please correct." S SRAFLAG=1,SRAFLAG1=1 Q
Q
CSET ; caled by set xref of mult anes start and end times used for concurrent case anes field stuffing
N SRSREC,SRCST,SRCET,SRTIME
I $$GET1^DIQ(130,DA(1),.214,"I")'=1 Q
S SRSREC=0
F S SRSREC=$O(^SRF(DA(1),50,SRSREC)) Q:'SRSREC D
.S:'$D(SRCST) SRCST=$$GET1^DIQ(130.213,SRSREC_","_DA(1)_",",.01,"I")
.S SRCET=$$GET1^DIQ(130.213,SRSREC_","_DA(1)_",",1,"I")
S SRTIME(130,DA(1)_",",.24)=SRCET,SRTIME(130,DA(1)_",",.21)=SRCST D FILE^DIE("","SRTIME","^TMP(""SR"",$J)")
Q
DEL ; called by kill xref of mult anes start and end times
I '$D(DA(2)) Q
I (DA(2)=1),(D=.01) S SRFDA(130,DA(1)_",",.21)="@" D FILE^DIE("","SRFDA","^TMP(""SR"",$J)") K SRFDA
I ($O(^SRF(DA(1),50,DA(2)))="B"),(D=1) S SRFDA(130,DA(1)_",",.24)="@",SRFDA(130,DA(1)_",",.214)="@" D FILE^DIE("","SRFDA","^TMP(""SR"",$J)") K SRFDA
Q
HELP ;
W !,"Enter ""Y"" only if the block of time entered is the final block of time for"
W !,"this case. If the block of time is not the final block, enter ""N""."
Q
BILLTIME() ; calculate total minutes for mult anes start and end times
N SRSREC,SRCST,SRCET,SRTTIME
S SRSREC=0,SRTTIME=0
I $$GET1^DIQ(130,D0,.214,"I")'=1 Q SRTTIME
I '$D(^SRF(D0,50)) Q SRTTIME
F S SRSREC=$O(^SRF(D0,50,SRSREC)) Q:'SRSREC D
.S SRCST=$$GET1^DIQ(130.213,SRSREC_","_D0_",",.01,"I"),SRCET=$$GET1^DIQ(130.213,SRSREC_","_D0_",",1,"I")
.D CALC
Q SRTTIME
CALC ; calculate minutes between start and end times
N SRETH,SRDHRS,SRSHR,SREHR,SRSMN,SREMN,SRSTH,X1,X2,Y,%H
S X1=SRCST,X2=0 D C^%DTC S SRSTH=%H
S X1=SRCET,X2=0 D C^%DTC S SRETH=%H
S SRDHRS=(SRETH-SRSTH)*24
S SRSHR=$E(($P(SRCST_"0",".",2)),1,2)
S SREHR=$E(($P(SRCET_"0",".",2)),1,2)
I SREHR<SRSHR S SREHR=SREHR+24,SRDHRS=SRDHRS-24
S SRSMN=$E(($P(SRCST_"00",".",2)),3,4)
S SREMN=$E(($P(SRCET_"00",".",2)),3,4)
I SREMN<SRSMN S SREMN=SREMN+60,SREHR=SREHR-1
S Y=(SRDHRS*60)+((SREHR-SRSHR)*60)+(SREMN-SRSMN)
S SRTTIME=SRTTIME+Y
Q
ANESTIME(SRDFN,SRFDATE,SRTDATE) ; API to return multiple anesthesia records and times
N SRCASE,SRREC,SRCNT,SRNON,SRX,SRDATE,SRRES,SRSC,SRCV,SRQO,SRIR,SREC,SRMST,SRHNC,SRAO,SRSREC,SRCST,SRCET,SRTTIME,SR,SRDIAG,SRSHAD
S (SRREC,SRCNT,SRRES)=0
I '$D(SRDFN)!'$D(SRFDATE) Q -1
I '$D(SRTDATE) S SRTDATE=SRFDATE
I '$D(^SRF("B",SRDFN)) Q 0
S SRFDATE=$P(SRFDATE,"."),SRTDATE=$P(SRTDATE,".")
F S SRREC=$O(^SRF("B",SRDFN,SRREC)) Q:'SRREC S SRCNT=SRCNT+1,SRCASE(SRCNT)=SRREC
S SRREC=0
F S SRREC=$O(SRCASE(SRREC)) Q:'SRREC D
.S SRCASE=SRCASE(SRREC)
.S SRNON=$S($P($G(^SRF(SRCASE,"NON")),"^")="Y":1,1:0)
.I 'SRNON S SRX=$G(^SRF(SRCASE,.2)),SRDATE=$P(SRX,"^",10)
.I SRNON S SRX=$G(^SRF(SRCASE,"NON")),SRDATE=$P(SRX,"^",4)
.S SRDATE=$P(SRDATE,".")
.I (SRDATE<SRFDATE)!(SRDATE>SRTDATE) K SRCASE(SRREC) Q
S SRREC=0
F S SRREC=$O(SRCASE(SRREC)) Q:'SRREC D
.S SRCASE=SRCASE(SRREC)
.I $$GET1^DIQ(130,SRCASE,.214,"I")'=1 S SRRES=-2 Q
.S SRDIAG=$P($G(^SRO(136,SRCASE,0)),"^",3)
.I 'SRDIAG S SRDIAG=$P($G(^SRF(SRCASE,34)),"^",2)
.S (SRAO,SREC,SRHNC,SRIR,SRMST,SRSHAD)=0
.S SR(0)=$G(^SRF(SRCASE,0))
.S SRSC=$P(SR(0),"^",16),SRAO=$P(SR(0),"^",17),SRIR=$P(SR(0),"^",18),SREC=$P(SR(0),"^",19),SRMST=$P(SR(0),"^",22),SRHNC=$P(SR(0),"^",23),SRCV=$P(SR(0),"^",24),SRSHAD=$P(SR(0),"^",25)
.I '$D(^SRF(SRCASE,50)) S:SRRES'=1 SRRES=-2 Q
.S SRRES=1,SRREC=0
.F S SRREC=$O(^SRF(SRCASE,50,SRREC)) Q:(SRREC="B")!(SRREC="") D
..S SRCST=$$GET1^DIQ(130.213,SRREC_","_SRCASE_",",.01,"I"),SRCET=$$GET1^DIQ(130.213,SRREC_","_SRCASE_",",1,"I")
..I 'SRCET K ^TMP("SRANES",$J,SRCASE) S SRRES=-2,SRREC="" Q
..S SRTTIME=0 D CALC
..S ^TMP("SRANES",$J,SRCASE,SRCST,SRCET)=SRDFN_"^"_SRTTIME_"^"_SRDIAG_"^"_SRSC_"^"_SRCV_"^"_SRAO_"^"_SRIR_"^"_SREC_"^"_SRMST_"^"_SRHNC_"^"_SRSHAD
Q SRRES
SROANEST ;BIR/TJH - ANESTHESIA ENTRY ;01 Jun 2003
+1 ;;3.0;Surgery;**119,150,152**;24 Jun 93
SINPUT ;
+1 NEW SRSTART
+2 SET Z=$EXTRACT($PIECE(^SRF($SELECT($DATA(SRTN):SRTN,1:DA(1)),0),"^",9),1,7)
SET X=$SELECT(X?1.4N.A!(X?1.2N1":"2N.A):Z_"@"_X,1:X)
KILL %DT,Z
SET %DT="RTX"
DO ^%DT
SET X=Y
IF Y<1
KILL X
+3 IF '$DATA(X)
IF $GET(SRFLAG)=1
Begin DoDot:1
+4 WRITE !!,"Check date format.",!," Examples of Valid Dates:",!," JAN 20 1957 or 20 JAN 57 or 1/20/57 or 012057",!," T (for TODAY), T+1 (for TOMORROW), T+2, T+7, etc."
+5 WRITE !," T-1 (for YESTERDAY), T-3W (for 3 WEEKS AGO), etc.",!," If the year is omitted, the computer uses CURRENT YEAR. Two digit year"
+6 WRITE !," assumes no more than 20 years in the future, or 80 years in the past.",!," If only the time is entered, the current date is assumed."
+7 WRITE !," Follow the date with a time, such as JAN 20@10, T@10AM, 10:30, etc.",!," You may enter a time, such as NOON, MIDNIGHT or NOW."
+8 WRITE !," You may enter NOW+3' (for current date and time Plus 3 minutes",!," *Note--the Apostrophe following the number of minutes)"
+9 WRITE !," Time is REQUIRED in this response.",!," Enter the time a member of the Anesthesia staff begins preparing the",!," patient for surgery in the O.R. suite or if the care is interrupted, the"
+10 WRITE !," time the care resumes."
End DoDot:1
KILL SRFLAG
QUIT
+11 IF '$DATA(X)
QUIT
+12 SET SRSTART=$PIECE($GET(^SRF($SELECT($DATA(SRTN):SRTN,1:DA(1)),.2)),"^",15)
+13 IF SRSTART=""
KILL SRFLAG
QUIT
+14 IF X<SRSTART
WRITE !!,"The time entered is before the 'TIME PAT IN HOLD AREA'. Please check the",!,"DATE/TIME entered for this field."
HANG 2
+15 KILL SRFLAG
+16 QUIT
STIME ;
+1 IF '$DATA(X)
QUIT
+2 NEW SRSPREC,SRPET,SRTIME,SRCRET
+3 SET SRCRET=$$GET1^DIQ(130.213,DA(2)_","_DA(1)_",",1,"I")
+4 IF SRCRET
IF (X>SRCRET)
WRITE !!,"Start time is after current end time. Please correct."
KILL X
QUIT
+5 SET SRSPREC=$ORDER(^SRF(DA(1),50,DA(2)),-1)
+6 IF SRSPREC'=0
Begin DoDot:1
+7 SET SRPET=$$GET1^DIQ(130.213,SRSPREC_","_DA(1)_",",1,"I")
+8 IF SRPET=""
WRITE !!,"New start time entry not permitted until previous end time is entered."
KILL X
QUIT
+9 IF SRPET>X
WRITE !!,"Start time is prior to previous end time. Please correct."
KILL X
End DoDot:1
+10 IF $DATA(X)
IF (DA(2)=1)
SET SRTIME(130,DA(1)_",",.21)=X
DO FILE^DIE("","SRTIME","^TMP(""SR"",$J)")
+11 QUIT
FINALT ;
+1 NEW SRCST,SRLET,SRYN,SRSNREC,SRFDA,SRTIME,SRLREC,SRCON
+2 IF $DATA(^SRF(DA(1),"CON"))
IF $PIECE(^("CON"),"^")
SET SRCON=$PIECE(^SRF(DA(1),"CON"),"^")
+3 SET SRCST=$$GET1^DIQ(130.213,DA(2)_","_DA(1)_",",.01,"I")
+4 IF X<SRCST
WRITE !!,"End time prior to start time. Please correct."
KILL X
QUIT
+5 SET SRSNREC=$ORDER(^SRF(DA(1),50,DA(2)))
+6 IF SRSNREC'="B"
QUIT
ASK WRITE !!,"Does this entry complete all start and end times for this case? (Y/N)// "
READ SRYN:DTIME
IF '$TEST!(SRYN["^")
SET SRYN="N"
QUIT
+1 SET SRYN=$EXTRACT(SRYN)
IF "YyNn?"'[SRYN
WRITE !,"Invalid response, please enter Yes or No. Use ? for help."
GOTO ASK
+2 IF "?"[SRYN
DO HELP
GOTO ASK
+3 IF ("Nn"[SRYN)
SET SRFDA(130,DA(1)_",",.214)="@"
DO FILE^DIE("","SRFDA","^TMP(""SR"",$J)")
KILL SRFDA
QUIT
+4 DO CHKTIME
+5 IF SRAFLAG=1
KILL SRAFLAG
QUIT
+6 SET SRLREC=$ORDER(^SRF(DA(1),50,"B"),-1)
+7 IF SRLREC'=DA(2)
SET SRLET=$$GET1^DIQ(130.213,SRLREC_","_DA(1)_",",1,"I")
+8 IF SRLREC=DA(2)
SET SRLET=X
+9 SET SRTIME(130,DA(1)_",",.24)=SRLET
SET SRTIME(130,DA(1)_",",.214)="1"
DO FILE^DIE("","SRTIME","^TMP(""SR"",$J)")
+10 KILL SRAFLAG
+11 IF '$DATA(SRCON)
QUIT
ASK2 ;
+1 WRITE !,"Does this entry complete all start and end times for the concurrent",!,"case? (Y/N)// "
READ SRYN:DTIME
IF '$TEST!(SRYN["^")
SET SRYN="N"
QUIT
+2 IF "?"[SRYN
DO HELP^SROCON
DO HELP
GOTO ASK2
+3 SET SRYN=$EXTRACT(SRYN)
IF "YyNn"'[SRYN
WRITE !,"Invalid response, please enter Yes or No. Use ? for help."
GOTO ASK2
+4 IF ("Nn"[SRYN)
IF (($PIECE(^SRF(SRCON,.2),"^",17)=1))
SET SRFDA(130,SRCON_",",.214)="@"
DO FILE^DIE("","SRFDA","^TMP(""SR"",$J)")
KILL SRFDA
QUIT
+5 SET SRTIME(130,SRCON_",",.214)="1"
DO FILE^DIE("","SRTIME","^TMP(""SR"",$J)")
+6 QUIT
CHKTIME ; verify blocks of time are valid
+1 NEW SRSREC,SRCST,SRCET,SRAFLAG1,SRSNREC,SRNST,SRLREC
+2 SET SRAFLAG=0
SET SRSREC=0
SET SRAFLAG1=0
+3 FOR
SET SRSREC=$ORDER(^SRF(DA(1),50,SRSREC))
IF 'SRSREC!(SRAFLAG1=1)
QUIT
Begin DoDot:1
+4 SET SRCST=$$GET1^DIQ(130.213,SRSREC_","_DA(1)_",",.01,"I")
SET SRCET=$$GET1^DIQ(130.213,SRSREC_","_DA(1)_",",1,"I")
+5 SET SRLREC=$ORDER(^SRF(DA(1),50,"B"),-1)
+6 IF (SRCET="")
IF (SRSREC'=SRLREC)
WRITE !!,"One or more time entries missing end time. Please correct."
SET SRAFLAG=1
SET SRAFLAG1=1
QUIT
+7 SET SRSNREC=$ORDER(^SRF(DA(1),50,SRSREC))
+8 IF SRSNREC="B"
SET SRAFLAG1=1
QUIT
+9 SET SRNST=$$GET1^DIQ(130.213,SRSNREC_","_DA(1)_",",.01,"I")
+10 IF SRNST<SRCET
WRITE !!,"Some time entries overlap. Please correct."
SET SRAFLAG=1
SET SRAFLAG1=1
QUIT
End DoDot:1
+11 QUIT
CSET ; caled by set xref of mult anes start and end times used for concurrent case anes field stuffing
+1 NEW SRSREC,SRCST,SRCET,SRTIME
+2 IF $$GET1^DIQ(130,DA(1),.214,"I")'=1
QUIT
+3 SET SRSREC=0
+4 FOR
SET SRSREC=$ORDER(^SRF(DA(1),50,SRSREC))
IF 'SRSREC
QUIT
Begin DoDot:1
+5 IF '$DATA(SRCST)
SET SRCST=$$GET1^DIQ(130.213,SRSREC_","_DA(1)_",",.01,"I")
+6 SET SRCET=$$GET1^DIQ(130.213,SRSREC_","_DA(1)_",",1,"I")
End DoDot:1
+7 SET SRTIME(130,DA(1)_",",.24)=SRCET
SET SRTIME(130,DA(1)_",",.21)=SRCST
DO FILE^DIE("","SRTIME","^TMP(""SR"",$J)")
+8 QUIT
DEL ; called by kill xref of mult anes start and end times
+1 IF '$DATA(DA(2))
QUIT
+2 IF (DA(2)=1)
IF (D=.01)
SET SRFDA(130,DA(1)_",",.21)="@"
DO FILE^DIE("","SRFDA","^TMP(""SR"",$J)")
KILL SRFDA
+3 IF ($ORDER(^SRF(DA(1),50,DA(2)))="B")
IF (D=1)
SET SRFDA(130,DA(1)_",",.24)="@"
SET SRFDA(130,DA(1)_",",.214)="@"
DO FILE^DIE("","SRFDA","^TMP(""SR"",$J)")
KILL SRFDA
+4 QUIT
HELP ;
+1 WRITE !,"Enter ""Y"" only if the block of time entered is the final block of time for"
+2 WRITE !,"this case. If the block of time is not the final block, enter ""N""."
+3 QUIT
BILLTIME() ; calculate total minutes for mult anes start and end times
+1 NEW SRSREC,SRCST,SRCET,SRTTIME
+2 SET SRSREC=0
SET SRTTIME=0
+3 IF $$GET1^DIQ(130,D0,.214,"I")'=1
QUIT SRTTIME
+4 IF '$DATA(^SRF(D0,50))
QUIT SRTTIME
+5 FOR
SET SRSREC=$ORDER(^SRF(D0,50,SRSREC))
IF 'SRSREC
QUIT
Begin DoDot:1
+6 SET SRCST=$$GET1^DIQ(130.213,SRSREC_","_D0_",",.01,"I")
SET SRCET=$$GET1^DIQ(130.213,SRSREC_","_D0_",",1,"I")
+7 DO CALC
End DoDot:1
+8 QUIT SRTTIME
CALC ; calculate minutes between start and end times
+1 NEW SRETH,SRDHRS,SRSHR,SREHR,SRSMN,SREMN,SRSTH,X1,X2,Y,%H
+2 SET X1=SRCST
SET X2=0
DO C^%DTC
SET SRSTH=%H
+3 SET X1=SRCET
SET X2=0
DO C^%DTC
SET SRETH=%H
+4 SET SRDHRS=(SRETH-SRSTH)*24
+5 SET SRSHR=$EXTRACT(($PIECE(SRCST_"0",".",2)),1,2)
+6 SET SREHR=$EXTRACT(($PIECE(SRCET_"0",".",2)),1,2)
+7 IF SREHR<SRSHR
SET SREHR=SREHR+24
SET SRDHRS=SRDHRS-24
+8 SET SRSMN=$EXTRACT(($PIECE(SRCST_"00",".",2)),3,4)
+9 SET SREMN=$EXTRACT(($PIECE(SRCET_"00",".",2)),3,4)
+10 IF SREMN<SRSMN
SET SREMN=SREMN+60
SET SREHR=SREHR-1
+11 SET Y=(SRDHRS*60)+((SREHR-SRSHR)*60)+(SREMN-SRSMN)
+12 SET SRTTIME=SRTTIME+Y
+13 QUIT
ANESTIME(SRDFN,SRFDATE,SRTDATE) ; API to return multiple anesthesia records and times
+1 NEW SRCASE,SRREC,SRCNT,SRNON,SRX,SRDATE,SRRES,SRSC,SRCV,SRQO,SRIR,SREC,SRMST,SRHNC,SRAO,SRSREC,SRCST,SRCET,SRTTIME,SR,SRDIAG,SRSHAD
+2 SET (SRREC,SRCNT,SRRES)=0
+3 IF '$DATA(SRDFN)!'$DATA(SRFDATE)
QUIT -1
+4 IF '$DATA(SRTDATE)
SET SRTDATE=SRFDATE
+5 IF '$DATA(^SRF("B",SRDFN))
QUIT 0
+6 SET SRFDATE=$PIECE(SRFDATE,".")
SET SRTDATE=$PIECE(SRTDATE,".")
+7 FOR
SET SRREC=$ORDER(^SRF("B",SRDFN,SRREC))
IF 'SRREC
QUIT
SET SRCNT=SRCNT+1
SET SRCASE(SRCNT)=SRREC
+8 SET SRREC=0
+9 FOR
SET SRREC=$ORDER(SRCASE(SRREC))
IF 'SRREC
QUIT
Begin DoDot:1
+10 SET SRCASE=SRCASE(SRREC)
+11 SET SRNON=$SELECT($PIECE($GET(^SRF(SRCASE,"NON")),"^")="Y":1,1:0)
+12 IF 'SRNON
SET SRX=$GET(^SRF(SRCASE,.2))
SET SRDATE=$PIECE(SRX,"^",10)
+13 IF SRNON
SET SRX=$GET(^SRF(SRCASE,"NON"))
SET SRDATE=$PIECE(SRX,"^",4)
+14 SET SRDATE=$PIECE(SRDATE,".")
+15 IF (SRDATE<SRFDATE)!(SRDATE>SRTDATE)
KILL SRCASE(SRREC)
QUIT
End DoDot:1
+16 SET SRREC=0
+17 FOR
SET SRREC=$ORDER(SRCASE(SRREC))
IF 'SRREC
QUIT
Begin DoDot:1
+18 SET SRCASE=SRCASE(SRREC)
+19 IF $$GET1^DIQ(130,SRCASE,.214,"I")'=1
SET SRRES=-2
QUIT
+20 SET SRDIAG=$PIECE($GET(^SRO(136,SRCASE,0)),"^",3)
+21 IF 'SRDIAG
SET SRDIAG=$PIECE($GET(^SRF(SRCASE,34)),"^",2)
+22 SET (SRAO,SREC,SRHNC,SRIR,SRMST,SRSHAD)=0
+23 SET SR(0)=$GET(^SRF(SRCASE,0))
+24 SET SRSC=$PIECE(SR(0),"^",16)
SET SRAO=$PIECE(SR(0),"^",17)
SET SRIR=$PIECE(SR(0),"^",18)
SET SREC=$PIECE(SR(0),"^",19)
SET SRMST=$PIECE(SR(0),"^",22)
SET SRHNC=$PIECE(SR(0),"^",23)
SET SRCV=$PIECE(SR(0),"^",24)
SET SRSHAD=$PIECE(SR(0),"^",25)
+25 IF '$DATA(^SRF(SRCASE,50))
IF SRRES'=1
SET SRRES=-2
QUIT
+26 SET SRRES=1
SET SRREC=0
+27 FOR
SET SRREC=$ORDER(^SRF(SRCASE,50,SRREC))
IF (SRREC="B")!(SRREC="")
QUIT
Begin DoDot:2
+28 SET SRCST=$$GET1^DIQ(130.213,SRREC_","_SRCASE_",",.01,"I")
SET SRCET=$$GET1^DIQ(130.213,SRREC_","_SRCASE_",",1,"I")
+29 IF 'SRCET
KILL ^TMP("SRANES",$JOB,SRCASE)
SET SRRES=-2
SET SRREC=""
QUIT
+30 SET SRTTIME=0
DO CALC
+31 SET ^TMP("SRANES",$JOB,SRCASE,SRCST,SRCET)=SRDFN_"^"_SRTTIME_"^"_SRDIAG_"^"_SRSC_"^"_SRCV_"^"_SRAO_"^"_SRIR_"^"_SREC_"^"_SRMST_"^"_SRHNC_"^"_SRSHAD
End DoDot:2
End DoDot:1
+32 QUIT SRRES