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

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

accomodate system that have CPT codes only in text field

File size: 5.0 KB
RevLine 
[673]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=""
[676]46 N PREVCPT,PREVDT S (PREVCPT,PREVDT)=""
[673]47 F S ZI=$O(VISIT(ZI),-1) Q:ZI="" D ; REVERSE TIME ORDER - MOST RECENT FIRST
48 . N ZDATE
49 . S ZDATE=$$DATE(VISIT(ZI,"DATE",0))
50 . S ZPRVARY=$NA(VISIT(ZI,"PRV"))
51 . N ZPRV
52 . S ZPRV=$$PRV(ZPRVARY) ; THE PRIMARY PROVIDER OBJECT IN THE FORM
53 . ; ACTORPROVIDER_IEN WHERE IEN IS THE PROVIDER IEN IN NEW PERSON
54 . N ZJ S ZJ=""
55 . F S ZJ=$O(VISIT(ZI,"CPT",ZJ)) Q:ZJ="" D ;FOR EACH CPT SEG
56 . . N ZRNF
57 . . N ZCPT S ZCPT=$$CPT(VISIT(ZI,"CPT",ZJ)) ;GET CPT CODE AND TEXT
58 . . I ZCPT'="" D ;IF CPT CODE IS PRESENT
[676]59 . . . I (ZCPT=PREVCPT)&(ZDATE=PREVDT) Q ; NO DUPS ALLOWED
[673]60 . . . W !,ZCPT," ",ZDATE," ",ZPRV
61 . . . S ZRNF("PROCACTOROBJID")=ZPRV
62 . . . S ZRNF("PROCCODE")=$P(ZCPT,U,1)
63 . . . S ZRNF("PROCCODESYS")="CPT-4"
64 . . . S ZRNF("PROCDATETEXT")="Procedure Date"
65 . . . S ZRNF("PROCDATETIME")=ZDATE
[674]66 . . . S ZRNF("PROCDESCOBJATTRCODE")="" ;NO PROC ATTRIBUTES YET
[673]67 . . . S ZRNF("PROCDESCOBJATTR")=""
68 . . . S ZRNF("PROCDESCOBJATTRCODESYS")="" ;WE DON'T HAVE PROC ATTRIBUTES
69 . . . S ZRNF("PROCDESCOBJATTRVAL")=""
70 . . . S ZRNF("PROCDESCTEXT")=$P(ZCPT,U,3)
71 . . . S ZRNF("PROCLINKID")="" ; NO LINKS YET
72 . . . S ZRNF("PROCLINKREL")="" ; NO LINKS YET
73 . . . S ZRNF("PROCOBJECTID")="PROCEDURE_"_ZI
74 . . . S ZRNF("PROCSTATUS")="Completed" ; Is this right?
75 . . . S ZRNF("PROCTYPE")=$P(ZCPT,U,2) ; NEED TO ADD THIS TO TEMPLATE
[674]76 . . . D RNF1TO2^C0CRNF(C0CPRC,"ZRNF") ; ADD THIS ROW TO THE ARRAY
[676]77 . . . S PREVCPT=ZCPT
78 . . . S PREVDT=ZDATE
[674]79 N ZRIM S ZRIM=$NA(^TMP("C0CRIM","VARS",DFN,"PROCEDURES"))
80 M @ZRIM=@C0CPRC@("V")
[673]81 Q
82 ;
83PRV(IARY) ; RETURNS THE PRIMARY PROVIDER FROM THE "PRV" ARRAY PASSED BY NAME
84 N ZI,ZR,ZRTN S ZI="" S ZR="" S ZRTN=""
85 F S ZI=$O(@IARY@(ZI)) Q:ZI="" D ; FOR EACH PRV SEG
86 . I ZR'="" Q ;ONLY WANT THE FIRST PRIMARY PROVIDER
87 . I $P(@IARY@(ZI),U,5)=1 S ZR=$P(@IARY@(ZI),U,1)
88 I ZR'="" S ZRTN="ACTORPROVIDER_"_ZR
89 Q ZRTN
90 ;
91DATE(ISTR) ; EXTRINSIC TO RETURN THE DATE IN CCR FORMAT
92 Q $$FMDTOUTC^C0CUTIL(ISTR,"D")
93 ;
94CPT(ISTR) ; EXTRINSIC THAT SEARCHES FOR CPT CODES AND RETURNS
95 ; CPT^CATEGORY^TEXT
96 N Z1,Z2,Z3,ZRTN
[677]97 S Z1=$P(ISTR,U,1)
98 I Z1="" D ;
99 . I ISTR["(CPT-4 " S Z1=$P($P(ISTR,"(CPT-4 ",2),")",1)
100 I Z1'="" D ; IF THERE IS A CPT CODE IN THERE
101 . ;S Z1=$P(ISTR,U,1)
[673]102 . S Z2=$P(ISTR,U,2)
103 . S Z3=$P(ISTR,U,3)
104 . S ZRTN=Z1_U_Z2_U_Z3
105 E S ZRTN=""
106 Q ZRTN
107 ;
108MAP(PROCXML,C0CPRC,PROCOUT) ; MAP PROCEDURES XML
109 ;
[674]110 N ZTEMP S ZTEMP=$NA(^TMP("C0CCCR",$J,DFN,"PROCTEMP")) ;WORK AREA FOR TEMPLATE
111 K @ZTEMP
112 N ZBLD
113 S ZBLD=$NA(^TMP("C0CCCR",$J,DFN,"PROCBLD")) ; BUILD LIST AREA
114 D QUEUE^C0CXPATH(ZBLD,PROCXML,1,1) ; FIRST LINE
115 N ZINNER
116 D QUERY^C0CXPATH(PROCXML,"//Procedures/Procedure","ZINNER") ;ONE PROC
117 N ZTMP,ZVAR,ZI
118 S ZI=""
119 F S ZI=$O(@C0CPRC@("V",ZI)) Q:ZI="" D ;FOR EACH PROCEDURE
120 . S ZTMP=$NA(@ZTEMP@(ZI)) ;THIS PROCEDURE XML
121 . S ZVAR=$NA(@C0CPRC@("V",ZI)) ;THIS PROCEDURE VARIABLES
122 . D MAP^C0CXPATH("ZINNER",ZVAR,ZTMP) ; MAP THE PROCEDURE
123 . D QUEUE^C0CXPATH(ZBLD,ZTMP,1,@ZTMP@(0)) ;QUE FOR BUILD
124 D QUEUE^C0CXPATH(ZBLD,PROCXML,@PROCXML@(0),@PROCXML@(0))
125 N ZZTMP
126 D BUILD^C0CXPATH(ZBLD,PROCOUT) ;BUILD FINAL XML
[676]127 K @ZTEMP,@ZBLD,@C0CPRC
[673]128 Q
129 ;
Note: See TracBrowser for help on using the repository browser.