VistA-Scheduling/m/BSDX25.m

219 lines
7.0 KiB
Mathematica
Raw Normal View History

BSDX25 ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 6/28/12 11:45am
;;1.6;BSDX;;Aug 31, 2011;Build 18
2011-05-03 04:28:05 -04:00
; Licensed under LGPL
2009-11-30 03:53:28 -05:00
;
2011-03-27 08:51:38 -04:00
; Change Log:
; 3110106: SMH -> Changed Check-in EP - Removed unused paramters. Will change C#
;
;
2009-11-30 03:53:28 -05:00
CHECKIND(BSDXY,BSDXAPTID,BSDXCDT,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXOG) ;EP
;Entry point for debugging
;
;I +$G(^BSDXDBUG("BREAK","CHECKIN")),+$G(^BSDXDBUG("BREAK"))=DUZ D DEBUG^%Serenji("CHECKIN^BSDX25(.BSDXY,BSDXAPTID,BSDXCDT,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXOG)",$P(^BSDXDBUG("BREAK"),U,2))
Q
;
CHECKIN(BSDXY,BSDXAPTID,BSDXCDT) ;Private EP Check in appointment
; Old additional vars: ,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXOG)
2011-01-09 07:26:23 -05:00
; Private to GUI; use BSDXAPI for general API to checkin patients
2011-03-27 08:51:38 -04:00
; Parameters:
; BSDXY: Global Out
; BSDXAPTID: Appointment ID in ^BSDXAPPT
; BSDXCDT: Checkin Date --> Changed
; BSDXCC: Clinic Stop IEN (not used)
; BSDXPRV: Provider IEN (not used)
; BSDXROU: Print Routing Slip? (not used)
; BSDXVCL: PCC+ Clinic IEN (not used)
; BSDXVFM: PCC+ Form IEN (not used)
; BSDXOG: PCC+ Outguide (true or false)
;
; Output:
; ADO.net table with 1 column ErrorID, 1 row result
; - 0 if all okay
; - Another number or text if not
;
N BSDXNOD,BSDXPATID,BSDXSTART,DIK,DA,BSDXID,BSDXZ,BSDXIENS,BSDXVEN
;
; Turn off SDAM Appointment Events BSDX Protocol Processing
2009-11-30 03:53:28 -05:00
N BSDXNOEV
S BSDXNOEV=1 ;Don't execute protocol
;
; Set min DUZ vars
D ^XBKVAR
;
; $ET
N $ET S $ET="G ERROR^BSDX25"
;
N BSDXI S BSDXI=0
2009-11-30 03:53:28 -05:00
K ^BSDXTMP($J)
S BSDXY="^BSDXTMP("_$J_")"
S ^BSDXTMP($J,0)="T00020ERRORID"_$C(30)
I '+BSDXAPTID D ERR("BSDX25: Invalid Appointment ID") Q
I '$D(^BSDXAPPT(BSDXAPTID,0)) D ERR("BSDX08: Invalid Appointment ID") Q
2011-01-09 07:26:23 -05:00
; Remove Date formatting v.1.5. Client will send date as FM Date.
;S:BSDXCDT["@0000" BSDXCDT=$P(BSDXCDT,"@")
;S %DT="T",X=BSDXCDT D ^%DT S BSDXCDT=Y
S BSDXCDT=+BSDXCDT ; Strip off zeros if C# sends them
2009-11-30 03:53:28 -05:00
I BSDXCDT=-1 D ERR(70) Q
I BSDXCDT>$$NOW^XLFDT S BSDXCDT=$$NOW^XLFDT
;Checkin BSDX APPOINTMENT entry
D BSDXCHK(BSDXAPTID,BSDXCDT)
S BSDXNOD=^BSDXAPPT(BSDXAPTID,0)
S BSDXPATID=$P(BSDXNOD,U,5)
S BSDXSTART=$P(BSDXNOD,U)
;
S BSDXSC1=$P(BSDXNOD,U,7) ;RESOURCEID
I BSDXSC1]"",$D(^BSDXRES(BSDXSC1,0)) D I +$G(BSDXZ) D ERR($P(BSDXZ,U,2)) Q
. S BSDXNOD=^BSDXRES(BSDXSC1,0)
. S BSDXSC1=$P(BSDXNOD,U,4) ;HOSPITAL LOCATION
. I BSDXSC1]"",$D(^SC(BSDXSC1,0)) D APCHK(.BSDXZ,BSDXSC1,BSDXPATID,BSDXCDT,BSDXSTART)
;
S BSDXI=BSDXI+1
S ^BSDXTMP($J,BSDXI)="0"_$C(30)
S BSDXI=BSDXI+1
S ^BSDXTMP($J,BSDXI)=$C(31)
Q
;
BSDXCHK(BSDXAPTID,BSDXCDT) ;
;
S BSDXIENS=BSDXAPTID_","
S BSDXFDA(9002018.4,BSDXIENS,.03)=BSDXCDT
D FILE^DIE("","BSDXFDA","BSDXMSG")
Q
;
APCHK(BSDXZ,BSDXSC1,BSDXDFN,BSDXCDT,BSDXSTART) ;
;Checkin appointment for patient BSDXDFN in clinic BSDXSC1
;at time BSDXSTART
S BSDXZ=$$CHECKIN1^BSDXAPI(BSDXDFN,BSDXSC1,BSDXSTART)
Q
;
2011-03-28 10:40:45 -04:00
RMCI(BSDXY,BSDXAPPTID) ; EP - Remove Check-in from BSDX APPT and 2/44
2011-03-27 01:33:30 -04:00
; Called by RPC [Fill in later]
;
; Parameters to pass:
; APPTID: IEN in file BSDX APPOINTMENT
;
; Return in global array:
; Record set with Column ERRORID; value of 0 AOK; other value
; --> means that something went wrong
2011-03-27 08:51:38 -04:00
;
; Error Reference:
; -1~Invalid Appointment ID (not passed)
; -2~Invalid Appointment ID (Doesn't exist in ^BSDXAPPT)
; -3~DB has corruption. Call Tech Support. (Resource ID doesn't exist in BSDXAPPT)
; -4~DB has corruption. Call Tech Support. (Resource ID in BSDXAPPT doesnt exist in BSDXRES)
; -5~BSDXAPI Error. Message depends on error.
; -100~Mumps Error
2011-03-27 08:51:38 -04:00
;
2011-03-27 01:33:30 -04:00
N BSDXNOEV S BSDXNOEV=1 ;Don't execute protocol
;
N $ET S $ET="G ERROR^BSDX25" ; Error Trap
;
; Set return variable and kill contents
S BSDXY=$NAME(^BSDXTMP($J))
2011-03-27 01:33:30 -04:00
K @BSDXY
;
N BSDXI S BSDXI=0 ; Initialize Counter
;
S ^BSDXTMP($J,BSDXI)="T00020ERRORID"_$C(30) ; Header of ADO recordset
;
2011-03-27 08:51:38 -04:00
TSTART (BSDXI):SERIAL ; Perform Autolocking
;
;;;test
I $g(bsdxdie) S X=8/0
;;;
I $g(bsdxrestart) k bsdxrestart TRESTART
;;;test
2011-03-27 01:33:30 -04:00
;
; Check for Appointment ID (passed and exists in file)
2011-03-27 08:51:38 -04:00
I '+$G(BSDXAPPTID) D ERR("-1~Invalid Appointment ID") QUIT
I '$D(^BSDXAPPT(BSDXAPPTID,0)) D ERR("-2~Invalid Appointment ID") QUIT
2011-03-27 01:33:30 -04:00
;
; Remove checkin from BSDX APPOINTMENT entry
2011-03-27 08:51:38 -04:00
D BSDXCHK(BSDXAPPTID,"@")
2011-03-27 01:33:30 -04:00
;
; Now, remove checkin from PIMS files 2/44
2011-03-27 08:51:38 -04:00
N BSDXNOD S BSDXNOD=^BSDXAPPT(BSDXAPPTID,0)
N BSDXPATID S BSDXPATID=$P(BSDXNOD,U,5) ; DFN
N BSDXSTART S BSDXSTART=$P(BSDXNOD,U) ; Start Date
2011-03-27 01:33:30 -04:00
N BSDXSC1 S BSDXSC1=$P(BSDXNOD,U,7) ; Resource ID
;
; If the resource doesn't exist, error out. DB is corrupt.
2011-03-27 08:51:38 -04:00
I 'BSDXSC1 D ERR("-3~DB has corruption. Call Tech Support.") QUIT
I '$D(^BSDXRES(BSDXSC1,0)) D ERR("-4~DB has corruption. Call Tech Support.") QUIT
2011-03-27 01:33:30 -04:00
;
N BSDXNOD S BSDXNOD=^BSDXRES(BSDXSC1,0) ; Resource 0 node
S BSDXSC1=$P(BSDXNOD,U,4) ;HOSPITAL LOCATION
;
N BSDXZ ; Scratch variable to hold error message
2011-03-27 08:51:38 -04:00
I BSDXSC1]"",$D(^SC(BSDXSC1,0)) S BSDXZ=$$RMCI^BSDXAPI(BSDXPATID,BSDXSC1,BSDXSTART)
I +$G(BSDXZ) D ERR("-5~"_$P(BSDXZ,U,2)) QUIT
2011-03-27 01:33:30 -04:00
;
TCOMMIT ; Save Data into Globals
;
; Return ADO recordset
S BSDXI=BSDXI+1
S ^BSDXTMP($J,BSDXI)="0"_$C(30)
S BSDXI=BSDXI+1
S ^BSDXTMP($J,BSDXI)=$C(31)
Q
;
2009-11-30 03:53:28 -05:00
CHKEVT(BSDXPAT,BSDXSTART,BSDXSC) ;EP Called by BSDX CHECKIN APPOINTMENT event
;when appointments CHECKIN via PIMS interface.
;Propagates CHECKIN to BSDXAPPT and raises refresh event to running GUI clients
;
Q:+$G(BSDXNOEV)
Q:'+$G(BSDXSC)
N BSDXSTAT,BSDXFOUND,BSDXRES
S BSDXSTAT=""
S:$G(SDATA("AFTER","STATUS"))["CHECKED IN" BSDXSTAT=$P(SDATA("AFTER","STATUS"),"^",4)
S BSDXFOUND=0
I $D(^BSDXRES("ALOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ALOC",BSDXSC,0)) S BSDXFOUND=$$CHKEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT)
I BSDXFOUND D CHKEVT3(BSDXRES) Q
I $D(^BXDXRES("ASSOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ASSOC",BSDXSC,0)) S BSDXFOUND=$$CHKEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT)
I BSDXFOUND D CHKEVT3(BSDXRES)
Q
;
CHKEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT) ;
;Get appointment id in BSDXAPT
;If found, call BSDXNOS(BSDXAPPT) and return 1
;else return 0
N BSDXFOUND,BSDXAPPT
S BSDXFOUND=0
Q:'+$G(BSDXRES) BSDXFOUND
Q:'$D(^BSDXAPPT("ARSRC",BSDXRES,BSDXSTART)) BSDXFOUND
S BSDXAPPT=0 F S BSDXAPPT=$O(^BSDXAPPT("ARSRC",BSDXRES,BSDXSTART,BSDXAPPT)) Q:'+BSDXAPPT D Q:BSDXFOUND
. S BSDXNOD=$G(^BSDXAPPT(BSDXAPPT,0)) Q:BSDXNOD=""
. I $P(BSDXNOD,U,5)=BSDXPAT,$P(BSDXNOD,U,12)="" S BSDXFOUND=1 Q
I BSDXFOUND,+$G(BSDXAPPT) D BSDXCHK(BSDXAPPT,BSDXSTAT)
Q BSDXFOUND
;
CHKEVT3(BSDXRES) ;
;Call RaiseEvent to notify GUI clients
;
N BSDXRESN
S BSDXRESN=$G(^BSDXRES(BSDXRES,0))
Q:BSDXRESN=""
S BSDXRESN=$P(BSDXRESN,"^")
D EVENT^BMXMEVN("BSDX SCHEDULE",BSDXRESN)
Q
;
ERROR ;
2011-03-27 08:51:38 -04:00
S $ETRAP="D ^%ZTER HALT" ; Emergency Error Trap for the wise
; Rollback, otherwise ^XTER will be empty from future rollback
I $TL>0 TROLLBACK
D ^%ZTER
S $EC="" ; Clear Error
; Log error message and send to client
D ERR("-100~Mumps Error")
2009-11-30 03:53:28 -05:00
Q
;
2011-03-27 01:33:30 -04:00
ERR(BSDXERR) ;Error processing
I $TLEVEL>0 TROLLBACK
2011-03-27 08:51:38 -04:00
S BSDXERR=$G(BSDXERR)
S BSDXERR=$P(BSDXERR,"~")_"~"_$TEXT(+0)_":"_$P(BSDXERR,"~",2) ; Append Routine Name
S BSDXI=$G(BSDXI)+1
2009-11-30 03:53:28 -05:00
S ^BSDXTMP($J,BSDXI)=BSDXERR_$C(30)
S BSDXI=BSDXI+1
S ^BSDXTMP($J,BSDXI)=$C(31)
2011-03-27 01:33:30 -04:00
QUIT