source: ccr/branches/ohum/p/C0CTIU.m@ 1469

Last change on this file since 1469 was 1433, checked in by Sam Habiel, 13 years ago

Update based on OHUM's latest routines

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