1 | PXRHS01 ; SLC/SBW - PCE Visit data extract main routine ;6/7/96
|
---|
2 | ;;1.0;PCE PATIENT CARE ENCOUNTER;**73**;Aug 12, 1996
|
---|
3 | ; Extract returns visit data with associated ICD-9, CPT, and
|
---|
4 | ; Provider data.
|
---|
5 | VISIT(DFN,ENDDT,BEGDT,OCCLIM,CATCODE,EXTRCODE,TIMEORD) ; Control branching
|
---|
6 | ;INPUT : DFN - Pointer to PATIENT file (#2)
|
---|
7 | ; ENDDT - Ending date/time in in internal FileMan format
|
---|
8 | ; - Defaults to today's date at 11:59 pm
|
---|
9 | ; BEGDT - Beginning date/time in internal FileMan format
|
---|
10 | ; - Defaults to one year prior to today's date
|
---|
11 | ; OCCLIM - Maximum number of visits returned
|
---|
12 | ; CATCODE - Pattern Match which controls visit data that is
|
---|
13 | ; returned (Can include multiple codes)
|
---|
14 | ; A = AMBULATORY
|
---|
15 | ; H = HOSPITALIZATION
|
---|
16 | ; I = IN HOSPITAL
|
---|
17 | ; C = CHART REVIEW
|
---|
18 | ; T = TELECOMMUNICATIONS
|
---|
19 | ; N = NOT FOUND
|
---|
20 | ; S = DAY SURGERY
|
---|
21 | ; O = OBSERVATION
|
---|
22 | ; E = EVENT (HISTORICAL)
|
---|
23 | ; R = NURSING HOME
|
---|
24 | ; D = DAILY HOSPITALIZATION DATA
|
---|
25 | ; X = ANCILLARY PACKAGE DAILY DATA
|
---|
26 | ; EXTRCODE - Pattern Match indicating which optional
|
---|
27 | ; data is returned (Can be multiple)
|
---|
28 | ; P = return PROVIDER data
|
---|
29 | ; C = return CPT (procedure) data
|
---|
30 | ; D = return ICD-9 (diagnosis) data
|
---|
31 | ; TIMEORD - Order visits on same day are indexed
|
---|
32 | ; Default is inverse cronological order
|
---|
33 | ; 1 = Time order in regular cronological order
|
---|
34 | ;
|
---|
35 | ;OUTPUT :
|
---|
36 | ; Data from VISIT (9000010) file except for hosp. loc. abbr.
|
---|
37 | ; ^TMP("PXHSV",$J,InvExDt,COUNT,0) = VISIT/ADMIT DATE&TIME [I;.01]
|
---|
38 | ; ^ TYPE [E;.03] ^ LOC. OF ENCOUNTER [E;.06]
|
---|
39 | ; ^ SERVICE CATEGORY [E;.07] ^ CHECK OUT DATE&TIME [I;.18]
|
---|
40 | ; ^ HOSPITAL LOCATION [E;.22] ^ HOSP. LOC. ABBREVIATION [E;44;1]
|
---|
41 | ; ^ OUTSIDE LOCATION [E;2101] ^ CLINIC [E;.08]
|
---|
42 | ; ^ WALK IN/APPT [E;.16] ^ LEVEL OF SERVICE [E;.17]
|
---|
43 | ; ^ ELIGIBILITY [E;.21]
|
---|
44 | ; Data from V CPT (9000010.18) file
|
---|
45 | ; ^TMP("PXHSV",$J,InvExDt,COUNT,"C",X) = CPT [I;.01]
|
---|
46 | ; ^ PROVIDER NARRATIVE [E;.04]
|
---|
47 | ; ^TMP("PXHSV",$J,InvExDt,COUNT,"C",X,MODIFIER)="" [E;1/.01]
|
---|
48 | ; Data from V POV (9000010.07) file
|
---|
49 | ; ^TMP("PXHSV",$J,InvExDt,COUNT,"D",X) = POV [I;.01]
|
---|
50 | ; ^ MODIFIER [E;.06] ^ CAUSE OF DX [E;.07]
|
---|
51 | ; ^ PLACE OF ACCIDENT [E;.11] ^ PRIMARY/SECONDARY [E;.12]
|
---|
52 | ; ^TMP("PXHSV",$J,InvExDt,COUNT,"D",X,"N") = PROVIDER NARRATIVE [E;.04]
|
---|
53 | ; Data from V PROVIDER (9000010.06) file
|
---|
54 | ; ^TMP("PXHSV",$J,InvExDt,COUNT,"P",X) = PROVIDER [E;.01]
|
---|
55 | ; ^ PRIMARY/SECONDARY [E;.04]
|
---|
56 | ; Data from V HOSPITALIZATION (9000010.02) file (If Service Category
|
---|
57 | ; is for hospitalization)
|
---|
58 | ; ^TMP("PXHSV",$J,InvExDt,COUNT,"H",X) = DATE OF DISCHARGE [I;.01]
|
---|
59 | ; ^ ADMITTING DX [E;.12]
|
---|
60 | ;
|
---|
61 | ; [] = [I(nternal)/E(xternal); Optional file #; Record #]
|
---|
62 | ; Subscripts:
|
---|
63 | ; InvExDt - Inverse FileMan date of DATE OF visit [.01]
|
---|
64 | ; Count - # of entry
|
---|
65 | ;
|
---|
66 | Q:$G(DFN)']""!'$D(^AUPNVSIT("AA",DFN))
|
---|
67 | N PXCNT,PXIVD,PXVDF,PXBEG,IBEGDT,IENDDT,CHGIVD,PXSTOP,IHSDATE
|
---|
68 | S:+$G(OCCLIM)'>0 OCCLIM=999
|
---|
69 | S:+$G(BEGDT)'>0 BEGDT=DT-10000
|
---|
70 | S:+$G(ENDDT)'>0 ENDDT=DT_".235959"
|
---|
71 | ; Chg regular dt/time to inverted dt/time
|
---|
72 | S IBEGDT=9999999-ENDDT,IENDDT=9999999-BEGDT+.235959
|
---|
73 | K ^TMP("PXHSV",$J)
|
---|
74 | S PXBEG=9999999-$P(ENDDT,"."),PXSTOP=(9999999-$P(BEGDT,"."))_".235959",PXCNT=0,IHSDATE=9999999-$$HSDATE+.235959
|
---|
75 | F S PXBEG=$O(^AUPNVSIT("AA",DFN,PXBEG)) Q:+PXBEG'>0!(PXBEG>PXSTOP) Q:PXBEG>IHSDATE D Q:PXCNT'<OCCLIM
|
---|
76 | .; Gets all valid visits on one day in last to first order
|
---|
77 | .; X-ref is in visit inverse date order but not inverse time order
|
---|
78 | . S (PXIVD,PXBEG)=$P(PXBEG,".")_".999999"
|
---|
79 | . ;start with last visit on a dt and don't duplicate any visits
|
---|
80 | . F S PXIVD=$O(^AUPNVSIT("AA",DFN,PXIVD),-1) Q:+PXIVD'>0!(PXIVD<$P(PXBEG,".")) D Q:PXCNT'<OCCLIM
|
---|
81 | . .;invert PXIVD to same format as IBEGDT and IENDDT. For Visit file
|
---|
82 | . .;date is inverted date/regular time. We want inverted date/time.
|
---|
83 | . . S CHGIVD=9999999-((9999999-$P(PXIVD,"."))_"."_$P(PXIVD,".",2))
|
---|
84 | . . Q:(CHGIVD<IBEGDT)!(CHGIVD>IENDDT)
|
---|
85 | . . S PXVDF=""
|
---|
86 | . . F S PXVDF=$O(^AUPNVSIT("AA",DFN,PXIVD,PXVDF)) Q:+PXVDF'>0 D GETREC^PXRHS02(PXVDF,$G(CATCODE),$G(EXTRCODE),$S(+$G(TIMEORD):PXIVD,1:""),.PXCNT) Q:PXCNT'<OCCLIM
|
---|
87 | Q
|
---|
88 | ;
|
---|
89 | HSDATE() ; $$() -> switch date
|
---|
90 | Q $P(^PX(815,1,0),U,3)
|
---|