source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORWLR2.m@ 1604

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

initial load of WorldVistAEHR

File size: 7.9 KB
RevLine 
[613]1ORWLR2 ; slc/dcm - VBEC Blood Bank Report ;01/16/03 15:02
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**172**;Dec 17, 1997
3 ;from ORWLR1 - Re-write of ^LR7OSBR1
4EN ;
5 N %DT,A,B,C,CMT,H,ID,J,ORI,T,X,X0,Y,PARENT
6 D H
7 ;
8 ;Get Antibodies
9 D ABID^VBECA1(PATID,PATNAM,PATDOB,.PARENT,.ARR)
10 I $O(ARR("ABID",0)) D
11 . D LN
12 . S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(4,.CCNT,"Antibodies identified: ",.CCNT),ID=0
13 . F S ID=$O(ARR("ABID",ID)) Q:'ID D
14 .. I CCNT>(GIOM-15) D LN S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT," ",.CCNT)
15 .. S ^TMP("ORLRC",$J,GCNT,0)=^TMP("ORLRC",$J,GCNT,0)_$$S^ORU4(CCNT,.CCNT,$P(ARR("ABID",ID),"^"),.CCNT)_$$S^ORU4(CCNT,.CCNT," : "_$P(ARR("ABID",ID),"^",2),.CCNT)
16 ;
17 ;Get Transfusion reactions
18 ;Note TRRX API there's no way to differentiate between reactions with or without units identified.
19 D TRRX^VBECA1(PATID,PATNAM,PATDOB,.PARENT,.ARR)
20 I $O(ARR("TRRX",0)) D
21 . D LINE^ORU4("^TMP(""ORLRC"",$J)",GIOM),LN
22 . S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(0,.CCNT,"TRANSFUSION REACTIONS",.CCNT)_$$S^ORU4(51,.CCNT,"UNIT ID",.CCNT)_$$S^ORU4(66,.CCNT,"COMPONENT",.CCNT)
23 . S ID=0 F S ID=$O(ARR("TRRX",ID)) Q:'ID S X=ARR("TRRX",ID) D
24 .. S Y=$TR($$FMTE^XLFDT(+X,"M"),"@"," ")
25 .. D LN
26 .. S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(0,.CCNT,Y,.CCNT)_$$S^ORU4(21,.CCNT,$P(X,U,2),.CCNT)_$$S^ORU4(51,.CCNT,$P(X,U,4),.CCNT)_$$S^ORU4(69,.CCNT,$P(X,U,3),.CCNT)
27 .. I $O(ARR("TRRX",ID,0)) D
28 ... S CMT=0 F S CMT=$O(ARR("TRRX",ID,CMT)) Q:'CMT S C=ARR("TRRX",ID,CMT) D
29 .... D LN
30 .... S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(0,.CCNT," "_C,.CCNT)
31 D LINE^ORU4("^TMP(""ORLRC"",$J)",GIOM)
32 ;
33 ;Get Xmatched units, Component requests, AHG
34 K ^TMP("BBD",$J)
35 D DFN^VBECA3A(DFN),CPRS^VBECA3B
36 D CX,C,TRAN,AHG
37 ;
38 ;Get Specimen Tests
39 I '$O(^TMP("BBD",$J,"SPECIMEN",0)) Q
40 S ORI=""
41 F S ORI=$O(^TMP("BBD",$J,"SPECIMEN",ORI),-1) Q:ORI="" D
42 . S ID=^TMP("BBD",$J,"SPECIMEN",ORI)
43 . Q:'$L($P(ID,"^"))
44 . S T=ORI
45 . D T,LN
46 . S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(4,.CCNT,T,.CCNT)
47 . D W
48 K ^TMP("BBD",$J)
49 Q
50W ;
51 S ^(0)=^TMP("ORLRC",$J,GCNT,0)_$$S^ORU4(21,.CCNT,$J($P(ID,"^",3),2),.CCNT)
52 S ^(0)=^TMP("ORLRC",$J,GCNT,0)_$$S^ORU4(24,.CCNT,$E($P(ID,"^",9),1,3),.CCNT)
53 F H=5,6,7,8,10 S Y=$P(ID,"^",H) S ^(0)=^TMP("ORLRC",$J,GCNT,0)_$$S^ORU4((30+$S(H=6:5,H=7:10,H=8:15,H=10:32,1:0)),.CCNT,$E(Y,1,3),.CCNT)
54 F X=10.3,11.3,2.91 I $D(^TMP("BBD",$J,"SPECIMEN",ORI,X)) S J=0 D
55 . I $D(^TMP("BBD",$J,"SPECIMEN",ORI,X))#2 D LN S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,ORN(X)_":"_^TMP("BBD",$J,"SPECIMEN",ORI,X),.CCNT)
56 I $D(^TMP("BBD",$J,"SPECIMEN",ORI,"63.012,.01")) S J=0 F S J=$O(^TMP("BBD",$J,"SPECIMEN",ORI,"63.012,.01",J)) Q:'J D
57 . S X=^TMP("BBD",$J,"SPECIMEN",ORI,"63.012,.01",J)
58 . D LN
59 . S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,"ELUATE ANTIBODY: "_X,.CCNT)
60 ;
61 I $D(^TMP("BBD",$J,"SPECIMEN",ORI,"63.46,.01")) S J=0 F S J=$O(^TMP("BBD",$J,"SPECIMEN",ORI,"63.46,.01",J)) Q:'J D
62 . S X=^TMP("BBD",$J,"SPECIMEN",ORI,"63.46,.01",J)
63 . D LN
64 . S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,"SERUM ANTIBODY IDENTIFIED: "_X,.CCNT)
65 ;
66 I $D(^TMP("BBD",$J,"SPECIMEN",ORI,"63.01,8")) S J=0 F S J=$O(^TMP("BBD",$J,"SPECIMEN",ORI,"63.01,8",J)) Q:'J D
67 . S X=^TMP("BBD",$J,"SPECIMEN",ORI,"63.01,8",J)
68 . D LN
69 . S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,"ANTIBODY SCREEN COMMENT: "_X,.CCNT)
70 ;
71 I $D(^TMP("BBD",$J,"SPECIMEN",ORI,"63.48,.01")) S J=0 F S J=$O(^TMP("BBD",$J,"SPECIMEN",ORI,"63.48,.01",J)) Q:'J D
72 . S X=^TMP("BBD",$J,"SPECIMEN",ORI,"63.48,.01",J)
73 . D LN
74 . S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,"ANTIBODY SCREEN COMMENT: "_X,.CCNT)
75 ;
76 I $D(^TMP("BBD",$J,"SPECIMEN",ORI,"63.199,.01")) S J=0 F S J=$O(^TMP("BBD",$J,"SPECIMEN",ORI,"63.199,.01",J)) Q:'J D
77 . S X=^TMP("BBD",$J,"SPECIMEN",ORI,"63.199,.01",J)
78 . D LN
79 . S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(8,.CCNT,X,.CCNT)
80 Q
81T ;Set Date/time format
82 S T=$$FMTE^XLFDT(T,2)
83 Q
84CX ;Crossmatch
85 N A,CNT,F,LOCAT
86 I '$O(^TMP("BBD",$J,"CROSSMATCH",0)) D Q
87 . D LN
88 . S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,"No UNITS assigned/xmatched",.CCNT)
89 . D LINE^ORU4("^TMP(""ORLRC"",$J)",GIOM)
90 D LINE^ORU4("^TMP(""ORLRC"",$J)",GIOM),LN
91 S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(6,.CCNT,"Unit assigned/xmatched:",.CCNT)_$$S^ORU4(46,.CCNT,"Exp date",.CCNT)_$$S^ORU4(64,.CCNT,"Loc",.CCNT)
92 S (CNT,A)=0 F S A=$O(^TMP("BBD",$J,"CROSSMATCH",A)) Q:'A D
93 . S F=^TMP("BBD",$J,"CROSSMATCH",A),CNT=CNT+1,LOCAT=$S($L($P(F,"^",7)):$P(F,"^",7),1:"BB-"_$P(F,"^",6))
94 . D LN
95 . S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,$J(CNT,2)_")",.CCNT)_$$S^ORU4(6,.CCNT,$P(F,"^"),.CCNT)_$$S^ORU4(17,.CCNT,$E($P(F,"^",2),1,19),.CCNT)_$$S^ORU4(38,.CCNT,$P(F,"^",3)_" "_$E($P(F,"^",4),1,3),.CCNT)
96 . S ^(0)=^TMP("ORLRC",$J,GCNT,0)_$$S^ORU4(45,.CCNT,$P(F,"^",5),.CCNT)_$$S^ORU4(64,.CCNT,LOCAT,.CCNT)
97 D LINE^ORU4("^TMP(""ORLRC"",$J)",GIOM)
98 Q
99C ;Component Request
100 N %DT,A,F,T,X,Y
101 I '$O(^TMP("BBD",$J,"COMPONENT REQUEST",0)) D Q
102 . D LN S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,"No component requests",.CCNT)
103 D LN
104 S X="Component requests"
105 S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,X,.CCNT)_$$S^ORU4(26,.CCNT,"Units",.CCNT)_$$S^ORU4(32,.CCNT,"Request date",.CCNT)_$$S^ORU4(49,.CCNT,"Date wanted",.CCNT)_$$S^ORU4(65,.CCNT,"Requestor",.CCNT)_$$S^ORU4(77,.CCNT,"By",.CCNT)
106 S A=0 F S A=$O(^TMP("BBD",$J,"COMPONENT REQUEST",A)) Q:'A D
107 . S F=^TMP("BBD",$J,"COMPONENT REQUEST",A),T="",%DT="T",X=$P(F,"^",3),Y=-1
108 . I $L(X) D ^%DT
109 . I Y'=-1 S T=Y D T
110 . D LN
111 . S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,$E($P(F,"^"),1,25),.CCNT)_$$S^ORU4(26,.CCNT,$J($P(F,"^",2),3),.CCNT)_$$S^ORU4(32,.CCNT,T,.CCNT)
112 . S T="",%DT="T",X=$P(F,"^",4),Y=-1
113 . I $L(X) D ^%DT
114 . I Y'=-1 S T=Y D T
115 . S X=$S($P(F,"^",6):$P(F,"^",6)_",",1:""),X=$S($L(X):$$GET1^DIQ(200,X,1),1:$P(F,"^",6))
116 . S ^TMP("ORLRC",$J,GCNT,0)=^TMP("ORLRC",$J,GCNT,0)_$$S^ORU4(49,.CCNT,T,.CCNT)_$$S^ORU4(65,.CCNT,$E($P(F,"^",5),1,10),.CCNT)_$$S^ORU4(77,.CCNT,X,.CCNT)
117 Q
118TRAN ;Transfusion Data
119 K ^TMP("TRAN",$J)
120 D TRAN^VBECA4(DFN,"TRAN")
121 Q:'$O(^TMP("TRAN",$J,0))
122 N ID,GMR,GMA,TD,C,BPN
123 D LINE^ORU4("^TMP(""ORLRC"",$J)",GIOM),LN
124 S X="Transfused Units ",^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,X,.CCNT),ID=0
125 D LN
126 F S ID=$O(^TMP("TRAN",$J,ID)) Q:'ID S GMR=^(ID) D
127 . D PARSE^ORWLR1,WRT
128 I $O(^TMP("TRAN",$J,"A"))'="" D
129 . D LN
130 . S X=" Blood Product Key: ",^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,X,.CCNT)
131 S GMI="A",C=0
132 F S GMI=$O(^TMP("TRAN",$J,GMI)) Q:GMI="" D
133 . S X=GMI_" = "_$G(^TMP("TRAN",$J,GMI))
134 . I C>0 D LN
135 . S C=C+1,^TMP("ORLRC",$J,GCNT,0)=$G(^TMP("ORLRC",$J,GCNT,0))_$$S^ORU4(21,.CCNT,X,.CCNT)
136 K ^TMP("TRAN",$J)
137 Q
138WRT ; Sets the Transfusion Record for each day
139 N GML,GMI1,GMI2,GMM,GMJ,CL
140 S GMM=$S(BPN#4:1,1:0),GML=BPN\4+GMM
141 D LN
142 S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,TD,.CCNT)
143 F GMI1=1:1:GML D
144 . F GMI2=1:1:($S((GMI1=GML)&(BPN#4):BPN#4,1:4)) D
145 .. S GMJ=((GMI1-1)*4)+GMI2,CL=(((GMI2-1)*15)+14)
146 .. S ^TMP("ORLRC",$J,GCNT,0)=$G(^TMP("ORLRC",$J,GCNT,0))_$$S^ORU4(CL,.CCNT,GMA(GMJ),.CCNT)
147 .. I $S(GMI2#4=0:1,GMI2=BPN:1,GMI2+(4*(GMI1-1))=BPN:1,1:0) D LN
148 Q
149H ;Header
150 N X
151 D LN
152 S X=GIOM/2-(10/2+5),^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(X,.CCNT,"---- BLOOD BANK ----",.CCNT)
153 D LN
154 S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(1,.CCNT,"ABO Rh: "_ORABORH,.CCNT)
155 Q
156AHG ;AHG Data
157 D LINE^ORU4("^TMP(""ORLRC"",$J)",GIOM),LN
158 S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(30,.CCNT,"|---",.CCNT)_$$S^ORU4(39,.CCNT,"AHG(direct)",.CCNT)_$$S^ORU4(55,.CCNT,"---|",.CCNT)_$$S^ORU4(62,.CCNT,"|-AHG(indirect)-|",.CCNT)
159 D LN
160 S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(4,.CCNT,"Date/time",.CCNT)_$$S^ORU4(20,.CCNT,"ABO",.CCNT)_$$S^ORU4(24,.CCNT,"Rh",.CCNT)_$$S^ORU4(30,.CCNT,"POLY",.CCNT)_$$S^ORU4(35,.CCNT,"IgG",.CCNT)_$$S^ORU4(40,.CCNT,"C3",.CCNT)
161 S ^(0)=^TMP("ORLRC",$J,GCNT,0)_$$S^ORU4(45,.CCNT,"Interpretation",.CCNT)_$$S^ORU4(62,.CCNT,"(Antibody screen)",.CCNT)
162 D LN
163 S ^TMP("ORLRC",$J,GCNT,0)=$$S^ORU4(4,.CCNT,"---------",.CCNT)_$$S^ORU4(20,.CCNT,"---",.CCNT)_$$S^ORU4(24,.CCNT,"--",.CCNT)_$$S^ORU4(30,.CCNT,"----",.CCNT)_$$S^ORU4(35,.CCNT,"---",.CCNT)
164 S ^(0)=^TMP("ORLRC",$J,GCNT,0)_$$S^ORU4(40,.CCNT,"---",.CCNT)_$$S^ORU4(45,.CCNT,"--------------",.CCNT)_$$S^ORU4(62,.CCNT,"-----------------",.CCNT)
165 Q
166LN ;Increment counts
167 S GCNT=GCNT+1,CCNT=1
168 Q
Note: See TracBrowser for help on using the repository browser.