source: ccr/trunk/p/C0CPROC.m@ 674

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

first version with Procedures

File size: 4.8 KB
Line 
1C0CPROC ; CCDCCR/GPL - CCR/CCD PROCESSING FOR PROCEDURES ; 01/21/10
2 ;;1.0;C0C;;Jan 21, 2010;
3 ;Copyright 2010 George Lilly, University of Minnesota and others.
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 W "NO ENTRY FROM TOP",!
22 Q
23 ;
24EXTRACT(PROCXML,DFN,PROCOUT) ; EXTRACT PROCEDURES INTO XML TEMPLATE
25 ; PROCXML AND PROCOUT ARE PASSED BY NAME SO GLOBALS CAN BE USED
26 ;
27 S C0CENC=$NA(^TMP("C0CENC",$J,DFN))
28 S C0CPRC=$NA(^TMP("C0CPRC",$J,DFN))
29 S C0CNTE=$NA(^TMP("C0CNTE",$J,DFN))
30 I '$D(@C0CPRC) D TIUGET(DFN,C0CENC,C0CPRC,C0CNTE) ; GET VARS IF NOT THERE
31 D MAP(PROCXML,C0CPRC,PROCOUT) ;MAP RESULTS FOR PROCEDURES
32 Q
33 ;
34TIUGET(DFN,C0CENC,C0CPRC,C0CNTE) ; CALLS ENTRY^C0CCPT TO GET PROCEDURES,
35 ; ENCOUNTERS AND NOTES. RETURNS THEM IN RNF2 ARRAYS PASSED BY NAME
36 ; C0CENC: ENCOUNTERS, C0CPRC: PROCEDURES, C0CNTE: NOTES
37 ; READY TO BE MAPPED TO XML BY MAP^C0CENC, MAP^C0CPROC, AND MAP^C0CCMT
38 ; THESE RETURN ARRAYS ARE NOT INITIALIZED, BUT ARE ADDED TO IF THEY
39 ; EXIST. THIS IS SO THAT ADDITIONAL PROCEDURES CAN BE OBTAINED FROM
40 ; THE SURGERY PACKGE AND ADDITIONAL COMMENTS FROM OTHER CCR SECTIONS
41 ;
42 K VISIT,LST,NOTE
43 D ENTRY^C0CCPT(DFN,,,1) ; RETURNS ALL RESULTS IN VISIT LOCAL VARIABLE
44 ; NEED TO ADD START AND END DATES FROM PARAMETERS
45 N ZI S ZI=""
46 F S ZI=$O(VISIT(ZI),-1) Q:ZI="" D ; REVERSE TIME ORDER - MOST RECENT FIRST
47 . N ZDATE
48 . S ZDATE=$$DATE(VISIT(ZI,"DATE",0))
49 . S ZPRVARY=$NA(VISIT(ZI,"PRV"))
50 . N ZPRV
51 . S ZPRV=$$PRV(ZPRVARY) ; THE PRIMARY PROVIDER OBJECT IN THE FORM
52 . ; ACTORPROVIDER_IEN WHERE IEN IS THE PROVIDER IEN IN NEW PERSON
53 . N ZJ S ZJ=""
54 . F S ZJ=$O(VISIT(ZI,"CPT",ZJ)) Q:ZJ="" D ;FOR EACH CPT SEG
55 . . N ZRNF
56 . . N ZCPT S ZCPT=$$CPT(VISIT(ZI,"CPT",ZJ)) ;GET CPT CODE AND TEXT
57 . . I ZCPT'="" D ;IF CPT CODE IS PRESENT
58 . . . W !,ZCPT," ",ZDATE," ",ZPRV
59 . . . S ZRNF("PROCACTOROBJID")=ZPRV
60 . . . S ZRNF("PROCCODE")=$P(ZCPT,U,1)
61 . . . S ZRNF("PROCCODESYS")="CPT-4"
62 . . . S ZRNF("PROCDATETEXT")="Procedure Date"
63 . . . S ZRNF("PROCDATETIME")=ZDATE
64 . . . S ZRNF("PROCDESCOBJATTRCODE")="" ;NO PROC ATTRIBUTES YET
65 . . . S ZRNF("PROCDESCOBJATTR")=""
66 . . . S ZRNF("PROCDESCOBJATTRCODESYS")="" ;WE DON'T HAVE PROC ATTRIBUTES
67 . . . S ZRNF("PROCDESCOBJATTRVAL")=""
68 . . . S ZRNF("PROCDESCTEXT")=$P(ZCPT,U,3)
69 . . . S ZRNF("PROCLINKID")="" ; NO LINKS YET
70 . . . S ZRNF("PROCLINKREL")="" ; NO LINKS YET
71 . . . S ZRNF("PROCOBJECTID")="PROCEDURE_"_ZI
72 . . . S ZRNF("PROCSTATUS")="Completed" ; Is this right?
73 . . . S ZRNF("PROCTYPE")=$P(ZCPT,U,2) ; NEED TO ADD THIS TO TEMPLATE
74 . . . D RNF1TO2^C0CRNF(C0CPRC,"ZRNF") ; ADD THIS ROW TO THE ARRAY
75 N ZRIM S ZRIM=$NA(^TMP("C0CRIM","VARS",DFN,"PROCEDURES"))
76 M @ZRIM=@C0CPRC@("V")
77 Q
78 ;
79PRV(IARY) ; RETURNS THE PRIMARY PROVIDER FROM THE "PRV" ARRAY PASSED BY NAME
80 N ZI,ZR,ZRTN S ZI="" S ZR="" S ZRTN=""
81 F S ZI=$O(@IARY@(ZI)) Q:ZI="" D ; FOR EACH PRV SEG
82 . I ZR'="" Q ;ONLY WANT THE FIRST PRIMARY PROVIDER
83 . I $P(@IARY@(ZI),U,5)=1 S ZR=$P(@IARY@(ZI),U,1)
84 I ZR'="" S ZRTN="ACTORPROVIDER_"_ZR
85 Q ZRTN
86 ;
87DATE(ISTR) ; EXTRINSIC TO RETURN THE DATE IN CCR FORMAT
88 Q $$FMDTOUTC^C0CUTIL(ISTR,"D")
89 ;
90CPT(ISTR) ; EXTRINSIC THAT SEARCHES FOR CPT CODES AND RETURNS
91 ; CPT^CATEGORY^TEXT
92 N Z1,Z2,Z3,ZRTN
93 I ISTR["(CPT-4 " D ; IF THERE IS A CPT CODE IN THERE
94 . S Z1=$P($P(ISTR,"(CPT-4 ",2),")",1)
95 . S Z2=$P(ISTR,U,2)
96 . S Z3=$P(ISTR,U,3)
97 . S ZRTN=Z1_U_Z2_U_Z3
98 E S ZRTN=""
99 Q ZRTN
100 ;
101MAP(PROCXML,C0CPRC,PROCOUT) ; MAP PROCEDURES XML
102 ;
103 N ZTEMP S ZTEMP=$NA(^TMP("C0CCCR",$J,DFN,"PROCTEMP")) ;WORK AREA FOR TEMPLATE
104 K @ZTEMP
105 N ZBLD
106 S ZBLD=$NA(^TMP("C0CCCR",$J,DFN,"PROCBLD")) ; BUILD LIST AREA
107 D QUEUE^C0CXPATH(ZBLD,PROCXML,1,1) ; FIRST LINE
108 N ZINNER
109 D QUERY^C0CXPATH(PROCXML,"//Procedures/Procedure","ZINNER") ;ONE PROC
110 N ZTMP,ZVAR,ZI
111 S ZI=""
112 F S ZI=$O(@C0CPRC@("V",ZI)) Q:ZI="" D ;FOR EACH PROCEDURE
113 . S ZTMP=$NA(@ZTEMP@(ZI)) ;THIS PROCEDURE XML
114 . S ZVAR=$NA(@C0CPRC@("V",ZI)) ;THIS PROCEDURE VARIABLES
115 . D MAP^C0CXPATH("ZINNER",ZVAR,ZTMP) ; MAP THE PROCEDURE
116 . D QUEUE^C0CXPATH(ZBLD,ZTMP,1,@ZTMP@(0)) ;QUE FOR BUILD
117 D QUEUE^C0CXPATH(ZBLD,PROCXML,@PROCXML@(0),@PROCXML@(0))
118 N ZZTMP
119 D BUILD^C0CXPATH(ZBLD,PROCOUT) ;BUILD FINAL XML
120 K @ZTEMP,@ZBLD
121 Q
122 ;
Note: See TracBrowser for help on using the repository browser.