source: FOIAVistA/trunk/r/PCE_PATIENT_CARE_ENCOUNTER-AUTN-EFDP-PX-VSIT--PXRM/PXRHS06.m@ 876

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

initial load of FOIAVistA 6/30/08 version

File size: 4.3 KB
Line 
1PXRHS06 ;ISL/SBW - PCE Visit Treatment data extract ;12/10/96
2 ;;1.0;PCE PATIENT CARE ENCOUNTER;**13**;Aug 12, 1996
3TREAT(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 ; returned (Can include multiple codes)
17 ; CATCODE - Pattern Match which controls visit data that is
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 TREATMENT (9000010.15) file
33 ; ^TMP("PXT,$J,InvDt,TREAT,IFN,0) = TREATMENT [E;.01]
34 ; ^ EVENT DATE/TIME or VISIT/ADMIT DATE&TIME [I;1201 or .03]
35 ; ^ HOW MANY [I;.04] ^ ORDERING PROVIDER [E;1202]
36 ; ^ ENCOUNTER PROVIDER [E;1204]
37 ; ^TMP("PXT",$J,InvDt,TREAT,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("PXT",$J,InvDt,TREAT,IFN,"S") = DATA SOURCE [E;80102]
41 ; ^TMP("PXT",$J,InvDt,TREAT,IFN,"P") = PROVIDER NARRATIVE [E;.06]
42 ; ^TMP("PXT",$J,InvDt,TREAT,IFN,"PNC") = PROVIDER NARR. CATEGORY [E;80201]
43 ;
44 ; [] = [I(nternal)/E(xternal); Optional file #; Record #]
45 ; Subscripts:
46 ; InvDt - Inverse FileMan date of DATE OF event or visit minus time
47 ; TREAT - TREATMENT PROVIDED
48 ; IFN - Internal Record #
49 ;
50 Q:$G(DFN)']""!'$D(^AUPNVTRT("AA",DFN))
51 N PXIVD,PXIFN,CNT,PDT,IBEGDT,IENDDT
52 S:+$G(OCCLIM)'>0 OCCLIM=999
53 S:+$G(BEGDT)'>0 BEGDT=DT-10000
54 S:+$G(ENDDT)'>0 ENDDT=DT_".235959"
55 ; Chg regular dt/time to inverted dt/time
56 S IBEGDT=9999999-ENDDT,IENDDT=9999999-BEGDT
57 K ^TMP("PXT",$J)
58 S PXIVD=IBEGDT,CNT=0
59 F S PXIVD=$O(^AUPNVTRT("AA",DFN,PXIVD)) Q:PXIVD'>0!(PXIVD>IENDDT) D Q:CNT'<OCCLIM
60 . S PXIFN=0
61 . F S PXIFN=$O(^AUPNVTRT("AA",DFN,PXIVD,PXIFN)) Q:PXIFN'>0 D
62 . . N DIC,DIQ,DR,DA,REC,VDATA,TREAT,TRDT,NUM,PNARR,PNARRC,COMMENT
63 . . N OPROV,EPROV,HLOC,HLOCABB,SOURCE,IDT
64 . . S DIC=9000010.15,DA=PXIFN,DIQ="REC(",DIQ(0)="IE"
65 . . S DR=".01;.03;.04;.06;1201;1202;1204;80102;80201;81101"
66 . . D EN^DIQ1
67 . . Q:'$D(REC)
68 . . S VDATA=$$GETVDATA^PXRHS03(+REC(9000010.15,DA,.03,"I"))
69 . . Q:$G(CATCODE)'[$P(VDATA,U,3) ;Only get data with passed serv. cat.
70 . . S TREAT=REC(9000010.15,DA,.01,"E")
71 . . S TRDT=REC(9000010.15,DA,1201,"I")
72 . . S:TRDT']"" TRDT=$P(VDATA,U)
73 . . S IDT=9999999-TRDT
74 . . I IDT<IBEGDT!(IDT>IENDDT) Q ;Only get data within date range
75 . . S NUM=REC(9000010.15,DA,.04,"I")
76 . . S OPROV=REC(9000010.15,DA,1202,"E")
77 . . S EPROV=REC(9000010.15,DA,1204,"E")
78 . . S HLOC=$P(VDATA,U,5)
79 . . S HLOCABB=$P(VDATA,U,6)
80 . . S SOURCE=REC(9000010.15,DA,80102,"E")
81 . . S COMMENT=REC(9000010.15,DA,81101,"E")
82 . . S PNARR=REC(9000010.15,DA,.06,"E")
83 . . S PNARRC=REC(9000010.15,DA,80201,"E")
84 . . S IDT=$P(IDT,".") ;Index with only date and no time
85 . . S ^TMP("PXT",$J,IDT,TREAT,DA,0)=TREAT_U_TRDT_U_NUM_U_OPROV_U_EPROV
86 . . S ^TMP("PXT",$J,IDT,TREAT,DA,1)=HLOC_U_HLOCABB_U_$P(VDATA,U,2)_U_$P(VDATA,U,4)
87 . . S ^TMP("PXT",$J,IDT,TREAT,DA,"S")=SOURCE
88 . . S ^TMP("PXT",$J,IDT,TREAT,DA,"P")=PNARR
89 . . S ^TMP("PXT",$J,IDT,TREAT,DA,"PNC")=PNARRC
90 . . S ^TMP("PXT",$J,IDT,TREAT,DA,"COM")=COMMENT
91 . . ; Counter by date not by visit. There may be multiple visits with
92 . . ; multiple treatments for any given day
93 . . I PXIVD'=$G(PDT) S CNT=CNT+1,PDT=PXIVD
94 Q
Note: See TracBrowser for help on using the repository browser.