source: FOIAVistA/trunk/r/SCHEDULING-SD-SC/SDAPI.m@ 1671

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

initial load of FOIAVistA 6/30/08 version

File size: 2.4 KB
Line 
1SDAPI ;ALB/MJK - Outpatient API ; 22 FEB 1994 11:30 am
2 ;;5.3;Scheduling;**27,44,97,132**;08/13/93
3 ;
4EN(DFN,SDT,SDCL,SDEVENT,SDERR,SDVIEN) ; -- main entry point for api
5 N SDROOT,SDMODE,SDRET,SDUZ,SDERROOT
6 ;
7 ; -- set init vars and do basic checks
8 D INIT(DFN,SDT,SDCL,.SDEVENT,.SDROOT,.SDMODE,.SDRET,.SDUZ)
9 IF $$ERRCHK^SDAPIER() G ENQ
10 ;
11 ; -- appointment check out event
12 IF @SDROOT@("EVENT")="CHECK-OUT" D G ENQ
13 . N SDOE
14 . S SDOE=$$EN^SDAPIAP(DFN,SDT,SDCL,SDUZ,SDMODE,$G(SDVIEN))
15 . S SDRET=$$FINAL(SDOE)
16 ;
17 S SDT1=SDT ;this is to record the actual date for SDVSIT
18 ; -- disposition event
19 IF @SDROOT@("EVENT")="DISPOSITION" D G ENQ
20 . N SDOE
21 . S SDOE=$$EN^SDAPIDP(DFN,SDT,SDCL,SDUZ,SDMODE,$G(SDVIEN))
22 . S SDRET=$$FINAL(SDOE)
23 ;
24 ; -- add/edit check out event ; return list of iens
25 IF @SDROOT@("EVENT")="ADD/EDIT CHECK-OUT" D G ENQ
26 . N SDOE
27 . S SDOE=$$EN^SDAPIAE0(DFN,SDT,SDCL,SDUZ,SDMODE,+$G(SDVIEN))
28 . S SDRET=$$FINAL(SDOE)
29 ;
30 ; -- delete appointment check out event
31 IF @SDROOT@("EVENT")="CHECK-OUT DELETE",$G(SDVIEN) D G ENQ
32 . N SDOE
33 . S SDOE=0
34 . F SDOE=$O(^SCE("AVSIT",SDVIEN,SDOE)) Q:'SDOE DO
35 ..I $D(^SCE(+SDOE,0)) D EN^SDCODEL(SDOE,SDMODE,,"PCE")
36 ..Q
37 .Q
38 ;
39ENQ D HDL
40 Q '$$ERRCHK^SDAPIER()_U_SDRET
41 ;
42INIT(DFN,SDT,SDCL,SDEVENT,SDROOT,SDMODE,SDRET,SDUZ) ; -- initialization of environment
43 S SDMODE="",SDRET=""
44 ; -- set error root
45 S SDERROOT=$S($G(SDERR)]"":SDERR,1:"SDERR")
46 ;
47 ; -- set event root
48 S SDROOT=$S($G(SDEVENT)]"":SDEVENT,1:"SDEVENT")
49 ;
50 ; -- error if no event data
51 I $G(@SDROOT@("EVENT"))="" D ERRFILE^SDAPIER(1)
52 ;
53 ; -- kill evt drv handle
54 D HDL
55 ;
56 ; -- error if no patient
57 I '$D(^DPT(+$G(DFN),0)) D ERRFILE^SDAPIER(2,DFN)
58 ;
59 ; -- error if no user
60 S SDUZ=+$G(@SDROOT@("USER")) I '$D(^VA(200,SDUZ,0)) D ERRFILE^SDAPIER(3,SDUZ)
61 ;
62 ; -- error if not a clinic
63 I @SDROOT@("EVENT")'="DISPOSITION",$P($G(^SC(+$G(SDCL),0)),U,3)'="C" D ERRFILE^SDAPIER(4,SDCL)
64 ;
65 ; -- error if no encounter date
66 I SDT="" D ERRFILE^SDAPIER(5)
67 ;
68INITQ Q
69 ;
70FINAL(SDOE) ; -- set up return value
71 ; -- return ien and status if c/o attempted
72 S SDRET=$S(SDOE:SDOE_U_$P($G(^SD(409.63,+$P($G(^SCE(SDOE,0)),U,12),0)),U),1:"")
73 I SDOE,'$$CHK^SDCOM(SDOE) D COMDT^SDCODEL(SDOE,0)
74 Q SDRET
75 ;
76 ;
77HOST(PROTOCOL,MESSAGE) ; -- specify info by protocol
78 Q
79 N SDRESULT
80 S SDRESULT=$$EN(DFN,SDT,SDCL,SDUZ,.SDEVENT)
81 Q
82 ;
83HDL ; -- kill evt drv hanndle
84 I $G(@SDROOT@("KILL HANDLE")) D HDLKILL^SDAMEVT()
85 Q
86 ;
Note: See TracBrowser for help on using the repository browser.