source: FOIAVistA/trunk/r/LAB_SERVICE-LR-LS/LRRPU.m@ 1528

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

initial load of FOIAVistA 6/30/08 version

File size: 3.8 KB
Line 
1LRRPU ;DALOI/JMC - Interim Report Results Utility ; May 10, 2004 0900
2 ;;5.2;LAB SERVICE;**286**;Sep 27, 1994
3 ;
4 ;
5TSTRES(LRDFN,LRSS,LRIDT,LRDN,LR60,LRCODE) ; Test results and parameters
6 ; Call with LRDFN = ien of entry in file #63
7 ; LRSS = subscript in file #63, currently only "CH" supported
8 ; LRIDT = inverse date/time of result
9 ; LRDN = ien of data name in "CH" subscript
10 ; LR60 = pointer to file 60 test related to this dataname (optional)
11 ; LRCODE = 1 - return NLT/LOINC codes (optional)
12 ;
13 ; Returns
14 ; LRY = result^normalcy flag^reference low^reference high^units^performing lab (file #4 ien)^therapeutic normal used (0=no/1=yes)^NLT order code;NLT name!NLT result code;NLT name!LOINC result code;LOINC name^performing user (DUZ)^EII
15 ;
16 N LRFLAG,LRNR,LRX,LRY,X,Y
17 S LRX=$G(^LR(LRDFN,LRSS,LRIDT,LRDN))
18 S LRY=$P(LRX,"^",1,2),$P(LRY,"^",7)=0
19 I LRSS="CH",$$GET1^DID(63.04,LRDN,"","TYPE")="SET" D
20 . S X=$$EXTERNAL^DILFD(63.04,LRDN,"",$P(LRY,"^"))
21 . I X'="" S $P(LRY,"^")=X
22 ;
23 ; Check for units/ranges stored in file #63
24 ; If flag (NPC>1) indicates units/ranges are stored but pieces 5-12
25 ; are null then use values from file #60 - some class III software
26 ; still does not store this info in file #63 when NPC>1.
27 S LRFLAG=0,LRNR=$TR($P(LRX,"^",5),"!","^")
28 I $G(^LR(LRDFN,LRSS,LRIDT,"NPC"))>1,$P(LRX,"^",5,12)'="" S LRFLAG=1
29 ;
30 I LRFLAG D
31 . I $P(LRNR,"^",11)="",$P(LRNR,"^",12)="" S $P(LRY,"^",3,4)=$P(LRNR,"^",2,3)
32 . E S $P(LRY,"^",3,4)=$P(LRNR,"^",11,12),$P(LRY,"^",7)=1
33 . S $P(LRY,"^",5)=$P(LRNR,"^",7)
34 ;
35 ; If no units/ranges (LRFLAG=0) then use file 60
36 ; values to determine reference ranges
37 ; If no therapeutic normals then return reference normals
38 ; Need to handle age and sex in normals from file #60
39 I 'LRFLAG D
40 . N AGE,DOB,LR61,LRCDT,LRDPF,LRLO,LRHI,LRTLO,LRTHI,SEX,X
41 . S LRDPF=$P(^LR(LRDFN,0),U,2),DFN=$P(^(0),U,3)
42 . S X=$G(^LR(LRDFN,LRSS,LRIDT,0)),LRCDT=$P(X,"^"),LR61=+$P(X,"^",5)
43 . S X=$$ROOT^DILFD(+LRDPF)
44 . S SEX=$P($G(@(X_+DFN_",0)")),"^",2),DOB=$P($G(@(X_+DFN_",0)")),"^",3)
45 . S AGE=$$CALCAGE(DOB,LRCDT)
46 . I '$G(LR60) S LR60=+$O(^LAB(60,"C","CH;"_LRDN_";1",0))
47 . S X=$G(^LAB(60,LR60,1,LR61,0)) Q:X=""
48 . S $P(LRY,"^",5)=$P(X,"^",7)
49 . S LRLO=$P(X,U,2),LRHI=$P(X,U,3),LRTLO=$P(X,U,11),LRTHI=$P(X,U,12)
50 . I LRTLO="",LRTHI="" D Q
51 . . I LRLO'="" S @("LRLO="_LRLO)
52 . . I LRHI'="" S @("LRHI="_LRHI)
53 . . S $P(LRY,"^",3)=LRLO,$P(LRY,"^",4)=LRHI
54 . I LRTLO'="" S @("LRTLO="_LRTLO)
55 . I LRTHI'="" S @("LRTHI="_LRTHI)
56 . S $P(LRY,"^",3)=LRTLO,$P(LRY,"^",4)=LRTHI,$P(LRY,"^",7)=1
57 ;
58 ; Remove leading/trailing quotes from normals.
59 I $P(LRY,"^",3)[$C(34) S $P(LRY,"^",3)=$$TRIM^XLFSTR($P(LRY,"^",3),"LR",$C(34))
60 I $P(LRY,"^",4)[$C(34) S $P(LRY,"^",4)=$$TRIM^XLFSTR($P(LRY,"^",4),"LR",$C(34))
61 ; Performing laboratory
62 S $P(LRY,"^",6)=$P(LRX,"^",9)
63 ;
64 ; Return NLT/LOINC codes
65 I $G(LRCODE)=1 D
66 . N LR64
67 . S X=$P($P(LRX,"^",3),"!",1,3)
68 . F I=1,2 I $P(X,"!",I)'="" D
69 . . S LR64=$O(^LAM("E",$P(X,"!",I),0)),Y=""
70 . . I LR64 S Y=$$GET1^DIQ(64,LR64_",",.01,"I")
71 . . I Y'="",Y["!" S Y=$TR(Y,"!","*")
72 . . S $P(X,"!",I)=$P(X,"!",I)_";"_Y
73 . I $P(X,"!",3)'="" D
74 . . S Y=$$GET1^DIQ(95.3,$P(X,"!",3)_",",.01)
75 . . S Y(0)=$$GET1^DIQ(95.3,$P(X,"!",3)_",",80)
76 . . I Y(0)["!" S Y(0)=$TR(Y(0),"!","*")
77 . . S $P(X,"!",3)=Y_";"_Y(0)
78 . S $P(LRY,"^",8)=X
79 ;
80 ; Performing user
81 S $P(LRY,"^",9)=$P(LRX,"^",4)
82 ; EII - Equipment instance Identifier
83 S $P(LRY,"^",10)=$P(LRX,"^",11)
84 ;
85 Q LRY
86 ;
87 ;
88CALCAGE(DOB,LRCDT) ; Calculate age based on difference between DOB and collection date.
89 ;
90 ; Call with DOB = patient date of birth
91 ; LRCDT = specimen collection date
92 ;
93 ; Returns AGE = patient's age in years at time of specimen collection
94 ;
95 I $T(DATE^LRDAGE)'="" Q $$DATE^LRDAGE(DOB,LRCDT)
96 ;
97 S AGE=99
98 I DOB>2000000,LRCDT>2000000,DOB'>LRCDT S X=$$FMDIFF^XLFDT(LRCDT,DOB,1),AGE=X\365.25
99 Q AGE
Note: See TracBrowser for help on using the repository browser.