SDESAPPTREQ2 ;ALB/ANU - APPOINTMENT REQUEST CREATE/UPDATE IN FILE2 ;Feb 16, 2022
;;5.3;Scheduling;**809**;Aug 13, 1993;Build 10
;;Per VHA Directive 6402, this routine should not be modified
;
Q
; This entry point is used for both the SDES SET APT REQ 2 CREATE and SDES SET APT REQ 2 UPDATE RPCs.
; The parameter list for each RPC must be kept in sync. This includes in the Remote Procedure file definition.
;
ARSET(SDECY,SDAPPTUPD,SDPATIENTDFN,SDCLNIEN,SDAPPTDTTM,SDLABDTTM,SDXRAYDTTM,SDEKGDTTM,SDVSTPURP,SDAPPTTYPE,SDCOLLATERAL,SDSCHREQTYPE,SDNXTAVAAPPT,SDFOLLOWUP) ; Create/Update Appointment Request
; INP - Input parameters array
;
; SDAPPTUPD = (req - integer) 1 for Update and 0 for Create Appointment
; SDPATIENTDFN = (req - integer) DFN Pointer to PATIENT file 2
; SDCLNIEN = (req - integer) IEN point to HOSPTIAL LOCATION file 44
; SDAPPTDTTM = (req - date) appointment date and time in ISO 8601 extended format (e.g. 2022-01-19T20:15:44)
; SDLABDTTM = (date) Lab Date/Time
; SDXRAYDTTM = (date) X-Ray Date/Time
; SDEKGDTTM = (date) EKG Date/Time
; SDVSTPURP = (req - integer) Visit Purpose (Values - 1 to 4)
; SDAPPTTYPE = (text) Appointment Type, Pointer to #409.1 (required for create)
; SDCOLLATERAL = (integer) Collateral Visit (1,0)
; SDSCHREQTYPE = (req - text) Scheduling Request Type (N,C,P etc.,)
; SDNXTAVAAPPT = (req - integer) Next Available Appointment Indicator (0,1,2,3)
; SDFOLLOWUP = (integer) Followup Visit
;
N POP,SDAPTREQ
;
D VALIDATE
I 'POP D
.I +SDAPPTUPD=1 D UPDATE Q
.I +SDAPPTUPD=0 D CREATE Q
D BUILDER
Q
;
VALIDATE ; Validate
;
S POP=0
;
;
I SDAPPTUPD'=1,SDAPPTUPD'=0 S SDAPTREQ("Error",1)="Invalid Update Flag." Q
;
; Patient DFN
S SDPATIENTDFN=$G(SDPATIENTDFN,"")
I SDPATIENTDFN="" S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,1) Q
I SDPATIENTDFN'="",'$D(^DPT(+SDPATIENTDFN,0)) S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,2) Q
;
; Clinic IEN
S SDCLNIEN=$G(SDCLNIEN,"")
I SDCLNIEN="" S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,18) Q
I '$D(^SC(+SDCLNIEN,0)) S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,19) Q
I $$INACTIVE^SDEC32(+SDCLNIEN) S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,19) Q
;
; Appointment Type
S SDAPPTTYPE=$G(SDAPPTTYPE,"")
I SDAPPTUPD=0,SDAPPTTYPE="" D ERRLOG^SDESJSON(.SDAPTREQ,60) S POP=1 Q
I SDAPPTTYPE'="",('$D(^SD(409.1,"B",SDAPPTTYPE))) D ERRLOG^SDESJSON(.SDAPTREQ,61) S POP=1 Q
I SDAPPTTYPE'="",($D(^SD(409.1,"B",SDAPPTTYPE))) S SDAPPTTYPE=$O(^SD(409.1,"B",SDAPPTTYPE,0))
;
; Appointment date/time of appt
S SDAPPTDTTM=$G(SDAPPTDTTM,"")
I SDAPPTDTTM="" S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,76) Q
S SDAPPTDTTM=$$ISOTFM^SDAMUTDT(SDAPPTDTTM,SDCLNIEN)
;S SDAPPTDTTM=$$GMTTFM^SDAMUTDT(SDAPPTDTTM)
I SDAPPTDTTM=-1 S SDAPPTDTTM="",POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,77) Q
I SDAPPTUPD=0,SDAPPTDTTM<DT S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,59) Q
;
; Lab Dt/Tm
S SDLABDTTM=$G(SDLABDTTM,"")
I SDLABDTTM'="" S SDLABDTTM=$$ISOTFM^SDAMUTDT(SDLABDTTM,SDCLNIEN)
;I SDLABDTTM'="" S SDLABDTTM=$$GMTTFM^SDAMUTDT(SDLABDTTM)
I SDLABDTTM=-1 S SDLABDTTM="",POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,147) Q
;
; XRAY Dt/Tm
S SDXRAYDTTM=$G(SDXRAYDTTM,"")
I SDXRAYDTTM'="" S SDXRAYDTTM=$$ISOTFM^SDAMUTDT(SDXRAYDTTM,SDCLNIEN)
;I SDXRAYDTTM'="" S SDXRAYDTTM=$$GMTTFM^SDAMUTDT(SDXRAYDTTM)
I SDXRAYDTTM=-1 S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,145) Q
;
; EKG Dt/Tm
S SDEKGDTTM=$G(SDEKGDTTM,"")
I SDEKGDTTM'="" S SDEKGDTTM=$$ISOTFM^SDAMUTDT(SDEKGDTTM,SDCLNIEN)
;I SDEKGDTTM'="" S SDEKGDTTM=$$GMTTFM^SDAMUTDT(SDEKGDTTM)
I SDEKGDTTM=-1 S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,146) Q
;
; Purpose of Visit
S SDVSTPURP=$G(SDVSTPURP,"")
S SDVSTPURP=$E(SDVSTPURP,1,1)
I SDVSTPURP="" S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,149) Q
I "1234"'[+SDVSTPURP S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,148) Q
;
; Collateral Visit
S SDCOLLATERAL=$G(SDCOLLATERAL,"")
S SDCOLLATERAL=$E(SDCOLLATERAL,1,1)
I SDCOLLATERAL'="",("01"'[SDCOLLATERAL) S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,150) Q
;
; Scheduling Request Type
S SDSCHREQTYPE=$G(SDSCHREQTYPE,"")
S SDSCHREQTYPE=$E(SDSCHREQTYPE,1,1)
I SDSCHREQTYPE="" S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,151) Q
I ("NCPWMAO"'[SDSCHREQTYPE) S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,152) Q
;
; Next Available Appointment Indicator
S SDNXTAVAAPPT=$G(SDNXTAVAAPPT,"")
S SDNXTAVAAPPT=$E(SDNXTAVAAPPT,1,1)
I SDNXTAVAAPPT="" S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,154) Q
I ("0123"'[SDNXTAVAAPPT) S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,153) Q
;
; Followup Visit
S SDFOLLOWUP=$G(SDFOLLOWUP,"")
I SDFOLLOWUP'="",("01"'[SDFOLLOWUP) S POP=1 D ERRLOG^SDESJSON(.SDAPTREQ,155) Q
;
Q
;
CREATE ;Build FDA array to creat a new entry in 2
; add appt to file 2
N SDECFDA,SDECIENS,SDERR
I $D(^DPT(SDPATIENTDFN,"S",SDAPPTDTTM,0)) S SDAPTREQ("Error",1)="Appointment Already Exists in File #2 for this Date/Time" Q
S SDECIENS="?+2,"_SDPATIENTDFN_","
S SDECIENS(2)=SDAPPTDTTM
S SDECFDA(2.98,SDECIENS,".01")=$$NULLDEL(SDCLNIEN)
S SDECFDA(2.98,SDECIENS,"3")=$S($G(^DPT(+$G(SDPATIENTDFN),.1))'="":"I",1:"")
S SDECFDA(2.98,SDECIENS,"5")=$$NULLDEL(SDLABDTTM) ;lab date/time
S SDECFDA(2.98,SDECIENS,"6")=$$NULLDEL(SDXRAYDTTM) ;xray date/time
S SDECFDA(2.98,SDECIENS,"7")=$$NULLDEL(SDEKGDTTM) ;ekg date/time
S SDECFDA(2.98,SDECIENS,"9")=$$NULLDEL(SDVSTPURP) ;Purpose of Visit
S SDECFDA(2.98,SDECIENS,"9.5")=$$NULLDEL(SDAPPTTYPE)
S SDECFDA(2.98,SDECIENS,"13")=$$NULLDEL(SDCOLLATERAL) ; Collateral Visit
S SDECFDA(2.98,SDECIENS,"14")="@"
S SDECFDA(2.98,SDECIENS,"15")="@"
S SDECFDA(2.98,SDECIENS,"16")="@"
S SDECFDA(2.98,SDECIENS,"17")="@"
S SDECFDA(2.98,SDECIENS,"19")=$$NULLDEL(DUZ) ;data entry clerk
S SDECFDA(2.98,SDECIENS,"20")=$$NOW^XLFDT
S SDECFDA(2.98,SDECIENS,"21")="@"
S SDECFDA(2.98,SDECIENS,"25")=$$NULLDEL(SDSCHREQTYPE) ;scheduling request type
S SDECFDA(2.98,SDECIENS,"26")=$$NULLDEL(SDNXTAVAAPPT) ;Next ava. appt. indicator
S SDECFDA(2.98,SDECIENS,"28")=$$NULLDEL(SDFOLLOWUP) ;follow-up visit yes/no
D UPDATE^DIE("","SDECFDA","SDECIENS","SDERR")
I $D(SDERR) S SDAPTREQ("Error",1)="Error trying to create Appointment in File #2." Q
S SDAPTREQ("Success")="Appointment is successfully created."
Q
;
NULLDEL(STR) ;return "@" to delete a field if the new data would be null ;*zeb+tag 722 2/19/19 added to support APPADD
Q $S(STR]"":STR,1:"@")
;
UPDATE ;Find ien for appt in file 2
; Update appt in file 2
N SDECFDA,SDECIENS,SDERR
I '$D(^DPT(SDPATIENTDFN,"S",SDAPPTDTTM,0)) S SDAPTREQ("Error",1)="Appointment is not found in File #2 for this Date/Time" Q
S SDECIENS=SDAPPTDTTM_","_SDPATIENTDFN_","
S SDECFDA(2.98,SDECIENS,".01")=SDCLNIEN
S SDECFDA(2.98,SDECIENS,"3")=$S($G(^DPT(+$G(SDPATIENTDFN),.1))'="":"I",1:"")
S SDECFDA(2.98,SDECIENS,"5")=SDLABDTTM ;lab date/time
S SDECFDA(2.98,SDECIENS,"6")=SDXRAYDTTM ;xray date/time
S SDECFDA(2.98,SDECIENS,"7")=SDEKGDTTM ;ekg date/time
S SDECFDA(2.98,SDECIENS,"9")=SDVSTPURP ;Purpose of Visit
S SDECFDA(2.98,SDECIENS,"9.5")=SDAPPTTYPE
S SDECFDA(2.98,SDECIENS,"13")=SDCOLLATERAL ; Collateral Visit
S SDECFDA(2.98,SDECIENS,"14")=""
S SDECFDA(2.98,SDECIENS,"15")=""
S SDECFDA(2.98,SDECIENS,"16")=""
S SDECFDA(2.98,SDECIENS,"17")=""
S SDECFDA(2.98,SDECIENS,"19")=DUZ ;data entry clerk
S SDECFDA(2.98,SDECIENS,"20")=$$NOW^XLFDT
S SDECFDA(2.98,SDECIENS,"25")=SDSCHREQTYPE ;scheduling request type
S SDECFDA(2.98,SDECIENS,"26")=SDNXTAVAAPPT ;Next ava. appt. indicator
S SDECFDA(2.98,SDECIENS,"28")=SDFOLLOWUP ;follow-up visit yes/no
D FILE^DIE("","SDECFDA","SDERR")
I $D(SDERR) S SDAPTREQ("Error",1)="Error trying to update Appointment in File #2." Q
S SDAPTREQ("Success")="Appointment is successfully updated."
Q
;
BUILDER ;Convert data to JSON
N JSONERR
S JSONERR=""
D ENCODE^SDESJSON(.SDAPTREQ,.SDECY,.JSONERR)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESAPPTREQ2 7842 printed Nov 22, 2024@18:05:34 Page 2
SDESAPPTREQ2 ;ALB/ANU - APPOINTMENT REQUEST CREATE/UPDATE IN FILE2 ;Feb 16, 2022
+1 ;;5.3;Scheduling;**809**;Aug 13, 1993;Build 10
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ; This entry point is used for both the SDES SET APT REQ 2 CREATE and SDES SET APT REQ 2 UPDATE RPCs.
+6 ; The parameter list for each RPC must be kept in sync. This includes in the Remote Procedure file definition.
+7 ;
ARSET(SDECY,SDAPPTUPD,SDPATIENTDFN,SDCLNIEN,SDAPPTDTTM,SDLABDTTM,SDXRAYDTTM,SDEKGDTTM,SDVSTPURP,SDAPPTTYPE,SDCOLLATERAL,SDSCHREQTYPE,SDNXTAVAAPPT,SDFOLLOWUP) ; Create/Update Appointment Request
+1 ; INP - Input parameters array
+2 ;
+3 ; SDAPPTUPD = (req - integer) 1 for Update and 0 for Create Appointment
+4 ; SDPATIENTDFN = (req - integer) DFN Pointer to PATIENT file 2
+5 ; SDCLNIEN = (req - integer) IEN point to HOSPTIAL LOCATION file 44
+6 ; SDAPPTDTTM = (req - date) appointment date and time in ISO 8601 extended format (e.g. 2022-01-19T20:15:44)
+7 ; SDLABDTTM = (date) Lab Date/Time
+8 ; SDXRAYDTTM = (date) X-Ray Date/Time
+9 ; SDEKGDTTM = (date) EKG Date/Time
+10 ; SDVSTPURP = (req - integer) Visit Purpose (Values - 1 to 4)
+11 ; SDAPPTTYPE = (text) Appointment Type, Pointer to #409.1 (required for create)
+12 ; SDCOLLATERAL = (integer) Collateral Visit (1,0)
+13 ; SDSCHREQTYPE = (req - text) Scheduling Request Type (N,C,P etc.,)
+14 ; SDNXTAVAAPPT = (req - integer) Next Available Appointment Indicator (0,1,2,3)
+15 ; SDFOLLOWUP = (integer) Followup Visit
+16 ;
+17 NEW POP,SDAPTREQ
+18 ;
+19 DO VALIDATE
+20 IF 'POP
Begin DoDot:1
+21 IF +SDAPPTUPD=1
DO UPDATE
QUIT
+22 IF +SDAPPTUPD=0
DO CREATE
QUIT
End DoDot:1
+23 DO BUILDER
+24 QUIT
+25 ;
VALIDATE ; Validate
+1 ;
+2 SET POP=0
+3 ;
+4 ;
+5 IF SDAPPTUPD'=1
IF SDAPPTUPD'=0
SET SDAPTREQ("Error",1)="Invalid Update Flag."
QUIT
+6 ;
+7 ; Patient DFN
+8 SET SDPATIENTDFN=$GET(SDPATIENTDFN,"")
+9 IF SDPATIENTDFN=""
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,1)
QUIT
+10 IF SDPATIENTDFN'=""
IF '$DATA(^DPT(+SDPATIENTDFN,0))
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,2)
QUIT
+11 ;
+12 ; Clinic IEN
+13 SET SDCLNIEN=$GET(SDCLNIEN,"")
+14 IF SDCLNIEN=""
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,18)
QUIT
+15 IF '$DATA(^SC(+SDCLNIEN,0))
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,19)
QUIT
+16 IF $$INACTIVE^SDEC32(+SDCLNIEN)
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,19)
QUIT
+17 ;
+18 ; Appointment Type
+19 SET SDAPPTTYPE=$GET(SDAPPTTYPE,"")
+20 IF SDAPPTUPD=0
IF SDAPPTTYPE=""
DO ERRLOG^SDESJSON(.SDAPTREQ,60)
SET POP=1
QUIT
+21 IF SDAPPTTYPE'=""
IF ('$DATA(^SD(409.1,"B",SDAPPTTYPE)))
DO ERRLOG^SDESJSON(.SDAPTREQ,61)
SET POP=1
QUIT
+22 IF SDAPPTTYPE'=""
IF ($DATA(^SD(409.1,"B",SDAPPTTYPE)))
SET SDAPPTTYPE=$ORDER(^SD(409.1,"B",SDAPPTTYPE,0))
+23 ;
+24 ; Appointment date/time of appt
+25 SET SDAPPTDTTM=$GET(SDAPPTDTTM,"")
+26 IF SDAPPTDTTM=""
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,76)
QUIT
+27 SET SDAPPTDTTM=$$ISOTFM^SDAMUTDT(SDAPPTDTTM,SDCLNIEN)
+28 ;S SDAPPTDTTM=$$GMTTFM^SDAMUTDT(SDAPPTDTTM)
+29 IF SDAPPTDTTM=-1
SET SDAPPTDTTM=""
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,77)
QUIT
+30 IF SDAPPTUPD=0
IF SDAPPTDTTM<DT
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,59)
QUIT
+31 ;
+32 ; Lab Dt/Tm
+33 SET SDLABDTTM=$GET(SDLABDTTM,"")
+34 IF SDLABDTTM'=""
SET SDLABDTTM=$$ISOTFM^SDAMUTDT(SDLABDTTM,SDCLNIEN)
+35 ;I SDLABDTTM'="" S SDLABDTTM=$$GMTTFM^SDAMUTDT(SDLABDTTM)
+36 IF SDLABDTTM=-1
SET SDLABDTTM=""
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,147)
QUIT
+37 ;
+38 ; XRAY Dt/Tm
+39 SET SDXRAYDTTM=$GET(SDXRAYDTTM,"")
+40 IF SDXRAYDTTM'=""
SET SDXRAYDTTM=$$ISOTFM^SDAMUTDT(SDXRAYDTTM,SDCLNIEN)
+41 ;I SDXRAYDTTM'="" S SDXRAYDTTM=$$GMTTFM^SDAMUTDT(SDXRAYDTTM)
+42 IF SDXRAYDTTM=-1
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,145)
QUIT
+43 ;
+44 ; EKG Dt/Tm
+45 SET SDEKGDTTM=$GET(SDEKGDTTM,"")
+46 IF SDEKGDTTM'=""
SET SDEKGDTTM=$$ISOTFM^SDAMUTDT(SDEKGDTTM,SDCLNIEN)
+47 ;I SDEKGDTTM'="" S SDEKGDTTM=$$GMTTFM^SDAMUTDT(SDEKGDTTM)
+48 IF SDEKGDTTM=-1
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,146)
QUIT
+49 ;
+50 ; Purpose of Visit
+51 SET SDVSTPURP=$GET(SDVSTPURP,"")
+52 SET SDVSTPURP=$EXTRACT(SDVSTPURP,1,1)
+53 IF SDVSTPURP=""
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,149)
QUIT
+54 IF "1234"'[+SDVSTPURP
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,148)
QUIT
+55 ;
+56 ; Collateral Visit
+57 SET SDCOLLATERAL=$GET(SDCOLLATERAL,"")
+58 SET SDCOLLATERAL=$EXTRACT(SDCOLLATERAL,1,1)
+59 IF SDCOLLATERAL'=""
IF ("01"'[SDCOLLATERAL)
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,150)
QUIT
+60 ;
+61 ; Scheduling Request Type
+62 SET SDSCHREQTYPE=$GET(SDSCHREQTYPE,"")
+63 SET SDSCHREQTYPE=$EXTRACT(SDSCHREQTYPE,1,1)
+64 IF SDSCHREQTYPE=""
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,151)
QUIT
+65 IF ("NCPWMAO"'[SDSCHREQTYPE)
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,152)
QUIT
+66 ;
+67 ; Next Available Appointment Indicator
+68 SET SDNXTAVAAPPT=$GET(SDNXTAVAAPPT,"")
+69 SET SDNXTAVAAPPT=$EXTRACT(SDNXTAVAAPPT,1,1)
+70 IF SDNXTAVAAPPT=""
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,154)
QUIT
+71 IF ("0123"'[SDNXTAVAAPPT)
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,153)
QUIT
+72 ;
+73 ; Followup Visit
+74 SET SDFOLLOWUP=$GET(SDFOLLOWUP,"")
+75 IF SDFOLLOWUP'=""
IF ("01"'[SDFOLLOWUP)
SET POP=1
DO ERRLOG^SDESJSON(.SDAPTREQ,155)
QUIT
+76 ;
+77 QUIT
+78 ;
CREATE ;Build FDA array to creat a new entry in 2
+1 ; add appt to file 2
+2 NEW SDECFDA,SDECIENS,SDERR
+3 IF $DATA(^DPT(SDPATIENTDFN,"S",SDAPPTDTTM,0))
SET SDAPTREQ("Error",1)="Appointment Already Exists in File #2 for this Date/Time"
QUIT
+4 SET SDECIENS="?+2,"_SDPATIENTDFN_","
+5 SET SDECIENS(2)=SDAPPTDTTM
+6 SET SDECFDA(2.98,SDECIENS,".01")=$$NULLDEL(SDCLNIEN)
+7 SET SDECFDA(2.98,SDECIENS,"3")=$SELECT($GET(^DPT(+$GET(SDPATIENTDFN),.1))'="":"I",1:"")
+8 ;lab date/time
SET SDECFDA(2.98,SDECIENS,"5")=$$NULLDEL(SDLABDTTM)
+9 ;xray date/time
SET SDECFDA(2.98,SDECIENS,"6")=$$NULLDEL(SDXRAYDTTM)
+10 ;ekg date/time
SET SDECFDA(2.98,SDECIENS,"7")=$$NULLDEL(SDEKGDTTM)
+11 ;Purpose of Visit
SET SDECFDA(2.98,SDECIENS,"9")=$$NULLDEL(SDVSTPURP)
+12 SET SDECFDA(2.98,SDECIENS,"9.5")=$$NULLDEL(SDAPPTTYPE)
+13 ; Collateral Visit
SET SDECFDA(2.98,SDECIENS,"13")=$$NULLDEL(SDCOLLATERAL)
+14 SET SDECFDA(2.98,SDECIENS,"14")="@"
+15 SET SDECFDA(2.98,SDECIENS,"15")="@"
+16 SET SDECFDA(2.98,SDECIENS,"16")="@"
+17 SET SDECFDA(2.98,SDECIENS,"17")="@"
+18 ;data entry clerk
SET SDECFDA(2.98,SDECIENS,"19")=$$NULLDEL(DUZ)
+19 SET SDECFDA(2.98,SDECIENS,"20")=$$NOW^XLFDT
+20 SET SDECFDA(2.98,SDECIENS,"21")="@"
+21 ;scheduling request type
SET SDECFDA(2.98,SDECIENS,"25")=$$NULLDEL(SDSCHREQTYPE)
+22 ;Next ava. appt. indicator
SET SDECFDA(2.98,SDECIENS,"26")=$$NULLDEL(SDNXTAVAAPPT)
+23 ;follow-up visit yes/no
SET SDECFDA(2.98,SDECIENS,"28")=$$NULLDEL(SDFOLLOWUP)
+24 DO UPDATE^DIE("","SDECFDA","SDECIENS","SDERR")
+25 IF $DATA(SDERR)
SET SDAPTREQ("Error",1)="Error trying to create Appointment in File #2."
QUIT
+26 SET SDAPTREQ("Success")="Appointment is successfully created."
+27 QUIT
+28 ;
NULLDEL(STR) ;return "@" to delete a field if the new data would be null ;*zeb+tag 722 2/19/19 added to support APPADD
+1 QUIT $SELECT(STR]"":STR,1:"@")
+2 ;
UPDATE ;Find ien for appt in file 2
+1 ; Update appt in file 2
+2 NEW SDECFDA,SDECIENS,SDERR
+3 IF '$DATA(^DPT(SDPATIENTDFN,"S",SDAPPTDTTM,0))
SET SDAPTREQ("Error",1)="Appointment is not found in File #2 for this Date/Time"
QUIT
+4 SET SDECIENS=SDAPPTDTTM_","_SDPATIENTDFN_","
+5 SET SDECFDA(2.98,SDECIENS,".01")=SDCLNIEN
+6 SET SDECFDA(2.98,SDECIENS,"3")=$SELECT($GET(^DPT(+$GET(SDPATIENTDFN),.1))'="":"I",1:"")
+7 ;lab date/time
SET SDECFDA(2.98,SDECIENS,"5")=SDLABDTTM
+8 ;xray date/time
SET SDECFDA(2.98,SDECIENS,"6")=SDXRAYDTTM
+9 ;ekg date/time
SET SDECFDA(2.98,SDECIENS,"7")=SDEKGDTTM
+10 ;Purpose of Visit
SET SDECFDA(2.98,SDECIENS,"9")=SDVSTPURP
+11 SET SDECFDA(2.98,SDECIENS,"9.5")=SDAPPTTYPE
+12 ; Collateral Visit
SET SDECFDA(2.98,SDECIENS,"13")=SDCOLLATERAL
+13 SET SDECFDA(2.98,SDECIENS,"14")=""
+14 SET SDECFDA(2.98,SDECIENS,"15")=""
+15 SET SDECFDA(2.98,SDECIENS,"16")=""
+16 SET SDECFDA(2.98,SDECIENS,"17")=""
+17 ;data entry clerk
SET SDECFDA(2.98,SDECIENS,"19")=DUZ
+18 SET SDECFDA(2.98,SDECIENS,"20")=$$NOW^XLFDT
+19 ;scheduling request type
SET SDECFDA(2.98,SDECIENS,"25")=SDSCHREQTYPE
+20 ;Next ava. appt. indicator
SET SDECFDA(2.98,SDECIENS,"26")=SDNXTAVAAPPT
+21 ;follow-up visit yes/no
SET SDECFDA(2.98,SDECIENS,"28")=SDFOLLOWUP
+22 DO FILE^DIE("","SDECFDA","SDERR")
+23 IF $DATA(SDERR)
SET SDAPTREQ("Error",1)="Error trying to update Appointment in File #2."
QUIT
+24 SET SDAPTREQ("Success")="Appointment is successfully updated."
+25 QUIT
+26 ;
BUILDER ;Convert data to JSON
+1 NEW JSONERR
+2 SET JSONERR=""
+3 DO ENCODE^SDESJSON(.SDAPTREQ,.SDECY,.JSONERR)
+4 QUIT