source: WorldVistAEHR/trunk/r/PCE_PATIENT_CARE_ENCOUNTER-AUTN-EFDP-PX-VSIT--PXRM/PXRHS08.m@ 861

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

initial load of WorldVistAEHR

File size: 4.7 KB
Line 
1PXRHS08 ;ISL/SBW - PCE Visit Patient Education data extract ;2/14/97
2 ;;1.0;PCE PATIENT CARE ENCOUNTER;**13,16**;Aug 12, 1996
3EDUC(DFN,ENDDT,BEGDT,OCCLIM,CATCODE) ; Control branching
4 ;INPUT : DFN - Pointer to PATIENT file (#2)
5 ; ENDDT - Ending date/time in internal FileMan format
6 ; - Defaults to today's date at 11:59 pm
7 ; BEGDT - Beginning date/time in internal FileMan format
8 ; - Defaults to one year prior to today's date
9 ; OCCLIM - Maximum number of days for which data is returned
10 ; (If multiple visits on a given day, all data for
11 ; these visit will be returned) or an "R" for
12 ; only the most recent occurrence of each topic
13 ; Note: If event date is used, it may appear that too
14 ; many occurrences are retrieved but it is
15 ; it is based on visit date not event date.
16 ; CATCODE - Pattern Match which controls visit data that is
17 ; returned (Can include multiple codes)
18 ; A = AMBULATORY
19 ; H = HOSPITALIZATION
20 ; I = IN HOSPITAL
21 ; C = CHART REVIEW
22 ; T = TELECOMMUNICATIONS
23 ; N = NOT FOUND
24 ; S = DAY SURGERY
25 ; O = OBSERVATION
26 ; E = EVENT (HISTORICAL)
27 ; R = NURSING HOME
28 ; D = DAILY HOSPITALIZATION DATA
29 ; X = ANCILLARY PACKAGE DAILY DATA
30 ;
31 ;OUTPUT :
32 ; Data from V Patient Education (9000010.16) file
33 ; ^TMP("PXPE",$J,InvDt,TOPIC,IFN,0) = TOPIC [E;.01]
34 ; ^ EVENT DATE/TIME or VISIT/ADMIT DATE&TIME [I;1201 or .03]
35 ; ^ LEVEL OF UNDERSTANDING [E;.06] ^ ORDERING PROVIDER [E;1202]
36 ; ^ ENCOUNTER PROVIDER [E;1204]
37 ; ^TMP("PXPE",$J,InvDt,TOPIC,IFN,1) = HOSPITAL LOCATION [E;9000010;.22]
38 ; ^ HOSP. LOC. ABBREVIATION [E;44;1]
39 ; ^ LOC OF ENCOUNTER [E;9000010;.06] ^ OUTSIDE LOC [E;9000010;2101]
40 ; ^TMP("PXPE",$J,InvDt,TOPIC,IFN,"S") = DATA SOURCE [E;80102]
41 ;
42 ; [] = [I(nternal)/E(xternal); Optional file #; Record #]
43 ; Subscripts:
44 ; InvDt - Inverse FileMan date of DATE OF event or visit
45 ; TOPIC - Patient Education Topic
46 ; IFN - Internal Record #
47 ;
48 Q:$G(DFN)']""!'$D(^AUPNVPED("AA",DFN))
49 N PXIED,PXIVD,PXIFN,CNT,PDT,GMA,IBEGDT,IENDDT
50 S:($G(OCCLIM)'="R")&(+$G(OCCLIM)'>0) OCCLIM=999
51 S:+$G(BEGDT)'>0 BEGDT=DT-10000
52 S:+$G(ENDDT)'>0 ENDDT=DT_".235959"
53 ; Chg regular dt/time to inverted dt/time
54 S IBEGDT=9999999-ENDDT,IENDDT=9999999-BEGDT
55 K ^TMP("PXPE",$J)
56 I OCCLIM="R" D Q ;Get each most recent topic for time period
57 . S PXIED=""
58 . F S PXIED=$O(^AUPNVPED("AA",DFN,PXIED)) Q:PXIED="" D
59 . . S PXIVD=$O(^AUPNVPED("AA",DFN,PXIED,""))
60 . . I (PXIVD'<IBEGDT)&(PXIVD'>IENDDT) D
61 . . . S PXIFN=$O(^AUPNVPED("AA",DFN,PXIED,PXIVD,""))
62 . . . D GETDATA
63 ;
64 ;. S CNT=0,PXIVD=IBEGDT
65 ;. F S PXIVD=$O(^AUPNVPED("AA",DFN,PXIVD)) Q:PXIVD'>0!(PXIVD>IENDDT) D Q:CNT'<OCCLIM
66 ;. . S PXIFN=0
67 ;. . F S PXIFN=$O(^AUPNVPED("AA",DFN,PXIVD,PXIFN)) Q:PXIFN'>0 D GETDATA
68 ;
69 I OCCLIM>0 D Q
70 . S PXED=""
71 . F S PXED=$O(^AUPNVPED("AA",DFN,PXED)) Q:PXED="" D
72 . . S PXIVD=IBEGDT,CNT=0
73 . . F S PXIVD=$O(^AUPNVPED("AA",DFN,PXED,PXIVD)) Q:PXIVD'>0!(PXIVD>IENDDT) D Q:CNT'<OCCLIM
74 . . . S PXIFN=0
75 . . . F S PXIFN=$O(^AUPNVPED("AA",DFN,PXED,PXIVD,PXIFN)) Q:PXIFN'>0 D Q:CNT'<OCCLIM
76 . . . . D GETDATA
77 Q
78 ;
79GETDATA ;
80 N DIC,DIQ,DR,DA,REC,VDATA,TOPIC,EDDT,LEVEL
81 N OPROV,EPROV,HLOC,HLOCABB,SOURCE,IDT,COMMENT
82 S DIC=9000010.16,DA=PXIFN,DIQ="REC(",DIQ(0)="IE"
83 S DR=".01;.03;.06;1201;1202;1204;80102;80201;81101"
84 D EN^DIQ1
85 Q:'$D(REC)
86 S VDATA=$$GETVDATA^PXRHS03(+REC(9000010.16,DA,.03,"I"))
87 Q:$G(CATCODE)'[$P(VDATA,U,3) ;Only get data with passed serv. cat.
88 S TOPIC=REC(9000010.16,DA,.01,"E")
89 S EDDT=REC(9000010.16,DA,1201,"I")
90 S:EDDT']"" EDDT=$P(VDATA,U)
91 S IDT=9999999-EDDT
92 I IDT<IBEGDT!(IDT>IENDDT) Q ;Only get data within date range
93 I OCCLIM="R" Q:$D(GMA(TOPIC)) ;Get only most recent Pat. Ed. topic
94 S LEVEL=REC(9000010.16,DA,.06,"E")
95 S OPROV=REC(9000010.16,DA,1202,"E")
96 S EPROV=REC(9000010.16,DA,1204,"E")
97 S HLOC=$P(VDATA,U,5)
98 S HLOCABB=$P(VDATA,U,6)
99 S SOURCE=REC(9000010.16,DA,80102,"E")
100 S COMMENT=REC(9000010.16,DA,81101,"E")
101 S ^TMP("PXPE",$J,IDT,TOPIC,DA,0)=TOPIC_U_EDDT_U_LEVEL_U_OPROV_U_EPROV
102 S ^TMP("PXPE",$J,IDT,TOPIC,DA,1)=HLOC_U_HLOCABB_U_$P(VDATA,U,2)_U_$P(VDATA,U,4)
103 S ^TMP("PXPE",$J,IDT,TOPIC,DA,"S")=SOURCE
104 S ^TMP("PXPE",$J,IDT,TOPIC,DA,"COM")=COMMENT
105 ; Counter by date not by visit. There may be multiple visits with
106 ; multiple patient education topics for any given day
107 I OCCLIM>0,PXIVD'=$G(PDT) S CNT=CNT+1,PDT=PXIVD
108 I OCCLIM="R" S GMA(TOPIC)=""
109 Q
Note: See TracBrowser for help on using the repository browser.