SDESAPPTDATA ;ALB/TAW,MGD,RRM,LAB,DJS,BWF,ANU - VISTA Appointment data getter ;OCT 12, 2023@11:38
;;5.3;Scheduling;**788,814,815,820,823,827,837,838,839,846,847,860,864**;Aug 13, 1993;Build 15
;;Per VHA Directive 6402, this routine should not be modified
;
; Reference to ^VA(200 in ICR #10060
Q
; The intention of this rtn is to return a unique set of data from the Appointment
;File (409.84) for a specific IEN.
;
; It is assumed by getting here all business logic and validation has been performed.
;
; This routine should only be used for retrieving data from the Appointment file.
;
SUMMARY(APPTDATA,IEN) ;
;Returns a basic set of data for a specific appointment
;
; Input
; IEN - Specific appointment IEN
; Return
; APPTDATA - Array of field names and the data for the field based on the IEN
;
N APPTARY,FN,IENS,SDMSG,SDDFN,RESOURCEIEN,CLINICIEN,SIEN,OVERBOOK,STIME,ETIME,X
N DATETIME,NUM,STATPOINTER,CLINICARY,STAT,CLINICDATA,PROV,CLINICAPPT
K APPTDATA
S FN=409.84,IENS=IEN_",",OVERBOOK=0
D GETS^DIQ(FN,IENS,".01;.02;.03;.04;.05;.06;.07;.12;.13;.121;.122;.14;.16;.17;.18;.22;1;3;4;100","IE","APPTARY","SDMSG") ;SD,814-Added 100 for the EAS Tracking Number
S RESOURCEIEN=$G(APPTARY(FN,IENS,.07,"I"))
S CLINICIEN=$$GET1^DIQ(409.831,RESOURCEIEN,.04,"I")
S APPTDATA("StartTime")=$G(APPTARY(FN,IENS,.01,"E"))
S APPTDATA("StartTimeFM")=$G(APPTARY(FN,IENS,.01,"I"))
S STIME=$G(APPTARY(FN,IENS,.01,"I"))
S APPTDATA("EndTime")=$G(APPTARY(FN,IENS,.02,"E"))
S ETIME=$G(APPTARY(FN,IENS,.02,"I"))
S APPTDATA("AppointmentTypeIEN")=$G(APPTARY(FN,IENS,.06,"I"))
S APPTDATA("LengthOfAppt")=$G(APPTARY(FN,IENS,.18,"E"))
S APPTDATA("RequestType")=$G(APPTARY(FN,IENS,.22,"E"))
S APPTDATA("RequestIEN")=$P($G(APPTARY(FN,IENS,.22,"I")),";")
K APPTARY(FN,IENS,1,"I"),APPTARY(FN,IENS,1,"E")
I $D(APPTARY(FN,IENS,1)) M APPTDATA("Note")=APPTARY(FN,IENS,1)
E S APPTDATA("Note")=""
S APPTDATA("AppointmentIEN")=IEN
S DATETIME=$G(APPTARY(FN,IENS,.03,"I"))
S APPTDATA("CheckIn")=$$FMTE^XLFDT(DATETIME)
S DATETIME=$G(APPTARY(FN,IENS,.04,"I"))
S APPTDATA("CheckInEntered")=$$FMTE^XLFDT(DATETIME)
S DATETIME=$G(APPTARY(FN,IENS,.14,"I"))
S APPTDATA("CheckOut")=$$FMTE^XLFDT(DATETIME)
S APPTDATA("EASTrackingNumber")=$G(APPTARY(FN,IENS,100,"I")) ;SD,814-Retrieve EAS Tracking Number
S CTIME=$G(APPTARY(FN,IENS,.12,"I"))
;S APPTDATA("CancelDateTime")=$$FMTISO^SDAMUTDT(CTIME,CLINICIEN)
S APPTDATA("CancelDateTime")=$$FMTE^XLFDT($G(APPTARY(FN,IENS,.12,"I")))
S APPTDATA("CancellationReason")=$G(APPTARY(FN,IENS,.122,"E"))
;CancelledByUser Data Elements
S CUSER=$G(APPTARY(FN,IENS,.121,"I"))
I CUSER D
.S APPTDATA("CancelledByUser","ID")=CUSER
.S APPTDATA("CancelledByUser","Name")=$G(APPTARY(FN,IENS,.121,"E"))
.S APPTDATA("CancelledByUser","SecId")=$$GET1^DIQ(200,CUSER,205.1,"I")
I '$D(APPTDATA("CancelledByUser")) S APPTDATA("CancelledByUser",1)=""
;
S APPTDATA("Walkin")=$G(APPTARY(FN,IENS,.13,"E"))
;
;Always send these Resource / Clinic data elements
S APPTDATA("Clinic","IsOverbook")=0
;S RESOURCEIEN=$G(APPTARY(FN,IENS,.07,"I"))
S APPTDATA("ResourceIEN")=RESOURCEIEN
S APPTDATA("Resource","Name")=$G(APPTARY(FN,IENS,.07,"E"))
;S CLINICIEN=$$GET1^DIQ(409.831,RESOURCEIEN,.04,"I")
S APPTDATA("Resource","ClinicIEN")=CLINICIEN
;847
D SETSTATUS^SDESGETAPPTWRAP5(.APPTDATA,IEN,CLINICIEN)
S APPTDATA("CurrentStatus")=APPTDATA("Status")
;
D APPTCLINIC^SDESCLINICDATA(.CLINICDATA,CLINICIEN)
M APPTDATA("Clinic")=CLINICDATA
S SDDFN=$G(APPTARY(FN,IENS,.05,"I"))
I CLINICIEN D
.S SIEN=0
.F S SIEN=$O(^SC(CLINICIEN,"S",STIME,SIEN)) Q:'SIEN D
..S X=$O(^SC(CLINICIEN,"S",STIME,SIEN,""),-1)
..Q:SDDFN'=$$GET1^DIQ(44.003,SIEN_","_STIME_","_CLINICIEN_",",.01,"I")
..S:X OVERBOOK=$G(^SC(CLINICIEN,"S",STIME,SIEN,X,"OB"))
..D GETS^DIQ(44.003,SIEN_","_STIME_","_CLINICIEN_",","10.5;30","IE","CLINICAPPT","SDMSG")
..S APPTDATA("Clinic","CurrentEligibilityCode")=$G(CLINICAPPT(44.003,SIEN_","_STIME_","_CLINICIEN_",",10.5,"E"))
..S APPTDATA("Clinic","EligibilityOfVisit")=$G(CLINICAPPT(44.003,SIEN_","_STIME_","_CLINICIEN_",",30,"E"))
S (SIEN,NUM)=0
F S SIEN=$O(^SDEC(409.84,IEN,3,SIEN)) Q:'SIEN D
.S NUM=NUM+1
.S STATPOINTER=$$GET1^DIQ(409.843,SIEN_","_IEN_",",.01,"I")
.S STAT=$$GET1^DIQ(409.842,STATPOINTER,.01,"E")
.S DATETIME=$$GET1^DIQ(409.843,SIEN_","_IEN_",",1,"E")
.S APPTDATA("CheckInSteps",NUM,"IEN")=SIEN
.S APPTDATA("CheckInSteps",NUM,"Status")=$G(STAT)
.S APPTDATA("CheckInSteps",NUM,"DateTime")=$$FMTE^XLFDT(DATETIME)
I '$D(APPTDATA("CheckInSteps")) S APPTDATA("CheckInSteps")=""
;
;Always send these Patient data elements
S APPTDATA("DFN")=SDDFN
S APPTDATA("Patient","EligibilityIEN")=$$GET1^DIQ(2,SDDFN_",",.361,"I")
S APPTDATA("Patient","Name")=$$GET1^DIQ(2,SDDFN_",",.01,"E")
; 864
S APPTDATA("Patient","DateOfBirth")=$$FMTISO^SDAMUTDT($$GET1^DIQ(2,SDDFN_",",.03,"I"))
S APPTDATA("Patient","DateOfDeath")=$$FMTISO^SDAMUTDT($$GET1^DIQ(2,SDDFN_",",.351,"I"))
;
; patient comments
D GETPATCOMMENTS(.APPTDATA,IEN)
; provider data elements
S PROV=$G(APPTARY(FN,IENS,.16,"I"))
S APPTDATA("Provider","ID")=PROV
S APPTDATA("Provider","Name")=$G(APPTARY(FN,IENS,.16,"E"))
S APPTDATA("Provider","SecId")=$$GET1^DIQ(200,PROV,205.1,"I")
Q
;Returns a basic set of data for a specific appointment with ISO dates
;
; Input
; IEN - Specific appointment IEN
; Return
; APPTDATA - Array of field names and the data for the field based on the IEN
;
SUMMARY2(APPTDATA,IEN) ;
N APPTARY,FN,IENS,SDMSG,SDDFN,RESOURCEIEN,CLINICIEN,SIEN,OVERBOOK,STIME,ETIME,X,PROV,CUSER
N DATETIME,NUM,STATPOINTER,CLINICARY,STAT,CLINICDATA,CIDATETIME,CODATETIME,CIENDATETIME,CTIME
N APPREQPTR,APPREQIEN,ORIGAPPTREQTYP
K APPTDATA
S FN=409.84,IENS=IEN_",",OVERBOOK=0
D GETS^DIQ(FN,IENS,".01;.02;.03;.04;.05;.06;.07;.12;.13;.14;.16;.17;.18;.22;.121;.122;1;2;3;4;100","IE","APPTARY","SDMSG") ;SD,814-Added 100 for the EAS Tracking Number
S RESOURCEIEN=$G(APPTARY(FN,IENS,.07,"I"))
S CLINICIEN=$$GET1^DIQ(409.831,RESOURCEIEN,.04,"I")
S STIME=$G(APPTARY(FN,IENS,.01,"I"))
S APPTDATA("AppointmentDateTime")=$$FMTISO^SDAMUTDT(STIME,CLINICIEN)
S APPTDATA("StartTimeFM")=$G(APPTARY(FN,IENS,.01,"I"))
S ETIME=$G(APPTARY(FN,IENS,.02,"I"))
S APPTDATA("EndTime")=$$FMTISO^SDAMUTDT(ETIME,CLINICIEN)
S APPTDATA("AppointmentTypeIEN")=$G(APPTARY(FN,IENS,.06,"I"))
S APPTDATA("LengthOfAppt")=$G(APPTARY(FN,IENS,.18,"E"))
S APPREQIEN=$P($G(APPTARY(FN,IENS,.22,"I")),";")
S APPTDATA("RequestType")=$G(APPTARY(FN,IENS,.22,"E"))
S APPTDATA("RequestIEN")=APPREQIEN
S APPREQPTR=$P($G(APPTARY(FN,IENS,.22,"I")),";",2)
I APPREQPTR[403.5 S ORIGAPPTREQTYP="R"
I APPREQPTR[123 S ORIGAPPTREQTYP=$$GET1^DIQ(123,APPREQIEN,13,"I")
I APPREQPTR[409.85 S ORIGAPPTREQTYP=$$GET1^DIQ(409.85,APPREQIEN,4,"I")
S APPTDATA("OriginatingRequestType")=$G(ORIGAPPTREQTYP)
K APPTARY(FN,IENS,1,"I"),APPTARY(FN,IENS,1,"E")
I $D(APPTARY(FN,IENS,1)) M APPTDATA("Note")=APPTARY(FN,IENS,1)
I '$D(APPTDATA("Note")) S APPTDATA("Note")=""
S APPTDATA("AppointmentIEN")=IEN
S CIDATETIME=$G(APPTARY(FN,IENS,.03,"I"))
S APPTDATA("CheckIn")=$$FMTISO^SDAMUTDT(CIDATETIME,CLINICIEN)
S CIENDATETIME=$G(APPTARY(FN,IENS,.04,"I"))
S APPTDATA("CheckInEntered")=$$FMTISO^SDAMUTDT(CIENDATETIME)
S CODATETIME=$G(APPTARY(FN,IENS,.14,"I"))
S APPTDATA("CheckOut")=$$FMTISO^SDAMUTDT(CODATETIME,CLINICIEN)
;847
D SETSTATUS^SDESGETAPPTWRAP5(.APPTDATA,IEN,CLINICIEN)
S APPTDATA("CurrentStatus")=APPTDATA("Status")
;
S APPTDATA("EASTrackingNumber")=$G(APPTARY(FN,IENS,100,"I")) ;SD,814-Retrieve EAS Tracking Number
S APPTDATA("Walkin")=$G(APPTARY(FN,IENS,.13,"E"))
S CTIME=$G(APPTARY(FN,IENS,.12,"I"))
S APPTDATA("CancelDateTime")=$$FMTISO^SDAMUTDT(CTIME,CLINICIEN)
S APPTDATA("CancellationReason")=$G(APPTARY(FN,IENS,.122,"E"))
;CancelledByUser Data Elements
S CUSER=$G(APPTARY(FN,IENS,.121,"I"))
I CUSER D
.S APPTDATA("CancelledByUser","ID")=CUSER
.S APPTDATA("CancelledByUser","Name")=$G(APPTARY(FN,IENS,.121,"E"))
.S APPTDATA("CancelledByUser","SecId")=$$GET1^DIQ(200,CUSER,205.1,"I")
I '$D(APPTDATA("CancelledByUser")) S APPTDATA("CancelledByUser",1)=""
;
; patient comments
D GETPATCOMMENTS(.APPTDATA,IEN)
;
; Resource / Clinic data elements
S APPTDATA("ResourceIEN")=RESOURCEIEN
I RESOURCEIEN D
.S APPTDATA("Resource","Name")=$G(APPTARY(FN,IENS,.07,"E"))
.S APPTDATA("Resource","ClinicIEN")=CLINICIEN
I '$D(APPTDATA("Resource")) S APPTDATA("Resource",1)=""
S SDDFN=$G(APPTARY(FN,IENS,.05,"I"))
I CLINICIEN D
.D APPTCLINIC^SDESCLINICDATA(.CLINICDATA,CLINICIEN)
.M APPTDATA("Clinic")=CLINICDATA
.S APPTDATA("Clinic","IsOverbook")=0
.S SIEN=0
.F S SIEN=$O(^SC(CLINICIEN,"S",STIME,SIEN)) Q:'SIEN D
..S X=$O(^SC(CLINICIEN,"S",STIME,SIEN,""),-1)
..Q:SDDFN'=$$GET1^DIQ(44.003,SIEN_","_STIME_","_CLINICIEN_",",.01,"I")
..S:X OVERBOOK=$G(^SC(CLINICIEN,"S",STIME,SIEN,X,"OB"))
I OVERBOOK="O",$D(APPTDATA("Clinic")) S APPTDATA("Clinic","IsOverbook")=1
I '$D(APPTDATA("Clinic")) S APPTDATA("Clinic",1)=""
;
S (SIEN,NUM)=0
F S SIEN=$O(^SDEC(409.84,IEN,3,SIEN)) Q:'SIEN D
.S NUM=NUM+1
.S STAT=$$GET1^DIQ(409.843,SIEN_","_IEN_",",.01,"E")
.S DATETIME=$$GET1^DIQ(409.843,SIEN_","_IEN_",",1,"I")
.S APPTDATA("CheckInSteps",NUM,"IEN")=SIEN
.S APPTDATA("CheckInSteps",NUM,"Status")=STAT
.S APPTDATA("CheckInSteps",NUM,"DateTime")=$$FMTISO^SDAMUTDT(DATETIME)
I '$D(APPTDATA("CheckInSteps")) S APPTDATA("CheckInSteps",1)=""
;
;Always send these Patient data elements
S APPTDATA("DFN")=SDDFN
S APPTDATA("Patient","EligibilityIEN")=$$GET1^DIQ(2,SDDFN_",",.361,"I")
S APPTDATA("Patient","Name")=$$GET1^DIQ(2,SDDFN_",",.01,"E")
; 864
S APPTDATA("Patient","DateOfBirth")=$$FMTISO^SDAMUTDT($$GET1^DIQ(2,SDDFN_",",.03,"I"))
S APPTDATA("Patient","DateOfDeath")=$$FMTISO^SDAMUTDT($$GET1^DIQ(2,SDDFN_",",.351,"I"))
; provider data elements
S PROV=$G(APPTARY(FN,IENS,.16,"I"))
I PROV D
.S APPTDATA("Provider","ID")=PROV
.S APPTDATA("Provider","Name")=$G(APPTARY(FN,IENS,.16,"E"))
.S APPTDATA("Provider","SecId")=$$GET1^DIQ(200,PROV,205.1,"I")
I '$D(APPTDATA("Provider")) S APPTDATA("Provider",1)=""
S APPTDATA("VVSApptID")=$G(APPTARY(FN,IENS,2,"I")) ;This field added as part of VSE2857
Q
N SUBIEN,COUNT
S SUBIEN=0,COUNT=0
F S SUBIEN=$O(^SDEC(409.84,IEN,6,SUBIEN)) Q:'SUBIEN D
.S COUNT=COUNT+1
.S APPTDATA("PatientComments",COUNT)=$$GET1^DIQ(409.846,SUBIEN_","_IEN_",",.01,"E")
I '$D(APPTDATA("PatientComments")) S APPTDATA("PatientComments",1)=""
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESAPPTDATA 10677 printed Oct 16, 2024@18:56:03 Page 2
SDESAPPTDATA ;ALB/TAW,MGD,RRM,LAB,DJS,BWF,ANU - VISTA Appointment data getter ;OCT 12, 2023@11:38
+1 ;;5.3;Scheduling;**788,814,815,820,823,827,837,838,839,846,847,860,864**;Aug 13, 1993;Build 15
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ; Reference to ^VA(200 in ICR #10060
+5 QUIT
+6 ; The intention of this rtn is to return a unique set of data from the Appointment
+7 ;File (409.84) for a specific IEN.
+8 ;
+9 ; It is assumed by getting here all business logic and validation has been performed.
+10 ;
+11 ; This routine should only be used for retrieving data from the Appointment file.
+12 ;
SUMMARY(APPTDATA,IEN) ;
+1 ;Returns a basic set of data for a specific appointment
+2 ;
+3 ; Input
+4 ; IEN - Specific appointment IEN
+5 ; Return
+6 ; APPTDATA - Array of field names and the data for the field based on the IEN
+7 ;
+8 NEW APPTARY,FN,IENS,SDMSG,SDDFN,RESOURCEIEN,CLINICIEN,SIEN,OVERBOOK,STIME,ETIME,X
+9 NEW DATETIME,NUM,STATPOINTER,CLINICARY,STAT,CLINICDATA,PROV,CLINICAPPT
+10 KILL APPTDATA
+11 SET FN=409.84
SET IENS=IEN_","
SET OVERBOOK=0
+12 ;SD,814-Added 100 for the EAS Tracking Number
DO GETS^DIQ(FN,IENS,".01;.02;.03;.04;.05;.06;.07;.12;.13;.121;.122;.14;.16;.17;.18;.22;1;3;4;100","IE","APPTARY","SDMSG")
+13 SET RESOURCEIEN=$GET(APPTARY(FN,IENS,.07,"I"))
+14 SET CLINICIEN=$$GET1^DIQ(409.831,RESOURCEIEN,.04,"I")
+15 SET APPTDATA("StartTime")=$GET(APPTARY(FN,IENS,.01,"E"))
+16 SET APPTDATA("StartTimeFM")=$GET(APPTARY(FN,IENS,.01,"I"))
+17 SET STIME=$GET(APPTARY(FN,IENS,.01,"I"))
+18 SET APPTDATA("EndTime")=$GET(APPTARY(FN,IENS,.02,"E"))
+19 SET ETIME=$GET(APPTARY(FN,IENS,.02,"I"))
+20 SET APPTDATA("AppointmentTypeIEN")=$GET(APPTARY(FN,IENS,.06,"I"))
+21 SET APPTDATA("LengthOfAppt")=$GET(APPTARY(FN,IENS,.18,"E"))
+22 SET APPTDATA("RequestType")=$GET(APPTARY(FN,IENS,.22,"E"))
+23 SET APPTDATA("RequestIEN")=$PIECE($GET(APPTARY(FN,IENS,.22,"I")),";")
+24 KILL APPTARY(FN,IENS,1,"I"),APPTARY(FN,IENS,1,"E")
+25 IF $DATA(APPTARY(FN,IENS,1))
MERGE APPTDATA("Note")=APPTARY(FN,IENS,1)
+26 IF '$TEST
SET APPTDATA("Note")=""
+27 SET APPTDATA("AppointmentIEN")=IEN
+28 SET DATETIME=$GET(APPTARY(FN,IENS,.03,"I"))
+29 SET APPTDATA("CheckIn")=$$FMTE^XLFDT(DATETIME)
+30 SET DATETIME=$GET(APPTARY(FN,IENS,.04,"I"))
+31 SET APPTDATA("CheckInEntered")=$$FMTE^XLFDT(DATETIME)
+32 SET DATETIME=$GET(APPTARY(FN,IENS,.14,"I"))
+33 SET APPTDATA("CheckOut")=$$FMTE^XLFDT(DATETIME)
+34 ;SD,814-Retrieve EAS Tracking Number
SET APPTDATA("EASTrackingNumber")=$GET(APPTARY(FN,IENS,100,"I"))
+35 SET CTIME=$GET(APPTARY(FN,IENS,.12,"I"))
+36 ;S APPTDATA("CancelDateTime")=$$FMTISO^SDAMUTDT(CTIME,CLINICIEN)
+37 SET APPTDATA("CancelDateTime")=$$FMTE^XLFDT($GET(APPTARY(FN,IENS,.12,"I")))
+38 SET APPTDATA("CancellationReason")=$GET(APPTARY(FN,IENS,.122,"E"))
+39 ;CancelledByUser Data Elements
+40 SET CUSER=$GET(APPTARY(FN,IENS,.121,"I"))
+41 IF CUSER
Begin DoDot:1
+42 SET APPTDATA("CancelledByUser","ID")=CUSER
+43 SET APPTDATA("CancelledByUser","Name")=$GET(APPTARY(FN,IENS,.121,"E"))
+44 SET APPTDATA("CancelledByUser","SecId")=$$GET1^DIQ(200,CUSER,205.1,"I")
End DoDot:1
+45 IF '$DATA(APPTDATA("CancelledByUser"))
SET APPTDATA("CancelledByUser",1)=""
+46 ;
+47 SET APPTDATA("Walkin")=$GET(APPTARY(FN,IENS,.13,"E"))
+48 ;
+49 ;Always send these Resource / Clinic data elements
+50 SET APPTDATA("Clinic","IsOverbook")=0
+51 ;S RESOURCEIEN=$G(APPTARY(FN,IENS,.07,"I"))
+52 SET APPTDATA("ResourceIEN")=RESOURCEIEN
+53 SET APPTDATA("Resource","Name")=$GET(APPTARY(FN,IENS,.07,"E"))
+54 ;S CLINICIEN=$$GET1^DIQ(409.831,RESOURCEIEN,.04,"I")
+55 SET APPTDATA("Resource","ClinicIEN")=CLINICIEN
+56 ;847
+57 DO SETSTATUS^SDESGETAPPTWRAP5(.APPTDATA,IEN,CLINICIEN)
+58 SET APPTDATA("CurrentStatus")=APPTDATA("Status")
+59 ;
+60 DO APPTCLINIC^SDESCLINICDATA(.CLINICDATA,CLINICIEN)
+61 MERGE APPTDATA("Clinic")=CLINICDATA
+62 SET SDDFN=$GET(APPTARY(FN,IENS,.05,"I"))
+63 IF CLINICIEN
Begin DoDot:1
+64 SET SIEN=0
+65 FOR
SET SIEN=$ORDER(^SC(CLINICIEN,"S",STIME,SIEN))
if 'SIEN
QUIT
Begin DoDot:2
+66 SET X=$ORDER(^SC(CLINICIEN,"S",STIME,SIEN,""),-1)
+67 if SDDFN'=$$GET1^DIQ(44.003,SIEN_","_STIME_","_CLINICIEN_",",.01,"I")
QUIT
+68 if X
SET OVERBOOK=$GET(^SC(CLINICIEN,"S",STIME,SIEN,X,"OB"))
+69 DO GETS^DIQ(44.003,SIEN_","_STIME_","_CLINICIEN_",","10.5;30","IE","CLINICAPPT","SDMSG")
+70 SET APPTDATA("Clinic","CurrentEligibilityCode")=$GET(CLINICAPPT(44.003,SIEN_","_STIME_","_CLINICIEN_",",10.5,"E"))
+71 SET APPTDATA("Clinic","EligibilityOfVisit")=$GET(CLINICAPPT(44.003,SIEN_","_STIME_","_CLINICIEN_",",30,"E"))
End DoDot:2
End DoDot:1
+72 SET (SIEN,NUM)=0
+73 FOR
SET SIEN=$ORDER(^SDEC(409.84,IEN,3,SIEN))
if 'SIEN
QUIT
Begin DoDot:1
+74 SET NUM=NUM+1
+75 SET STATPOINTER=$$GET1^DIQ(409.843,SIEN_","_IEN_",",.01,"I")
+76 SET STAT=$$GET1^DIQ(409.842,STATPOINTER,.01,"E")
+77 SET DATETIME=$$GET1^DIQ(409.843,SIEN_","_IEN_",",1,"E")
+78 SET APPTDATA("CheckInSteps",NUM,"IEN")=SIEN
+79 SET APPTDATA("CheckInSteps",NUM,"Status")=$GET(STAT)
+80 SET APPTDATA("CheckInSteps",NUM,"DateTime")=$$FMTE^XLFDT(DATETIME)
End DoDot:1
+81 IF '$DATA(APPTDATA("CheckInSteps"))
SET APPTDATA("CheckInSteps")=""
+82 ;
+83 ;Always send these Patient data elements
+84 SET APPTDATA("DFN")=SDDFN
+85 SET APPTDATA("Patient","EligibilityIEN")=$$GET1^DIQ(2,SDDFN_",",.361,"I")
+86 SET APPTDATA("Patient","Name")=$$GET1^DIQ(2,SDDFN_",",.01,"E")
+87 ; 864
+88 SET APPTDATA("Patient","DateOfBirth")=$$FMTISO^SDAMUTDT($$GET1^DIQ(2,SDDFN_",",.03,"I"))
+89 SET APPTDATA("Patient","DateOfDeath")=$$FMTISO^SDAMUTDT($$GET1^DIQ(2,SDDFN_",",.351,"I"))
+90 ;
+91 ; patient comments
+92 DO GETPATCOMMENTS(.APPTDATA,IEN)
+93 ; provider data elements
+94 SET PROV=$GET(APPTARY(FN,IENS,.16,"I"))
+95 SET APPTDATA("Provider","ID")=PROV
+96 SET APPTDATA("Provider","Name")=$GET(APPTARY(FN,IENS,.16,"E"))
+97 SET APPTDATA("Provider","SecId")=$$GET1^DIQ(200,PROV,205.1,"I")
+98 QUIT
+99 ;Returns a basic set of data for a specific appointment with ISO dates
+100 ;
+101 ; Input
+102 ; IEN - Specific appointment IEN
+103 ; Return
+104 ; APPTDATA - Array of field names and the data for the field based on the IEN
+105 ;
SUMMARY2(APPTDATA,IEN) ;
+1 NEW APPTARY,FN,IENS,SDMSG,SDDFN,RESOURCEIEN,CLINICIEN,SIEN,OVERBOOK,STIME,ETIME,X,PROV,CUSER
+2 NEW DATETIME,NUM,STATPOINTER,CLINICARY,STAT,CLINICDATA,CIDATETIME,CODATETIME,CIENDATETIME,CTIME
+3 NEW APPREQPTR,APPREQIEN,ORIGAPPTREQTYP
+4 KILL APPTDATA
+5 SET FN=409.84
SET IENS=IEN_","
SET OVERBOOK=0
+6 ;SD,814-Added 100 for the EAS Tracking Number
DO GETS^DIQ(FN,IENS,".01;.02;.03;.04;.05;.06;.07;.12;.13;.14;.16;.17;.18;.22;.121;.122;1;2;3;4;100","IE","APPTARY","SDMSG")
+7 SET RESOURCEIEN=$GET(APPTARY(FN,IENS,.07,"I"))
+8 SET CLINICIEN=$$GET1^DIQ(409.831,RESOURCEIEN,.04,"I")
+9 SET STIME=$GET(APPTARY(FN,IENS,.01,"I"))
+10 SET APPTDATA("AppointmentDateTime")=$$FMTISO^SDAMUTDT(STIME,CLINICIEN)
+11 SET APPTDATA("StartTimeFM")=$GET(APPTARY(FN,IENS,.01,"I"))
+12 SET ETIME=$GET(APPTARY(FN,IENS,.02,"I"))
+13 SET APPTDATA("EndTime")=$$FMTISO^SDAMUTDT(ETIME,CLINICIEN)
+14 SET APPTDATA("AppointmentTypeIEN")=$GET(APPTARY(FN,IENS,.06,"I"))
+15 SET APPTDATA("LengthOfAppt")=$GET(APPTARY(FN,IENS,.18,"E"))
+16 SET APPREQIEN=$PIECE($GET(APPTARY(FN,IENS,.22,"I")),";")
+17 SET APPTDATA("RequestType")=$GET(APPTARY(FN,IENS,.22,"E"))
+18 SET APPTDATA("RequestIEN")=APPREQIEN
+19 SET APPREQPTR=$PIECE($GET(APPTARY(FN,IENS,.22,"I")),";",2)
+20 IF APPREQPTR[403.5
SET ORIGAPPTREQTYP="R"
+21 IF APPREQPTR[123
SET ORIGAPPTREQTYP=$$GET1^DIQ(123,APPREQIEN,13,"I")
+22 IF APPREQPTR[409.85
SET ORIGAPPTREQTYP=$$GET1^DIQ(409.85,APPREQIEN,4,"I")
+23 SET APPTDATA("OriginatingRequestType")=$GET(ORIGAPPTREQTYP)
+24 KILL APPTARY(FN,IENS,1,"I"),APPTARY(FN,IENS,1,"E")
+25 IF $DATA(APPTARY(FN,IENS,1))
MERGE APPTDATA("Note")=APPTARY(FN,IENS,1)
+26 IF '$DATA(APPTDATA("Note"))
SET APPTDATA("Note")=""
+27 SET APPTDATA("AppointmentIEN")=IEN
+28 SET CIDATETIME=$GET(APPTARY(FN,IENS,.03,"I"))
+29 SET APPTDATA("CheckIn")=$$FMTISO^SDAMUTDT(CIDATETIME,CLINICIEN)
+30 SET CIENDATETIME=$GET(APPTARY(FN,IENS,.04,"I"))
+31 SET APPTDATA("CheckInEntered")=$$FMTISO^SDAMUTDT(CIENDATETIME)
+32 SET CODATETIME=$GET(APPTARY(FN,IENS,.14,"I"))
+33 SET APPTDATA("CheckOut")=$$FMTISO^SDAMUTDT(CODATETIME,CLINICIEN)
+34 ;847
+35 DO SETSTATUS^SDESGETAPPTWRAP5(.APPTDATA,IEN,CLINICIEN)
+36 SET APPTDATA("CurrentStatus")=APPTDATA("Status")
+37 ;
+38 ;SD,814-Retrieve EAS Tracking Number
SET APPTDATA("EASTrackingNumber")=$GET(APPTARY(FN,IENS,100,"I"))
+39 SET APPTDATA("Walkin")=$GET(APPTARY(FN,IENS,.13,"E"))
+40 SET CTIME=$GET(APPTARY(FN,IENS,.12,"I"))
+41 SET APPTDATA("CancelDateTime")=$$FMTISO^SDAMUTDT(CTIME,CLINICIEN)
+42 SET APPTDATA("CancellationReason")=$GET(APPTARY(FN,IENS,.122,"E"))
+43 ;CancelledByUser Data Elements
+44 SET CUSER=$GET(APPTARY(FN,IENS,.121,"I"))
+45 IF CUSER
Begin DoDot:1
+46 SET APPTDATA("CancelledByUser","ID")=CUSER
+47 SET APPTDATA("CancelledByUser","Name")=$GET(APPTARY(FN,IENS,.121,"E"))
+48 SET APPTDATA("CancelledByUser","SecId")=$$GET1^DIQ(200,CUSER,205.1,"I")
End DoDot:1
+49 IF '$DATA(APPTDATA("CancelledByUser"))
SET APPTDATA("CancelledByUser",1)=""
+50 ;
+51 ; patient comments
+52 DO GETPATCOMMENTS(.APPTDATA,IEN)
+53 ;
+54 ; Resource / Clinic data elements
+55 SET APPTDATA("ResourceIEN")=RESOURCEIEN
+56 IF RESOURCEIEN
Begin DoDot:1
+57 SET APPTDATA("Resource","Name")=$GET(APPTARY(FN,IENS,.07,"E"))
+58 SET APPTDATA("Resource","ClinicIEN")=CLINICIEN
End DoDot:1
+59 IF '$DATA(APPTDATA("Resource"))
SET APPTDATA("Resource",1)=""
+60 SET SDDFN=$GET(APPTARY(FN,IENS,.05,"I"))
+61 IF CLINICIEN
Begin DoDot:1
+62 DO APPTCLINIC^SDESCLINICDATA(.CLINICDATA,CLINICIEN)
+63 MERGE APPTDATA("Clinic")=CLINICDATA
+64 SET APPTDATA("Clinic","IsOverbook")=0
+65 SET SIEN=0
+66 FOR
SET SIEN=$ORDER(^SC(CLINICIEN,"S",STIME,SIEN))
if 'SIEN
QUIT
Begin DoDot:2
+67 SET X=$ORDER(^SC(CLINICIEN,"S",STIME,SIEN,""),-1)
+68 if SDDFN'=$$GET1^DIQ(44.003,SIEN_","_STIME_","_CLINICIEN_",",.01,"I")
QUIT
+69 if X
SET OVERBOOK=$GET(^SC(CLINICIEN,"S",STIME,SIEN,X,"OB"))
End DoDot:2
End DoDot:1
+70 IF OVERBOOK="O"
IF $DATA(APPTDATA("Clinic"))
SET APPTDATA("Clinic","IsOverbook")=1
+71 IF '$DATA(APPTDATA("Clinic"))
SET APPTDATA("Clinic",1)=""
+72 ;
+73 SET (SIEN,NUM)=0
+74 FOR
SET SIEN=$ORDER(^SDEC(409.84,IEN,3,SIEN))
if 'SIEN
QUIT
Begin DoDot:1
+75 SET NUM=NUM+1
+76 SET STAT=$$GET1^DIQ(409.843,SIEN_","_IEN_",",.01,"E")
+77 SET DATETIME=$$GET1^DIQ(409.843,SIEN_","_IEN_",",1,"I")
+78 SET APPTDATA("CheckInSteps",NUM,"IEN")=SIEN
+79 SET APPTDATA("CheckInSteps",NUM,"Status")=STAT
+80 SET APPTDATA("CheckInSteps",NUM,"DateTime")=$$FMTISO^SDAMUTDT(DATETIME)
End DoDot:1
+81 IF '$DATA(APPTDATA("CheckInSteps"))
SET APPTDATA("CheckInSteps",1)=""
+82 ;
+83 ;Always send these Patient data elements
+84 SET APPTDATA("DFN")=SDDFN
+85 SET APPTDATA("Patient","EligibilityIEN")=$$GET1^DIQ(2,SDDFN_",",.361,"I")
+86 SET APPTDATA("Patient","Name")=$$GET1^DIQ(2,SDDFN_",",.01,"E")
+87 ; 864
+88 SET APPTDATA("Patient","DateOfBirth")=$$FMTISO^SDAMUTDT($$GET1^DIQ(2,SDDFN_",",.03,"I"))
+89 SET APPTDATA("Patient","DateOfDeath")=$$FMTISO^SDAMUTDT($$GET1^DIQ(2,SDDFN_",",.351,"I"))
+90 ; provider data elements
+91 SET PROV=$GET(APPTARY(FN,IENS,.16,"I"))
+92 IF PROV
Begin DoDot:1
+93 SET APPTDATA("Provider","ID")=PROV
+94 SET APPTDATA("Provider","Name")=$GET(APPTARY(FN,IENS,.16,"E"))
+95 SET APPTDATA("Provider","SecId")=$$GET1^DIQ(200,PROV,205.1,"I")
End DoDot:1
+96 IF '$DATA(APPTDATA("Provider"))
SET APPTDATA("Provider",1)=""
+97 ;This field added as part of VSE2857
SET APPTDATA("VVSApptID")=$GET(APPTARY(FN,IENS,2,"I"))
+98 QUIT
+1 NEW SUBIEN,COUNT
+2 SET SUBIEN=0
SET COUNT=0
+3 FOR
SET SUBIEN=$ORDER(^SDEC(409.84,IEN,6,SUBIEN))
if 'SUBIEN
QUIT
Begin DoDot:1
+4 SET COUNT=COUNT+1
+5 SET APPTDATA("PatientComments",COUNT)=$$GET1^DIQ(409.846,SUBIEN_","_IEN_",",.01,"E")
End DoDot:1
+6 IF '$DATA(APPTDATA("PatientComments"))
SET APPTDATA("PatientComments",1)=""
+7 QUIT
+8 ;