SDAPI ;ALB/MJK - Outpatient API ; 22 FEB 1994 11:30 am
;;5.3;Scheduling;**27,44,97,132,1015**;08/13/93;Build 21
;
EN(DFN,SDT,SDCL,SDEVENT,SDERR,SDVIEN) ; -- main entry point for api
N SDROOT,SDMODE,SDRET,SDUZ,SDERROOT
;
; -- set init vars and do basic checks
D INIT(DFN,SDT,SDCL,.SDEVENT,.SDROOT,.SDMODE,.SDRET,.SDUZ)
IF $$ERRCHK^SDAPIER() G ENQ
;
; -- appointment check out event
IF @SDROOT@("EVENT")="CHECK-OUT" D G ENQ
. N SDOE
. S SDOE=$$EN^SDAPIAP(DFN,SDT,SDCL,SDUZ,SDMODE,$G(SDVIEN))
. S SDRET=$$FINAL(SDOE)
;
S SDT1=SDT ;this is to record the actual date for SDVSIT
; -- disposition event
IF @SDROOT@("EVENT")="DISPOSITION" D G ENQ
. N SDOE
. S SDOE=$$EN^SDAPIDP(DFN,SDT,SDCL,SDUZ,SDMODE,$G(SDVIEN))
. S SDRET=$$FINAL(SDOE)
;
; -- add/edit check out event ; return list of iens
IF @SDROOT@("EVENT")="ADD/EDIT CHECK-OUT" D G ENQ
. N SDOE
. S SDOE=$$EN^SDAPIAE0(DFN,SDT,SDCL,SDUZ,SDMODE,+$G(SDVIEN))
. S SDRET=$$FINAL(SDOE)
;
; -- delete appointment check out event
IF @SDROOT@("EVENT")="CHECK-OUT DELETE",$G(SDVIEN) D G ENQ
. N SDOE
. S SDOE=0
. F SDOE=$O(^SCE("AVSIT",SDVIEN,SDOE)) Q:'SDOE DO
..I $D(^SCE(+SDOE,0)) D EN^SDCODEL(SDOE,SDMODE,,"PCE")
..Q
.Q
;
ENQ D HDL
Q '$$ERRCHK^SDAPIER()_U_SDRET
;
INIT(DFN,SDT,SDCL,SDEVENT,SDROOT,SDMODE,SDRET,SDUZ) ; -- initialization of environment
S SDMODE="",SDRET=""
; -- set error root
S SDERROOT=$S($G(SDERR)]"":SDERR,1:"SDERR")
;
; -- set event root
S SDROOT=$S($G(SDEVENT)]"":SDEVENT,1:"SDEVENT")
;
; -- error if no event data
I $G(@SDROOT@("EVENT"))="" D ERRFILE^SDAPIER(1)
;
; -- kill evt drv handle
D HDL
;
; -- error if no patient
I '$D(^DPT(+$G(DFN),0)) D ERRFILE^SDAPIER(2,DFN)
;
; -- error if no user
S SDUZ=+$G(@SDROOT@("USER")) I '$D(^VA(200,SDUZ,0)) D ERRFILE^SDAPIER(3,SDUZ)
;
; -- error if not a clinic
I @SDROOT@("EVENT")'="DISPOSITION",$P($G(^SC(+$G(SDCL),0)),U,3)'="C" D ERRFILE^SDAPIER(4,SDCL)
;
; -- error if no encounter date
I SDT="" D ERRFILE^SDAPIER(5)
;
INITQ Q
;
FINAL(SDOE) ; -- set up return value
; -- return ien and status if c/o attempted
S SDRET=$S(SDOE:SDOE_U_$P($G(^SD(409.63,+$P($G(^SCE(SDOE,0)),U,12),0)),U),1:"")
I SDOE,'$$CHK^SDCOM(SDOE) D COMDT^SDCODEL(SDOE,0)
Q SDRET
;
;
HOST(PROTOCOL,MESSAGE) ; -- specify info by protocol
Q
N SDRESULT
S SDRESULT=$$EN(DFN,SDT,SDCL,SDUZ,.SDEVENT)
Q
;
HDL ; -- kill evt drv hanndle
I $G(@SDROOT@("KILL HANDLE")) D HDLKILL^SDAMEVT()
Q
;
SDAPI ;ALB/MJK - Outpatient API ; 22 FEB 1994 11:30 am
+1 ;;5.3;Scheduling;**27,44,97,132,1015**;08/13/93;Build 21
+2 ;
EN(DFN,SDT,SDCL,SDEVENT,SDERR,SDVIEN) ; -- main entry point for api
+1 NEW SDROOT,SDMODE,SDRET,SDUZ,SDERROOT
+2 ;
+3 ; -- set init vars and do basic checks
+4 DO INIT(DFN,SDT,SDCL,.SDEVENT,.SDROOT,.SDMODE,.SDRET,.SDUZ)
+5 IF $$ERRCHK^SDAPIER()
GOTO ENQ
+6 ;
+7 ; -- appointment check out event
+8 IF @SDROOT@("EVENT")="CHECK-OUT"
Begin DoDot:1
+9 NEW SDOE
+10 SET SDOE=$$EN^SDAPIAP(DFN,SDT,SDCL,SDUZ,SDMODE,$GET(SDVIEN))
+11 SET SDRET=$$FINAL(SDOE)
End DoDot:1
GOTO ENQ
+12 ;
+13 ;this is to record the actual date for SDVSIT
SET SDT1=SDT
+14 ; -- disposition event
+15 IF @SDROOT@("EVENT")="DISPOSITION"
Begin DoDot:1
+16 NEW SDOE
+17 SET SDOE=$$EN^SDAPIDP(DFN,SDT,SDCL,SDUZ,SDMODE,$GET(SDVIEN))
+18 SET SDRET=$$FINAL(SDOE)
End DoDot:1
GOTO ENQ
+19 ;
+20 ; -- add/edit check out event ; return list of iens
+21 IF @SDROOT@("EVENT")="ADD/EDIT CHECK-OUT"
Begin DoDot:1
+22 NEW SDOE
+23 SET SDOE=$$EN^SDAPIAE0(DFN,SDT,SDCL,SDUZ,SDMODE,+$GET(SDVIEN))
+24 SET SDRET=$$FINAL(SDOE)
End DoDot:1
GOTO ENQ
+25 ;
+26 ; -- delete appointment check out event
+27 IF @SDROOT@("EVENT")="CHECK-OUT DELETE"
IF $GET(SDVIEN)
Begin DoDot:1
+28 NEW SDOE
+29 SET SDOE=0
+30 FOR SDOE=$ORDER(^SCE("AVSIT",SDVIEN,SDOE))
IF 'SDOE
QUIT
Begin DoDot:2
+31 IF $DATA(^SCE(+SDOE,0))
DO EN^SDCODEL(SDOE,SDMODE,,"PCE")
+32 QUIT
End DoDot:2
+33 QUIT
End DoDot:1
GOTO ENQ
+34 ;
ENQ DO HDL
+1 QUIT '$$ERRCHK^SDAPIER()_U_SDRET
+2 ;
INIT(DFN,SDT,SDCL,SDEVENT,SDROOT,SDMODE,SDRET,SDUZ) ; -- initialization of environment
+1 SET SDMODE=""
SET SDRET=""
+2 ; -- set error root
+3 SET SDERROOT=$SELECT($GET(SDERR)]"":SDERR,1:"SDERR")
+4 ;
+5 ; -- set event root
+6 SET SDROOT=$SELECT($GET(SDEVENT)]"":SDEVENT,1:"SDEVENT")
+7 ;
+8 ; -- error if no event data
+9 IF $GET(@SDROOT@("EVENT"))=""
DO ERRFILE^SDAPIER(1)
+10 ;
+11 ; -- kill evt drv handle
+12 DO HDL
+13 ;
+14 ; -- error if no patient
+15 IF '$DATA(^DPT(+$GET(DFN),0))
DO ERRFILE^SDAPIER(2,DFN)
+16 ;
+17 ; -- error if no user
+18 SET SDUZ=+$GET(@SDROOT@("USER"))
IF '$DATA(^VA(200,SDUZ,0))
DO ERRFILE^SDAPIER(3,SDUZ)
+19 ;
+20 ; -- error if not a clinic
+21 IF @SDROOT@("EVENT")'="DISPOSITION"
IF $PIECE($GET(^SC(+$GET(SDCL),0)),U,3)'="C"
DO ERRFILE^SDAPIER(4,SDCL)
+22 ;
+23 ; -- error if no encounter date
+24 IF SDT=""
DO ERRFILE^SDAPIER(5)
+25 ;
INITQ QUIT
+1 ;
FINAL(SDOE) ; -- set up return value
+1 ; -- return ien and status if c/o attempted
+2 SET SDRET=$SELECT(SDOE:SDOE_U_$PIECE($GET(^SD(409.63,+$PIECE($GET(^SCE(SDOE,0)),U,12),0)),U),1:"")
+3 IF SDOE
IF '$$CHK^SDCOM(SDOE)
DO COMDT^SDCODEL(SDOE,0)
+4 QUIT SDRET
+5 ;
+6 ;
HOST(PROTOCOL,MESSAGE) ; -- specify info by protocol
+1 QUIT
+2 NEW SDRESULT
+3 SET SDRESULT=$$EN(DFN,SDT,SDCL,SDUZ,.SDEVENT)
+4 QUIT
+5 ;
HDL ; -- kill evt drv hanndle
+1 IF $GET(@SDROOT@("KILL HANDLE"))
DO HDLKILL^SDAMEVT()
+2 QUIT
+3 ;