source: FOIAVistA/tag/r/SURGERY-SR/SROANEST.m@ 628

Last change on this file since 628 was 628, checked in by George Lilly, 14 years ago

initial load of FOIAVistA 6/30/08 version

File size: 7.8 KB
Line 
1SROANEST ;BIR/TJH - ANESTHESIA ENTRY ;01 Jun 2003
2 ;;3.0;Surgery;**119,150,152**;24 Jun 93
3SINPUT ;
4 N SRSTART
5 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
6 I '$D(X),$G(SRFLAG)=1 D K SRFLAG Q
7 .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."
8 .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"
9 .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."
10 .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."
11 .W !," You may enter NOW+3' (for current date and time Plus 3 minutes",!," *Note--the Apostrophe following the number of minutes)"
12 .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"
13 .W !," time the care resumes."
14 Q:'$D(X)
15 S SRSTART=$P($G(^SRF($S($D(SRTN):SRTN,1:DA(1)),.2)),"^",15)
16 I SRSTART="" K SRFLAG Q
17 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
18 K SRFLAG
19 Q
20STIME ;
21 I '$D(X) Q
22 N SRSPREC,SRPET,SRTIME,SRCRET
23 S SRCRET=$$GET1^DIQ(130.213,DA(2)_","_DA(1)_",",1,"I")
24 I SRCRET,(X>SRCRET) W !!,"Start time is after current end time. Please correct." K X Q
25 S SRSPREC=$O(^SRF(DA(1),50,DA(2)),-1)
26 I SRSPREC'=0 D
27 .S SRPET=$$GET1^DIQ(130.213,SRSPREC_","_DA(1)_",",1,"I")
28 .I SRPET="" W !!,"New start time entry not permitted until previous end time is entered." K X Q
29 .I SRPET>X W !!,"Start time is prior to previous end time. Please correct." K X
30 I $D(X),(DA(2)=1) S SRTIME(130,DA(1)_",",.21)=X D FILE^DIE("","SRTIME","^TMP(""SR"",$J)")
31 Q
32FINALT ;
33 N SRCST,SRLET,SRYN,SRSNREC,SRFDA,SRTIME,SRLREC,SRCON
34 I $D(^SRF(DA(1),"CON")),$P(^("CON"),"^") S SRCON=$P(^SRF(DA(1),"CON"),"^")
35 S SRCST=$$GET1^DIQ(130.213,DA(2)_","_DA(1)_",",.01,"I")
36 I X<SRCST W !!,"End time prior to start time. Please correct." K X Q
37 S SRSNREC=$O(^SRF(DA(1),50,DA(2)))
38 I SRSNREC'="B" Q
39ASK 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
40 S SRYN=$E(SRYN) I "YyNn?"'[SRYN W !,"Invalid response, please enter Yes or No. Use ? for help." G ASK
41 I "?"[SRYN D HELP G ASK
42 I ("Nn"[SRYN) S SRFDA(130,DA(1)_",",.214)="@" D FILE^DIE("","SRFDA","^TMP(""SR"",$J)") K SRFDA Q
43 D CHKTIME
44 I SRAFLAG=1 K SRAFLAG Q
45 S SRLREC=$O(^SRF(DA(1),50,"B"),-1)
46 I SRLREC'=DA(2) S SRLET=$$GET1^DIQ(130.213,SRLREC_","_DA(1)_",",1,"I")
47 I SRLREC=DA(2) S SRLET=X
48 S SRTIME(130,DA(1)_",",.24)=SRLET,SRTIME(130,DA(1)_",",.214)="1" D FILE^DIE("","SRTIME","^TMP(""SR"",$J)")
49 K SRAFLAG
50 Q:'$D(SRCON)
51ASK2 ;
52 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
53 I "?"[SRYN D HELP^SROCON D HELP G ASK2
54 S SRYN=$E(SRYN) I "YyNn"'[SRYN W !,"Invalid response, please enter Yes or No. Use ? for help." G ASK2
55 I ("Nn"[SRYN),(($P(^SRF(SRCON,.2),"^",17)=1)) S SRFDA(130,SRCON_",",.214)="@" D FILE^DIE("","SRFDA","^TMP(""SR"",$J)") K SRFDA Q
56 S SRTIME(130,SRCON_",",.214)="1" D FILE^DIE("","SRTIME","^TMP(""SR"",$J)")
57 Q
58CHKTIME ; verify blocks of time are valid
59 N SRSREC,SRCST,SRCET,SRAFLAG1,SRSNREC,SRNST,SRLREC
60 S SRAFLAG=0,SRSREC=0,SRAFLAG1=0
61 F S SRSREC=$O(^SRF(DA(1),50,SRSREC)) Q:'SRSREC!(SRAFLAG1=1) D
62 .S SRCST=$$GET1^DIQ(130.213,SRSREC_","_DA(1)_",",.01,"I"),SRCET=$$GET1^DIQ(130.213,SRSREC_","_DA(1)_",",1,"I")
63 .S SRLREC=$O(^SRF(DA(1),50,"B"),-1)
64 .I (SRCET=""),(SRSREC'=SRLREC) W !!,"One or more time entries missing end time. Please correct." S SRAFLAG=1,SRAFLAG1=1 Q
65 .S SRSNREC=$O(^SRF(DA(1),50,SRSREC))
66 .I SRSNREC="B" S SRAFLAG1=1 Q
67 .S SRNST=$$GET1^DIQ(130.213,SRSNREC_","_DA(1)_",",.01,"I")
68 .I SRNST<SRCET W !!,"Some time entries overlap. Please correct." S SRAFLAG=1,SRAFLAG1=1 Q
69 Q
70CSET ; caled by set xref of mult anes start and end times used for concurrent case anes field stuffing
71 N SRSREC,SRCST,SRCET,SRTIME
72 I $$GET1^DIQ(130,DA(1),.214,"I")'=1 Q
73 S SRSREC=0
74 F S SRSREC=$O(^SRF(DA(1),50,SRSREC)) Q:'SRSREC D
75 .S:'$D(SRCST) SRCST=$$GET1^DIQ(130.213,SRSREC_","_DA(1)_",",.01,"I")
76 .S SRCET=$$GET1^DIQ(130.213,SRSREC_","_DA(1)_",",1,"I")
77 S SRTIME(130,DA(1)_",",.24)=SRCET,SRTIME(130,DA(1)_",",.21)=SRCST D FILE^DIE("","SRTIME","^TMP(""SR"",$J)")
78 Q
79DEL ; called by kill xref of mult anes start and end times
80 I '$D(DA(2)) Q
81 I (DA(2)=1),(D=.01) S SRFDA(130,DA(1)_",",.21)="@" D FILE^DIE("","SRFDA","^TMP(""SR"",$J)") K SRFDA
82 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
83 Q
84HELP ;
85 W !,"Enter ""Y"" only if the block of time entered is the final block of time for"
86 W !,"this case. If the block of time is not the final block, enter ""N""."
87 Q
88BILLTIME() ; calculate total minutes for mult anes start and end times
89 N SRSREC,SRCST,SRCET,SRTTIME
90 S SRSREC=0,SRTTIME=0
91 I $$GET1^DIQ(130,D0,.214,"I")'=1 Q SRTTIME
92 I '$D(^SRF(D0,50)) Q SRTTIME
93 F S SRSREC=$O(^SRF(D0,50,SRSREC)) Q:'SRSREC D
94 .S SRCST=$$GET1^DIQ(130.213,SRSREC_","_D0_",",.01,"I"),SRCET=$$GET1^DIQ(130.213,SRSREC_","_D0_",",1,"I")
95 .D CALC
96 Q SRTTIME
97CALC ; calculate minutes between start and end times
98 N SRETH,SRDHRS,SRSHR,SREHR,SRSMN,SREMN,SRSTH,X1,X2,Y,%H
99 S X1=SRCST,X2=0 D C^%DTC S SRSTH=%H
100 S X1=SRCET,X2=0 D C^%DTC S SRETH=%H
101 S SRDHRS=(SRETH-SRSTH)*24
102 S SRSHR=$E(($P(SRCST_"0",".",2)),1,2)
103 S SREHR=$E(($P(SRCET_"0",".",2)),1,2)
104 I SREHR<SRSHR S SREHR=SREHR+24,SRDHRS=SRDHRS-24
105 S SRSMN=$E(($P(SRCST_"00",".",2)),3,4)
106 S SREMN=$E(($P(SRCET_"00",".",2)),3,4)
107 I SREMN<SRSMN S SREMN=SREMN+60,SREHR=SREHR-1
108 S Y=(SRDHRS*60)+((SREHR-SRSHR)*60)+(SREMN-SRSMN)
109 S SRTTIME=SRTTIME+Y
110 Q
111ANESTIME(SRDFN,SRFDATE,SRTDATE) ; API to return multiple anesthesia records and times
112 N SRCASE,SRREC,SRCNT,SRNON,SRX,SRDATE,SRRES,SRSC,SRCV,SRQO,SRIR,SREC,SRMST,SRHNC,SRAO,SRSREC,SRCST,SRCET,SRTTIME,SR,SRDIAG,SRSHAD
113 S (SRREC,SRCNT,SRRES)=0
114 I '$D(SRDFN)!'$D(SRFDATE) Q -1
115 I '$D(SRTDATE) S SRTDATE=SRFDATE
116 I '$D(^SRF("B",SRDFN)) Q 0
117 S SRFDATE=$P(SRFDATE,"."),SRTDATE=$P(SRTDATE,".")
118 F S SRREC=$O(^SRF("B",SRDFN,SRREC)) Q:'SRREC S SRCNT=SRCNT+1,SRCASE(SRCNT)=SRREC
119 S SRREC=0
120 F S SRREC=$O(SRCASE(SRREC)) Q:'SRREC D
121 .S SRCASE=SRCASE(SRREC)
122 .S SRNON=$S($P($G(^SRF(SRCASE,"NON")),"^")="Y":1,1:0)
123 .I 'SRNON S SRX=$G(^SRF(SRCASE,.2)),SRDATE=$P(SRX,"^",10)
124 .I SRNON S SRX=$G(^SRF(SRCASE,"NON")),SRDATE=$P(SRX,"^",4)
125 .S SRDATE=$P(SRDATE,".")
126 .I (SRDATE<SRFDATE)!(SRDATE>SRTDATE) K SRCASE(SRREC) Q
127 S SRREC=0
128 F S SRREC=$O(SRCASE(SRREC)) Q:'SRREC D
129 .S SRCASE=SRCASE(SRREC)
130 .I $$GET1^DIQ(130,SRCASE,.214,"I")'=1 S SRRES=-2 Q
131 .S SRDIAG=$P($G(^SRO(136,SRCASE,0)),"^",3)
132 .I 'SRDIAG S SRDIAG=$P($G(^SRF(SRCASE,34)),"^",2)
133 .S (SRAO,SREC,SRHNC,SRIR,SRMST,SRSHAD)=0
134 .S SR(0)=$G(^SRF(SRCASE,0))
135 .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)
136 .I '$D(^SRF(SRCASE,50)) S:SRRES'=1 SRRES=-2 Q
137 .S SRRES=1,SRREC=0
138 .F S SRREC=$O(^SRF(SRCASE,50,SRREC)) Q:(SRREC="B")!(SRREC="") D
139 ..S SRCST=$$GET1^DIQ(130.213,SRREC_","_SRCASE_",",.01,"I"),SRCET=$$GET1^DIQ(130.213,SRREC_","_SRCASE_",",1,"I")
140 ..I 'SRCET K ^TMP("SRANES",$J,SRCASE) S SRRES=-2,SRREC="" Q
141 ..S SRTTIME=0 D CALC
142 ..S ^TMP("SRANES",$J,SRCASE,SRCST,SRCET)=SRDFN_"^"_SRTTIME_"^"_SRDIAG_"^"_SRSC_"^"_SRCV_"^"_SRAO_"^"_SRIR_"^"_SREC_"^"_SRMST_"^"_SRHNC_"^"_SRSHAD
143 Q SRRES
Note: See TracBrowser for help on using the repository browser.