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

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

initial load of WorldVistAEHR

File size: 3.4 KB
Line 
1PXRHS12 ;ISL/SBW - PCE Visit Hospitalization data extract routine ;6/7/96
2 ;;1.0;PCE PATIENT CARE ENCOUNTER;**73**;Aug 12, 1996
3 ; Extract returns Hospitalization visit data with associated ICD-9,
4 ; CPT, and Provider data.
5VISIT(DFN,ENDDT,BEGDT,OCCLIM) ; Control branching
6 ;INPUT : DFN - Pointer to PATIENT file (#2)
7 ; ENDDT - Ending date/time 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 ;
13 ;OUTPUT :
14 ; Data from VISIT (9000010) file except for hosp. loc. abbr.
15 ; ^TMP("PXHSV",$J,InvExDt,COUNT,0) = VISIT/ADMIT DATE&TIME [I;.01]
16 ; ^ TYPE [E;.03] ^ LOC. OF ENCOUNTER [E;.06]
17 ; ^ SERVICE CATEGORY [E;.07] ^ CHECK OUT DATE&TIME [I;.18]
18 ; ^ HOSPITAL LOCATION [E;.22] ^ HOSP. LOC. ABBREVIATION [E;44;1]
19 ; ^ OUTSIDE LOCATION [E;2101] ^ CLINIC [E;.08]
20 ; ^ WALK IN/APPT [E;.16] ^ LEVEL OF SERVICE [E;.17]
21 ; ^ ELIGIBILITY [E;.21]
22 ; Data from V CPT (9000010.18) file
23 ; ^TMP("PXHSV",$J,InvExDt,COUNT,"C",X) = CPT [I;.01]
24 ; ^ PROVIDER NARRATIVE [E;.04]
25 ; ^TMP("PXHSV",$J,InvExDt,COUNT,"C",MODIFIER)="" [E;1/.01]
26 ; Data from V POV (9000010.07) file
27 ; ^TMP("PXHSV",$J,InvExDt,COUNT,"D",X) = POV [I;.01]
28 ; ^ MODIFIER [E;.06] ^ CAUSE OF DX [E;.07]
29 ; ^ PLACE OF ACCIDENT [E;.11] ^ PRIMARY/SECONDARY [E;.12]
30 ; ^TMP("PXHSV",$J,InvExDt,COUNT,"D",X,"N") = PROVIDER NARRATIVE [E;.04]
31 ; Data from V PROVIDER (9000010.06) file
32 ; ^TMP("PXHSV",$J,InvExDt,COUNT,"P",X) = PROVIDER [E;.01]
33 ; ^ PRIMARY/SECONDARY [E;.04]
34 ; Data from V HOSPITALIZATION (9000010.02) file (If Service Category
35 ; is for hospitalization)
36 ; ^TMP("PXHSV",$J,InvExDt,COUNT,"H",X) = DATE OF DISCHARGE [I;.01]
37 ; ^ ADMITTING DX [E;.12]
38 ;
39 ; [] = [I(nternal)/E(xternal); Optional file #; Record #]
40 ; Subscripts:
41 ; InvExDt - Inverse FileMan date of DATE OF visit [.01]
42 ; Count - # of entry
43 ;
44 Q:$G(DFN)']""!'$D(^AUPNVSIT("AAH",DFN))
45 N PXCNT,PXIVD,PXVDF,PXBEG,CATCODE,IBEGDT,IENDDT,CHGIVD,PXSTOP
46 S CATCODE="H" ;Get only Hospitalization visits
47 S EXTRCODE="PCD" ;Get provider, CPT, and ICD-9 data
48 S:+$G(OCCLIM)'>0 OCCLIM=999
49 S:+$G(BEGDT)'>0 BEGDT=DT-10000
50 S:+$G(ENDDT)'>0 ENDDT=DT_".235959"
51 ; Chg regular dt/time to inverted dt/time
52 S IBEGDT=9999999-ENDDT,IENDDT=9999999-BEGDT
53 K ^TMP("PXHSV",$J)
54 S PXBEG=9999999-$P(ENDDT,"."),PXSTOP=(9999999-$P(BEGDT,"."))_".235959",PXCNT=0
55 F S PXBEG=$O(^AUPNVSIT("AAH",DFN,PXBEG)) Q:+PXBEG'>0!(PXBEG>PXSTOP) D Q:PXCNT'<OCCLIM
56 .; Gets all valid visits on one day in last to first order
57 .; X-ref is in visit inverse date order but not inverse time order
58 . S (PXIVD,PXBEG)=$P(PXBEG,".")_".999999"
59 . ;start with last visit on a dt and don't duplicate any visits
60 . F S PXIVD=$O(^AUPNVSIT("AAH",DFN,PXIVD),-1) Q:+PXIVD'>0!(PXIVD<$P(PXBEG,".")) D Q:PXCNT'<OCCLIM
61 . .;invert PXIVD to same format as IBEGDT and IENDDT. For Visit file
62 . .;date is inverted date/regular time. We want inverted date/time.
63 . . S CHGIVD=9999999-((9999999-$P(PXIVD,"."))_"."_$P(PXIVD,".",2))
64 . . Q:(CHGIVD<IBEGDT)!(CHGIVD>IENDDT)
65 . . S PXVDF=""
66 . . F S PXVDF=$O(^AUPNVSIT("AAH",DFN,PXIVD,PXVDF)) Q:+PXVDF'>0 D GETREC^PXRHS02(PXVDF,$G(CATCODE),$G(EXTRCODE),"",.PXCNT) Q:PXCNT'<OCCLIM
67 Q
Note: See TracBrowser for help on using the repository browser.