source: ccr/trunk/p/C0CTIU.m@ 1652

Last change on this file since 1652 was 1586, checked in by Sam Habiel, 12 years ago

Changed license to AGPL. Some clean-up for XINDEX

File size: 9.3 KB
RevLine 
[1544]1C0CTIU ; C0C/ELN - PROCESSING FOR TIU NOTES ; 19/10/2010
[1586]2 ;;1.2;CCD/CCR GENERATION UTILITIES;;Oct 30, 2012;Build 50
3 ; (C) ELN 2010
[1544]4 ;
[1586]5 ; This program is free software: you can redistribute it and/or modify
6 ; it under the terms of the GNU Affero General Public License as
7 ; published by the Free Software Foundation, either version 3 of the
8 ; License, or (at your option) any later version.
[1544]9 ;
[1586]10 ; This program is distributed in the hope that it will be useful,
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ; GNU Affero General Public License for more details.
14 ;
15 ; You should have received a copy of the GNU Affero General Public License
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
17 ;
[1544]18 ;ELN - Modified Routine of C0CLABS
19MAP(MIXML,DFN,MOXML) ;TO MAKE THIS COMPATIBLE WITH OLD CALLING FOR EXTRACT
20 ; ASSUMES THAT EXTRACT HAS BEEN RUN AND THE VARIABLES STORED IN MIVAR
21 ; MIXML,MIVAR, AND MOXML ARE PASSED BY NAME
22 ; MIXML IS THE TEMPLATE TO USE
23 ; MOXML IS THE OUTPUT XML ARRAY
24 ; DFN IS THE PATIENT RECORD NUMBER
25 N C0COXML,C0CO,C0CV,C0CIXML
26 I '$D(MIVAR) S C0CV="" ;DEFAULT
27 E S C0CV=MIVAR ;PASSED VARIABLE ARRAY
28 I '$D(MIXML) S C0CIXML="" ;DEFAULT
29 E S C0CIXML=MIXML ;PASSED INPUT XML
30 D RPCMAP(.C0COXML,DFN,C0CV,C0CIXML) ; CALL RPC TO DO THE WORK
31 I '$D(MOXML) D Q
32 . S C0CO=$NA(^TMP("C0CCCR",$J,DFN,"RESULTS")) ;DEFAULT FOR OUTPUT
33 . M @C0CO=C0COXML ; COPY RESULTS TO OUTPUT
34 E D
35 . N C0COOXML
36 . S CCRGLO=$NA(^TMP("C0CCCR",$J,DFN,"CCR"))
37 . D QUERY^C0CXPATH(CCRGLO,"//ContinuityOfCareRecord/Body/Results","C0CRSXML")
38 . S C0COCNT=$O(C0CRSXML(""),-1)
39 . S C0CRES=0
40 . F S C0CRES=$O(C0COXML(C0CRES)) Q:C0CRES="" D
41 . . Q:$G(C0COXML(C0CRES))="<Results>"!($G(C0COXML(C0CRES))="</Results>")
42 . . S C0CRSXML(C0COCNT)=$G(C0COXML(C0CRES))
43 . . S C0COCNT=C0COCNT+1
44 . S C0CRSXML(C0COCNT)="</Results>"
45 . S C0CRSXML(0)=C0COCNT
46 . D REPLACE^C0CXPATH(CCRGLO,"","//ContinuityOfCareRecord/Body")
47 . D INSERT^C0CXPATH(CCRGLO,"C0CRSXML","//ContinuityOfCareRecord/Body")
48 ;
49 S C0CO=MOXML,@C0CO@(0)=0
50 K C0CRSXML,C0COCNT,C0COXML,C0CRES
51 K C0CCNT
52 Q
53RPCMAP(RTN,DFN,RMIVAR,RMIXML) ; RPC ENTRY POINT FOR MAPPING RESULTS
54 ; RTN IS PASSED BY REFERENCE
55 N C0CT0,C0CT,C0CV ; CCR TEMPLATE, RESULTS SUBTEMPLATE, VARIABLES
56 N C0CRT,C0CTT ; TEST REQUEST TEMPLATE, TEST RESULT TEMPLATE
57 I '$D(DEBUG) S DEBUG=0 ; DEFAULT NO DEBUGGING
58 I RMIXML="" D ; INPUT XML NOT PASSED
59 . D LOAD^C0CCCR0("C0CT0") ; LOAD ENTIRE CCR TEMPLATE
60 . D QUERY^C0CXPATH("C0CT0","//ContinuityOfCareRecord/Body/Results","C0CT0R")
61 . S C0CT="C0CT0R" ; NAME OF EXTRACTED RESULTS TEMPLATE
62 E S C0CT=RMIXML ; WE ARE PASSED THE RESULTS PART OF THE TEMPLATE
63 I RMIVAR="" D ; LOCATION OF VARIABLES NOT PASSED
64 . S C0CV=$NA(^TMP("C0CCCR",$J,"RESULTS")) ;DEFAULT VARIABLE LOCATION
65 E S C0CV=RMIVAR ; PASSED LOCATIONS OF VARS
66 D CP^C0CXPATH(C0CT,"C0CRT") ; START MAKING TEST REQUEST TEMPLATE
67 D REPLACE^C0CXPATH("C0CRT","","//Results/Result/Test") ; DELETE TEST FROM REQ
68 D QUERY^C0CXPATH(C0CT,"//Results/Result/Test","C0CTT") ; MAKE TEST TEMPLATE
69 D EXTRACT("C0CT",DFN,) ; FIRST CALL EXTRACT
70 I '$D(@C0CV@(0)) D Q ; NO VARS THERE
71 . S RTN(0)=0 ; PASS BACK NO RESULTS INDICATOR
72 ; NO RESULTS QUIT
73 I @C0CV@(0)=0 S RTN(0)=0 Q
74 S RIMVARS=$NA(^TMP("C0CRIM","VARS",DFN,"RESULTS"))
75 K @RIMVARS
76 M @RIMVARS=@C0CV ; UPDATE RIMVARS SO THEY STAY IN SYNCH
77 N C0CI,C0CIN,C0CJ,C0CJS,C0CJE,C0CJN,C0CMAP,C0CTMAP,C0CTMP
78 S C0CIN=@C0CV@(0) ; COUNT OF RESULTS (OBR)
79 N C0CRTMP ; AREA TO BUILD ONE RESULT REQUEST AND ALL TESTS FOR IT
80 N C0CRBASE S C0CRBASE=$NA(^TMP($J,"TESTTMP")) ;WORK AREA
81 N C0CRBLD ; BUILD LIST FOR XML - THE BUILD IS DELAYED UNTIL THE END
82 ; TO IMPROVE PERFORMANCE
83 D QUEUE^C0CXPATH("C0CRBLD","C0CRT",1,1) ;<Results>
84 F C0CI=1:1:C0CIN D ; LOOP THROUGH VARIABLES
85 . K C0CMAP,C0CTMP ;EMPTY OUT LAST BATCH OF VARIABLES
86 . S C0CRTMP=$NA(@C0CRBASE@(C0CI)) ;PARTITION OF WORK AREA FOR EACH TEST
87 . S C0CMAP=$NA(@C0CV@(C0CI)) ;
88 . ;MAPPING FOR TEST REQUEST GOES HERE
89 . D MAP^C0CXPATH("C0CRT",C0CMAP,C0CRTMP) ; MAP OBR DATA
90 . ;D QOPEN^C0CXPATH("C0CRBLD",C0CRTMP,C0CIS) ;1ST PART OF XML
91 . D QUEUE^C0CXPATH("C0CRBLD",C0CRTMP,2,@C0CRTMP@(0)-4) ;UP TO <Test>
92 . I $D(@C0CMAP@("M","TEST",0)) D ; TESTS EXIST
93 . . S C0CJN=@C0CMAP@("M","TEST",0) ; NUMBER OF TESTS
94 . . K C0CTO ; CLEAR OUTPUT VARIABLE
95 . . F C0CJ=1:1:C0CJN D ;FOR EACH TEST RESULT
96 . . . K C0CTMAP ; EMPTY MAPS FOR TEST RESULTS
97 . . . S C0CTMP=$NA(@C0CRBASE@(C0CI,C0CJ)) ;WORK AREA FOR TEST RESULTS
98 . . . S C0CTMAP=$NA(@C0CMAP@("M","TEST",C0CJ)) ;
99 . . . D XMAP^C0CTIU1("C0CTT",C0CTMAP,C0CTMP) ; MAP TO TMP
100 . . . I C0CJ=1 S C0CJS=2 E S C0CJS=1 ;FIRST TIME,SKIP THE <Test>
101 . . . I C0CJ=C0CJN S C0CJE=@C0CTMP@(0)-1 E S C0CJE=@C0CTMP@(0) ;</Test>
102 . . . S C0CJS=1 S C0CJE=@C0CTMP@(0) ; INSERT ALL OF THE TEXT XML
103 . . . D QUEUE^C0CXPATH("C0CRBLD",C0CTMP,C0CJS,C0CJE) ; ADD TO BUILD LIST
104 . D QUEUE^C0CXPATH("C0CRBLD","C0CRT",C0CRT(0)-1,C0CRT(0)-1) ;</Result>
105 D QUEUE^C0CXPATH("C0CRBLD","C0CRT",C0CRT(0),C0CRT(0)) ;</Results>
106 D BUILD^C0CTIU1("C0CRBLD","RTN") ;RENDER THE XML
107 K @C0CRBASE ; CLEAR OUT TEMPORARY STURCTURE
108 Q
109 ;
110 ;
111EXTRACT(ILXML,DFN,OLXML) ; EXTRACT TIU NOTES INTO THE C0CLVAR GLOBAL
112 ;
113 S C0CLB=$NA(^TMP("C0CCCR",$J,"RESULTS")) ; BASE GLB FOR LABS VARS
114 D DT^DILF(,$$GET^C0CPARMS("TIULIMIT"),.C0CTSDT)
115 D DT^DILF(,$$GET^C0CPARMS("TIUSTART"),.C0CTEDT) ; END DATE TODAY - IMPLEMENT END DATE PARM
116 ;
117 S TIUIEN=0,TIUCNT=1
118 F S TIUIEN=$O(^TIU(8925,"C",DFN,TIUIEN)) Q:TIUIEN="" D
119 . S TIUY="",TIUDA=TIUIEN,ACTION="VIEW",U="^"
120 . ;SELECT ONLY COMPLETED NOTES
121 . Q:$P(^TIU(8925,TIUIEN,0),U,5)=""
122 . Q:$P(^TIU(8925.6,$P(^TIU(8925,TIUIEN,0),U,5),0),U)'="COMPLETED"
123 . ;VALIDATE ON SIGNATURE DATE #1501
124 . Q:$P(^TIU(8925,TIUIEN,15),U)<C0CTSDT!($P(^TIU(8925,TIUIEN,15),U)>C0CTEDT)
125 . D TGET(TIUY,TIUIEN,ACTION,TIUCNT)
126 . S TIUCNT=TIUCNT+1
127 ;ELN K @C0CLB ; CLEAR OUT OLD VARS IF ANY
128 N QTSAV S QTSAV=$G(C0CQT) ;SAVE QUIET FLAG
129 S C0CQT=1 ; SURPRESS LISTING
130 D LIST ; EXTRACT THE VARIABLES
131 K ^TMP("C0CTIU",$J),TIUIEN,TIUCNT,TIUDA,TIUY,C0CLB,C0CTSDT,C0CTEDT
132 S C0CQT=QTSAV ; RESET SILENT FLAG
133 I $D(OLXML) S @OLXML@(0)=0 ; EXTRACT DOES NOT PRODUCE XML... SEE MAP^C0CLABS
134 Q
135 ;REUSING from ^TIUSRVR2
136TGET(TIUY,TIUDA,ACTION,TIUCNT) ; Build ^TMP("TIUVIEW",$J,
137 N TIUL,TIUREC,TIUARR,TIUGDATA,TIUNAME,TIUPRM0,TIUPRM1,X,Y,TIUCPF,ONBROWSE
138 K ^TMP("TIUVIEW",$J),^TMP("TIU FOCUS",$J)
139 S C0CTIU=$NA(^TMP("C0CTIU",$J,TIUCNT))
140 S ACTION=$G(ACTION,"VIEW"),TIUL=0
141 D SETPARM^TIULE
142 S TIUGDATA=$$SETGDATA^TIUSRVR1(TIUDA)
143 S TIUY=$NA(^TMP("TIUVIEW",$J))
144 S TIUARR="^TMP(""TIUVIEW"",$J)"
145 I '$D(^TIU(8925,+TIUDA,0)) Q
146 ; Initialize ^TMP("TIU FOCUS",$J) to the entry that has focus
147 S ^TMP("TIU FOCUS",$J)=TIUDA
148 ; Call INQUIRE to get record
149 ;Set a flag to indicate whether or not a Title is a memer of the
150 ;Clinical Procedures Class (1=Yes and 0=No)
151 S TIUCPF=+$$ISA^TIULX(+$G(^TIU(8925,TIUDA,0)),+$$CLASS^TIUCP)
152 ; Call INQUIRE to get record
153 D INQUIRE^TIUSRVR2(TIUDA,.TIUREC,TIUCPF)
154 ; First, load dictation, transcription data, etc.
155 ;D LOADTOP^TIUSRVR1(.TIUREC,TIUDA,.TIUL,TIUGDATA,TIUCPF)
156 ; Next, load the remainder of the record
157 D LOADREC^TIUSRVR2(TIUDA,.TIUL,TIUGDATA,0,ACTION)
158 K ^TMP("TIU FOCUS",$J)
159 ;S VALMCNT=+$G(TIUL)
160 M @C0CTIU@("TIUREC")=TIUREC(8925,TIUDA)
161 M @C0CTIU@("TIUTEXT")=@TIUY
162 K ^TMP("TIUVEW",$J)
163 Q
164LIST ;EXTRACT THE RESULT VARIABLES TO C0CLB
165 ;
166 ;N C0CI,C0CJ,C0COBT,C0CHB,C0CVAR
167 I '$D(C0CLB) S C0CLB=$NA(^TMP("C0CCCR",$J,"RESULTS")) ; BASE GLB FOR LABS VARS
168 I '$D(C0CQT) S C0CQT=0
169 I '$D(DFN) S DFN=1 ; DEFAULT TEST PATIENT
170 S C0CI=""
171 S @C0CLB@(0)=$O(^TMP("C0CCCR",$J,"RESULTS",""),-1) ; INITALIZE RESULTS VARS COUNT
172 S C0CCNT=0,C0CTIU=$NA(^TMP("C0CTIU",$J))
173 F S C0CCNT=$O(@C0CTIU@(C0CCNT)) Q:C0CCNT="" D
174 . D C0CRES,C0CTRES
175 K C0CCNT,C0CTIU,C0CI,C0CLI,C0CX1
176 Q
177C0CRES ;SET TITLE NAME PART EQUIVALENT TO TEST NAME PART
178 N XV
179 S @C0CLB@(0)=@C0CLB@(0)+1 ; INCREMENT COUNT
180 S C0CLI=@C0CLB@(0) ; INDEX FOR THIS RESULT
181 S XV("RESULTOBJECTID")="RESULT_"_C0CLI
182 S C0CX1=$G(@C0CTIU@(C0CCNT,"TIUREC",1502))
183 S XV("RESULTSOURCEACTORID")="ACTORPROVIDER_"_$O(^VA(200,"B",$G(C0CX1),0))
184 S XV("RESULTASSESSMENTDATETIME")=$$FMDTOUTC^C0CUTIL($$C0CDATE^C0CTIU1($G(@C0CTIU@(C0CCNT,"TIUREC",1501))),"DT")
185 S XV("RESULTCODE")=""
186 S XV("RESULTCODINGSYSTEM")=""
187 S XV("RESULTSTATUS")="COMPLETED"
188 S XV("RESULTDESCRIPTIONTEXT")="Progress Notes"
189 M @C0CLB@(C0CLI)=XV ; PERSIST THE OBR VARS
190 Q
191C0CTRES ;SET REPORT TEXT PART EQUIVALENT TO RESULT
192 N XV,C0CLOBX,C0CZG,C0CLB2
193 S C0CLOBX=0
194 S XV("RESULTTESTCODEVALUE")=$G(@C0CTIU@(C0CCNT,"TIUREC",.01))
195 S XV("RESULTTESTCODINGSYSTEM")=""
196 S XV("RESULTTESTDESCRIPTIONTEXT")=$G(@C0CTIU@(C0CCNT,"TIUREC",.01)) ; DESCRIPTION TEXT
197 S C0CZG=""
198 S XV("RESULTTESTVALUE")="Notes"
199 M XV("RESULTTESTVALUE","WP")=@C0CTIU@(C0CCNT,"TIUTEXT")
200 S C0CLB2=$NA(@C0CLB@(C0CLI,"M","TEST")) ; INDENT FOR TEST RESULTS
201 S C0CLOBX=C0CLOBX+1 ; INCREMENT TEST COUNT
202 S @C0CLB2@(0)=C0CLOBX ; STORE THE TEST COUNT
203 S XV("RESULTTESTOBJECTID")="RESULTTEST_"_C0CLI_"_"_C0CLOBX
204 S XV("RESULTTESTSOURCEACTORID")="ACTORORGANIZATION_"_$O(^VA(200,$O(^VA(200,"B",$G(C0CX1),0)),2,0))
205 S XV("RESULTTESTNORMALSOURCEACTORID")=XV("RESULTTESTSOURCEACTORID")
206 S XV("RESULTTESTDATETIME")=$$FMDTOUTC^C0CUTIL($$C0CDATE^C0CTIU1($G(@C0CTIU@(C0CCNT,"TIUREC",1501))),"DT")
207 S XV("RESULTTESTUNITS")=""
208 S XV("RESULTTESTFLAG")=""
209 S XV("RESULTTESTSTATUSTEXT")=""
210 S XV("RESULTTESTNORMALDESCTEXT")=""
211 M @C0CLB2@(C0CLOBX)=XV ; PERSIST THE TEST RESULT VARIABLES
212 Q
Note: See TracBrowser for help on using the repository browser.