source: FOIAVistA/trunk/r/LAB_SERVICE-LR-LS/LR7OB63.m@ 1688

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

initial load of FOIAVistA 6/30/08 version

File size: 4.7 KB
Line 
1LR7OB63 ; DALOI/dcm - Get Lab data from 63 ;8/11/97
2 ;;5.2;LAB SERVICE;**121,187,286**;Sep 27, 1994
3 ;
463(CTR,LRDFN,SS,IVDT,CORRECT) ;Get data from file 63
5 ;CTR=Counter
6 ;LRDFN=Patient ID
7 ;SS=Subscript for results 'CH'-Chem Tox 'MI'-Microbiology, etc.
8 ;IVDT=Inverse D/T verified
9 ;CORRECT=1 if a corrected result, 0 if not
10 ;See ^LR7OB69 for description of LRX array
11 I $G(CONTROL)="ZC" Q
12 N IFN
13 I $L(SS),$L($T(@SS)) G @SS
14 Q
15 ;
16 ;
17CH ;Chem, Hem, Tox, Ria, Ser, etc.
18 N LRX,X0,Y1,Y2,Y3,Y4,Y5,Y6,Y12,Y14,Y15,Y16,Y17,Y18
19 Q:'$D(^LR(LRDFN,"CH",+$G(IVDT),0)) S X0=^(0)
20 S Y6=$S(+$G(CORRECT):"C",$P(X0,"^",3):"F",1:"")
21 S Y16=$P(X0,"^",6)
22 S Y17=$$ORD^LR7OR2(LRDFN,IVDT),Y18=";CH;"_IVDT
23 ;
24 I '$D(SEX) N SEX S SEX=$P($G(@("^"_$P(LRDPF,"^",2)_+DFN_",0)")),"^",2)
25 ;
26 I '$D(DOB)!'$D(AGE) N AGE,DOB D
27 . S DOB=$P($G(@("^"_$P(LRDPF,"^",2)_+DFN_",0)")),"^",3)
28 . S AGE=$S($D(DT)&(DOB?7N):DT-DOB\10000,1:"??")
29 ;
30 S IFN=1
31 F S IFN=$O(^LR(LRDFN,"CH",IVDT,IFN)) Q:IFN<1 S X=^(IFN) I $D(TSTY(IFN))!($D(BYPASS)),$S('$D(LRSB):1,$D(LRSB(IFN)):1,1:0) D
32 . I $D(LRSB(IFN)),$D(LRSA(IFN)),'$D(LRSA(IFN,2)) Q ;Only re-transmit changed results
33 . S Y1=IFN,Y1=$O(^LAB(60,"C","CH;"_Y1_";1",0)),Y2=$P(X,"^"),Y3=$P(X,"^",2),Y12=$P(X,"^",4)
34 . S:Y2="pending" Y6="P" ;Set result status to P for pending results
35 . Q:"IN"[$P(^LAB(60,Y1,0),"^",3) S Y15=$P($G(^LAB(60,Y1,.1)),"^")
36 . S (Y9,Y10,Y11,Y14)=""
37 . I $P($G(^LAB(60,Y1,64)),"^") S Y9=$P(^(64),"^"),Y9=$P(^LAM(Y9,0),"^",2),Y10=$P(^(0),"^"),Y11="99NLT"
38 . ;D UNIT(Y1,$P(X0,"^",5),SEX,DOB,AGE)
39 . S LRX=$$TSTRES^LRRPU(LRDFN,"CH",IVDT,IFN,Y1)
40 . S Y2=$P(LRX,"^"),Y3=$P(LRX,"^",2),Y4=$P(LRX,"^",5),Y5=$P(LRX,"^",3)_$S($P(LRX,"^",4)'="":"-"_$P(LRX,"^",4),1:"")
41 . I $P(LRX,"^",7) S Y14="T"
42 . S Y2=$$TRIM^XLFSTR($$RESULT(Y1,Y2),"LR"," ")
43 . S ^TMP("LRX",$J,69,CTR,63,IFN)=Y1_"^"_Y2_"^"_Y3_"^"_Y4_"^"_Y5_"^"_Y6_"^^^"_Y9_"^"_Y10_"^"_Y11_"^"_Y12_"^^"_Y14_"^"_Y15_"^"_Y16_"^"_Y17_"^"_Y18
44 ;
45 I $D(GOTCOM(LRDFN,"CH",IVDT)) Q
46 S GOTCOM(LRDFN,"CH",IVDT)="",IFN=0
47 F S IFN=$O(^LR(LRDFN,"CH",IVDT,1,IFN)) Q:IFN<1 S ^TMP("LRX",$J,69,CTR,63,"N",IFN)=$P(^LR(LRDFN,"CH",IVDT,1,IFN,0),"^")
48 ;
49 Q
50 ;
51 ;
52MI ;Microbiology
53 D MI^LR7OB63A()
54 Q
55 ;
56 ;
57BB ;Blood bank
58 D BB1()
59 Q
60 ;
61 ;
62BB1(SPECMEN) ;Blood bank
63 ;SPECMEN=ptr to 61, to specify specimen (optional)
64 N X0,Y1,Y2,Y3,Y4,Y5,Y6,Y15,Y18,Y19,CTR1
65 Q:'$D(^LR(LRDFN,"BB",+$G(IVDT),0)) S X0=^(0),Y6=$S(+$G(CORRECT):"C",$P(X0,"^",3):"F",1:""),Y19=$P(X0,"^",5),CTR1=0,Y18=";BB;"_IVDT
66 ;There are other multiples for blood bank in file 63 that also need to be processed, this is just a start.
67 I $G(SPECMEN),Y19'=SPECMEN Q
68 S IFN=1 F S IFN=$O(^LR(LRDFN,"BB",IVDT,IFN)) Q:IFN<1 I $D(^(IFN))#2 S XNODE=^(IFN) F IFN1=1:1:$L(XNODE,"^") S X1=$P(XNODE,"^",IFN1) I $L(X1) D
69 . S X=$$NODEPIK(63.01,IFN,IFN1,X1) ;X=field^data
70 . I $L($P(X,"^")) S CTR1=CTR1+1,^TMP("LRX",$J,69,CTR,63,CTR1)=X_"^^^^"_Y6_"^^^^^^^^^"_X_"^^^"_Y18_"^"_Y19
71 I $D(^LR(LRDFN,"BB",IVDT,99)) S Y1="Specimen Comment: " S IFN=0 F S IFN=$O(^LR(LRDFN,"BB",IVDT,99,IFN)) Q:IFN<1 S Y2=^(IFN,0),^TMP("LRX",$J,69,CTR,63,"N",IFN)=Y1_"^"_Y2
72 Q
73 ;
74 ;
75EM ;Electron Microscopy
76 D SS^LR7OB63C("EM")
77 Q
78 ;
79 ;
80SP ;Surgical Pathology
81 D SS^LR7OB63C("SP")
82 Q
83 ;
84 ;
85CY ;Cytology
86 D SS^LR7OB63C("CY")
87 Q
88 ;
89 ;
90AU ;Autopsy
91 D AU^LR7OB63D
92 Q
93 ;
94 ;
95NODEPIK(FILE,NODE,PIECE,DATA) ;Set field name and data into X
96 N Z,Y,Y1,Y2
97 S Z=$O(^DD(FILE,"GL",NODE,PIECE,0)),X=""
98 I Z S Y=^DD(FILE,Z,0),Y1=$P(Y,"^"),Y2=DATA S:$P(Y,"^",2)["S" Y2=$$SET(FILE,Z,Y2) S:$P(Y,"^",2)["P"!($P(Y,"^",2)["V") Y2=$$POINTER(FILE,Z,Y2) S X=Y1_"^"_Y2
99 Q X
100 ;
101 ;
102UNIT(X,SPEC,SEX,DOB,AGE) ;Find units and ref range
103 ;X=Result
104 ;SPEC=Specimen ptr
105 ;SEX=Patient sex
106 ;DOB=Patient Date of birth
107 ;AGE=Patient age
108 ;Output: Y4=Units, Y5=Ref Range, Y14=T or "" (If T, range is theraputic)
109 N LO,HI
110 S (Y4,Y5,Y14)=""
111 Q:'$D(^LAB(60,+X,1,+SPEC,0)) S X=^(0) ;No units/ranges defined
112 S Y4=$P(X,"^",7)
113 S @("LO="_$S($L($P(X,"^",2)):$P(X,"^",2),$L($P(X,"^",11)):$P(X,"^",11),1:""""""))
114 S @("HI="_$S($L($P(X,"^",3)):$P(X,"^",3),$L($P(X,"^",12)):$P(X,"^",12),1:""""""))
115 S Y5=$S($L(HI):LO_"-"_HI,1:LO)
116 S Y14=$S('$L($P(X,"^",2))&$L($P(X,"^",11)):"T",1:"")
117 Q
118 ;
119 ;
120RESULT(TEST,RESULT) ;Convert result to external format
121 ;TEST=Test ptr to file 60
122 ;RESULT=Test result
123 N X,X1,LRCW
124 S LRCW="",X1=$P($G(^LAB(60,TEST,.1)),"^",3),X1=$S($L(X1):X1,1:"$J(X,8)"),X=RESULT,@("X="_X1)
125 Q X
126 ;
127 ;
128STRIP(TEXT) ;Strips white space from text
129 N I,X
130 S X="" F I=1:1:$L(TEXT," ") S:$A($P(TEXT," ",I))>0 X=X_$P(TEXT," ",I)
131 Q X
132 ;
133 ;
134SET(FILE,FIELD,RESULT) ;Interpret set of codes
135 S X=$P(^DD(FILE,FIELD,0),"^",3),X=$P($P(";"_X,";"_RESULT_":",2),";")
136 Q X
137 ;
138 ;
139POINTER(FILE,FIELD,RESULT) ;Interpret pointer values
140 N X
141 S X=$P(^DD(FILE,FIELD,0),"^",2)
142 I X["V" S X1=@("^"_$P(RESULT,";",2)_+RESULT_",0)")
143 I X'["V" S X1=$P(@("^"_$P(^DD(FILE,FIELD,0),"^",3)_RESULT_",0)"),"^")
144 Q X1
Note: See TracBrowser for help on using the repository browser.