SDES2CREATEAPPT ;ALB/BLB,LAB/BLB,ANU,TJB,LAB,TJB,ANU,BLB,TJB,BLB- SDES2 CREATE APPOINTMENT ;Jun 17,2024
;;5.3;Scheduling;**866,869,873,875,877,880,881,886**;Aug 13, 1993;Build 13
;;Per VHA Directive 6402, this routine should not be modified
;
; Reference to DUZ^XUP is supported by IA #7487
;
;---------------------------------------------------------------
;
;APPOINTMENT("START DATE TIME")="2024-09-20T10:00-04:00" APPOINTMENT START TIME - (REQUIRED) - ISO FORMAT
;APPOINTMENT("END DATE TIME")="2024-09-20T10:30-04:00" APPOINTMENT END TIME - (REQUIRED) - ISO FORMAT
;APPOINTMENT("DFN")=7242620 DFN - (REQUIRED) - PATIENT IEN
;APPOINTMENT("RESOURCE IEN")=2063 SDEC RESOURCE IEN (REQUIRED)
;APPOINTMENT("WALKIN")="n" WALKIN - (y/n)
;APPOINTMENT("PATIENT INDICATED DATE")="2022-08-09" DESIRED DATE/TIME - ISO FORMAT
;APPOINTMENT("EXTERNAL ID")="THIIA FREE TEXT EXTERNAL ID FIELD" EXTERNAL ID - (FREE TEXT 1-50)
;APPOINTMENT("REQUEST TYPE")="A|34534" SD REQUEST TYPE (REQUIRED) - REQTYPE|REQUESTIEN
;APPOINTMENT("PROVIDER IEN")=520881805 PROVIDER IEN
;APPOINTMENT("CLINIC IEN")=3754 CLINIC IEN (REQUIRED)
;APPOINTMENT("NOTE")="THIIA NOTE" NOTE - FREE TEXT 1-150
;APPOINTMENT("APPOINTMENT TYPE")=1 APPOINTMENT TYPE IEN - POINTER TO ^SD(409.1)
; -------Either APPOINTMENT TYPE IEN or APPOINTMENT TYPE TYPENAME is Required--------
;APPOINTMENT("APPOINTMENT TYPE TYPENAME")="" APPOINTMENT TYPE TYPENAME - TYPENAME from ^SD(409.1)
;APPOINTMENT("PATIENT STATUS")="N" PATIENT STATUS - (N/E) N:NEW E:ESTABLISHED
;APPOINTMENT("APPOINTMENT LENGTH")=30 APPOINTMENT LENGTH (REQUIRED) - IN MINUTES (5-240)
;APPOINTMENT("SERVICE CONNECTED")="Y" SERVICE CONNECTED - YES/NO
;APPOINTMENT("SERVICE CONNECTED PERCENTAGE")=50 SERVICE CONNECTED PERCENTAGE - 0-100
;APPOINTMENT("MRTC")=1 MRTC (1 for YES 0 for NO)
;APPOINTMENT("MRTC PARENT")=252559 PARENT REQUEST (APPOINTMENT REQUEST IEN)
;APPOINTMENT("APPOINTMENT REASON")="TEST" APPOINTMENT REASON
;APPOINTMENT("PATIENT ELIGIBILITY")=2 PATIENT ELIGIBILITY IEN - POINTER TO ^DIC(8
;APPOINTMENT("OVERBOOK")="O" OVERBOOK (0 for no, 1 for yes)
;APPOINTMENT("LAB DATE TIME")="2022-08-09T10:00-04:00" LAB DATE/TIME - ISO FORMAT
;APPOINTMENT("XRAY DATE TIME")="2022-08-09T10:00-04:00" XRAY DATE/TIME - ISO FORMAT
;APPOINTMENT("EKG DATE TIME")="2022-08-09T10:00-04:00" EKG DATE/TIME - ISO FORMAT
;APPOINTMENT("PURPOSE")=1 PURPOSE (REQUIRED)- '1' FOR C&P; '2' FOR 10-10; '3' FOR SCHEDULED VISIT; '4' FOR UNSCHED. VISIT
;APPOINTMENT("COLLATERAL")=1 COLLATERAL - 1 FOR YES
;APPOINTMENT("SCHEDULE REQUEST TYPE")="N" SCHEDULE REQUEST TYPE (REQUIRED)
;APPOINTMENT("NEXT AVAILABLE APPOINTMENT")=1 NEXT AVAILABLE APPOINTMENT (REQUIRED)
;APPOINTMENT("FOLLOWUP")=1 FOLLOWUP - 1 FOR YES 0 FOR NO
;
; associated functions live in SDES2APPTUTIL
;
Q
;
CREATE(JSON,SDCONTEXT,APPOINTMENT) ;
N APPT,ERRORS,DELETE,APPTIEN,APPTIEN44,VAL,RECALLRETURN,RECALL,ENCOUNTER,APPTMSG
;
D VALIDATE(.ERRORS,.SDCONTEXT,.APPOINTMENT,.VAL)
I $D(ERRORS) S ERRORS("Appointment","IEN")="" S APPT("Appointment","Message")="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
I $G(SDCONTEXT("USER DUZ"))'="" N DUZ D DUZ^XUP(SDCONTEXT("USER DUZ"))
;
D CREATE40984(.ERRORS,.DELETE,.APPTIEN,.APPOINTMENT,$P($G(APPOINTMENT("REQUEST TYPE")),"|"),$P($G(APPOINTMENT("REQUEST TYPE")),"|",2),$G(SDCONTEXT("USER DUZ")),$TR($E($G(APPOINTMENT("NOTE")),1,150),"^"," "),$G(SDCONTEXT("ACHERON AUDIT ID")))
D CREATE44(.ERRORS,.APPOINTMENT,.DELETE,.APPTIEN44,$G(SDCONTEXT("USER DUZ")),$G(APPOINTMENT("CLINIC IEN")),$G(APPOINTMENT("START DATE TIME")))
D CREATE2(.ERRORS,.DELETE,.APPOINTMENT,$G(SDCONTEXT("USER DUZ")),$G(APPOINTMENT("CLINIC IEN")),$G(APPOINTMENT("START DATE TIME")),$G(APPOINTMENT("DFN")))
I $D(ERRORS) S ERRORS("Appointment","IEN")="" S APPT("Appointment","Message")="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
;
I $P($G(APPOINTMENT("REQUEST TYPE")),"|")="A" D APPTREQ^SDES2APPTUTIL(.SDCONTEXT,.APPOINTMENT,APPTIEN,.APPTMSG)
I $P($G(APPOINTMENT("REQUEST TYPE")),"|")="R" D RECALL^SDES2APPTUTIL(.RECALLRETURN,.SDCONTEXT,.RECALL,$P($G(APPOINTMENT("REQUEST TYPE")),"|",2))
I $P($G(APPOINTMENT("REQUEST TYPE")),"|")="C" D CONSULT^SDES2APPTUTIL(.APPOINTMENT,APPTIEN44,$G(SDCONTEXT("USER DUZ")))
;
D SETMISSIONELIG^SDESMISSIONELG($G(APPTIEN))
;
D ENCOUNTERS^SDES2APPTUTIL(.APPOINTMENT,.ENCOUNTER)
;
D MAKE^SDES2APPTUTIL($G(APPOINTMENT("DFN")),$G(APPOINTMENT("START DATE TIME")),$G(APPOINTMENT("CLINIC IEN")))
;
;D DECREMENTAVAIL1^SDES2APPTUTIL($G(APPOINTMENT("CLINIC IEN")),$G(APPOINTMENT("START DATE TIME")),$G(APPOINTMENT("APPOINTMENT LENGTH")))
D AVUPDT^SDEC07C(APPOINTMENT("CLINIC IEN"),APPOINTMENT("START DATE TIME"),APPOINTMENT("APPOINTMENT LENGTH")) ;Update Clinic availability;
;
;
I $D(ERRORS) S ERRORS("Appointment","IEN")=APPTIEN D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
;
S APPT("Appointment","IEN")=APPTIEN
S APPT("Appointment","Message")=$G(APPTMSG)
D BUILDJSON^SDES2JSON(.JSON,.APPT)
Q
;
CREATE40984(ERRORS,DELETE,APPTIEN,APPOINTMENT,REQUESTTYPE,REQUESTIEN,USERID,NOTE,EAS) ;
N FDA,APPTERROR,NEWIEN,APPTERROR,APPTNOTES
;
S FDA(409.84,"+1,",.01)=$G(APPOINTMENT("START DATE TIME"))
S FDA(409.84,"+1,",.02)=$G(APPOINTMENT("END DATE TIME"))
S FDA(409.84,"+1,",.05)=$G(APPOINTMENT("DFN"))
S FDA(409.84,"+1,",.06)=$G(APPOINTMENT("APPOINTMENT TYPE"))
S FDA(409.84,"+1,",.07)=$G(APPOINTMENT("RESOURCE IEN"))
S FDA(409.84,"+1,",.08)=$S(USERID:USERID,1:DUZ)
S FDA(409.84,"+1,",.09)=$$NOW^XLFDT
S FDA(409.84,"+1,",.13)=$G(APPOINTMENT("WALKIN"))
S FDA(409.84,"+1,",.16)=$G(APPOINTMENT("PROVIDER IEN"))
S FDA(409.84,"+1,",.18)=$G(APPOINTMENT("APPOINTMENT LENGTH"))
S FDA(409.84,"+1,",.2)=$G(APPOINTMENT("PATIENT INDICATED DATE"))
S FDA(409.84,"+1,",.21)=$G(APPOINTMENT("EXTERNAL ID"))
S FDA(409.84,"+1,",.22)=$S(REQUESTTYPE'="":REQUESTIEN_";"_$S(REQUESTTYPE="E":"SDWL(409.3,",REQUESTTYPE="C":"GMR(123,",REQUESTTYPE="R":"SD(403.5,",REQUESTTYPE="A":"SDEC(409.85,",1:""),1:"")
S FDA(409.84,"+1,",.23)=$G(APPOINTMENT("PATIENT STATUS"))
S FDA(409.84,"+1,",100)=EAS
D UPDATE^DIE(,"FDA","NEWIEN","APPTERROR") K FDA,APPTERROR
I $D(APPTERROR) D ERRLOG^SDESJSON(.ERRORS,173) Q
;
S APPTIEN=$G(NEWIEN(1))
;
D STORENOTE^SDES2APPTUTIL(APPTIEN,NOTE,.APPTNOTES)
D STOREREQUESTCOMM^SDES2APPTUTIL(REQUESTIEN)
;
S DELETE(409.84)=$G(APPTIEN)_","
Q
;
CREATE44(ERRORS,APPOINTMENT,DELETE,APPTIEN44,USERID,CLINICIEN,STARTDATETIME) ;
N FDA,NEWIEN44001,NEWIEN44003,APPTERROR,IENS
;
I '$D(^SC($G(CLINICIEN),"S",STARTDATETIME)) D
.S NEWIEN44001(1)=STARTDATETIME
.S FDA(44.001,"+1,"_CLINICIEN_",",.01)=STARTDATETIME
.D UPDATE^DIE(,"FDA","NEWIEN44001","APPTERROR") K FDA,APPTERROR N FDA,APPTERROR
I $D(APPTERROR) D DELETERECORD^SDES2APPTUTIL(.DELETE),ERRLOG^SDESJSON(.ERRORS,173) Q
;
S IENS=STARTDATETIME_","_CLINICIEN_","
S FDA(44.003,"+1,"_IENS,.01)=$G(APPOINTMENT("DFN"))
S FDA(44.003,"+1,"_IENS,1)=$G(APPOINTMENT("APPOINTMENT LENGTH"))
S FDA(44.003,"+1,"_IENS,3)=$TR($E($G(APPOINTMENT("APPOINTMENT REASON")),1,150),"^"," ")
S FDA(44.003,"+1,"_IENS,30)=$G(APPOINTMENT("PATIENT ELIGIBILITY"))
S FDA(44.003,"+1,"_IENS,9)=$S($G(APPOINTMENT("OVERBOOK"))="O":"O",1:"")
S FDA(44.003,"+1,"_IENS,7)=$S(USERID:USERID,1:DUZ)
S FDA(44.003,"+1,"_IENS,8)=$$NOW^XLFDT
D UPDATE^DIE(,"FDA","NEWIEN44003","APPTERROR") K FDA,APPTERROR
I $D(APPTERROR) D DELETERECORD^SDES2APPTUTIL(.DELETE),ERRLOG^SDESJSON(.ERRORS,173) Q
;
S DELETE(44.003)=$G(NEWIEN44003(1))_","_STARTDATETIME_","_CLINICIEN_","
S APPTIEN44=$G(NEWIEN44003(1))
Q
;
CREATE2(ERRORS,DELETE,APPOINTMENT,USERID,CLINICIEN,STARTDATETIME,DFN) ;
N FDA,NEWIEN,APPTERROR,IENS
;
I $D(^DPT(DFN,"S",STARTDATETIME,0)) D
.D DELETECANRECORD^SDES2APPTUTIL(DFN,STARTDATETIME,CLINICIEN)
;
S NEWIEN(1)=STARTDATETIME
S IENS="+1,"_DFN_","
S FDA(2.98,IENS,".01")=CLINICIEN
S FDA(2.98,IENS,"3")=$S($G(^DPT(+$G(DFN),.1))'="":"I",1:"")
S FDA(2.98,IENS,"5")=$G(APPOINTMENT("LAB DATE TIME"))
S FDA(2.98,IENS,"6")=$G(APPOINTMENT("XRAY DATE TIME"))
S FDA(2.98,IENS,"7")=$G(APPOINTMENT("EKG DATE TIME"))
S FDA(2.98,IENS,"9")=$G(APPOINTMENT("PURPOSE"))
S FDA(2.98,IENS,"9.5")=$G(APPOINTMENT("APPOINTMENT TYPE"))
S FDA(2.98,IENS,"13")=$G(APPOINTMENT("COLLATERAL"))
S FDA(2.98,IENS,"19")=$S(USERID:USERID,1:DUZ)
S FDA(2.98,IENS,"20")=$$NOW^XLFDT
S FDA(2.98,IENS,"25")=$G(APPOINTMENT("SCHEDULE REQUEST TYPE"))
S FDA(2.98,IENS,"26")=$G(APPOINTMENT("NEXT AVAILABLE APPOINTMENT"))
S FDA(2.98,IENS,"27")=$G(APPOINTMENT("PATIENT INDICATED DATE"))
S FDA(2.98,IENS,"28")=$G(APPOINTMENT("FOLLOWUP"))
;
L +^DPT(DFN):3
I '$T D ERRLOG^SDESJSON(.ERRORS,187),DELETERECORD^SDES2APPTUTIL(.DELETE) Q
;
D UPDATE^DIE("","FDA","NEWIEN","APPTERROR") K FDA
;
L -^DPT(DFN)
I $D(APPTERROR) D DELETERECORD^SDES2APPTUTIL(.DELETE),ERRLOG^SDESJSON(.ERRORS,173) Q
Q
;
VALIDATE(ERRORS,SDCONTEXT,APPOINTMENT,VAL,BLOCKANDMOVE) ;
;
D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
I $D(ERRORS) Q
;
;
; =IEN/pointer validation=
;
D VALFILEIEN^SDES2VALUTIL(.VAL,.ERRORS,44,$G(APPOINTMENT("CLINIC IEN")),1,,18,19)
D VALFILEIEN^SDES2VALUTIL(.VAL,.ERRORS,2,$G(APPOINTMENT("DFN")),1,,1,2)
D VALFILEIEN^SDES2VALUTIL(.VAL,.ERRORS,200,$G(APPOINTMENT("PROVIDER IEN")),,,,54)
D VALFILEIEN^SDES2VALUTIL(.VAL,.ERRORS,409.85,$G(APPOINTMENT("MRTC PARENT")),,,,179) I $L($G(APPOINTMENT("MRTC PARENT"))),$$GET1^DIQ(409.85,$G(APPOINTMENT("MRTC PARENT"))_",",23,"I")="C" D ERRLOG^SDESJSON(.ERRORS,433)
D VALFILEIEN^SDES2VALUTIL(.VAL,.ERRORS,409.831,$G(APPOINTMENT("RESOURCE IEN")),,,,70)
D VALFILEIEN^SDES2VALUTIL(.VAL,.ERRORS,8,$G(APPOINTMENT("PATIENT ELIGIBILITY")),,,,143)
;
;
; =date validation=
;
S APPOINTMENT("START DATE TIME")=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$G(APPOINTMENT("START DATE TIME")),$G(APPOINTMENT("CLINIC IEN")),1,165,166)
S APPOINTMENT("END DATE TIME")=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$G(APPOINTMENT("END DATE TIME")),$G(APPOINTMENT("CLINIC IEN")),1,167,168)
I $G(APPOINTMENT("START DATE TIME"))>$G(APPOINTMENT("END DATE TIME")) D ERRLOG^SDESJSON(.ERRORS,13)
I $G(APPOINTMENT("START DATE TIME"))>$$FMADD^XLFDT($$NOW^XLFDT(),$S($$GET1^DIQ(44,$G(APPOINTMENT("CLINIC IEN")),2002):$$GET1^DIQ(44,$G(APPOINTMENT("CLINIC IEN")),2002),1:390)) D ERRLOG^SDESJSON(.ERRORS,177)
;
S APPOINTMENT("PATIENT INDICATED DATE")=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$G(APPOINTMENT("PATIENT INDICATED DATE")),$G(APPOINTMENT("CLINIC IEN")),,,58)
S APPOINTMENT("LAB DATE TIME")=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$G(APPOINTMENT("LAB DATE TIME")),$G(APPOINTMENT("CLINIC IEN")),,,147)
S APPOINTMENT("XRAY DATE TIME")=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$G(APPOINTMENT("XRAY DATE TIME")),$G(APPOINTMENT("CLINIC IEN")),,,145)
S APPOINTMENT("EKG DATE TIME")=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$G(APPOINTMENT("EKG DATE TIME")),$G(APPOINTMENT("CLINIC IEN")),,,146)
;
;
; =general field validation=
;
D VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,409.85,41,$G(APPOINTMENT("MRTC")))
S APPOINTMENT("MRTC")=$G(VAL(409.85,41,"I"))
;
D VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,2.98,9,$G(APPOINTMENT("PURPOSE")),1,,149,148)
S APPOINTMENT("PURPOSE")=$G(VAL(2.98,9,"I"))
;
D VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,2.98,13,$G(APPOINTMENT("COLLATERAL")),,,,150)
S APPOINTMENT("COLLATERAL")=$G(VAL(2.98,13,"I"))
;
D VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,2.98,25,$G(APPOINTMENT("SCHEDULE REQUEST TYPE")),1,,151,152)
S APPOINTMENT("SCHEDULE REQUEST TYPE")=$G(VAL(2.98,25,"I"))
;
D VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,2.98,26,$G(APPOINTMENT("NEXT AVAILABLE APPOINTMENT")),1,,154,153)
S APPOINTMENT("NEXT AVAILABLE APPOINTMENT")=$G(VAL(2.98,26,"I"))
;
D VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,2.98,28,$G(APPOINTMENT("FOLLOWUP")),,,,155)
S APPOINTMENT("FOLLOWUP")=$G(VAL(2.98,28,"I"))
;
D VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,409.84,.18,$G(APPOINTMENT("APPOINTMENT LENGTH")),1,,115,116)
;
D VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,44.003,9,$G(APPOINTMENT("OVERBOOK")))
S APPOINTMENT("OVERBOOK")=$G(VAL(44.003,9,"I"))
;
D VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,409.85,15,$G(APPOINTMENT("SERVICE CONNECTED")))
S APPOINTMENT("SERVICE CONNECTED")=$G(VAL(409.85,15,"I"))
;
D VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,409.85,14,$G(APPOINTMENT("SERVICE CONNECTED PERCENTAGE")))
;
D VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,409.84,.23,$G(APPOINTMENT("PATIENT STATUS")))
S APPOINTMENT("PATIENT STATUS")=$G(VAL(409.84,.23,"I"))
;
D VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,409.84,.13,$G(APPOINTMENT("WALKIN")),,,,178)
S APPOINTMENT("WALKIN")=$G(VAL(409.84,.13,"I"))
;
;
I '$G(BLOCKANDMOVE) D
.D REQUESTTYPE^SDES2APPTUTIL(.ERRORS,.APPOINTMENT,$P($G(APPOINTMENT("REQUEST TYPE")),"|"),$P($G(APPOINTMENT("REQUEST TYPE")),"|",2),$G(APPOINTMENT("DFN")))
D GETAPPTTYPE^SDES2APPTUTIL(.ERRORS,.APPOINTMENT,$G(APPOINTMENT("APPOINTMENT TYPE")),$G(APPOINTMENT("APPOINTMENT TYPE NAME")))
D GETPID^SDES2APPTUTIL(.APPOINTMENT,$G(APPOINTMENT("PATIENT INDICATED DATE")),$P($G(APPOINTMENT("REQUEST TYPE")),"|"),$P($G(APPOINTMENT("REQUEST TYPE")),"|",2))
I $D(ERRORS) Q
;
;
D GETPROVIDER^SDES2APPTUTIL(.APPOINTMENT,$G(APPOINTMENT("CLINIC IEN")),$G(APPOINTMENT("PROVIDER IEN")),$P($G(APPOINTMENT("REQUEST TYPE")),"|"),$P($G(APPOINTMENT("REQUEST TYPE")),"|",2))
D GETRESOURCE^SDES2APPTUTIL(.ERRORS,.APPOINTMENT,$G(APPOINTMENT("CLINIC IEN")))
I $$ORDERCHECKLOCK^SDES2APPTUTIL(.ERRORS,$G(APPOINTMENT("REQUEST TYPE")),$G(APPOINTMENT("DFN")))
I $$INACTIVE^SDESUTIL($G(APPOINTMENT("CLINIC IEN"))) D ERRLOG^SDESJSON(.ERRORS,19)
I $$APPTIN44EXISTS^SDES2APPTUTIL($G(APPOINTMENT("DFN")),$G(APPOINTMENT("CLINIC IEN")),$G(APPOINTMENT("START DATE TIME"))) D ERRLOG^SDESJSON(.ERRORS,175)
I '$G(BLOCKANDMOVE) D
.I $$APPTINDIFFTZ^SDES2APPTUTIL($G(APPOINTMENT("DFN")),$G(APPOINTMENT("START DATE TIME"))) D ERRLOG^SDES2JSON(.ERRORS,570)
;
;
I $G(APPOINTMENT("WALKIN"))="y",$P($G(APPOINTMENT("START DATE TIME")),".")<$P($$NOW^XLFDT(),".")!($P($G(APPOINTMENT("START DATE TIME")),".")>$P($$NOW^XLFDT(),".")) D ERRLOG^SDESJSON(.ERRORS,166)
I $$FMDIFF^XLFDT($G(APPOINTMENT("END DATE TIME")),$G(APPOINTMENT("START DATE TIME")),2)/60'=$G(APPOINTMENT("APPOINTMENT LENGTH")) D ERRLOG^SDESJSON(.ERRORS,116)
I $P($$FMTISO^SDAMUTDT($G(APPOINTMENT("START DATE TIME"))),"T",2)="" D ERRLOG^SDESJSON(.ERRORS,166)
I $P($$FMTISO^SDAMUTDT($G(APPOINTMENT("END DATE TIME"))),"T",2)="" D ERRLOG^SDESJSON(.ERRORS,168)
;
I APPOINTMENT("MRTC"),'$L($G(APPOINTMENT("MRTC PARENT"))) D ERRLOG^SDESJSON(.ERRORS,536)
I $L($G(APPOINTMENT("MRTC PARENT"))),$$GET1^DIQ(409.85,$G(APPOINTMENT("MRTC PARENT"))_",",.01,"I")'=$G(APPOINTMENT("DFN")) D ERRLOG^SDESJSON(.ERRORS,536)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2CREATEAPPT 15720 printed Oct 16, 2024@18:54:08 Page 2
SDES2CREATEAPPT ;ALB/BLB,LAB/BLB,ANU,TJB,LAB,TJB,ANU,BLB,TJB,BLB- SDES2 CREATE APPOINTMENT ;Jun 17,2024
+1 ;;5.3;Scheduling;**866,869,873,875,877,880,881,886**;Aug 13, 1993;Build 13
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ; Reference to DUZ^XUP is supported by IA #7487
+5 ;
+6 ;---------------------------------------------------------------
+7 ;
+8 ;APPOINTMENT("START DATE TIME")="2024-09-20T10:00-04:00" APPOINTMENT START TIME - (REQUIRED) - ISO FORMAT
+9 ;APPOINTMENT("END DATE TIME")="2024-09-20T10:30-04:00" APPOINTMENT END TIME - (REQUIRED) - ISO FORMAT
+10 ;APPOINTMENT("DFN")=7242620 DFN - (REQUIRED) - PATIENT IEN
+11 ;APPOINTMENT("RESOURCE IEN")=2063 SDEC RESOURCE IEN (REQUIRED)
+12 ;APPOINTMENT("WALKIN")="n" WALKIN - (y/n)
+13 ;APPOINTMENT("PATIENT INDICATED DATE")="2022-08-09" DESIRED DATE/TIME - ISO FORMAT
+14 ;APPOINTMENT("EXTERNAL ID")="THIIA FREE TEXT EXTERNAL ID FIELD" EXTERNAL ID - (FREE TEXT 1-50)
+15 ;APPOINTMENT("REQUEST TYPE")="A|34534" SD REQUEST TYPE (REQUIRED) - REQTYPE|REQUESTIEN
+16 ;APPOINTMENT("PROVIDER IEN")=520881805 PROVIDER IEN
+17 ;APPOINTMENT("CLINIC IEN")=3754 CLINIC IEN (REQUIRED)
+18 ;APPOINTMENT("NOTE")="THIIA NOTE" NOTE - FREE TEXT 1-150
+19 ;APPOINTMENT("APPOINTMENT TYPE")=1 APPOINTMENT TYPE IEN - POINTER TO ^SD(409.1)
+20 ; -------Either APPOINTMENT TYPE IEN or APPOINTMENT TYPE TYPENAME is Required--------
+21 ;APPOINTMENT("APPOINTMENT TYPE TYPENAME")="" APPOINTMENT TYPE TYPENAME - TYPENAME from ^SD(409.1)
+22 ;APPOINTMENT("PATIENT STATUS")="N" PATIENT STATUS - (N/E) N:NEW E:ESTABLISHED
+23 ;APPOINTMENT("APPOINTMENT LENGTH")=30 APPOINTMENT LENGTH (REQUIRED) - IN MINUTES (5-240)
+24 ;APPOINTMENT("SERVICE CONNECTED")="Y" SERVICE CONNECTED - YES/NO
+25 ;APPOINTMENT("SERVICE CONNECTED PERCENTAGE")=50 SERVICE CONNECTED PERCENTAGE - 0-100
+26 ;APPOINTMENT("MRTC")=1 MRTC (1 for YES 0 for NO)
+27 ;APPOINTMENT("MRTC PARENT")=252559 PARENT REQUEST (APPOINTMENT REQUEST IEN)
+28 ;APPOINTMENT("APPOINTMENT REASON")="TEST" APPOINTMENT REASON
+29 ;APPOINTMENT("PATIENT ELIGIBILITY")=2 PATIENT ELIGIBILITY IEN - POINTER TO ^DIC(8
+30 ;APPOINTMENT("OVERBOOK")="O" OVERBOOK (0 for no, 1 for yes)
+31 ;APPOINTMENT("LAB DATE TIME")="2022-08-09T10:00-04:00" LAB DATE/TIME - ISO FORMAT
+32 ;APPOINTMENT("XRAY DATE TIME")="2022-08-09T10:00-04:00" XRAY DATE/TIME - ISO FORMAT
+33 ;APPOINTMENT("EKG DATE TIME")="2022-08-09T10:00-04:00" EKG DATE/TIME - ISO FORMAT
+34 ;APPOINTMENT("PURPOSE")=1 PURPOSE (REQUIRED)- '1' FOR C&P; '2' FOR 10-10; '3' FOR SCHEDULED VISIT; '4' FOR UNSCHED. VISIT
+35 ;APPOINTMENT("COLLATERAL")=1 COLLATERAL - 1 FOR YES
+36 ;APPOINTMENT("SCHEDULE REQUEST TYPE")="N" SCHEDULE REQUEST TYPE (REQUIRED)
+37 ;APPOINTMENT("NEXT AVAILABLE APPOINTMENT")=1 NEXT AVAILABLE APPOINTMENT (REQUIRED)
+38 ;APPOINTMENT("FOLLOWUP")=1 FOLLOWUP - 1 FOR YES 0 FOR NO
+39 ;
+40 ; associated functions live in SDES2APPTUTIL
+41 ;
+42 QUIT
+43 ;
CREATE(JSON,SDCONTEXT,APPOINTMENT) ;
+1 NEW APPT,ERRORS,DELETE,APPTIEN,APPTIEN44,VAL,RECALLRETURN,RECALL,ENCOUNTER,APPTMSG
+2 ;
+3 DO VALIDATE(.ERRORS,.SDCONTEXT,.APPOINTMENT,.VAL)
+4 IF $DATA(ERRORS)
SET ERRORS("Appointment","IEN")=""
SET APPT("Appointment","Message")=""
DO BUILDJSON^SDES2JSON(.JSON,.ERRORS)
QUIT
+5 IF $GET(SDCONTEXT("USER DUZ"))'=""
NEW DUZ
DO DUZ^XUP(SDCONTEXT("USER DUZ"))
+6 ;
+7 DO CREATE40984(.ERRORS,.DELETE,.APPTIEN,.APPOINTMENT,$PIECE($GET(APPOINTMENT("REQUEST TYPE")),"|"),$PIECE(...
... $GET(APPOINTMENT("REQUEST TYPE")),"|",2),$GET(SDCONTEXT("USER DUZ")),$TRANSLATE($EXTRACT($GET(APPOINTMENT("NOTE")),1,150),"^"," "),$GET(SDCONTEXT("ACHERON AUDIT ID")))
+8 DO CREATE44(.ERRORS,.APPOINTMENT,.DELETE,.APPTIEN44,$GET(SDCONTEXT("USER DUZ")),$GET(APPOINTMENT("CLINIC IEN")),$GET(APPOINTMENT("START DATE TIME")))
+9 DO CREATE2(.ERRORS,.DELETE,.APPOINTMENT,$GET(SDCONTEXT("USER DUZ")),$GET(APPOINTMENT("CLINIC IEN")),$GET(APPOINTMENT("START DATE TIME")),$GET(APPOINTMENT("DFN")))
+10 IF $DATA(ERRORS)
SET ERRORS("Appointment","IEN")=""
SET APPT("Appointment","Message")=""
DO BUILDJSON^SDES2JSON(.JSON,.ERRORS)
QUIT
+11 ;
+12 IF $PIECE($GET(APPOINTMENT("REQUEST TYPE")),"|")="A"
DO APPTREQ^SDES2APPTUTIL(.SDCONTEXT,.APPOINTMENT,APPTIEN,.APPTMSG)
+13 IF $PIECE($GET(APPOINTMENT("REQUEST TYPE")),"|")="R"
DO RECALL^SDES2APPTUTIL(.RECALLRETURN,.SDCONTEXT,.RECALL,$PIECE($GET(APPOINTMENT("REQUEST TYPE")),"|",2))
+14 IF $PIECE($GET(APPOINTMENT("REQUEST TYPE")),"|")="C"
DO CONSULT^SDES2APPTUTIL(.APPOINTMENT,APPTIEN44,$GET(SDCONTEXT("USER DUZ")))
+15 ;
+16 DO SETMISSIONELIG^SDESMISSIONELG($GET(APPTIEN))
+17 ;
+18 DO ENCOUNTERS^SDES2APPTUTIL(.APPOINTMENT,.ENCOUNTER)
+19 ;
+20 DO MAKE^SDES2APPTUTIL($GET(APPOINTMENT("DFN")),$GET(APPOINTMENT("START DATE TIME")),$GET(APPOINTMENT("CLINIC IEN")))
+21 ;
+22 ;D DECREMENTAVAIL1^SDES2APPTUTIL($G(APPOINTMENT("CLINIC IEN")),$G(APPOINTMENT("START DATE TIME")),$G(APPOINTMENT("APPOINTMENT LENGTH")))
+23 ;Update Clinic availability;
DO AVUPDT^SDEC07C(APPOINTMENT("CLINIC IEN"),APPOINTMENT("START DATE TIME"),APPOINTMENT("APPOINTMENT LENGTH"))
+24 ;
+25 ;
+26 IF $DATA(ERRORS)
SET ERRORS("Appointment","IEN")=APPTIEN
DO BUILDJSON^SDES2JSON(.JSON,.ERRORS)
QUIT
+27 ;
+28 SET APPT("Appointment","IEN")=APPTIEN
+29 SET APPT("Appointment","Message")=$GET(APPTMSG)
+30 DO BUILDJSON^SDES2JSON(.JSON,.APPT)
+31 QUIT
+32 ;
CREATE40984(ERRORS,DELETE,APPTIEN,APPOINTMENT,REQUESTTYPE,REQUESTIEN,USERID,NOTE,EAS) ;
+1 NEW FDA,APPTERROR,NEWIEN,APPTERROR,APPTNOTES
+2 ;
+3 SET FDA(409.84,"+1,",.01)=$GET(APPOINTMENT("START DATE TIME"))
+4 SET FDA(409.84,"+1,",.02)=$GET(APPOINTMENT("END DATE TIME"))
+5 SET FDA(409.84,"+1,",.05)=$GET(APPOINTMENT("DFN"))
+6 SET FDA(409.84,"+1,",.06)=$GET(APPOINTMENT("APPOINTMENT TYPE"))
+7 SET FDA(409.84,"+1,",.07)=$GET(APPOINTMENT("RESOURCE IEN"))
+8 SET FDA(409.84,"+1,",.08)=$SELECT(USERID:USERID,1:DUZ)
+9 SET FDA(409.84,"+1,",.09)=$$NOW^XLFDT
+10 SET FDA(409.84,"+1,",.13)=$GET(APPOINTMENT("WALKIN"))
+11 SET FDA(409.84,"+1,",.16)=$GET(APPOINTMENT("PROVIDER IEN"))
+12 SET FDA(409.84,"+1,",.18)=$GET(APPOINTMENT("APPOINTMENT LENGTH"))
+13 SET FDA(409.84,"+1,",.2)=$GET(APPOINTMENT("PATIENT INDICATED DATE"))
+14 SET FDA(409.84,"+1,",.21)=$GET(APPOINTMENT("EXTERNAL ID"))
+15 SET FDA(409.84,"+1,",.22)=$SELECT(REQUESTTYPE'="":REQUESTIEN_";"_$SELECT(REQUESTTYPE="E":"SDWL(409.3,",REQUESTTYPE="C":"GMR(123,",REQUESTTYPE="R":"SD(403.5,",REQUESTTYPE="A":"SDEC(409.85,",1:""),1:"")
+16 SET FDA(409.84,"+1,",.23)=$GET(APPOINTMENT("PATIENT STATUS"))
+17 SET FDA(409.84,"+1,",100)=EAS
+18 DO UPDATE^DIE(,"FDA","NEWIEN","APPTERROR")
KILL FDA,APPTERROR
+19 IF $DATA(APPTERROR)
DO ERRLOG^SDESJSON(.ERRORS,173)
QUIT
+20 ;
+21 SET APPTIEN=$GET(NEWIEN(1))
+22 ;
+23 DO STORENOTE^SDES2APPTUTIL(APPTIEN,NOTE,.APPTNOTES)
+24 DO STOREREQUESTCOMM^SDES2APPTUTIL(REQUESTIEN)
+25 ;
+26 SET DELETE(409.84)=$GET(APPTIEN)_","
+27 QUIT
+28 ;
CREATE44(ERRORS,APPOINTMENT,DELETE,APPTIEN44,USERID,CLINICIEN,STARTDATETIME) ;
+1 NEW FDA,NEWIEN44001,NEWIEN44003,APPTERROR,IENS
+2 ;
+3 IF '$DATA(^SC($GET(CLINICIEN),"S",STARTDATETIME))
Begin DoDot:1
+4 SET NEWIEN44001(1)=STARTDATETIME
+5 SET FDA(44.001,"+1,"_CLINICIEN_",",.01)=STARTDATETIME
+6 DO UPDATE^DIE(,"FDA","NEWIEN44001","APPTERROR")
KILL FDA,APPTERROR
NEW FDA,APPTERROR
End DoDot:1
+7 IF $DATA(APPTERROR)
DO DELETERECORD^SDES2APPTUTIL(.DELETE)
DO ERRLOG^SDESJSON(.ERRORS,173)
QUIT
+8 ;
+9 SET IENS=STARTDATETIME_","_CLINICIEN_","
+10 SET FDA(44.003,"+1,"_IENS,.01)=$GET(APPOINTMENT("DFN"))
+11 SET FDA(44.003,"+1,"_IENS,1)=$GET(APPOINTMENT("APPOINTMENT LENGTH"))
+12 SET FDA(44.003,"+1,"_IENS,3)=$TRANSLATE($EXTRACT($GET(APPOINTMENT("APPOINTMENT REASON")),1,150),"^"," ")
+13 SET FDA(44.003,"+1,"_IENS,30)=$GET(APPOINTMENT("PATIENT ELIGIBILITY"))
+14 SET FDA(44.003,"+1,"_IENS,9)=$SELECT($GET(APPOINTMENT("OVERBOOK"))="O":"O",1:"")
+15 SET FDA(44.003,"+1,"_IENS,7)=$SELECT(USERID:USERID,1:DUZ)
+16 SET FDA(44.003,"+1,"_IENS,8)=$$NOW^XLFDT
+17 DO UPDATE^DIE(,"FDA","NEWIEN44003","APPTERROR")
KILL FDA,APPTERROR
+18 IF $DATA(APPTERROR)
DO DELETERECORD^SDES2APPTUTIL(.DELETE)
DO ERRLOG^SDESJSON(.ERRORS,173)
QUIT
+19 ;
+20 SET DELETE(44.003)=$GET(NEWIEN44003(1))_","_STARTDATETIME_","_CLINICIEN_","
+21 SET APPTIEN44=$GET(NEWIEN44003(1))
+22 QUIT
+23 ;
CREATE2(ERRORS,DELETE,APPOINTMENT,USERID,CLINICIEN,STARTDATETIME,DFN) ;
+1 NEW FDA,NEWIEN,APPTERROR,IENS
+2 ;
+3 IF $DATA(^DPT(DFN,"S",STARTDATETIME,0))
Begin DoDot:1
+4 DO DELETECANRECORD^SDES2APPTUTIL(DFN,STARTDATETIME,CLINICIEN)
End DoDot:1
+5 ;
+6 SET NEWIEN(1)=STARTDATETIME
+7 SET IENS="+1,"_DFN_","
+8 SET FDA(2.98,IENS,".01")=CLINICIEN
+9 SET FDA(2.98,IENS,"3")=$SELECT($GET(^DPT(+$GET(DFN),.1))'="":"I",1:"")
+10 SET FDA(2.98,IENS,"5")=$GET(APPOINTMENT("LAB DATE TIME"))
+11 SET FDA(2.98,IENS,"6")=$GET(APPOINTMENT("XRAY DATE TIME"))
+12 SET FDA(2.98,IENS,"7")=$GET(APPOINTMENT("EKG DATE TIME"))
+13 SET FDA(2.98,IENS,"9")=$GET(APPOINTMENT("PURPOSE"))
+14 SET FDA(2.98,IENS,"9.5")=$GET(APPOINTMENT("APPOINTMENT TYPE"))
+15 SET FDA(2.98,IENS,"13")=$GET(APPOINTMENT("COLLATERAL"))
+16 SET FDA(2.98,IENS,"19")=$SELECT(USERID:USERID,1:DUZ)
+17 SET FDA(2.98,IENS,"20")=$$NOW^XLFDT
+18 SET FDA(2.98,IENS,"25")=$GET(APPOINTMENT("SCHEDULE REQUEST TYPE"))
+19 SET FDA(2.98,IENS,"26")=$GET(APPOINTMENT("NEXT AVAILABLE APPOINTMENT"))
+20 SET FDA(2.98,IENS,"27")=$GET(APPOINTMENT("PATIENT INDICATED DATE"))
+21 SET FDA(2.98,IENS,"28")=$GET(APPOINTMENT("FOLLOWUP"))
+22 ;
+23 LOCK +^DPT(DFN):3
+24 IF '$TEST
DO ERRLOG^SDESJSON(.ERRORS,187)
DO DELETERECORD^SDES2APPTUTIL(.DELETE)
QUIT
+25 ;
+26 DO UPDATE^DIE("","FDA","NEWIEN","APPTERROR")
KILL FDA
+27 ;
+28 LOCK -^DPT(DFN)
+29 IF $DATA(APPTERROR)
DO DELETERECORD^SDES2APPTUTIL(.DELETE)
DO ERRLOG^SDESJSON(.ERRORS,173)
QUIT
+30 QUIT
+31 ;
VALIDATE(ERRORS,SDCONTEXT,APPOINTMENT,VAL,BLOCKANDMOVE) ;
+1 ;
+2 DO VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
+3 IF $DATA(ERRORS)
QUIT
+4 ;
+5 ;
+6 ; =IEN/pointer validation=
+7 ;
+8 DO VALFILEIEN^SDES2VALUTIL(.VAL,.ERRORS,44,$GET(APPOINTMENT("CLINIC IEN")),1,,18,19)
+9 DO VALFILEIEN^SDES2VALUTIL(.VAL,.ERRORS,2,$GET(APPOINTMENT("DFN")),1,,1,2)
+10 DO VALFILEIEN^SDES2VALUTIL(.VAL,.ERRORS,200,$GET(APPOINTMENT("PROVIDER IEN")),,,,54)
+11 DO VALFILEIEN^SDES2VALUTIL(.VAL,.ERRORS,409.85,$GET(APPOINTMENT("MRTC PARENT")),,,,179)
IF $LENGTH($GET(APPOINTMENT("MRTC PARENT")))
IF $$GET1^DIQ(409.85,$GET(APPOINTMENT("MRTC PARENT"))_",",23,"I")="C"
DO ERRLOG^SDESJSON(.ERRORS,433)
+12 DO VALFILEIEN^SDES2VALUTIL(.VAL,.ERRORS,409.831,$GET(APPOINTMENT("RESOURCE IEN")),,,,70)
+13 DO VALFILEIEN^SDES2VALUTIL(.VAL,.ERRORS,8,$GET(APPOINTMENT("PATIENT ELIGIBILITY")),,,,143)
+14 ;
+15 ;
+16 ; =date validation=
+17 ;
+18 SET APPOINTMENT("START DATE TIME")=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$GET(APPOINTMENT("START DATE TIME")),$GET(APPOINTMENT("CLINIC IEN")),1,165,166)
+19 SET APPOINTMENT("END DATE TIME")=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$GET(APPOINTMENT("END DATE TIME")),$GET(APPOINTMENT("CLINIC IEN")),1,167,168)
+20 IF $GET(APPOINTMENT("START DATE TIME"))>$GET(APPOINTMENT("END DATE TIME"))
DO ERRLOG^SDESJSON(.ERRORS,13)
+21 IF $GET(APPOINTMENT("START DATE TIME"))>$$FMADD^XLFDT($$NOW^XLFDT(),$SELECT($$GET1^DIQ(44,$GET(APPOINTMENT("CLINIC IEN")),2002):$$GET1^DIQ(44,$GET(APPOINTMENT("CLINIC IEN")),2002),1:390))
DO ERRLOG^SDESJSON(.ERRORS,177)
+22 ;
+23 SET APPOINTMENT("PATIENT INDICATED DATE")=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$GET(APPOINTMENT("PATIENT INDICATED DATE")),$GET(APPOINTMENT("CLINIC IEN")),,,58)
+24 SET APPOINTMENT("LAB DATE TIME")=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$GET(APPOINTMENT("LAB DATE TIME")),$GET(APPOINTMENT("CLINIC IEN")),,,147)
+25 SET APPOINTMENT("XRAY DATE TIME")=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$GET(APPOINTMENT("XRAY DATE TIME")),$GET(APPOINTMENT("CLINIC IEN")),,,145)
+26 SET APPOINTMENT("EKG DATE TIME")=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$GET(APPOINTMENT("EKG DATE TIME")),$GET(APPOINTMENT("CLINIC IEN")),,,146)
+27 ;
+28 ;
+29 ; =general field validation=
+30 ;
+31 DO VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,409.85,41,$GET(APPOINTMENT("MRTC")))
+32 SET APPOINTMENT("MRTC")=$GET(VAL(409.85,41,"I"))
+33 ;
+34 DO VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,2.98,9,$GET(APPOINTMENT("PURPOSE")),1,,149,148)
+35 SET APPOINTMENT("PURPOSE")=$GET(VAL(2.98,9,"I"))
+36 ;
+37 DO VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,2.98,13,$GET(APPOINTMENT("COLLATERAL")),,,,150)
+38 SET APPOINTMENT("COLLATERAL")=$GET(VAL(2.98,13,"I"))
+39 ;
+40 DO VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,2.98,25,$GET(APPOINTMENT("SCHEDULE REQUEST TYPE")),1,,151,152)
+41 SET APPOINTMENT("SCHEDULE REQUEST TYPE")=$GET(VAL(2.98,25,"I"))
+42 ;
+43 DO VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,2.98,26,$GET(APPOINTMENT("NEXT AVAILABLE APPOINTMENT")),1,,154,153)
+44 SET APPOINTMENT("NEXT AVAILABLE APPOINTMENT")=$GET(VAL(2.98,26,"I"))
+45 ;
+46 DO VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,2.98,28,$GET(APPOINTMENT("FOLLOWUP")),,,,155)
+47 SET APPOINTMENT("FOLLOWUP")=$GET(VAL(2.98,28,"I"))
+48 ;
+49 DO VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,409.84,.18,$GET(APPOINTMENT("APPOINTMENT LENGTH")),1,,115,116)
+50 ;
+51 DO VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,44.003,9,$GET(APPOINTMENT("OVERBOOK")))
+52 SET APPOINTMENT("OVERBOOK")=$GET(VAL(44.003,9,"I"))
+53 ;
+54 DO VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,409.85,15,$GET(APPOINTMENT("SERVICE CONNECTED")))
+55 SET APPOINTMENT("SERVICE CONNECTED")=$GET(VAL(409.85,15,"I"))
+56 ;
+57 DO VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,409.85,14,$GET(APPOINTMENT("SERVICE CONNECTED PERCENTAGE")))
+58 ;
+59 DO VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,409.84,.23,$GET(APPOINTMENT("PATIENT STATUS")))
+60 SET APPOINTMENT("PATIENT STATUS")=$GET(VAL(409.84,.23,"I"))
+61 ;
+62 DO VALFIELD^SDES2VALUTIL(.VAL,.ERRORS,409.84,.13,$GET(APPOINTMENT("WALKIN")),,,,178)
+63 SET APPOINTMENT("WALKIN")=$GET(VAL(409.84,.13,"I"))
+64 ;
+65 ;
+66 IF '$GET(BLOCKANDMOVE)
Begin DoDot:1
+67 DO REQUESTTYPE^SDES2APPTUTIL(.ERRORS,.APPOINTMENT,$PIECE($GET(APPOINTMENT("REQUEST TYPE")),"|"),$PIECE($GET(APPOINTMENT("REQUEST TYPE")),"|",2),$GET(APPOINTMENT("DFN")))
End DoDot:1
+68 DO GETAPPTTYPE^SDES2APPTUTIL(.ERRORS,.APPOINTMENT,$GET(APPOINTMENT("APPOINTMENT TYPE")),$GET(APPOINTMENT("APPOINTMENT TYPE NAME")))
+69 DO GETPID^SDES2APPTUTIL(.APPOINTMENT,$GET(APPOINTMENT("PATIENT INDICATED DATE")),$PIECE($GET(APPOINTMENT("REQUEST TYPE")),"|"),$PIECE($GET(APPOINTMENT("REQUEST TYPE")),"|",2))
+70 IF $DATA(ERRORS)
QUIT
+71 ;
+72 ;
+73 DO GETPROVIDER^SDES2APPTUTIL(.APPOINTMENT,$GET(APPOINTMENT("CLINIC IEN")),$GET(APPOINTMENT("PROVIDER IEN")),$PIECE($GET(APPOINTMENT("REQUEST TYPE")),"|"),$PIECE($GET(APPOINTMENT("REQUEST TYPE")),"|",2))
+74 DO GETRESOURCE^SDES2APPTUTIL(.ERRORS,.APPOINTMENT,$GET(APPOINTMENT("CLINIC IEN")))
+75 IF $$ORDERCHECKLOCK^SDES2APPTUTIL(.ERRORS,$GET(APPOINTMENT("REQUEST TYPE")),$GET(APPOINTMENT("DFN")))
+76 IF $$INACTIVE^SDESUTIL($GET(APPOINTMENT("CLINIC IEN")))
DO ERRLOG^SDESJSON(.ERRORS,19)
+77 IF $$APPTIN44EXISTS^SDES2APPTUTIL($GET(APPOINTMENT("DFN")),$GET(APPOINTMENT("CLINIC IEN")),$GET(APPOINTMENT("START DATE TIME")))
DO ERRLOG^SDESJSON(.ERRORS,175)
+78 IF '$GET(BLOCKANDMOVE)
Begin DoDot:1
+79 IF $$APPTINDIFFTZ^SDES2APPTUTIL($GET(APPOINTMENT("DFN")),$GET(APPOINTMENT("START DATE TIME")))
DO ERRLOG^SDES2JSON(.ERRORS,570)
End DoDot:1
+80 ;
+81 ;
+82 IF $GET(APPOINTMENT("WALKIN"))="y"
IF $PIECE($GET(APPOINTMENT("START DATE TIME")),".")<$PIECE($$NOW^XLFDT(),".")!($PIECE($GET(APPOINTMENT("START DATE TIME")),".")>$PIECE($$NOW^XLFDT(),"."))
DO ERRLOG^SDESJSON(.ERRORS,166)
+83 IF $$FMDIFF^XLFDT($GET(APPOINTMENT("END DATE TIME")),$GET(APPOINTMENT("START DATE TIME")),2)/60'=$GET(APPOINTMENT("APPOINTMENT LENGTH"))
DO ERRLOG^SDESJSON(.ERRORS,116)
+84 IF $PIECE($$FMTISO^SDAMUTDT($GET(APPOINTMENT("START DATE TIME"))),"T",2)=""
DO ERRLOG^SDESJSON(.ERRORS,166)
+85 IF $PIECE($$FMTISO^SDAMUTDT($GET(APPOINTMENT("END DATE TIME"))),"T",2)=""
DO ERRLOG^SDESJSON(.ERRORS,168)
+86 ;
+87 IF APPOINTMENT("MRTC")
IF '$LENGTH($GET(APPOINTMENT("MRTC PARENT")))
DO ERRLOG^SDESJSON(.ERRORS,536)
+88 IF $LENGTH($GET(APPOINTMENT("MRTC PARENT")))
IF $$GET1^DIQ(409.85,$GET(APPOINTMENT("MRTC PARENT"))_",",.01,"I")'=$GET(APPOINTMENT("DFN"))
DO ERRLOG^SDESJSON(.ERRORS,536)
+89 QUIT
+90 ;