PXRHS14 ;ISL/SBW - PCE Visit data extract routine ;7/25/96 09:06
;;1.0;PCE PATIENT CARE ENCOUNTER;;Aug 12, 1996
; Extract returns visit data in block of OCCLIM. Can be called multiple
; times for a patient. Parameter passing by reference with FROM and
; RECNO variables allows the routine to process multiple calls without
; missing data.
VISIT(DFN,FROM,RECNO,OCCLIM,CATCODE,PSTAT) ; Control branching
;INPUT: DFN - Pointer to PATIENT file (#2).
; FROM - Index entry from which to begin the list.
; Passed by reference.
; RECNO - Record number. Passed by reference.
; - Should be null for 1st call to this entry point.
; OCCLIM - Maximum number of visits to return.
; CATCODE - Pattern Match which controls visit data that is
; returned (Can include multiple codes).
; A = AMBULATORY
; H = HOSPITALIZATION
; I = IN HOSPITAL
; C = CHART REVIEW
; T = TELECOMMUNICATIONS
; N = NOT FOUND
; S = DAY SURGERY
; O = OBSERVATION
; E = EVENT (HISTORICAL)
; R = NURSING HOME
; D = DAILY HOSPITALIZATION DATA
; X = ANCILLARY PACKAGE DAILY DATA
; PSTAT - Patient Status.
; 1 = Inpatient
; 0 or NULL = Outpatient
;
;OUTPUT:
; Data from VISIT (9000010) file except for hosp. loc. abbr.
; ^TMP("PXV",$J,InvExDt,RecNo,0) = VISIT/ADMIT DATE&TIME [I;.01]
; ^ LOC. OF ENCOUNTER [E;.06] ^ SERVICE CATEGORY [E;.07]
; ^ CLINIC [E;.08] ^ WALK IN/APPT (deleted field always null)[E;.16]
; ^ EVALUATION AND MANAGEMENT CODE (deleted field always null)[E;.17]
; ^ HOSPITAL LOCATION [E;.22]
;
; [] = [I(nternal)/E(xternal); Field #]
; Subscripts:
; InvExDt - Inverted Visit Date from "AA" x-ref
; RecNo - Record Number
;
; Calling routine is required to delete ^TMP("PXV",$J). It can be
; deleted between multiple calls to this entry point or after
; the calling routine makes the last call depending on how the data
; needs to be accumulated.
Q:$G(DFN)']""!'$D(^AUPNVSIT("AA",DFN))
N PXCNT,FIRST
N DIC,DIQ,DR,DA,VISIT,LOC,SERCAT,CLINIC,WALKAPT,LEVEL,HLOC
S FIRST=1
S:+$G(OCCLIM)'>0 OCCLIM=999
S:+$G(FROM)'>0 FROM=""
S:+$G(RECNO)'>0 RECNO=""
S PXCNT=0
F S:(RECNO=""!'FIRST) FROM=$O(^AUPNVSIT("AA",DFN,FROM)) Q:+FROM'>0 D Q:PXCNT'<OCCLIM
. I 'FIRST S RECNO=0
. S FIRST=0
. F S RECNO=$O(^AUPNVSIT("AA",DFN,FROM,RECNO)) Q:+RECNO'>0 D Q:PXCNT'<OCCLIM
. . N REC
. . S DIC=9000010,DA=RECNO,DIQ="REC(",DIQ(0)="IE"
. . S DR=".01;.06;.07;.08;.09;.11;.22;15002"
. . D EN^DIQ1
. . Q:'$D(REC)
. . Q:$G(CATCODE)'[REC(9000010,DA,.07,"I")!(REC(9000010,DA,.09,"I")'>0)!+(REC(9000010,DA,.11,"I"))!(+$G(PSTAT)'=+REC(9000010,DA,15002,"I"))
. . S VISIT=REC(9000010,DA,.01,"I")
. . S LOC=REC(9000010,DA,.06,"E")
. . S SERCAT=REC(9000010,DA,.07,"E")
. . S CLINIC=REC(9000010,DA,.08,"E")
. . ;- return null for deleted fields .16 and .17
. . S WALKAPT="" ;REC(9000010,DA,.16,"E")
. . S LEVEL="" ;REC(9000010,DA,.17,"E")
. . S HLOC=REC(9000010,DA,.22,"E")
. . S ^TMP("PXV",$J,FROM,RECNO)=VISIT_U_LOC_U_SERCAT_U_CLINIC_U_WALKAPT_U_HLOC
. . S PXCNT=PXCNT+1
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXRHS14 3413 printed Oct 16, 2024@18:31:09 Page 2
PXRHS14 ;ISL/SBW - PCE Visit data extract routine ;7/25/96 09:06
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;;Aug 12, 1996
+2 ; Extract returns visit data in block of OCCLIM. Can be called multiple
+3 ; times for a patient. Parameter passing by reference with FROM and
+4 ; RECNO variables allows the routine to process multiple calls without
+5 ; missing data.
VISIT(DFN,FROM,RECNO,OCCLIM,CATCODE,PSTAT) ; Control branching
+1 ;INPUT: DFN - Pointer to PATIENT file (#2).
+2 ; FROM - Index entry from which to begin the list.
+3 ; Passed by reference.
+4 ; RECNO - Record number. Passed by reference.
+5 ; - Should be null for 1st call to this entry point.
+6 ; OCCLIM - Maximum number of visits to return.
+7 ; CATCODE - Pattern Match which controls visit data that is
+8 ; returned (Can include multiple codes).
+9 ; A = AMBULATORY
+10 ; H = HOSPITALIZATION
+11 ; I = IN HOSPITAL
+12 ; C = CHART REVIEW
+13 ; T = TELECOMMUNICATIONS
+14 ; N = NOT FOUND
+15 ; S = DAY SURGERY
+16 ; O = OBSERVATION
+17 ; E = EVENT (HISTORICAL)
+18 ; R = NURSING HOME
+19 ; D = DAILY HOSPITALIZATION DATA
+20 ; X = ANCILLARY PACKAGE DAILY DATA
+21 ; PSTAT - Patient Status.
+22 ; 1 = Inpatient
+23 ; 0 or NULL = Outpatient
+24 ;
+25 ;OUTPUT:
+26 ; Data from VISIT (9000010) file except for hosp. loc. abbr.
+27 ; ^TMP("PXV",$J,InvExDt,RecNo,0) = VISIT/ADMIT DATE&TIME [I;.01]
+28 ; ^ LOC. OF ENCOUNTER [E;.06] ^ SERVICE CATEGORY [E;.07]
+29 ; ^ CLINIC [E;.08] ^ WALK IN/APPT (deleted field always null)[E;.16]
+30 ; ^ EVALUATION AND MANAGEMENT CODE (deleted field always null)[E;.17]
+31 ; ^ HOSPITAL LOCATION [E;.22]
+32 ;
+33 ; [] = [I(nternal)/E(xternal); Field #]
+34 ; Subscripts:
+35 ; InvExDt - Inverted Visit Date from "AA" x-ref
+36 ; RecNo - Record Number
+37 ;
+38 ; Calling routine is required to delete ^TMP("PXV",$J). It can be
+39 ; deleted between multiple calls to this entry point or after
+40 ; the calling routine makes the last call depending on how the data
+41 ; needs to be accumulated.
+42 if $GET(DFN)']""!'$DATA(^AUPNVSIT("AA",DFN))
QUIT
+43 NEW PXCNT,FIRST
+44 NEW DIC,DIQ,DR,DA,VISIT,LOC,SERCAT,CLINIC,WALKAPT,LEVEL,HLOC
+45 SET FIRST=1
+46 if +$GET(OCCLIM)'>0
SET OCCLIM=999
+47 if +$GET(FROM)'>0
SET FROM=""
+48 if +$GET(RECNO)'>0
SET RECNO=""
+49 SET PXCNT=0
+50 FOR
if (RECNO=""!'FIRST)
SET FROM=$ORDER(^AUPNVSIT("AA",DFN,FROM))
if +FROM'>0
QUIT
Begin DoDot:1
+51 IF 'FIRST
SET RECNO=0
+52 SET FIRST=0
+53 FOR
SET RECNO=$ORDER(^AUPNVSIT("AA",DFN,FROM,RECNO))
if +RECNO'>0
QUIT
Begin DoDot:2
+54 NEW REC
+55 SET DIC=9000010
SET DA=RECNO
SET DIQ="REC("
SET DIQ(0)="IE"
+56 SET DR=".01;.06;.07;.08;.09;.11;.22;15002"
+57 DO EN^DIQ1
+58 if '$DATA(REC)
QUIT
+59 if $GET(CATCODE)'[REC(9000010,DA,.07,"I")!(REC(9000010,DA,.09,"I")'>0)!+(REC(9000010,DA,.11,"I"))!(+$GET(PSTAT)'=+REC(9000010,DA,15002,"I"))
QUIT
+60 SET VISIT=REC(9000010,DA,.01,"I")
+61 SET LOC=REC(9000010,DA,.06,"E")
+62 SET SERCAT=REC(9000010,DA,.07,"E")
+63 SET CLINIC=REC(9000010,DA,.08,"E")
+64 ;- return null for deleted fields .16 and .17
+65 ;REC(9000010,DA,.16,"E")
SET WALKAPT=""
+66 ;REC(9000010,DA,.17,"E")
SET LEVEL=""
+67 SET HLOC=REC(9000010,DA,.22,"E")
+68 SET ^TMP("PXV",$JOB,FROM,RECNO)=VISIT_U_LOC_U_SERCAT_U_CLINIC_U_WALKAPT_U_HLOC
+69 SET PXCNT=PXCNT+1
End DoDot:2
if PXCNT'<OCCLIM
QUIT
End DoDot:1
if PXCNT'<OCCLIM
QUIT
+70 QUIT