SDES2CRTVETAPPT ;ALB/BLB,MGD,TJB - SDES2 CREATE VET REQ AND APPT ;Jun 17, 2024
;;5.3;Scheduling;**867,869,877,881**;Aug 13, 1993;Build 10
;;Per VHA Directive 6402, this routine should not be modified
;
; REQUEST("APPOINTMENT END TIME") = (Required) APPT END TIME - ISO FORMAT
; REQUEST("APPOINTMENT LENGTH") = (Required) APPT LENGTH IN MINUTES (5-240)
; REQUEST("APPOINTMENT START TIME") = (Required) APPT START TIME - ISO FORMAT
; REQUEST("CLINIC IEN") = (Required) CLINIC IEN
; REQUEST("CREATE DATE") = (Required) DATE/TIME ENTERED (#409.85,9.5) in ISO8601 date/time format to include offset (e.g. CCYY-MM-DDTHH:MM-NNNN)
; REQUEST("PATIENT INDICATED DATE") = (Required) CID/PID DATE - ISO FORMAT
; REQUEST("DFN") = (Required) PATIENT IEN
; REQUEST("APPOINTMENT REASON") = (Optional) FREE TEXT (1-150)
; REQUEST("COLLATERAL VISIT") = (Optional) COLLATERAL - 1 FOR YES
; REQUEST("APPOINTMENT TYPE IEN") = (Optional) POINTER TO APPOINTMENT TYPE FILE (#409.1)
; Either APPOINTMENT TYPE IEN or APPOINTMENT TYPE NAME is Required
; REQUEST("APPOINTMENT TYPE NAME") = (Optional) NAME from APPOINTMENT TYPE FILE (#409.1)
; REQUEST("EAS") = (Optional) Enterprise APPT Scheduling Tracking Number associated to an appt.
; REQUEST("FOLLOWUP") = (Optional) FOLLOWUP VISIT - 1 FOR YES 0 FOR NO
; REQUEST("INSTITUTION NAME") = (Optional) Institution name from the INSTITUTION file
; REQUEST("MODALITY") = (Optional) Valid Values: FACE2FACE, TELEPHONE, VIDEO
; REQUEST("NOTE") = (Optional) NOTE - FREE TEXT 1-150
; REQUEST("OVERBOOK") = (Optional) OVERBOOK (0 for no, 1 for yes)
; REQUEST("PATIENT COMMENT") = (Optional) Patient-entered comments when using VAOS or other web-service (stored at 409.85,60 a word processing field)
; REQUEST("PATIENT ELIGIBILITY IEN") = (Optional) ELIGIBILITY IEN
; REQUEST("PATIENT PREFERRED END DATE",1) = (Optional) PATIENT PREFERRED END DATE 1 - ISO FORMAT
; REQUEST("PATIENT PREFERRED END DATE",2) = (Optional) PATIENT PREFERRED END DATE 2 - ISO FORMAT
; REQUEST("PATIENT PREFERRED END DATE",3) = (Optional) PATIENT PREFERRED END DATE 3 - ISO FORMAT
; REQUEST("PATIENT PREFERRED START DATE",1)= (Optional) PATIENT PREFERRED START DATE 1 - ISO FORMAT
; REQUEST("PATIENT PREFERRED START DATE",2)= (Optional) PATIENT PREFERRED START DATE 2 - ISO FORMAT
; REQUEST("PATIENT PREFERRED START DATE",3)= (Optional) PATIENT PREFERRED START DATE 3 - ISO FORMAT
; REQUEST("PATIENT STATUS") = (Optional) PATIENT STATUS - "NEW" OR "ESTABLISHED
; REQUEST("PRIORITY") = (Optional) PRIORITY - "ASAP" or FUTURE
; REQUEST("PRIORITY GROUP") = (Optional) ENROLLMENT PRIORITY - GROUP 1 - GROUP 7
; REQUEST("REQUEST COMMENT") = (Optional) REQUEST COMMENT
; REQUEST("SECONDARY STOP CODE") = (Optional) Secondary Stop Code Number pointer to CLINIC STOP file #40.7 used to populate the REQ SECONDARY STOP CODE field in 409.85
; REQUEST("SERVICE CONNECTED") = (Optional) Valid Values: YES, NO
; REQUEST("SERVICE CONNECTED PERCENTAGE") = (Optional) SC % = 0-100
; REQUEST("STATION NUMBER") = (Optional) STATION NUMBER (#99),INSTITUTION (#4)
; REQUEST("STOP CODE") = (Optional) CLINIC STOP pointer to CLINIC STOP file 40.7 used to populate the REQ SERVICE/SPECIALTY field in 409.85
; REQUEST("VAOS GUID") = (Optional) VAOS GUID
;
Q
;
CREATEREQANDAPPT(JSON,SDCONTEXT,REQUEST) ;
N ERRORS,RETURN,REQUESTIEN,JSONREQUEST,REQUESTRETURN,JSONAPPT,APPTRETURN,APPOINTMENT,JSONDISP,DISPOSITION,VALRETURN
;
; validate
D VALIDATE(.ERRORS,.VALRETURN,.SDCONTEXT,$G(REQUEST("DFN")),$G(REQUEST("APPOINTMENT START TIME")),$G(REQUEST("APPOINTMENT END TIME")),$G(REQUEST("CLINIC IEN")))
I $D(ERRORS) S ERRORS("Appointment","IEN")="",ERRORS("Request","IEN")="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
;
; create request
D CREATEREQUEST(.JSONREQUEST,.REQUESTRETURN,.REQUEST,.REQUESTIEN,.ERRORS)
I $D(ERRORS) S ERRORS("Appointment","IEN")="",ERRORS("Request","IEN")="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
S RETURN("Request","IEN")=REQUESTIEN
;
; create appointment
D CREATEAPPT(.JSONAPPT,.APPTRETURN,.APPTIEN,REQUESTIEN,.SDCONTEXT,.ERRORS)
I $D(ERRORS) S ERRORS("Appointment","IEN")="",ERRORS("Request","IEN")="" D DELETEREQUEST(REQUESTIEN),BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
S RETURN("Appointment","IEN")=APPTIEN
;
; disposition request
D DISPOSITIONREQ(.DISPOSITION,.JSONDISP,.SDCONTEXT,REQUESTIEN,$G(REQUEST("PATIENT COMMENT")))
;
; json
D BUILDJSON^SDES2JSON(.JSON,.RETURN)
Q
;
CREATEREQUEST(JSONREQUEST,REQUESTRETURN,REQUEST,REQUESTIEN,ERRORS) ;
N INSTITUTIONIEN,VALIDATEREQUEST
S REQUEST("REQUESTED BY")="PATIENT"
S REQUEST("REQUEST SUB TYPE")="APPT"
M VALIDATEREQUEST=REQUEST
D VALIDATE^SDESCREATEAPPREQ(.VALIDATEREQUEST,.INSTITUTIONIEN,.ERRORS)
I $D(ERRORS) Q
;
D CREATEREQUEST^SDESCREATEAPPREQ(.JSONREQUEST,.REQUEST)
D DECODE^XLFJSON("JSONREQUEST","REQUESTRETURN")
S REQUESTIEN=$G(REQUESTRETURN("Request","IEN"))
Q
;
CREATEAPPT(JSONAPPT,APPTRETURN,APPTIEN,REQUESTIEN,SDCONTEXT,ERRORS) ;
N VAL,VALIDATEAPPT
D BUILDAPPTARRAY(.REQUEST,.APPOINTMENT,REQUESTIEN)
;
M VALIDATEAPPT=APPOINTMENT
D VALIDATE^SDES2CREATEAPPT(.ERRORS,.SDCONTEXT,.VALIDATEAPPT,.VAL)
I $D(ERRORS) Q
;
D CREATE^SDES2CREATEAPPT(.JSONAPPT,.SDCONTEXT,.APPOINTMENT)
D DECODE^XLFJSON("JSONAPPT","APPTRETURN")
S APPTIEN=$G(APPTRETURN("Appointment","IEN"))
Q
;
DISPOSITIONREQ(DISPOSITION,JSONDISP,SDCONTEXT,REQUESTIEN,COMMENTS) ;
S DISPOSITION("DISP")="REMOVED/SCHEDULED-ASSIGNED"
S DISPOSITION("REQUEST ID")=REQUESTIEN
S DISPOSITION("DISPDT")=$TR($$FMTE^XLFDT($$NOW^XLFDT,"7DZ"),"/","-")
S DISPOSITION("PATCMMTS")=COMMENTS
D DISPOSITION^SDES2ARCLOSE(.JSONDISP,.SDCONTEXT,.DISPOSITION)
Q
;
DELETEREQUEST(REQUESTIEN) ;
N FDA
S FDA(409.85,REQUESTIEN_",",.01)="@"
D FILE^DIE(,"FDA") K FDA
Q
;
VALIDATE(ERRORS,VALRETURN,SDCONTEXT,DFN,START,END,CLINICIEN) ;
D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
D VALFILEIEN^SDES2VALUTIL(.VALRETURN,.ERRORS,2,DFN,1,,1,2)
D VALFILEIEN^SDES2VALUTIL(.VALRETURN,.ERRORS,44,CLINICIEN,1,,18,19)
D CHECKAPPTOVERLAP(.ERRORS,DFN,START,END)
;
S START=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,START,CLINICIEN,1,165,166)
S END=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,END,CLINICIEN,1,167,168)
Q
;
CHECKAPPTOVERLAP(ERRORS,DFN,START,END) ; checking for overlaps with existing appointments
N APPTIEN,APPTSTART,APPTEND,OVERLAP
;
S APPTIEN=0,OVERLAP=0
F S APPTIEN=$O(^SDEC(409.84,"CPAT",DFN,APPTIEN)) Q:'APPTIEN!(OVERLAP) D
.S APPTSTART=$$GET1^DIQ(409.84,APPTIEN,.01,"I")
.S APPTEND=$$GET1^DIQ(409.84,APPTIEN,.02,"I")
.I START>=APPTSTART,START<APPTEND S OVERLAP=1 Q
.I END>APPTSTART,END<=APPTEND S OVERLAP=1
I $G(OVERLAP) D ERRLOG^SDESJSON(.ERRORS,540)
Q
;
BUILDAPPTARRAY(REQUEST,APPOINTMENT,REQUESTIEN) ;
S APPOINTMENT("START DATE TIME")=$G(REQUEST("APPOINTMENT START TIME"))
S APPOINTMENT("END DATE TIME")=REQUEST("APPOINTMENT END TIME")
S APPOINTMENT("DFN")=$G(REQUEST("DFN"))
S APPOINTMENT("RESOURCE IEN")=$S($G(REQUEST("CLINIC IEN"))="":"",1:$$GETRES^SDESINPUTVALUTL($G(REQUEST("CLINIC IEN")),1))
S APPOINTMENT("WALKIN")=""
S APPOINTMENT("PATIENT INDICATED DATE")=$$FMTISO^SDAMUTDT($G(REQUEST("PATIENT INDICATED DATE")))
S APPOINTMENT("EXTERNAL ID")=""
S APPOINTMENT("REQUEST TYPE")="A|"_REQUESTIEN
S APPOINTMENT("PROVIDER IEN")=""
S APPOINTMENT("CLINIC IEN")=$G(REQUEST("CLINIC IEN"))
S APPOINTMENT("NOTE")=$G(REQUEST("NOTE"))
S APPOINTMENT("APPOINTMENT TYPE")=$G(REQUEST("APPOINTMENT TYPE IEN"))
S APPOINTMENT("APPOINTMENT TYPE NAME")=$G(REQUEST("APPOINTMENT TYPE NAME"))
S APPOINTMENT("PATIENT STATUS")=$G(REQUEST("PATIENT STATUS"))
S APPOINTMENT("APPOINTMENT LENGTH")=$G(REQUEST("APPOINTMENT LENGTH"))
S APPOINTMENT("SERVICE CONNECTED")=$G(REQUEST("SERVICE CONNECTED"))
S APPOINTMENT("SERVICE CONNECTED PERCENTAGE")=$G(REQUEST("SERVICE CONNECTED PERCENTAGE"))
S APPOINTMENT("MRTC")=0
S APPOINTMENT("MRTC PARENT")=""
S APPOINTMENT("APPOINTMENT REASON")=$G(REQUEST("APPOINTMENT REASON"))
S APPOINTMENT("PATIENT ELIGIBILITY")=$G(REQUEST("PATIENT ELIGIBILITY IEN"))
S APPOINTMENT("OVERBOOK")=$G(REQUEST("OVERBOOK"))
S APPOINTMENT("LAB DATE TIME")=""
S APPOINTMENT("XRAY DATE TIME")=""
S APPOINTMENT("EKG DATE TIME")=""
S APPOINTMENT("PURPOSE")=3 ;Always set to '3' - per Judy Mercado
S APPOINTMENT("COLLATERAL")=$G(REQUEST("COLLATERAL VISIT"))
S APPOINTMENT("SCHEDULE REQUEST TYPE")="P" ;Always set to 'P' - per Judy Mercado
S APPOINTMENT("NEXT AVAILABLE APPOINTMENT")=0 ;Always set to '0' - per Judy Mercado
S APPOINTMENT("FOLLOWUP")=$G(REQUEST("FOLLOWUP"))
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2CRTVETAPPT 9131 printed Dec 13, 2024@02:53:40 Page 2
SDES2CRTVETAPPT ;ALB/BLB,MGD,TJB - SDES2 CREATE VET REQ AND APPT ;Jun 17, 2024
+1 ;;5.3;Scheduling;**867,869,877,881**;Aug 13, 1993;Build 10
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ; REQUEST("APPOINTMENT END TIME") = (Required) APPT END TIME - ISO FORMAT
+5 ; REQUEST("APPOINTMENT LENGTH") = (Required) APPT LENGTH IN MINUTES (5-240)
+6 ; REQUEST("APPOINTMENT START TIME") = (Required) APPT START TIME - ISO FORMAT
+7 ; REQUEST("CLINIC IEN") = (Required) CLINIC IEN
+8 ; REQUEST("CREATE DATE") = (Required) DATE/TIME ENTERED (#409.85,9.5) in ISO8601 date/time format to include offset (e.g. CCYY-MM-DDTHH:MM-NNNN)
+9 ; REQUEST("PATIENT INDICATED DATE") = (Required) CID/PID DATE - ISO FORMAT
+10 ; REQUEST("DFN") = (Required) PATIENT IEN
+11 ; REQUEST("APPOINTMENT REASON") = (Optional) FREE TEXT (1-150)
+12 ; REQUEST("COLLATERAL VISIT") = (Optional) COLLATERAL - 1 FOR YES
+13 ; REQUEST("APPOINTMENT TYPE IEN") = (Optional) POINTER TO APPOINTMENT TYPE FILE (#409.1)
+14 ; Either APPOINTMENT TYPE IEN or APPOINTMENT TYPE NAME is Required
+15 ; REQUEST("APPOINTMENT TYPE NAME") = (Optional) NAME from APPOINTMENT TYPE FILE (#409.1)
+16 ; REQUEST("EAS") = (Optional) Enterprise APPT Scheduling Tracking Number associated to an appt.
+17 ; REQUEST("FOLLOWUP") = (Optional) FOLLOWUP VISIT - 1 FOR YES 0 FOR NO
+18 ; REQUEST("INSTITUTION NAME") = (Optional) Institution name from the INSTITUTION file
+19 ; REQUEST("MODALITY") = (Optional) Valid Values: FACE2FACE, TELEPHONE, VIDEO
+20 ; REQUEST("NOTE") = (Optional) NOTE - FREE TEXT 1-150
+21 ; REQUEST("OVERBOOK") = (Optional) OVERBOOK (0 for no, 1 for yes)
+22 ; REQUEST("PATIENT COMMENT") = (Optional) Patient-entered comments when using VAOS or other web-service (stored at 409.85,60 a word processing field)
+23 ; REQUEST("PATIENT ELIGIBILITY IEN") = (Optional) ELIGIBILITY IEN
+24 ; REQUEST("PATIENT PREFERRED END DATE",1) = (Optional) PATIENT PREFERRED END DATE 1 - ISO FORMAT
+25 ; REQUEST("PATIENT PREFERRED END DATE",2) = (Optional) PATIENT PREFERRED END DATE 2 - ISO FORMAT
+26 ; REQUEST("PATIENT PREFERRED END DATE",3) = (Optional) PATIENT PREFERRED END DATE 3 - ISO FORMAT
+27 ; REQUEST("PATIENT PREFERRED START DATE",1)= (Optional) PATIENT PREFERRED START DATE 1 - ISO FORMAT
+28 ; REQUEST("PATIENT PREFERRED START DATE",2)= (Optional) PATIENT PREFERRED START DATE 2 - ISO FORMAT
+29 ; REQUEST("PATIENT PREFERRED START DATE",3)= (Optional) PATIENT PREFERRED START DATE 3 - ISO FORMAT
+30 ; REQUEST("PATIENT STATUS") = (Optional) PATIENT STATUS - "NEW" OR "ESTABLISHED
+31 ; REQUEST("PRIORITY") = (Optional) PRIORITY - "ASAP" or FUTURE
+32 ; REQUEST("PRIORITY GROUP") = (Optional) ENROLLMENT PRIORITY - GROUP 1 - GROUP 7
+33 ; REQUEST("REQUEST COMMENT") = (Optional) REQUEST COMMENT
+34 ; REQUEST("SECONDARY STOP CODE") = (Optional) Secondary Stop Code Number pointer to CLINIC STOP file #40.7 used to populate the REQ SECONDARY STOP CODE field in 409.85
+35 ; REQUEST("SERVICE CONNECTED") = (Optional) Valid Values: YES, NO
+36 ; REQUEST("SERVICE CONNECTED PERCENTAGE") = (Optional) SC % = 0-100
+37 ; REQUEST("STATION NUMBER") = (Optional) STATION NUMBER (#99),INSTITUTION (#4)
+38 ; REQUEST("STOP CODE") = (Optional) CLINIC STOP pointer to CLINIC STOP file 40.7 used to populate the REQ SERVICE/SPECIALTY field in 409.85
+39 ; REQUEST("VAOS GUID") = (Optional) VAOS GUID
+40 ;
+41 QUIT
+42 ;
CREATEREQANDAPPT(JSON,SDCONTEXT,REQUEST) ;
+1 NEW ERRORS,RETURN,REQUESTIEN,JSONREQUEST,REQUESTRETURN,JSONAPPT,APPTRETURN,APPOINTMENT,JSONDISP,DISPOSITION,VALRETURN
+2 ;
+3 ; validate
+4 DO VALIDATE(.ERRORS,.VALRETURN,.SDCONTEXT,$GET(REQUEST("DFN")),$GET(REQUEST("APPOINTMENT START TIME")),$GET(REQUEST("APPOINTMENT END TIME")),$GET(REQUEST("CLINIC IEN")))
+5 IF $DATA(ERRORS)
SET ERRORS("Appointment","IEN")=""
SET ERRORS("Request","IEN")=""
DO BUILDJSON^SDES2JSON(.JSON,.ERRORS)
QUIT
+6 ;
+7 ; create request
+8 DO CREATEREQUEST(.JSONREQUEST,.REQUESTRETURN,.REQUEST,.REQUESTIEN,.ERRORS)
+9 IF $DATA(ERRORS)
SET ERRORS("Appointment","IEN")=""
SET ERRORS("Request","IEN")=""
DO BUILDJSON^SDES2JSON(.JSON,.ERRORS)
QUIT
+10 SET RETURN("Request","IEN")=REQUESTIEN
+11 ;
+12 ; create appointment
+13 DO CREATEAPPT(.JSONAPPT,.APPTRETURN,.APPTIEN,REQUESTIEN,.SDCONTEXT,.ERRORS)
+14 IF $DATA(ERRORS)
SET ERRORS("Appointment","IEN")=""
SET ERRORS("Request","IEN")=""
DO DELETEREQUEST(REQUESTIEN)
DO BUILDJSON^SDES2JSON(.JSON,.ERRORS)
QUIT
+15 SET RETURN("Appointment","IEN")=APPTIEN
+16 ;
+17 ; disposition request
+18 DO DISPOSITIONREQ(.DISPOSITION,.JSONDISP,.SDCONTEXT,REQUESTIEN,$GET(REQUEST("PATIENT COMMENT")))
+19 ;
+20 ; json
+21 DO BUILDJSON^SDES2JSON(.JSON,.RETURN)
+22 QUIT
+23 ;
CREATEREQUEST(JSONREQUEST,REQUESTRETURN,REQUEST,REQUESTIEN,ERRORS) ;
+1 NEW INSTITUTIONIEN,VALIDATEREQUEST
+2 SET REQUEST("REQUESTED BY")="PATIENT"
+3 SET REQUEST("REQUEST SUB TYPE")="APPT"
+4 MERGE VALIDATEREQUEST=REQUEST
+5 DO VALIDATE^SDESCREATEAPPREQ(.VALIDATEREQUEST,.INSTITUTIONIEN,.ERRORS)
+6 IF $DATA(ERRORS)
QUIT
+7 ;
+8 DO CREATEREQUEST^SDESCREATEAPPREQ(.JSONREQUEST,.REQUEST)
+9 DO DECODE^XLFJSON("JSONREQUEST","REQUESTRETURN")
+10 SET REQUESTIEN=$GET(REQUESTRETURN("Request","IEN"))
+11 QUIT
+12 ;
CREATEAPPT(JSONAPPT,APPTRETURN,APPTIEN,REQUESTIEN,SDCONTEXT,ERRORS) ;
+1 NEW VAL,VALIDATEAPPT
+2 DO BUILDAPPTARRAY(.REQUEST,.APPOINTMENT,REQUESTIEN)
+3 ;
+4 MERGE VALIDATEAPPT=APPOINTMENT
+5 DO VALIDATE^SDES2CREATEAPPT(.ERRORS,.SDCONTEXT,.VALIDATEAPPT,.VAL)
+6 IF $DATA(ERRORS)
QUIT
+7 ;
+8 DO CREATE^SDES2CREATEAPPT(.JSONAPPT,.SDCONTEXT,.APPOINTMENT)
+9 DO DECODE^XLFJSON("JSONAPPT","APPTRETURN")
+10 SET APPTIEN=$GET(APPTRETURN("Appointment","IEN"))
+11 QUIT
+12 ;
DISPOSITIONREQ(DISPOSITION,JSONDISP,SDCONTEXT,REQUESTIEN,COMMENTS) ;
+1 SET DISPOSITION("DISP")="REMOVED/SCHEDULED-ASSIGNED"
+2 SET DISPOSITION("REQUEST ID")=REQUESTIEN
+3 SET DISPOSITION("DISPDT")=$TRANSLATE($$FMTE^XLFDT($$NOW^XLFDT,"7DZ"),"/","-")
+4 SET DISPOSITION("PATCMMTS")=COMMENTS
+5 DO DISPOSITION^SDES2ARCLOSE(.JSONDISP,.SDCONTEXT,.DISPOSITION)
+6 QUIT
+7 ;
DELETEREQUEST(REQUESTIEN) ;
+1 NEW FDA
+2 SET FDA(409.85,REQUESTIEN_",",.01)="@"
+3 DO FILE^DIE(,"FDA")
KILL FDA
+4 QUIT
+5 ;
VALIDATE(ERRORS,VALRETURN,SDCONTEXT,DFN,START,END,CLINICIEN) ;
+1 DO VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
+2 DO VALFILEIEN^SDES2VALUTIL(.VALRETURN,.ERRORS,2,DFN,1,,1,2)
+3 DO VALFILEIEN^SDES2VALUTIL(.VALRETURN,.ERRORS,44,CLINICIEN,1,,18,19)
+4 DO CHECKAPPTOVERLAP(.ERRORS,DFN,START,END)
+5 ;
+6 SET START=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,START,CLINICIEN,1,165,166)
+7 SET END=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,END,CLINICIEN,1,167,168)
+8 QUIT
+9 ;
CHECKAPPTOVERLAP(ERRORS,DFN,START,END) ; checking for overlaps with existing appointments
+1 NEW APPTIEN,APPTSTART,APPTEND,OVERLAP
+2 ;
+3 SET APPTIEN=0
SET OVERLAP=0
+4 FOR
SET APPTIEN=$ORDER(^SDEC(409.84,"CPAT",DFN,APPTIEN))
if 'APPTIEN!(OVERLAP)
QUIT
Begin DoDot:1
+5 SET APPTSTART=$$GET1^DIQ(409.84,APPTIEN,.01,"I")
+6 SET APPTEND=$$GET1^DIQ(409.84,APPTIEN,.02,"I")
+7 IF START>=APPTSTART
IF START<APPTEND
SET OVERLAP=1
QUIT
+8 IF END>APPTSTART
IF END<=APPTEND
SET OVERLAP=1
End DoDot:1
+9 IF $GET(OVERLAP)
DO ERRLOG^SDESJSON(.ERRORS,540)
+10 QUIT
+11 ;
BUILDAPPTARRAY(REQUEST,APPOINTMENT,REQUESTIEN) ;
+1 SET APPOINTMENT("START DATE TIME")=$GET(REQUEST("APPOINTMENT START TIME"))
+2 SET APPOINTMENT("END DATE TIME")=REQUEST("APPOINTMENT END TIME")
+3 SET APPOINTMENT("DFN")=$GET(REQUEST("DFN"))
+4 SET APPOINTMENT("RESOURCE IEN")=$SELECT($GET(REQUEST("CLINIC IEN"))="":"",1:$$GETRES^SDESINPUTVALUTL($GET(REQUEST("CLINIC IEN")),1))
+5 SET APPOINTMENT("WALKIN")=""
+6 SET APPOINTMENT("PATIENT INDICATED DATE")=$$FMTISO^SDAMUTDT($GET(REQUEST("PATIENT INDICATED DATE")))
+7 SET APPOINTMENT("EXTERNAL ID")=""
+8 SET APPOINTMENT("REQUEST TYPE")="A|"_REQUESTIEN
+9 SET APPOINTMENT("PROVIDER IEN")=""
+10 SET APPOINTMENT("CLINIC IEN")=$GET(REQUEST("CLINIC IEN"))
+11 SET APPOINTMENT("NOTE")=$GET(REQUEST("NOTE"))
+12 SET APPOINTMENT("APPOINTMENT TYPE")=$GET(REQUEST("APPOINTMENT TYPE IEN"))
+13 SET APPOINTMENT("APPOINTMENT TYPE NAME")=$GET(REQUEST("APPOINTMENT TYPE NAME"))
+14 SET APPOINTMENT("PATIENT STATUS")=$GET(REQUEST("PATIENT STATUS"))
+15 SET APPOINTMENT("APPOINTMENT LENGTH")=$GET(REQUEST("APPOINTMENT LENGTH"))
+16 SET APPOINTMENT("SERVICE CONNECTED")=$GET(REQUEST("SERVICE CONNECTED"))
+17 SET APPOINTMENT("SERVICE CONNECTED PERCENTAGE")=$GET(REQUEST("SERVICE CONNECTED PERCENTAGE"))
+18 SET APPOINTMENT("MRTC")=0
+19 SET APPOINTMENT("MRTC PARENT")=""
+20 SET APPOINTMENT("APPOINTMENT REASON")=$GET(REQUEST("APPOINTMENT REASON"))
+21 SET APPOINTMENT("PATIENT ELIGIBILITY")=$GET(REQUEST("PATIENT ELIGIBILITY IEN"))
+22 SET APPOINTMENT("OVERBOOK")=$GET(REQUEST("OVERBOOK"))
+23 SET APPOINTMENT("LAB DATE TIME")=""
+24 SET APPOINTMENT("XRAY DATE TIME")=""
+25 SET APPOINTMENT("EKG DATE TIME")=""
+26 ;Always set to '3' - per Judy Mercado
SET APPOINTMENT("PURPOSE")=3
+27 SET APPOINTMENT("COLLATERAL")=$GET(REQUEST("COLLATERAL VISIT"))
+28 ;Always set to 'P' - per Judy Mercado
SET APPOINTMENT("SCHEDULE REQUEST TYPE")="P"
+29 ;Always set to '0' - per Judy Mercado
SET APPOINTMENT("NEXT AVAILABLE APPOINTMENT")=0
+30 SET APPOINTMENT("FOLLOWUP")=$GET(REQUEST("FOLLOWUP"))
+31 QUIT
+32 ;