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

SDESGETPATAPPT.m

Go to the documentation of this file.
SDESGETPATAPPT ;ALB/BLB,ANU - VISTA SCHEDULING RPCS ;JUNE 27, 2023@14:48
 ;;5.3;Scheduling;**809,847**;Aug 13, 1993;Build 4
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 Q
 ;
GETSINGLEAPPT(SDECY,DFN,DATETIME,CLINIC) ; get single appt from patient 2 multiple based on dfn and date/time
 N DFNERRORS,HASDFNERRORS,RETURN,HASDTTMERRORS,DTTMERRORS,SINGLEAPPT,APPT,SDPATAPPT,NUM,ERRORS,HASCLINICERRORS
 ;;
 S HASDFNERRORS=$$VALIDATEPTDFN(.ERRORS,$G(DFN))
 I HASDFNERRORS M RETURN=ERRORS
 ;;
 S HASDTTMERRORS=$$VALIDATEDTTM(.ERRORS,$G(DATETIME))
 I HASDTTMERRORS M RETURN=ERRORS
 ;;
 S HASCLINICERRORS=$$VALIDATECLINIC(.ERRORS,$G(CLINIC))
 I HASCLINICERRORS M RETURN=ERRORS
 ; 
 I '$D(ERRORS) D
 .S NUM=1
 .S SINGLEAPPT=$$GETAPPT(.SDPATAPPT,$G(DFN),$$ISOTFM^SDAMUTDT(DATETIME,CLINIC))
 .I SINGLEAPPT M RETURN=SDPATAPPT
 ;;
 D BUILDJSON(.SDECY,.RETURN) ;
 D CLEANUP
 Q
 ;
GETALLAPPTS(SDECY,DFN) ;
 N HASDFNERRORS,RETURN,APPT,NUM,ERRORS,SUBIEN,SDPATAPPT
 ;
 S HASDFNERRORS=$$VALIDATEPTDFN(.ERRORS,$G(DFN))
 I HASDFNERRORS M RETURN=ERRORS
 ;
 I '$D(ERRORS) D
 .S SUBIEN=0,NUM=0
 .F  S SUBIEN=$O(^DPT(DFN,"S",SUBIEN)) Q:'SUBIEN  D
 ..S NUM=NUM+1
 ..S APPT=$$GETAPPT(.SDPATAPPT,$G(DFN),SUBIEN)
 ..I $G(APPT) M RETURN=SDPATAPPT
 D BUILDJSON(.SDECY,.RETURN)
 D CLEANUP
 Q
VALIDATECLINIC(ERRORS,CLINIC) ;
 N ERRORFLAG
 I CLINIC="" S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,18)
 I CLINIC'="",'$D(^SC(CLINIC,0)) S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,19)
 Q $D(ERRORFLAG)
 ;
VALIDATEPTDFN(ERRORS,DFN) ; VALIDATE PATIENT DFN
 N ERRORFLAG
 I DFN="" S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,1)
 I DFN'="",'$D(^DPT(DFN,0)) S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,2)
 Q $D(ERRORFLAG)
 ;
VALIDATEDTTM(ERRORS,DATETIME) ;
 N ERRORFLAG,VALIDATED
 I DATETIME="" S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,25)
 I DATETIME'="" D
 .S VALIDATED=$$ISOTFM^SDAMUTDT(DATETIME,CLINIC)
 .I VALIDATED=-1!(VALIDATED="") S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,27)
 Q $D(ERRORFLAG)
 ;
GETAPPT(SDPATAPPT,DFN,DATETIME) ; get patient appointment from file
 N IENS,F,APPTARY,FMDATE,CLINICIEN,OUTPDATE
 S F=2.98
 S IENS=DATETIME_","_DFN_"," ;
 D GETS^DIQ(F,IENS,"**","IE","APPTARY","ERR")
 S CLINICIEN=$G(APPTARY(F,IENS,.01,"I"))
 S SDPATAPPT("PatientAppt",NUM,"AppointmentDateTime")=$$FMTISO^SDAMUTDT($G(APPTARY(F,IENS,.001,"I")),CLINICIEN)
 S SDPATAPPT("PatientAppt",NUM,"Clinic")=$G(APPTARY(F,IENS,.01,"E"))
 S SDPATAPPT("PatientAppt",NUM,"TelephoneOfClinic")=$G(APPTARY(F,IENS,.02,"E"))
 S SDPATAPPT("PatientAppt",NUM,"Status")=$G(APPTARY(F,IENS,3,"E"))
 S SDPATAPPT("PatientAppt",NUM,"RealAppointment")=$G(APPTARY(F,IENS,4,"E"))
 S SDPATAPPT("PatientAppt",NUM,"LabDateTime")=$$FMTISO^SDAMUTDT($G(APPTARY(F,IENS,5,"I")),CLINICIEN)
 S SDPATAPPT("PatientAppt",NUM,"XrayDateTime")=$$FMTISO^SDAMUTDT($G(APPTARY(F,IENS,6,"I")),CLINICIEN)
 S SDPATAPPT("PatientAppt",NUM,"EkgDateTime")=$$FMTISO^SDAMUTDT($G(APPTARY(F,IENS,7,"I")),CLINICIEN)
 S SDPATAPPT("PatientAppt",NUM,"RoutingSlipPrinted")=$G(APPTARY(F,IENS,8,"E"))
 S SDPATAPPT("PatientAppt",NUM,"RoutingSlipPrintDate")=$$FMTISO^SDAMUTDT($G(APPTARY(F,IENS,8.5,"I")))
 S SDPATAPPT("PatientAppt",NUM,"PurposeOfVisit")=$G(APPTARY(F,IENS,9,"E"))
 S SDPATAPPT("PatientAppt",NUM,"AppointmentType")=$G(APPTARY(F,IENS,9.5,"E"))
 S SDPATAPPT("PatientAppt",NUM,"SpecialSurveyDisposition")=$G(APPTARY(F,IENS,10,"E"))
 S SDPATAPPT("PatientAppt",NUM,"NumberOfCollateralSeen")=$G(APPTARY(F,IENS,11,"E"))
 S SDPATAPPT("PatientAppt",NUM,"AutoRebookedApptDateTime")=$$FMTISO^SDAMUTDT($G(APPTARY(F,IENS,12,"I")))
 S SDPATAPPT("PatientAppt",NUM,"CollateralVisit")=$G(APPTARY(F,IENS,13,"E"))
 S SDPATAPPT("PatientAppt",NUM,"NoShowCancelledBy")=$G(APPTARY(F,IENS,14,"E"))
 S SDPATAPPT("PatientAppt",NUM,"NoShowCancelDateTime")=$$FMTISO^SDAMUTDT($G(APPTARY(F,IENS,15,"I")))
 S SDPATAPPT("PatientAppt",NUM,"CancellationReason")=$G(APPTARY(F,IENS,16,"E"))
 S SDPATAPPT("PatientAppt",NUM,"CancellationRemarks")=$G(APPTARY(F,IENS,17,"E"))
 S SDPATAPPT("PatientAppt",NUM,"ApptCancelled")=$G(APPTARY(F,IENS,18,"E"))
 S SDPATAPPT("PatientAppt",NUM,"DataEntryClerk")=$G(APPTARY(F,IENS,19,"E"))
 S SDPATAPPT("PatientAppt",NUM,"DateApptMade")=$$FMTISO^SDAMUTDT($G(APPTARY(F,IENS,20,"I")))
 S OUTPDATE=$$GET1^DIQ(409.68,$G(APPTARY(F,IENS,21,"I")),.01,"I")
 S SDPATAPPT("PatientAppt",NUM,"OutpatientEncounter")=$$FMTISO^SDAMUTDT($G(OUTPDATE))
 S SDPATAPPT("PatientAppt",NUM,"EncounterFormsPrinted")=$G(APPTARY(F,IENS,22,"E"))
 S SDPATAPPT("PatientAppt",NUM,"EncounterFormsAsAddOns")=$G(APPTARY(F,IENS,23,"E"))
 S SDPATAPPT("PatientAppt",NUM,"EncounterConversionStatus")=$G(APPTARY(F,IENS,23.1,"E"))
 S SDPATAPPT("PatientAppt",NUM,"AppointmentTypeSubCategory")=$G(APPTARY(F,IENS,24,"E"))
 S SDPATAPPT("PatientAppt",NUM,"SchedulingRequestType")=$G(APPTARY(F,IENS,25,"E"))
 S SDPATAPPT("PatientAppt",NUM,"NextAvaApptIndicator")=$G(APPTARY(F,IENS,26,"E"))
 S SDPATAPPT("PatientAppt",NUM,"DesiredDateOfAppointment")=$$FMTISO^SDAMUTDT($G(APPTARY(F,IENS,27,"I")))
 S SDPATAPPT("PatientAppt",NUM,"FollowUpVisit")=$G(APPTARY(F,IENS,28,"E"))
 S SDPATAPPT("PatientAppt",NUM,"SchedulingApplication")=$G(APPTARY(F,IENS,29,"I"))
 S SDPATAPPT("PatientAppt",NUM,"SchedulerName")=$G(APPTARY(F,IENS,30,"E"))
 ;S SDPATAPPT("PatientAppt",NUM,"CurrentStatus")=$G(APPTARY(F,IENS,100,"E"))
 I $D(SDPATAPPT) Q 1
 Q 0
 ;
BUILDJSON(SDECY,RETURN) ; build json
 N ERR
 S ERR=""
 D ENCODE^XLFJSON("RETURN","SDECY","ERR")
 Q
 ;
CLEANUP ; kill vars
 K RETURN,ERRORS,DTTMERRORS,APPTARY,SDPATAPPT,APPTARY
 Q