Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SDES2CREATEAPPT

SDES2CREATEAPPT.m

Go to the documentation of this file.
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
 ;