source: ccr/trunk/p/C0CPROBS.m@ 728

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

support for incoming CCDs

File size: 7.7 KB
Line 
1C0CPROBS ; CCDCCR/GPL/CJE - CCR/CCD PROCESSING FOR PROBLEMS ; 6/6/08
2 ;;1.0;C0C;;May 19, 2009;
3 ;Copyright 2008,2009 George Lilly, University of Minnesota.
4 ;Licensed under the terms of the GNU General Public License.
5 ;See attached copy of the License.
6 ;
7 ;This program is free software; you can redistribute it and/or modify
8 ;it under the terms of the GNU General Public License as published by
9 ;the Free Software Foundation; either version 2 of the License, or
10 ;(at your option) any later version.
11 ;
12 ;This program is distributed in the hope that it will be useful,
13 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;GNU General Public License for more details.
16 ;
17 ;You should have received a copy of the GNU General Public License along
18 ;with this program; if not, write to the Free Software Foundation, Inc.,
19 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 ;
21 ;
22 ; PROCESS THE PROBLEMS SECTION OF THE CCR
23 ;
24EXTRACT(IPXML,DFN,OUTXML) ; EXTRACT PROBLEMS INTO PROVIDED XML TEMPLATE
25 ;
26 ; INXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
27 ; INXML WILL CONTAIN ONLY THE PROBLEM SECTION OF THE OVERALL TEMPLATE
28 ; ONLY THE XML FOR ONE PROBLEM WILL BE PASSED. THIS ROUTINE WILL MAKE
29 ; COPIES AS NECESSARY TO REPRESENT MULTIPLE PROBLEMS
30 ; INSERT^C0CXPATH IS USED TO APPEND THE PROBLEMS TO THE OUTPUT
31 ;
32 N RPCRSLT,J,K,PTMP,X,VMAP,TBU
33 S TVMAP=$NA(^TMP("C0CCCR",$J,"PROBVALS"))
34 S TARYTMP=$NA(^TMP("C0CCCR",$J,"PROBARYTMP"))
35 K @TVMAP,@TARYTMP ; KILL OLD ARRAY VALUES
36 I $$RPMS^C0CUTIL() D RPMS ; IF BGOPRB ROUTINE IS MISSING (IE RPMS)
37 I ($$VISTA^C0CUTIL())!($$WV^C0CUTIL())!($$OV^C0CUTIL()) D VISTA QUIT
38 Q
39 ;
40RPMS ; GETS THE PROBLEM LIST FOR RPMS
41 S RPCGLO=$NA(^TMP("BGO",$J))
42 D GET^BGOPROB(.RPCRSLT,DFN) ; CALL THE PROBLEM LIST RPC
43 ; FORMAT OF RPC:
44 ; Number Code [1] ^ Patient IEN [2] ^ ICD Code [3] ^ Modify Date [4] ^ Class [5] ^ Provider Narrative [6] ^
45 ; Date Entered [7] ^ Status [8] ^ Date Onset [9] ^ Problem IEN [10] ^ Notes [11] ^ ICD9 IEN [12] ^
46 ; ICD9 Short Name [13] ^ Provider [14] ^ Facility IEN [15] ^ Priority [16]
47 I '$D(@RPCGLO) W "NULL RESULT FROM GET^BGOPROB ",! S @OUTXML@(0)=0 Q
48 S J=""
49 F S J=$O(@RPCGLO@(J)) Q:J="" D ; FOR EACH PROBLEM IN THE LIST
50 . S VMAP=$NA(@TVMAP@(J))
51 . K @VMAP
52 . I DEBUG W "VMAP= ",VMAP,!
53 . S PTMP=@RPCRSLT@(J) ; PULL OUT PROBLEM FROM RPC RETURN ARRAY
54 . N C0CG1,C0CT ; ARRAY FOR VALUES FROM GLOBAL
55 . D GETN1^C0CRNF("C0CG1",9000011,$P(PTMP,U,10),"") ;GET VALUES BY NAME
56 . S @VMAP@("PROBLEMOBJECTID")="PROBLEM"_J ; UNIQUE OBJID FOR PROBLEM
57 . S @VMAP@("PROBLEMIEN")=$P(PTMP,U,10)
58 . S @VMAP@("PROBLEMSTATUS")=$S($P(PTMP,U,8)="A":"Active",$P(PTMP,U,8)="I":"Inactive",1:"")
59 . S @VMAP@("PROBLEMDESCRIPTION")=$P(PTMP,U,6)
60 . S @VMAP@("PROBLEMCODINGVERSION")=""
61 . S @VMAP@("PROBLEMCODEVALUE")=$P(PTMP,U,3)
62 . S @VMAP@("PROBLEMDATEOFONSET")=$$FMDTOUTC^C0CUTIL($$ZVALUEI^C0CRNF("DATE OF ONSET","C0CG1"),"DT")
63 . S @VMAP@("PROBLEMDATEMOD")=$$FMDTOUTC^C0CUTIL($$ZVALUEI^C0CRNF("DATE LAST MODIFIED","C0CG1"),"DT")
64 . ;S @VMAP@("PROBLEMSC")=$P(PTMP,U,7) ;UNKNOWN NOT MAPPED IN C0CCCR0
65 . ;S @VMAP@("PROBLEMSE")=$P(PTMP,U,8) ;UNKNOWN NOT MAPPED IN C0CCCR0
66 . ;S @VMAP@("PROBLEMCONDITION")=$P(PTMP,U,9) ;NOT MAPPED IN C0CCCR0
67 . ;S @VMAP@("PROBLEMLOC")=$P(PTMP,U,10) ;NOT MAPPED IN C0CCCR0
68 . ;S @VMAP@("PROBLEMLOCTYPE")=$P(PTMP,U,11) ;NOT MAPPED IN C0CCCR0
69 . ;S @VMAP@("PROBLEMPROVIDER")=$P(PTMP,U,12) ;NOT MAPPED IN C0CCCR0
70 . ;S X=@VMAP@("PROBLEMPROVIDER") ; FORMAT Y;NAME Y IS IEN OF PROVIDER
71 . S @VMAP@("PROBLEMSOURCEACTORID")="ACTORPROVIDER_"_$$ZVALUEI^C0CRNF("RECORDING PROVIDER","C0CG1")
72 . ;S @VMAP@("PROBLEMSERVICE")=$P(PTMP,U,13) ;NOT MAPPED IN C0CCCR0
73 . ;S @VMAP@("PROBLEMHASCMT")=$P(PTMP,U,14) ;NOT MAPPED IN C0CCCR0
74 . ;S @VMAP@("PROBLEMDTREC")=$$FMDTOUTC^C0CUTIL($P(PTMP,U,15),"DT") ;NOT MAPPED IN C0CCCR0
75 . ;S @VMAP@("PROBLEMINACT")=$$FMDTOUTC^C0CUTIL($P(PTMP,U,16),"DT") ;NOT MAPPED IN C0CCCR0
76 . S ARYTMP=$NA(@TARYTMP@(J))
77 . ; W "ARYTMP= ",ARYTMP,!
78 . K @ARYTMP
79 . D MAP^C0CXPATH(IPXML,VMAP,ARYTMP) ;
80 . I J=1 D ; FIRST ONE IS JUST A COPY
81 . . ; W "FIRST ONE",!
82 . . D CP^C0CXPATH(ARYTMP,OUTXML)
83 . . ; W "OUTXML ",OUTXML,!
84 . I J>1 D ; AFTER THE FIRST, INSERT INNER XML
85 . . D INSINNER^C0CXPATH(OUTXML,ARYTMP)
86 ; ZWR ^TMP("C0CCCR",$J,"PROBVALS",*)
87 ; ZWR ^TMP("C0CCCR",$J,"PROBARYTMP",*) ; SHOW THE RESULTS
88 ; ZWR @OUTXML
89 ; $$HTML^DILF(
90 ; GENERATE THE NARITIVE HTML FOR THE CCD
91 I CCD D CCD ; IF THIS IS FOR A CCD
92 D MISSINGVARS
93 Q
94 ;
95VISTA ; GETS THE PROBLEM LIST FOR VISTA
96 D LIST^ORQQPL3(.RPCRSLT,DFN,"") ; CALL THE PROBLEM LIST RPC
97 I '$D(RPCRSLT(1)) D Q ; RPC RETURNS NULL
98 . W "NULL RESULT FROM LIST^ORQQPL3 ",!
99 . S @OUTXML@(0)=0
100 . ; Q
101 ; I DEBUG ZWR RPCRSLT
102 S @TVMAP@(0)=RPCRSLT(0) ; SAVE NUMBER OF PROBLEMS
103 F J=1:1:RPCRSLT(0) D ; FOR EACH PROBLEM IN THE LIST
104 . S VMAP=$NA(@TVMAP@(J))
105 . K @VMAP
106 . I DEBUG W "VMAP= ",VMAP,!
107 . S PTMP=RPCRSLT(J) ; PULL OUT PROBLEM FROM RPC RETURN ARRAY
108 . S @VMAP@("PROBLEMOBJECTID")="PROBLEM"_J ; UNIQUE OBJID FOR PROBLEM
109 . S @VMAP@("PROBLEMIEN")=$P(PTMP,U,1)
110 . S @VMAP@("PROBLEMSTATUS")=$S($P(PTMP,U,2)="A":"Active",1:"")
111 . S @VMAP@("PROBLEMDESCRIPTION")=$P(PTMP,U,3)
112 . S @VMAP@("PROBLEMCODINGVERSION")=""
113 . S @VMAP@("PROBLEMCODEVALUE")=$P(PTMP,U,4)
114 . S @VMAP@("PROBLEMDATEOFONSET")=$$FMDTOUTC^C0CUTIL($P(PTMP,U,5),"DT")
115 . S @VMAP@("PROBLEMDATEMOD")=$$FMDTOUTC^C0CUTIL($P(PTMP,U,6),"DT")
116 . S @VMAP@("PROBLEMSC")=$P(PTMP,U,7)
117 . S @VMAP@("PROBLEMSE")=$P(PTMP,U,8)
118 . S @VMAP@("PROBLEMCONDITION")=$P(PTMP,U,9)
119 . S @VMAP@("PROBLEMLOC")=$P(PTMP,U,10)
120 . S @VMAP@("PROBLEMLOCTYPE")=$P(PTMP,U,11)
121 . S @VMAP@("PROBLEMPROVIDER")=$P(PTMP,U,12)
122 . S X=@VMAP@("PROBLEMPROVIDER") ; FORMAT Y;NAME Y IS IEN OF PROVIDER
123 . S @VMAP@("PROBLEMSOURCEACTORID")="ACTORPROVIDER_"_$P(X,";",1)
124 . S @VMAP@("PROBLEMSERVICE")=$P(PTMP,U,13)
125 . S @VMAP@("PROBLEMHASCMT")=$P(PTMP,U,14)
126 . S @VMAP@("PROBLEMDTREC")=$$FMDTOUTC^C0CUTIL($P(PTMP,U,15),"DT")
127 . S @VMAP@("PROBLEMINACT")=$$FMDTOUTC^C0CUTIL($P(PTMP,U,16),"DT")
128 . S ARYTMP=$NA(@TARYTMP@(J))
129 . ; W "ARYTMP= ",ARYTMP,!
130 . K @ARYTMP
131 . D MAP^C0CXPATH(IPXML,VMAP,ARYTMP) ;
132 . I J=1 D ; FIRST ONE IS JUST A COPY
133 . . ; W "FIRST ONE",!
134 . . D CP^C0CXPATH(ARYTMP,OUTXML)
135 . . ; W "OUTXML ",OUTXML,!
136 . I J>1 D ; AFTER THE FIRST, INSERT INNER XML
137 . . D INSINNER^C0CXPATH(OUTXML,ARYTMP)
138 ; ZWR ^TMP("C0CCCR",$J,"PROBVALS",*)
139 ; ZWR ^TMP("C0CCCR",$J,"PROBARYTMP",*) ; SHOW THE RESULTS
140 ; ZWR @OUTXML
141 ; $$HTML^DILF(
142 ; GENERATE THE NARITIVE HTML FOR THE CCD
143 I CCD D CCD ; IF THIS IS FOR A CCD
144 D MISSINGVARS
145 Q
146CCD
147 N HTMP,HOUT,HTMLO,C0CPROBI,ZX
148 F C0CPROBI=1:1:RPCRSLT(0) D ; FOR EACH PROBLEM
149 . S VMAP=$NA(@TVMAP@(C0CPROBI))
150 . I DEBUG W "VMAP =",VMAP,!
151 . D QUERY^C0CXPATH(TGLOBAL,"//ContinuityOfCareRecord/Body/PROBLEMS-HTML","HTMP") ; GET THE HTML FROM THE TEMPLATE
152 . D UNMARK^C0CXPATH("HTMP") ; REMOVE <PROBLEMS-HTML> MARKUP
153 . ; D PARY^C0CXPATH("HTMP") ; PRINT IT
154 . D MAP^C0CXPATH("HTMP",VMAP,"HOUT") ; MAP THE VARIABLES
155 . ; D PARY^C0CXPATH("HOUT") ; PRINT IT AGAIN
156 . I C0CPROBI=1 D ; FIRST ONE IS JUST A COPY
157 . . D CP^C0CXPATH("HOUT","HTMLO")
158 . I C0CPROBI>1 D ; AFTER THE FIRST, INSERT INNER HTML
159 . . I DEBUG W "DOING INNER",!
160 . . N HTMLBLD,HTMLTMP
161 . . D QUEUE^C0CXPATH("HTMLBLD","HTMLO",1,HTMLO(0)-1)
162 . . D QUEUE^C0CXPATH("HTMLBLD","HOUT",2,HOUT(0)-1)
163 . . D QUEUE^C0CXPATH("HTMLBLD","HTMLO",HTMLO(0),HTMLO(0))
164 . . D BUILD^C0CXPATH("HTMLBLD","HTMLTMP")
165 . . D CP^C0CXPATH("HTMLTMP","HTMLO")
166 . . ; D INSINNER^C0CXPATH("HOUT","HTMLO","//")
167 I DEBUG D PARY^C0CXPATH("HTMLO")
168 D INSB4^C0CXPATH(OUTXML,"HTMLO") ; INSERT AT TOP OF SECTION
169 Q
170MISSINGVARS
171 N PROBSTMP,I
172 D MISSING^C0CXPATH(ARYTMP,"PROBSTMP") ; SEARCH XML FOR MISSING VARS
173 I PROBSTMP(0)>0 D ; IF THERE ARE MISSING VARS -
174 . ; STRINGS MARKED AS @@X@@
175 . W !,"PROBLEMS Missing list: ",!
176 . F I=1:1:PROBSTMP(0) W PROBSTMP(I),!
177 Q
178 ;
Note: See TracBrowser for help on using the repository browser.