ADGREADM ; IHS/ADC/PDW/ENM - READMISSION CHECKS ; [ 03/25/1999 11:48 AM ]
;;5.0;ADMISSION/DISCHARGE/TRANSFER;;MAR 25, 1999
;
;***> called by other routines to check if patient was readmitted
;within time limits set by facility as stated in site parameters
;Input variables: DFN=patient internal #
; DGPMDA=admission internal #
;
I '$D(DGOPT) D VAR^ADGVAR
K DGRE,DGLSTA,DGDS,DGDSA Q:'$D(DFN) Q:'$D(DGPMDA)
LAD ; -- last admission
S DGLSTA=+$G(^DGPM(+$$M3P,0)) S:$$RE DGRE="A"
LDS ;--last day surgery
S (DGDSA,DGDS)="" Q:'$D(^ADGDS(DFN))
S DGDSA=$$DSP,DGDS=+$G(^ADGDS(DFN,"DS",+DGDSA,0))
Q:$P($G(^ADGDS(DFN,"DS",+DGDSA,2)),U,3,4)["Y" ;no-show or canceled
Q:'DGDS S X=DGDT D H^%DTC S X1=%H,X=DGDS D H^%DTC
I (X1'<%H),(X1-%H)'>$P(DGOPT("QA1"),U,2) D
. S DGRE=$S($D(DGRE):"A&D",1:"D")
I $P($G(^ADGDS(DFN,"DS",+DGDSA,2)),U,2)="Y",$D(DGRE) D
. S DGRE=$S(DGRE["A":"A&DS",1:"DS") ;adm directly from DS
Q
;
RE() ; -- readmission
N X,Y S X=+$G(^DGPM(+$$M3P,0)) D H^%DTC S Y=%H
S X=+^DGPM(DGPMDA,0) D H^%DTC Q $S((%H-Y)'>$$RA:1,1:0)
;
RA() ; -- QA time length for readmission
Q +$G(^DG(43,1,9999999.02))
;
M3P() ; -- movement, discharge, previous
Q $O(^DGPM("ATID3",DFN,+$O(^DGPM("ATID3",DFN,9999999.9999999-^DGPM(DGPMDA,0))),0))
;
M1P() ; -- movement, admission, previous
Q $O(^DGPM("ATID1",DFN,+$O(^DGPM("ATID1",DFN,9999999.9999999-^DGPM(DGPMDA,0))),0))
;
DSP() ; -- day surgery previous
Q $O(^ADGDS("APID",DFN,+$O(^ADGDS("APID",DFN,9999999.9999999-^DGPM(DGPMDA,0))),0))
ADGREADM ; IHS/ADC/PDW/ENM - READMISSION CHECKS ; [ 03/25/1999 11:48 AM ]
+1 ;;5.0;ADMISSION/DISCHARGE/TRANSFER;;MAR 25, 1999
+2 ;
+3 ;***> called by other routines to check if patient was readmitted
+4 ;within time limits set by facility as stated in site parameters
+5 ;Input variables: DFN=patient internal #
+6 ; DGPMDA=admission internal #
+7 ;
+8 IF '$DATA(DGOPT)
DO VAR^ADGVAR
+9 KILL DGRE,DGLSTA,DGDS,DGDSA
IF '$DATA(DFN)
QUIT
IF '$DATA(DGPMDA)
QUIT
LAD ; -- last admission
+1 SET DGLSTA=+$GET(^DGPM(+$$M3P,0))
IF $$RE
SET DGRE="A"
LDS ;--last day surgery
+1 SET (DGDSA,DGDS)=""
IF '$DATA(^ADGDS(DFN))
QUIT
+2 SET DGDSA=$$DSP
SET DGDS=+$GET(^ADGDS(DFN,"DS",+DGDSA,0))
+3 ;no-show or canceled
IF $PIECE($GET(^ADGDS(DFN,"DS",+DGDSA,2)),U,3,4)["Y"
QUIT
+4 IF 'DGDS
QUIT
SET X=DGDT
DO H^%DTC
SET X1=%H
SET X=DGDS
DO H^%DTC
+5 IF (X1'<%H)
IF (X1-%H)'>$PIECE(DGOPT("QA1"),U,2)
Begin DoDot:1
+6 SET DGRE=$SELECT($DATA(DGRE):"A&D",1:"D")
End DoDot:1
+7 IF $PIECE($GET(^ADGDS(DFN,"DS",+DGDSA,2)),U,2)="Y"
IF $DATA(DGRE)
Begin DoDot:1
+8 ;adm directly from DS
SET DGRE=$SELECT(DGRE["A":"A&DS",1:"DS")
End DoDot:1
+9 QUIT
+10 ;
RE() ; -- readmission
+1 NEW X,Y
SET X=+$GET(^DGPM(+$$M3P,0))
DO H^%DTC
SET Y=%H
+2 SET X=+^DGPM(DGPMDA,0)
DO H^%DTC
QUIT $SELECT((%H-Y)'>$$RA:1,1:0)
+3 ;
RA() ; -- QA time length for readmission
+1 QUIT +$GET(^DG(43,1,9999999.02))
+2 ;
M3P() ; -- movement, discharge, previous
+1 QUIT $ORDER(^DGPM("ATID3",DFN,+$ORDER(^DGPM("ATID3",DFN,9999999.9999999-^DGPM(DGPMDA,0))),0))
+2 ;
M1P() ; -- movement, admission, previous
+1 QUIT $ORDER(^DGPM("ATID1",DFN,+$ORDER(^DGPM("ATID1",DFN,9999999.9999999-^DGPM(DGPMDA,0))),0))
+2 ;
DSP() ; -- day surgery previous
+1 QUIT $ORDER(^ADGDS("APID",DFN,+$ORDER(^ADGDS("APID",DFN,9999999.9999999-^DGPM(DGPMDA,0))),0))