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

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

Changed license to AGPL. Some clean-up for XINDEX

  • Property svn:mergeinfo set to (toggle deleted branches)
    /ccr/branches/ohum/o-old/p/C0CPROC.m1290
    /ccr/branches/ohum/p/C0CPROC.m1291-1543
    /ccr/branches/ohum/p/p/C0CPROC.m1287-1289
File size: 5.7 KB
Line 
1C0CPROC ; CCDCCR/GPL - CCR/CCD PROCESSING FOR PROCEDURES ; 01/21/10
2 ;;1.2;CCD/CCR GENERATION UTILITIES;;Oct 30, 2012;Build 50
3 ;
4 ; This program is free software: you can redistribute it and/or modify
5 ; it under the terms of the GNU Affero General Public License as
6 ; published by the Free Software Foundation, either version 3 of the
7 ; License, or (at your option) any later version.
8 ;
9 ; This program is distributed in the hope that it will be useful,
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ; GNU Affero General Public License for more details.
13 ;
14 ; You should have received a copy of the GNU Affero General Public License
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ;
17 W "NO ENTRY FROM TOP",!
18 Q
19 ;
20SETVARS ; SET UP VARIABLES FOR PROCEDURES, ENCOUNTERS, AND NOTES
21 S C0CENC=$NA(^TMP("C0CCCR",$J,"C0CENC",DFN))
22 S C0CPRC=$NA(^TMP("C0CCCR",$J,"C0CPRC",DFN))
23 S C0CNTE=$NA(^TMP("C0CCCR",$J,"C0CNTE",DFN))
24 ; ADDITION FOR CERTIFICATION
25 S C0CPRSLT=$NA(^TMP("C0CCCR",$J,"C0CPRSLT",DFN))
26 Q
27 ;
28EXTRACT(PROCXML,DFN,PROCOUT) ; EXTRACT PROCEDURES INTO XML TEMPLATE
29 ; PROCXML AND PROCOUT ARE PASSED BY NAME SO GLOBALS CAN BE USED
30 ;
31 D SETVARS ; SET UP VARIABLES
32 I '$D(@C0CPRC) D TIUGET(DFN,C0CENC,C0CPRC,C0CNTE) ; GET VARS IF NOT THERE
33 D MAP(PROCXML,C0CPRC,PROCOUT) ;MAP RESULTS FOR PROCEDURES
34 Q
35 ;
36TIUGET(DFN,C0CENC,C0CPRC,C0CNTE) ; CALLS ENTRY^C0CCPT TO GET PROCEDURES,
37 ; ENCOUNTERS AND NOTES. RETURNS THEM IN RNF2 ARRAYS PASSED BY NAME
38 ; C0CENC: ENCOUNTERS, C0CPRC: PROCEDURES, C0CNTE: NOTES
39 ; READY TO BE MAPPED TO XML BY MAP^C0CENC, MAP^C0CPROC, AND MAP^C0CCMT
40 ; THESE RETURN ARRAYS ARE NOT INITIALIZED, BUT ARE ADDED TO IF THEY
41 ; EXIST. THIS IS SO THAT ADDITIONAL PROCEDURES CAN BE OBTAINED FROM
42 ; THE SURGERY PACKGE AND ADDITIONAL COMMENTS FROM OTHER CCR SECTIONS
43 ;
44 K VISIT,LST,NOTE,C0CLPRC
45 ; C0CLPRC IS A LOOKUP TABLE FOR USE IN BUILDING ENCOUNTERS
46 ; FORMAT C0CLPRC(VISITIEN,CPT)=PROCOBJECTID FOR BUILDING LINKS TO PROCEDURES
47 D ENTRY^C0CCPT(DFN,,,1) ; RETURNS ALL RESULTS IN VISIT LOCAL VARIABLE
48 ; NEED TO ADD START AND END DATES FROM PARAMETERS
49 N ZI S ZI=""
50 N PREVCPT,PREVDT S (PREVCPT,PREVDT)=""
51 F S ZI=$O(VISIT(ZI),-1) Q:ZI="" D ; REVERSE TIME ORDER - MOST RECENT FIRST
52 . N ZDATE
53 . S ZDATE=$$DATE(VISIT(ZI,"DATE",0))
54 . S ZPRVARY=$NA(VISIT(ZI,"PRV"))
55 . N ZPRV
56 . S ZPRV=$$PRV(ZPRVARY) ; THE PRIMARY PROVIDER OBJECT IN THE FORM
57 . ; ACTORPROVIDER_IEN WHERE IEN IS THE PROVIDER IEN IN NEW PERSON
58 . N ZJ S ZJ=""
59 . F S ZJ=$O(VISIT(ZI,"CPT",ZJ)) Q:ZJ="" D ;FOR EACH CPT SEG
60 . . N ZRNF
61 . . N ZCPT S ZCPT=$$CPT(VISIT(ZI,"CPT",ZJ)) ;GET CPT CODE AND TEXT
62 . . I ZCPT'="" D ;IF CPT CODE IS PRESENT
63 . . . I (ZCPT=PREVCPT)&(ZDATE=PREVDT) Q ; NO DUPS ALLOWED
64 . . . W !,ZCPT," ",ZDATE," ",ZPRV
65 . . . S ZRNF("PROCACTOROBJID")=ZPRV
66 . . . N PROCCODE S PROCCODE=$P(ZCPT,U,1)
67 . . . S ZRNF("PROCCODE")=PROCCODE
68 . . . S ZRNF("PROCCODESYS")="CPT-4"
69 . . . S ZRNF("PROCDATETEXT")="Procedure Date"
70 . . . S ZRNF("PROCDATETIME")=ZDATE
71 . . . S ZRNF("PROCDESCOBJATTRCODE")="" ;NO PROC ATTRIBUTES YET
72 . . . S ZRNF("PROCDESCOBJATTR")=""
73 . . . S ZRNF("PROCDESCOBJATTRCODESYS")="" ;WE DON'T HAVE PROC ATTRIBUTES
74 . . . S ZRNF("PROCDESCOBJATTRVAL")=""
75 . . . S ZRNF("PROCDESCTEXT")=$P(ZCPT,U,3)
76 . . . S ZRNF("PROCLINKID")="" ; NO LINKS YET
77 . . . S ZRNF("PROCLINKREL")="" ; NO LINKS YET
78 . . . ; additions for Certification - need to have EKG in Results
79 . . . S ZRNF("PROCTEXT")=$G(VISIT(ZI,"TEXT",1)) ; POTENTIAL RESULT
80 . . . S ZRNF("PROCOBJECTID")="PROCEDURE_"_ZI_"_"_ZJ
81 . . . S C0CLPRC(ZI,PROCCODE)=ZRNF("PROCOBJECTID") ; LOOKUP TABLE FOR ENCOUNTERS
82 . . . S ZRNF("PROCSTATUS")="Completed" ; Is this right?
83 . . . S ZRNF("PROCTYPE")=$P(ZCPT,U,2) ; NEED TO ADD THIS TO TEMPLATE
84 . . . D RNF1TO2^C0CRNF(C0CPRC,"ZRNF") ; ADD THIS ROW TO THE ARRAY
85 . . . ; FOR CERTIFICATION - SAVE EKG RESULTS gpl
86 . . . W !,"CPT=",ZCPT
87 . . . I ZCPT["93000" D ; THIS IS AN EKG
88 . . . . D RNF1TO2^C0CRNF(C0CPRSLT,"ZRNF") ; SAVE FOR LABS
89 . . . . M ^GPL("RNF2")=@C0CPRSLT
90 . . . S PREVCPT=ZCPT
91 . . . S PREVDT=ZDATE
92 N ZRIM S ZRIM=$NA(^TMP("C0CRIM","VARS",DFN,"PROCEDURES"))
93 M @ZRIM=@C0CPRC@("V")
94 Q
95 ;
96PRV(IARY) ; RETURNS THE PRIMARY PROVIDER FROM THE "PRV" ARRAY PASSED BY NAME
97 N ZI,ZR,ZRTN S ZI="" S ZR="" S ZRTN=""
98 F S ZI=$O(@IARY@(ZI)) Q:ZI="" D ; FOR EACH PRV SEG
99 . I ZR'="" Q ;ONLY WANT THE FIRST PRIMARY PROVIDER
100 . I $P(@IARY@(ZI),U,5)=1 S ZR=$P(@IARY@(ZI),U,1)
101 I ZR'="" S ZRTN="ACTORPROVIDER_"_ZR
102 Q ZRTN
103 ;
104DATE(ISTR) ; EXTRINSIC TO RETURN THE DATE IN CCR FORMAT
105 Q $$FMDTOUTC^C0CUTIL(ISTR,"DT")
106 ;
107CPT(ISTR) ; EXTRINSIC THAT SEARCHES FOR CPT CODES AND RETURNS
108 ; CPT^CATEGORY^TEXT
109 N Z1,Z2,Z3,ZRTN
110 S Z1=$P(ISTR,U,1)
111 I Z1="" D ;
112 . I ISTR["(CPT-4 " S Z1=$P($P(ISTR,"(CPT-4 ",2),")",1)
113 I Z1'="" D ; IF THERE IS A CPT CODE IN THERE
114 . ;S Z1=$P(ISTR,U,1)
115 . S Z2=$P(ISTR,U,2)
116 . S Z3=$P(ISTR,U,3)
117 . S ZRTN=Z1_U_Z2_U_Z3
118 E S ZRTN=""
119 Q ZRTN
120 ;
121MAP(PROCXML,C0CPRC,PROCOUT) ; MAP PROCEDURES XML
122 ;
123 N ZTEMP S ZTEMP=$NA(^TMP("C0CCCR",$J,DFN,"PROCTEMP")) ;WORK AREA FOR TEMPLATE
124 K @ZTEMP
125 N ZBLD
126 S ZBLD=$NA(^TMP("C0CCCR",$J,DFN,"PROCBLD")) ; BUILD LIST AREA
127 D QUEUE^C0CXPATH(ZBLD,PROCXML,1,1) ; FIRST LINE
128 N ZINNER
129 D QUERY^C0CXPATH(PROCXML,"//Procedures/Procedure","ZINNER") ;ONE PROC
130 N ZTMP,ZVAR,ZI
131 S ZI=""
132 F S ZI=$O(@C0CPRC@("V",ZI)) Q:ZI="" D ;FOR EACH PROCEDURE
133 . S ZTMP=$NA(@ZTEMP@(ZI)) ;THIS PROCEDURE XML
134 . S ZVAR=$NA(@C0CPRC@("V",ZI)) ;THIS PROCEDURE VARIABLES
135 . D MAP^C0CXPATH("ZINNER",ZVAR,ZTMP) ; MAP THE PROCEDURE
136 . D QUEUE^C0CXPATH(ZBLD,ZTMP,1,@ZTMP@(0)) ;QUE FOR BUILD
137 D QUEUE^C0CXPATH(ZBLD,PROCXML,@PROCXML@(0),@PROCXML@(0))
138 N ZZTMP
139 D BUILD^C0CXPATH(ZBLD,PROCOUT) ;BUILD FINAL XML
140 K @ZTEMP,@ZBLD,@C0CPRC
141 Q
142 ;
Note: See TracBrowser for help on using the repository browser.