SDVSIT2 ;ALB/RMO/MJK - Encounter Utilities;28 DEC 1992 10:00 am
;;5.3;Scheduling;**27,44,132,1015**;08/13/93;Build 21
;IHS/ANMC/LJF 1/02/2002 if visit already on entry, just quit
;
GETAPT(DFN,SDT,SDCL,SDVIEN) ;Look-up Outpatient Encounter IEN for Appt
; Input -- DFN Patient file IEN
; SDT Appointment Date/Time
; SDCL Hospital Location file IEN for Appt
; SDVIEN Visit file pointer [optional]
; Output -- Outpatient Encounter file IEN
N Y
S Y=+$P($G(^DPT(DFN,"S",SDT,0)),"^",20)
I 'Y D APPT^SDVSIT(DFN,SDT,SDCL,$G(SDVIEN)) S Y=+$P($G(^DPT(DFN,"S",SDT,0)),"^",20)
;ihs/cmi/maw 02/23/2012 1015 gonna leave this commented out for now to see if fixes EHR
;I Y,$P($G(^SCE(Y,0)),U,5)]"" Q Y ;IHS/ANMC/LJF 1/02/2002
IF Y D VIEN(Y,$G(SDVIEN))
Q +$G(Y)
;
GETAE(SDVIEN,SDATYPE,SDOPE) ;Look-up Outpatient Encounter IEN for add/edit
; Input -- SDVIEN Visit file pointer
; SDATYPE Appointment Type [optional]
; SDOEP Parent encounter ien [optional]
;
; Output -- Outpatient Encounter file IEN
N Y
S Y=+$O(^SCE("AVSIT",SDVIEN,0))
I 'Y D AEUPD^SDVSIT(SDVIEN,$G(SDATYPE),$G(SDOPE)) S Y=+$O(^SCE("AVSIT",SDVIEN,0))
IF Y D VIEN(Y,SDVIEN)
Q +$G(Y)
;
GETDISP(DFN,SDT,SDVIEN) ;Look-up Outpatient Encounter IEN for disposition
; Input -- DFN Patient file IEN
; SDT Disposition Date/Time
; SDVIEN Visit file pointer [optional]
; Output -- Outpatient Encounter file IEN
N Y
S Y=+$P($G(^DPT(DFN,"DIS",9999999-SDT,0)),"^",18)
I 'Y D DISP^SDVSIT(DFN,SDT,$G(SDVIEN)) S Y=+$P($G(^DPT(DFN,"DIS",9999999-SDT,0)),"^",18)
IF Y D VIEN(Y,$G(SDVIEN))
Q +$G(Y)
;
OKAE(SDOE) ; -- is add/edit ok for credit
N Y,X S Y=1
S X=$G(^SCE(SDOE,0))
I $$REQ^SDM1A(+X)="CO",'$P(X,U,7) S Y=0
Q Y
;
VIEN(SDOE,SDVIEN) ; -- stuff in Visit IEN if not already set
; -- needed for those sites that don't have
; scheduling turned on in Visit Tracking
; Required input SDOE = Outpatient Encounter pointer
; SDVIEN = Visit file pointer or null or zero
;
; -- quit if no vien passed
G VIENQ:'SDVIEN
N Y,SDOE0
S SDOE0=$G(^SCE(+SDOE,0))
; -- quit is no encounter
G VIENQ:SDOE0=""
; -- set visit ien if vien not already set
IF '$P(SDOE0,U,5) D
. N DIE,DA,DR
. S DIE="^SCE(",DA=SDOE,DR=".05////"_SDVIEN D ^DIE
IF '$P(SDOE0,U,4) D
. N DIE,DA,DR,SDLOC
. S SDLOC=$P($G(^AUPNVSIT(SDVIEN,0)),U,22)
. IF SDLOC S DIE="^SCE(",DA=SDOE,DR=".04////"_SDLOC D ^DIE
VIENQ Q
;
SDVSIT2 ;ALB/RMO/MJK - Encounter Utilities;28 DEC 1992 10:00 am
+1 ;;5.3;Scheduling;**27,44,132,1015**;08/13/93;Build 21
+2 ;IHS/ANMC/LJF 1/02/2002 if visit already on entry, just quit
+3 ;
GETAPT(DFN,SDT,SDCL,SDVIEN) ;Look-up Outpatient Encounter IEN for Appt
+1 ; Input -- DFN Patient file IEN
+2 ; SDT Appointment Date/Time
+3 ; SDCL Hospital Location file IEN for Appt
+4 ; SDVIEN Visit file pointer [optional]
+5 ; Output -- Outpatient Encounter file IEN
+6 NEW Y
+7 SET Y=+$PIECE($GET(^DPT(DFN,"S",SDT,0)),"^",20)
+8 IF 'Y
DO APPT^SDVSIT(DFN,SDT,SDCL,$GET(SDVIEN))
SET Y=+$PIECE($GET(^DPT(DFN,"S",SDT,0)),"^",20)
+9 ;ihs/cmi/maw 02/23/2012 1015 gonna leave this commented out for now to see if fixes EHR
+10 ;I Y,$P($G(^SCE(Y,0)),U,5)]"" Q Y ;IHS/ANMC/LJF 1/02/2002
+11 IF Y
DO VIEN(Y,$GET(SDVIEN))
+12 QUIT +$GET(Y)
+13 ;
GETAE(SDVIEN,SDATYPE,SDOPE) ;Look-up Outpatient Encounter IEN for add/edit
+1 ; Input -- SDVIEN Visit file pointer
+2 ; SDATYPE Appointment Type [optional]
+3 ; SDOEP Parent encounter ien [optional]
+4 ;
+5 ; Output -- Outpatient Encounter file IEN
+6 NEW Y
+7 SET Y=+$ORDER(^SCE("AVSIT",SDVIEN,0))
+8 IF 'Y
DO AEUPD^SDVSIT(SDVIEN,$GET(SDATYPE),$GET(SDOPE))
SET Y=+$ORDER(^SCE("AVSIT",SDVIEN,0))
+9 IF Y
DO VIEN(Y,SDVIEN)
+10 QUIT +$GET(Y)
+11 ;
GETDISP(DFN,SDT,SDVIEN) ;Look-up Outpatient Encounter IEN for disposition
+1 ; Input -- DFN Patient file IEN
+2 ; SDT Disposition Date/Time
+3 ; SDVIEN Visit file pointer [optional]
+4 ; Output -- Outpatient Encounter file IEN
+5 NEW Y
+6 SET Y=+$PIECE($GET(^DPT(DFN,"DIS",9999999-SDT,0)),"^",18)
+7 IF 'Y
DO DISP^SDVSIT(DFN,SDT,$GET(SDVIEN))
SET Y=+$PIECE($GET(^DPT(DFN,"DIS",9999999-SDT,0)),"^",18)
+8 IF Y
DO VIEN(Y,$GET(SDVIEN))
+9 QUIT +$GET(Y)
+10 ;
OKAE(SDOE) ; -- is add/edit ok for credit
+1 NEW Y,X
SET Y=1
+2 SET X=$GET(^SCE(SDOE,0))
+3 IF $$REQ^SDM1A(+X)="CO"
IF '$PIECE(X,U,7)
SET Y=0
+4 QUIT Y
+5 ;
VIEN(SDOE,SDVIEN) ; -- stuff in Visit IEN if not already set
+1 ; -- needed for those sites that don't have
+2 ; scheduling turned on in Visit Tracking
+3 ; Required input SDOE = Outpatient Encounter pointer
+4 ; SDVIEN = Visit file pointer or null or zero
+5 ;
+6 ; -- quit if no vien passed
+7 IF 'SDVIEN
GOTO VIENQ
+8 NEW Y,SDOE0
+9 SET SDOE0=$GET(^SCE(+SDOE,0))
+10 ; -- quit is no encounter
+11 IF SDOE0=""
GOTO VIENQ
+12 ; -- set visit ien if vien not already set
+13 IF '$PIECE(SDOE0,U,5)
Begin DoDot:1
+14 NEW DIE,DA,DR
+15 SET DIE="^SCE("
SET DA=SDOE
SET DR=".05////"_SDVIEN
DO ^DIE
End DoDot:1
+16 IF '$PIECE(SDOE0,U,4)
Begin DoDot:1
+17 NEW DIE,DA,DR,SDLOC
+18 SET SDLOC=$PIECE($GET(^AUPNVSIT(SDVIEN,0)),U,22)
+19 IF SDLOC
SET DIE="^SCE("
SET DA=SDOE
SET DR=".04////"_SDLOC
DO ^DIE
End DoDot:1
VIENQ QUIT
+1 ;