source: WorldVistAEHR/trunk/r/SURGERY-SR/SROAL1.m@ 1036

Last change on this file since 1036 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.1 KB
RevLine 
[613]1SROAL1 ;BIR/ADM - LOAD PREOPERATIVE LAB DATA ;02/14/07
2 ;;3.0; Surgery ;**18,38,47,54,65,71,81,88,100,125,153,160**;24 Jun 93;Build 7
3 ;
4 ; Reference to ^LR( supported by DBIA #194
5 ;
6 Q:'$D(SRTN) N SRBLUD K SRAD,SRAT S SRSOUT=0
7 W !!,"This selection loads the most recent lab data for tests performed",!,"within 90 days before the operation unless otherwise specified."
8YEP W !!,"Do you want to automatically load preoperative lab data ? YES// " R SRYN:DTIME G:'$T!(SRYN["^") END
9 S SRYN=$E(SRYN) I "YyNn"'[SRYN W !!,"Enter <RET> to automatically load preoperative lab data from the patient's lab record, or 'NO' to return to the menu." G YEP
10 I "Yy"'[SRYN W !!,"Lab data NOT loaded." G END
11START S SRALR=$S($D(^DPT($P(^SRF(SRTN,0),"^"),"LR")):$P(^("LR"),"^"),1:"")
12 S SRAOP=$P($G(^SRF(SRTN,.2)),"^",2) I 'SRAOP W !!,"The 'Time the Operation Began' must be entered before continuing." D TMCHK G:SRSOUT END
13 S SRST=9999999-SRAOP,X1=SRAOP,X2=-90 D C^%DTC S SREND=9999999-X
14SRAT ; Get test and data name(s) for test from file 139.2.
15 W !!,"..Searching lab record for latest preoperative test data...."
16 K DIC S DIC=61,DIC(0)="",X="SERUM" D ^DIC S SRSER=+Y K DIC S DIC=61,DIC(0)="",X="PLASMA" D ^DIC K DIC S SRP=+Y
17 K DIC S DIC=61,DIC(0)="",X="BLOOD" D ^DIC S SRBLUD=+Y
18 F SRAT=1,4,7,8,11,13:1:20,25 D SP
19 S SRAT=26,X1=SRAOP,X2=-2 D C^%DTC S SREND=9999999-X D SP
20 S SRAT=27,X1=SRAOP,X2=-1000 D C^%DTC S SREND=9999999-X D SP
21 I $$LOCK^SROUTL(SRTN) D ^SROAL11 S SRCON=$P($G(^SRF(SRTN,"CON")),"^") D:SRCON CONCC D UNLOCK^SROUTL(SRTN)
22END I 'SRSOUT W !!,"Press <RET> to continue " R X:DTIME
23 W @IOF
24 Q
25CONCC ; update concurrent case
26 S SRTN1=SRTN,SRTN=SRCON D N4^SROAL11 S SRTN=SRTN1
27 Q
28SP S SRASP=$P(^SRO(139.2,SRAT,2),"^") K SRADT F SRADN=0:0 S SRADN=$O(^SRO(139.2,SRAT,1,SRADN)) Q:SRADN'>0 S SRATN=$P(^(SRADN,0),"^") D LABCHK
29 D NS
30 Q
31LABCHK ; Get latest test values from patient's lab record.
32 I SRALR F SRAIDT=SRST:0 S SRAIDT=$O(^LR(SRALR,"CH",SRAIDT)) Q:SRAIDT'>0!(SRAIDT>SREND) I $D(^(SRAIDT,SRATN)) S SRSP=$P(^(0),"^",5) D
33 .I (SRAT>1&(SRAT<16))!(SRAT=26)!(SRAT>20&(SRAT<25)),SRSP=SRSER!(SRSP=SRP)!(SRSP=SRBLUD) D COMP Q
34 .I SRSP=SRASP D COMP
35 Q
36NS ; check for no sample
37 I '$D(SRAT(SRAT)) S SRAT(SRAT)="NS",SRAD(SRAT)=""
38 Q
39COMP S SRX=$P(^LR(SRALR,"CH",SRAIDT,SRATN),"^") I $P(^LR(SRALR,"CH",SRAIDT,0),"^",3)'="","canccommentpending"'[SRX,SRX'["CANC" D DATA
40 Q
41DATA I $D(SRADT),SRAIDT>SRADT Q
42 I +SRX'=SRX D
43 .N X1,X2 S SRZ="" I " <>"[$E(SRX) S SRZ=$E(SRX),SRX=$E(SRX,2,99)
44 .I SRX?.N0.1".".N D Q
45 ..S X1=$P(SRX,"."),X1=+X1 S:X1=0 X1=""
46 ..S X2="."_$P(SRX,".",2),X2=+X2 S:X2=0 X2=""
47 ..S SRX=X1_X2,SRX=+SRX,SRX=SRZ_SRX
48 .S SRX="*"
49 S SRAT(SRAT)=SRX D:SRAT(SRAT)["." DEC S SRAD(SRAT)=$E($P(^LR(SRALR,"CH",SRAIDT,0),"^"),1,7),SRADT=SRAIDT
50 Q
51TMCHK W !!,"Do you want to enter 'Time the Operation Began' at this time ? YES// " R SRYN:DTIME I '$T!(SRYN["^") S SRSOUT=1 Q
52 S SRYN=$E(SRYN)
53 I "YyNn"'[SRYN W !!,"The time that the operation began must be entered prior to capturing the",!,"preoperative lab data. Enter 'YES' to input 'Time the Operation Began',",!,"or 'NO' to return to the menu." G TMCHK
54 I "Yy"'[SRYN S SRSOUT=1 Q
55 I $$LOCK^SROUTL(SRTN) D D UNLOCK^SROUTL(SRTN)
56 .W ! K DR S DR=".22T",DA=SRTN,DIE=130 D ^DIE K DR
57 S SRAOP=$P($G(^SRF(SRTN,.2)),"^",2) I 'SRAOP S SRSOUT=1
58 Q
59DEC ; convert to proper decimal place
60 I +SRAT(SRAT)=SRAT(SRAT) S SRAT(SRAT)=SRAT(SRAT)+.005\.01*.01 Q
61 S SR1=$E(SRAT(SRAT)),SR2=$E(SRAT(SRAT),2,99),SR2=SR2+.005\.01*.01,SRAT(SRAT)=SR1_SR2
62 Q
63CREAT ; from SROACL1 for creatinine
64 N SRSER,SRP K DIC S DIC=61,DIC(0)="",X="SERUM" D ^DIC S SRSER=+Y K DIC S DIC=61,DIC(0)="",X="PLASMA" D ^DIC K DIC S SRP=+Y
65 S SRLB=0 F SRLB=4,8,20 D
66 .S VALUE=$P($G(^SRF(SRTN,201)),"^",SRLB),SRAOPDT=$P(^SRF(SRTN,0),"^",9) I DT>SRAOPDT,VALUE Q
67 .S SRSOUT=0,SRALR=$S($D(^DPT($P(^SRF(SRTN,0),"^"),"LR")):$P(^("LR"),"^"),1:"")
68 .S SRAOP=SRAOPDT,SRST=9999999-SRAOP,X1=SRAOP,X2=-30 D C^%DTC S SREND=9999999-X
69 .S SRAT=$S(SRLB=4:7,SRLB=8:11,1:1),SRASP=$P(^SRO(139.2,SRAT,2),"^") K SRADT F SRADN=0:0 S SRADN=$O(^SRO(139.2,SRAT,1,SRADN)) Q:'SRADN S SRATN=$P(^(SRADN,0),"^") D LABCHK
70 .I $D(SRAT(SRAT)),$$LOCK^SROUTL(SRTN) S $P(^SRF(SRTN,201),"^",SRLB)=SRAT(SRAT),$P(^(202),"^",SRLB)=SRAD(SRAT) D UNLOCK^SROUTL(SRTN)
71 K SRLB
72 Q
Note: See TracBrowser for help on using the repository browser.