source: FOIAVistA/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORHL11.m@ 1582

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

initial load of FOIAVistA 6/30/08 version

File size: 5.3 KB
Line 
1RORHL11 ;HOIFO/BH,SG - HL7 CYTOPATHOLOGY DATA: OBR,OBX ; 3/13/06 9:24am
2 ;;1.5;CLINICAL CASE REGISTRIES;**1**;Feb 17, 2006;Build 24
3 ;
4 ; This routine uses the following IAs:
5 ;
6 ; #4344 $$CYPATH^LA7UTL02 (controlled)
7 ;
8 Q
9 ;
10 ;***** SEARCHES BY SPECIMEN COLLECTION DATE
11CD() ;
12 N ENDT,ERRCNT,IDT,STDT
13 S ERRCNT=0
14 S STDT=9999999-RORSTDT
15 S ENDT=9999999-RORENDT
16 S IDT=$O(^LR(LRDFN,"CY",STDT))
17 F S IDT=$O(^LR(LRDFN,"CY",IDT),-1) Q:'IDT!(IDT'>ENDT) D
18 . S:$$OBROBX(IDT) ERRCNT=ERRCNT+1
19 Q ERRCNT
20 ;
21 ;***** SEARCHES FOR CYTOPATHOLOGY DATA
22 ;
23 ; RORDFN IEN of the patient in the PATIENT file (#2)
24 ;
25 ; .DXDTS Reference to a local variable where the
26 ; data extraction time frames are stored.
27 ;
28 ; [CDSMODE] Search the data by:
29 ; 0 completion/result date (default)
30 ; 1 specimen collection date
31 ;
32 ; Return Values:
33 ; <0 Error code
34 ; 0 Ok
35 ; >0 Non-fatal error(s)
36 ;
37EN1(RORDFN,DXDTS,CDSMODE,RORPTR,RORFILE,HLFS,HLECH) ;
38 N ERRCNT,IDX,LRDFN,RC,RORENDT,RORIEN,RORSTDT
39 S (ERRCNT,RC)=0
40 ;
41 S LRDFN=+$$LABREF^RORUTL18(RORDFN) Q:LRDFN'>0 0
42 ;
43 S IDX=0
44 F S IDX=$O(DXDTS(10,IDX)) Q:IDX'>0 D Q:RC<0
45 . S RORSTDT=$P(DXDTS(10,IDX),U),RORENDT=$P(DXDTS(10,IDX),U,2)
46 . ;---
47 . S RC=$S($G(CDSMODE):$$CD(),1:$$RAD())
48 . S:RC>0 ERRCNT=ERRCNT+RC
49 ;
50 Q $S(RC<0:RC,1:ERRCNT)
51 ;
52 ;*****
53ICD(RPS) ;
54 Q:$D(@RORTMP@("ICD9"))<10
55 N CNT,ICDLST,INDEX,RORICD,TMP
56 S ICDID=$$SEGID("ICD9","ICD9",CS)
57 S (INDEX,RORICD)="",CNT=0
58 F S INDEX=$O(@RORTMP@("ICD9",INDEX)) Q:INDEX="" D
59 . S TMP=$G(@RORTMP@("ICD9",INDEX))
60 . S:TMP'="" CNT=CNT+1,$P(RORICD,RPS,CNT)=TMP
61 D:RORICD'="" SETOBX(ICDID,RORICD)
62 Q
63 ;
64 ;***** CREATES OBR AND OBX SEGMENTS
65OBROBX(RORIDT) ;
66 N ERRCNT,RC,RORMSG,RORTMP,TMP
67 S (ERRCNT,RC)=0
68 S RORTMP=$$ALLOC^RORTMP()
69 ;---
70 I $$CYPATH^LA7UTL02(LRDFN,RORIDT,RORTMP,"RORMSG") D
71 . S RC=$$OBR(RORTMP,RORIDT)
72 . I RC S ERRCNT=ERRCNT+1 Q:RC<0
73 . ;---
74 . S RC=$$OBX(RORTMP)
75 . I RC S ERRCNT=ERRCNT+1 Q:RC<0
76 E D:$D(RORMSG)>1
77 . N I,INFO S TMP=""
78 . F I=1:1 S TMP=$O(RORMSG(TMP)) Q:TMP="" S INFO(I)=RORMSG(TMP)
79 . S RC=$$ERROR^RORERR(-56,,.INFO,,0,"$$CYPATH^LA7UTL02")
80 ;---
81 D FREE^RORTMP(RORTMP)
82 Q $S(RC<0:RC,1:ERRCNT)
83 ;
84 ;***** CYTOPATHOLOGY OBR SEGMENT BUILDER
85 ;
86 ; RORTMP Closed root of the array holding lab data
87 ; RORIEN IEN of Cyto Visit
88 ;
89 ; Return Values:
90 ; <0 Error code
91 ; 0 Ok
92 ; >0 Non-fatal error(s)
93 ;
94OBR(RORTMP,RORIEN) ;
95 N CS,CPA,ERRCNT,RC,RORSEG,TMP
96 S (ERRCNT,RC)=0
97 D ECH^RORHL7(.CS)
98 ;
99 ;--- Initialize the segment
100 S RORSEG(0)="OBR"
101 ;
102 ;--- OBR-3 - Cyto Path Acc #
103 S CPA=$P($G(@RORTMP@("DEMO",RORIEN)),U,2) Q:CPA="" 0
104 S RORSEG(3)=CPA
105 ;
106 ;--- OBR-4
107 S RORSEG(4)="88108"_CS_"CYTOPATHOLOGY, CONCENT"_CS_"C4"
108 ;
109 ;--- OBR-7 - Date/Time Specimen Taken
110 S TMP=$$FMTHL7^XLFDT($P(@RORTMP@("DEMO",RORIEN),U))
111 I TMP'>0 D Q RC
112 . S RC=$$ERROR^RORERR(-100,,,,"No specimen date","$$CYPATH^LA7UTL02")
113 S RORSEG(7)=TMP
114 ;
115 ;--- OBR-24 - Service Section ID
116 S RORSEG(24)="CP"
117 ;
118 ;--- OBR-44 - Divsion
119 S RORSEG(44)=$$SITE^RORUTL03(CS)
120 ;
121 ;--- Store the segment
122 D ADDSEG^RORHL7(.RORSEG)
123 Q ERRCNT
124 ;
125 ;***** CYTOPATHOLOGY OBX SEGMENT BUILDER
126 ;
127 ; RORTMP Closed root of the array holding lab data
128 ;
129 ; Return Values:
130 ; <0 Error code
131 ; 0 Ok
132 ; >0 Non-fatal error(s)
133 ;
134OBX(RORTMP) ;
135 N CS,ERRCNT,RC,RPS,TMP
136 S (ERRCNT,RC)=0
137 D ECH^RORHL7(.CS,,.RPS)
138 ;
139 D:$D(@RORTMP@("SPEC")) SPECIMEN
140 D SETOBXWP($$SEGID("BCH","Brief clinical History",CS),"CHIS")
141 D SETOBXWP($$SEGID("PDIAG","Preoperative Diagnosis",CS),"PREDX")
142 D SETOBXWP($$SEGID("OF","Operative Findings",CS),"OPERDX")
143 D SETOBXWP($$SEGID("POPDIAG","Postoperative Diagnosis",CS),"POSTDX")
144 D SETOBXWP($$SEGID("MICRO","Microscopic Examination",CS),"MICRO")
145 D SETOBXWP($$SEGID("CDIAG","Cytopathology Diagnosis",CS),"CYTODX")
146 D ICD(RPS)
147 ;
148 Q $S(RC<0:RC,1:ERRCNT)
149 ;
150 ;***** SEARCHES BY COMPLETION (RESULT) DATE
151RAD() ;
152 N ERRCNT,IDT,RCDT
153 S (ERRCNT,IDT)=0
154 F S IDT=$O(^LR(LRDFN,"CY",IDT)) Q:'IDT D
155 . S RCDT=$P($G(^LR(LRDFN,"CY",IDT,0)),U,3)
156 . I RCDT'<RORSTDT,RCDT<RORENDT S:$$OBROBX(IDT) ERRCNT=ERRCNT+1
157 Q ERRCNT
158 ;
159 ;***** CONSTRUCTS SEGMENT IDENTIFIER
160SEGID(PONE,PTWO,CS) ; Create segment identifier
161 Q PONE_CS_PTWO_CS_"VA080"
162 ;
163 ;***** CREATE AND STORE THE OBX SEGMENTS
164SETOBX(OBX3,OBX5) ;
165 N RORSEG
166 ;--- Initialize the segment
167 S RORSEG(0)="OBX"
168 ;--- OBX-2
169 S RORSEG(2)="FT"
170 ;--- OBX-3
171 S RORSEG(3)=OBX3
172 ;--- OBX-5
173 S RORSEG(5)=$$ESCAPE^RORHL7(OBX5)
174 ;--- OBX-11
175 S RORSEG(11)="F"
176 ;--- Store the segment
177 D ADDSEG^RORHL7(.RORSEG)
178 Q
179 ;
180SETOBXWP(OBX3,SUBS) ;
181 N BR,CNT,I,I1,RORSEG,TMP
182 S BR=$E(HLECH,3)_".br"_$E(HLECH,3)
183 Q:$D(@RORTMP@(SUBS))<10
184 ;--- Initialize the segment
185 S RORSEG(0)="OBX"
186 ;--- OBX-2 - Value Type
187 S RORSEG(2)="FT"
188 ;--- OBX-3 - Observation Identifier
189 S RORSEG(3)=OBX3
190 ;--- OBX-5 - Observation Value
191 S I=$O(@RORTMP@(SUBS,"")),CNT=0
192 F Q:I="" S I1=$O(@RORTMP@(SUBS,I)) D S I=I1
193 . S TMP=$$ESCAPE^RORHL7(@RORTMP@(SUBS,I))
194 . S CNT=CNT+1,RORSEG(5,CNT)=$S(I1'="":TMP_BR,1:TMP)
195 ;--- OBX-11 - Observation Result Status
196 S RORSEG(11)="F"
197 ;--- Store the segment
198 D:$D(RORSEG(5)) ADDSEG^RORHL7(.RORSEG)
199 Q
200 ;
201 ;***** MAKES SPECIMEN OBX
202SPECIMEN ;
203 N INDEX,RORSPEC,SPECID
204 S SPECID=$$SEGID("SPEC","Specimen",CS)
205 S INDEX=""
206 F S INDEX=$O(@RORTMP@("SPEC",INDEX)) Q:INDEX="" D
207 . S RORSPEC=$G(@RORTMP@("SPEC",INDEX))
208 . D:RORSPEC'="" SETOBX(SPECID,RORSPEC)
209 Q
Note: See TracBrowser for help on using the repository browser.