SDES2BLDAPPTOBJ ;ALB/LAB,JAS,BWF,LAB,JAS - VISTA SCHEDULING BUILD APPOINTMENT OBJECT ;OCT 3, 2024
;;5.3;Scheduling;**871,877,880,893**;Aug 13, 1993;Build 6
;;Per VHA Directive 6402, this routine should not be modified
;
Q
;
BUILDAPPTOBJ(APPTOBJ,APPTIEN,RECCNT,ERRORS,SDDUZ) ;Called from GET APPT RPCs to build appointment object.
N SDDFN,CLINIEN,CANCELID,SDIEN
D GET40984INFO(.APPTOBJ,APPTIEN,.SDDFN,.CLINIEN,.CANCELID,RECCNT)
D GET2INFO^SDES2BLDAPPT2(.APPTOBJ,APPTIEN,SDDFN,RECCNT,SDDUZ)
D GET298INFO^SDES2BLDAPPT2(.APPTOBJ,APPTIEN,SDDFN,RECCNT,CLINIEN)
I CLINIEN="" D ERRLOG^SDESJSON(.ERRORS,555,"Appointment IEN "_APPTIEN_". Unable to retrieve Clinic appointment data") Q
D GET44INFO^SDES2BLDAPPT44(.APPTOBJ,.CLINIEN,RECCNT)
S SDIEN=$$GET44RECORDIENS(CLINIEN,APPTOBJ("Appointment",RECCNT,"StartTimeFM"),SDDFN,.APPTOBJ)
I 'SDIEN D BLANK44003INFO^SDES2BLDAPPT44(.APPTOBJ,RECCNT) Q
D GET44003INFO^SDES2BLDAPPT44(.APPTOBJ,CLINIEN,SDIEN,RECCNT)
Q
;
GET40984INFO(APPTOBJ,APPTIEN,SDDFN,CLINIEN,CANCELID,RECCNT) ;
N IENS,RESOURCEIEN,APPTDATA,APPTSTATDT,APPREQIEN,APPREQPTR,ORIGAPPTREQTYP,ARRAY40984,SDMSG
S IENS=APPTIEN_","
D GETS^DIQ(409.84,IENS,".01;.02;.03;.04;.05;.06;.07;.08;.09;.12;.13;.121;.122;.14;.16;.17;.18;.2;.22;1;2;3;4;100","IE","ARRAY40984","SDMSG")
S RESOURCEIEN=$G(ARRAY40984(409.84,IENS,.07,"I"))
S CLINIEN=$$GET1^DIQ(409.831,RESOURCEIEN,.04,"I")
S SDDFN=$G(ARRAY40984(409.84,IENS,.05,"I"))
S APPTOBJ("Appointment",RECCNT,"AppointmentDateTime")=$$FMTISO^SDAMUTDT($G(ARRAY40984(409.84,IENS,.01,"I")),CLINIEN)
S APPTOBJ("Appointment",RECCNT,"AppointmentIEN")=APPTIEN
S APPTOBJ("Appointment",RECCNT,"AppointmentTypeIEN")=$G(ARRAY40984(409.84,IENS,.06,"I"))
S APPTOBJ("Appointment",RECCNT,"AppointmentType")=$G(ARRAY40984(409.84,IENS,.06,"E"))
S APPTOBJ("Appointment",RECCNT,"CancelDateTime")=$$FMTISO^SDAMUTDT($G(ARRAY40984(409.84,IENS,.12,"I")),CLINIEN)
S APPTOBJ("Appointment",RECCNT,"DateAppointmentMade")=$$FMTISO^SDAMUTDT($G(ARRAY40984(409.84,IENS,.09,"I")))
S APPTOBJ("Appointment",RECCNT,"CancellationReason")=$G(ARRAY40984(409.84,IENS,.122,"E"))
S CANCELID=$G(ARRAY40984(409.84,IENS,.121,"I"))
S:'CANCELID APPTOBJ("Appointment",RECCNT,"CancelledByUser",1)=""
I CANCELID D
. S APPTOBJ("Appointment",RECCNT,"CancelledByUser","ID")=$G(ARRAY40984(409.84,IENS,.121,"I"))
. S APPTOBJ("Appointment",RECCNT,"CancelledByUser","Name")=$G(ARRAY40984(409.84,IENS,.121,"E"))
. S APPTOBJ("Appointment",RECCNT,"CancelledByUser","SecId")=$$GET1^DIQ(200,CANCELID,205.1,"I")
S APPTOBJ("Appointment",RECCNT,"CheckIn")=$$FMTISO^SDAMUTDT($G(ARRAY40984(409.84,IENS,.03,"I")),CLINIEN)
S APPTOBJ("Appointment",RECCNT,"CheckInEntered")=$$FMTISO^SDAMUTDT($G(ARRAY40984(409.84,IENS,.04,"I")))
S APPTOBJ("Appointment",RECCNT,"CheckOut")=$$FMTISO^SDAMUTDT($G(ARRAY40984(409.84,IENS,.14,"I")),CLINIEN)
S APPTOBJ("Appointment",RECCNT,"Clinic","ClinicIEN")=CLINIEN
S APPTSTATDT=$$APPTSTATUS^SDES2GETSTATUS(APPTIEN,CLINIEN)
S APPTOBJ("Appointment",RECCNT,"CurrentStatus")=$P(APPTSTATDT,U)
S APPTOBJ("Appointment",RECCNT,"Status")=$P(APPTSTATDT,U)
S APPTOBJ("Appointment",RECCNT,"DesiredDateOfAppointment")=$$FMTISO^SDAMUTDT($G(ARRAY40984(409.84,IENS,.2,"I")))
S APPTOBJ("Appointment",RECCNT,"StatusCancelDateTime")=$$FMTISO^SDAMUTDT($P(APPTSTATDT,U,2),CLINIEN)
S APPTOBJ("Appointment",RECCNT,"EASTrackingNumber")=$G(ARRAY40984(409.84,IENS,100,"I"))
S APPTOBJ("Appointment",RECCNT,"EndTime")=$$FMTISO^SDAMUTDT($G(ARRAY40984(409.84,IENS,.02,"I")),CLINIEN)
S APPTOBJ("Appointment",RECCNT,"LengthOfAppt")=$G(ARRAY40984(409.84,IENS,.18,"E"))
K ARRAY40984(409.84,IENS,1,"I"),ARRAY40984(409.84,IENS,1,"E")
I $D(ARRAY40984(409.84,IENS,1)) M APPTOBJ("Appointment",RECCNT,"Note")=ARRAY40984(409.84,IENS,1)
I '$D(APPTOBJ("Appointment",RECCNT,"Note")) S APPTOBJ("Appointment",RECCNT,"Note")=""
S APPREQIEN=$P($G(ARRAY40984(409.84,IENS,.22,"I")),";")
S APPREQPTR=$P($G(ARRAY40984(409.84,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 APPTOBJ("Appointment",RECCNT,"OriginatingRequestType")=$G(ORIGAPPTREQTYP)
I $G(ARRAY40984(409.84,IENS,.16,"I"))'="" D
. S APPTOBJ("Appointment",RECCNT,"Provider","ID")=$G(ARRAY40984(409.84,IENS,.16,"I"))
. S APPTOBJ("Appointment",RECCNT,"Provider","Name")=$G(ARRAY40984(409.84,IENS,.16,"E"))
. S APPTOBJ("Appointment",RECCNT,"Provider","SecId")=$$GET1^DIQ(200,$G(ARRAY40984(409.84,IENS,.16,"I")),205.1,"I")
S:($G(ARRAY40984(409.84,IENS,.16,"I"))="") APPTOBJ("Appointment",RECCNT,"Provider",1)=""
S APPTOBJ("Appointment",RECCNT,"RequestIEN")=APPREQIEN
S APPTOBJ("Appointment",RECCNT,"RequestType")=$G(ARRAY40984(409.84,IENS,.22,"E"))
S APPTOBJ("Appointment",RECCNT,"Resource","Name")=$G(ARRAY40984(409.84,IENS,.07,"E"))
S APPTOBJ("Appointment",RECCNT,"Resource","ClinicIEN")=CLINIEN
S APPTOBJ("Appointment",RECCNT,"ResourceIEN")=RESOURCEIEN
S APPTOBJ("Appointment",RECCNT,"StartTimeFM")=$G(ARRAY40984(409.84,IENS,.01,"I"))
S APPTOBJ("Appointment",RECCNT,"VVSApptID")=$G(ARRAY40984(409.84,IENS,2,"I"))
S APPTOBJ("Appointment",RECCNT,"Walkin")=$G(ARRAY40984(409.84,IENS,.13,"E"))
S APPTOBJ("Appointment",RECCNT,"MRTCFlag")=0
S:((APPREQPTR[409.85)&($$GET1^DIQ(409.85,APPREQIEN,43.8)'="")) APPTOBJ("Appointment",RECCNT,"MRTCFlag")=1
S APPTOBJ("Appointment",RECCNT,"DataEntryClerk")=$G(ARRAY40984(409.84,IENS,.08,"E"))
D GETPATCOMMENTS(.APPTOBJ,APPTIEN,RECCNT)
D CHECKINSTEPS(.APPTOBJ,APPTIEN,RECCNT)
D GETNOTEAUDIT(.APPTOBJ,APPTIEN,RECCNT)
Q
;
N SUBIEN,COUNT
S SUBIEN=0,COUNT=0
F S SUBIEN=$O(^SDEC(409.84,APPTIEN,6,SUBIEN)) Q:'SUBIEN D
.S COUNT=COUNT+1
.S APPTOBJ("Appointment",RECCNT,"PatientComments",COUNT)=$$GET1^DIQ(409.846,SUBIEN_","_APPTIEN_",",.01,"E")
I '$D(APPTOBJ("Appointment",RECCNT,"PatientComments")) S APPTOBJ("Appointment",RECCNT,"PatientComments",1)=""
Q
;
CHECKINSTEPS(APPTOBJ,APPTIEN,RECCNT) ;
N SDIEN,NUM,DATETIME
S (SDIEN,NUM)=0
F S SDIEN=$O(^SDEC(409.84,APPTIEN,3,SDIEN)) Q:'SDIEN D
.S NUM=NUM+1
.S DATETIME=$$GET1^DIQ(409.843,SDIEN_","_APPTIEN_",",1,"I")
.S APPTOBJ("Appointment",RECCNT,"CheckInSteps",NUM,"IEN")=SDIEN
.S APPTOBJ("Appointment",RECCNT,"CheckInSteps",NUM,"Status")=$$GET1^DIQ(409.843,SDIEN_","_APPTIEN_",",.01,"E")
.S APPTOBJ("Appointment",RECCNT,"CheckInSteps",NUM,"DateTime")=$$FMTISO^SDAMUTDT(DATETIME)
I '$D(APPTOBJ("Appointment",RECCNT,"CheckInSteps")) S APPTOBJ("Appointment",RECCNT,"CheckInSteps",1)=""
Q
;
GETNOTEAUDIT(APPTOBJ,APPTIEN,RECCNT) ;
N SUBIEN,COUNT
S SUBIEN=0,COUNT=0
F S SUBIEN=$O(^SDEC(409.84,APPTIEN,"NOTEAUD",SUBIEN)) Q:'SUBIEN D
.S COUNT=COUNT+1
.S APPTOBJ("Appointment",RECCNT,"NoteAuditing",COUNT,"DateNoteAdded")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.847,SUBIEN_","_APPTIEN_",",.01,"I"))
.S APPTOBJ("Appointment",RECCNT,"NoteAuditing",COUNT,"NoteAddedByDUZ")=$$GET1^DIQ(409.847,SUBIEN_","_APPTIEN_",",1,"I")
.S APPTOBJ("Appointment",RECCNT,"NoteAuditing",COUNT,"NoteAddedByName")=$$GET1^DIQ(409.847,SUBIEN_","_APPTIEN_",",1,"E")
.S APPTOBJ("Appointment",RECCNT,"NoteAuditing",COUNT,"Note")=$$GET1^DIQ(409.847,SUBIEN_","_APPTIEN_",",2,"I")
I '$D(APPTOBJ("Appointment",RECCNT,"NoteAuditing")) S APPTOBJ("Appointment",RECCNT,"NoteAuditing",1)=""
Q
;
GET44RECORDIENS(CLINICIEN,APPTSTARTTIME,SDDFN,APPTOBJ) ;
;want to process through until we get to the correct appointment for time and clinic
N FOUND,IENS44003,SUBIEN,APPTCNT,MATCH,CHECKIEN
S FOUND=0,APPTCNT=0
S SUBIEN=0 F S SUBIEN=$O(^SC(CLINICIEN,"S",APPTSTARTTIME,1,SUBIEN)) Q:'SUBIEN!($G(FOUND)=1) D
.I $$GET1^DIQ(44.003,SUBIEN_","_APPTSTARTTIME_","_CLINICIEN_",",.01,"I")=SDDFN D
.. S CHECKIEN=SUBIEN_","_APPTSTARTTIME_","_CLINICIEN_","
.. S MATCH=$$MATCHAPPOINTMENT(.APPTOBJ,CHECKIEN)
.. Q:'MATCH
..S APPTCNT=APPTCNT+1
..S IENS44003=SUBIEN_","_APPTSTARTTIME_","_CLINICIEN_",",FOUND=1 Q
Q $G(IENS44003)
;
MATCHAPPOINTMENT(APPTOBJ,CHECKIEN) ;
Q:(APPTOBJ("Appointment",RECCNT,"CancelDateTime")="")&($$GET1^DIQ(44.003,CHECKIEN,310,"I")="C") 0
Q 1
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2BLDAPPTOBJ 8215 printed Dec 13, 2024@02:53:20 Page 2
SDES2BLDAPPTOBJ ;ALB/LAB,JAS,BWF,LAB,JAS - VISTA SCHEDULING BUILD APPOINTMENT OBJECT ;OCT 3, 2024
+1 ;;5.3;Scheduling;**871,877,880,893**;Aug 13, 1993;Build 6
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ;
BUILDAPPTOBJ(APPTOBJ,APPTIEN,RECCNT,ERRORS,SDDUZ) ;Called from GET APPT RPCs to build appointment object.
+1 NEW SDDFN,CLINIEN,CANCELID,SDIEN
+2 DO GET40984INFO(.APPTOBJ,APPTIEN,.SDDFN,.CLINIEN,.CANCELID,RECCNT)
+3 DO GET2INFO^SDES2BLDAPPT2(.APPTOBJ,APPTIEN,SDDFN,RECCNT,SDDUZ)
+4 DO GET298INFO^SDES2BLDAPPT2(.APPTOBJ,APPTIEN,SDDFN,RECCNT,CLINIEN)
+5 IF CLINIEN=""
DO ERRLOG^SDESJSON(.ERRORS,555,"Appointment IEN "_APPTIEN_". Unable to retrieve Clinic appointment data")
QUIT
+6 DO GET44INFO^SDES2BLDAPPT44(.APPTOBJ,.CLINIEN,RECCNT)
+7 SET SDIEN=$$GET44RECORDIENS(CLINIEN,APPTOBJ("Appointment",RECCNT,"StartTimeFM"),SDDFN,.APPTOBJ)
+8 IF 'SDIEN
DO BLANK44003INFO^SDES2BLDAPPT44(.APPTOBJ,RECCNT)
QUIT
+9 DO GET44003INFO^SDES2BLDAPPT44(.APPTOBJ,CLINIEN,SDIEN,RECCNT)
+10 QUIT
+11 ;
GET40984INFO(APPTOBJ,APPTIEN,SDDFN,CLINIEN,CANCELID,RECCNT) ;
+1 NEW IENS,RESOURCEIEN,APPTDATA,APPTSTATDT,APPREQIEN,APPREQPTR,ORIGAPPTREQTYP,ARRAY40984,SDMSG
+2 SET IENS=APPTIEN_","
+3 DO GETS^DIQ(409.84,IENS,".01;.02;.03;.04;.05;.06;.07;.08;.09;.12;.13;.121;.122;.14;.16;.17;.18;.2;.22;1;2;3;4;100","IE","ARRAY40984","SDMSG")
+4 SET RESOURCEIEN=$GET(ARRAY40984(409.84,IENS,.07,"I"))
+5 SET CLINIEN=$$GET1^DIQ(409.831,RESOURCEIEN,.04,"I")
+6 SET SDDFN=$GET(ARRAY40984(409.84,IENS,.05,"I"))
+7 SET APPTOBJ("Appointment",RECCNT,"AppointmentDateTime")=$$FMTISO^SDAMUTDT($GET(ARRAY40984(409.84,IENS,.01,"I")),CLINIEN)
+8 SET APPTOBJ("Appointment",RECCNT,"AppointmentIEN")=APPTIEN
+9 SET APPTOBJ("Appointment",RECCNT,"AppointmentTypeIEN")=$GET(ARRAY40984(409.84,IENS,.06,"I"))
+10 SET APPTOBJ("Appointment",RECCNT,"AppointmentType")=$GET(ARRAY40984(409.84,IENS,.06,"E"))
+11 SET APPTOBJ("Appointment",RECCNT,"CancelDateTime")=$$FMTISO^SDAMUTDT($GET(ARRAY40984(409.84,IENS,.12,"I")),CLINIEN)
+12 SET APPTOBJ("Appointment",RECCNT,"DateAppointmentMade")=$$FMTISO^SDAMUTDT($GET(ARRAY40984(409.84,IENS,.09,"I")))
+13 SET APPTOBJ("Appointment",RECCNT,"CancellationReason")=$GET(ARRAY40984(409.84,IENS,.122,"E"))
+14 SET CANCELID=$GET(ARRAY40984(409.84,IENS,.121,"I"))
+15 if 'CANCELID
SET APPTOBJ("Appointment",RECCNT,"CancelledByUser",1)=""
+16 IF CANCELID
Begin DoDot:1
+17 SET APPTOBJ("Appointment",RECCNT,"CancelledByUser","ID")=$GET(ARRAY40984(409.84,IENS,.121,"I"))
+18 SET APPTOBJ("Appointment",RECCNT,"CancelledByUser","Name")=$GET(ARRAY40984(409.84,IENS,.121,"E"))
+19 SET APPTOBJ("Appointment",RECCNT,"CancelledByUser","SecId")=$$GET1^DIQ(200,CANCELID,205.1,"I")
End DoDot:1
+20 SET APPTOBJ("Appointment",RECCNT,"CheckIn")=$$FMTISO^SDAMUTDT($GET(ARRAY40984(409.84,IENS,.03,"I")),CLINIEN)
+21 SET APPTOBJ("Appointment",RECCNT,"CheckInEntered")=$$FMTISO^SDAMUTDT($GET(ARRAY40984(409.84,IENS,.04,"I")))
+22 SET APPTOBJ("Appointment",RECCNT,"CheckOut")=$$FMTISO^SDAMUTDT($GET(ARRAY40984(409.84,IENS,.14,"I")),CLINIEN)
+23 SET APPTOBJ("Appointment",RECCNT,"Clinic","ClinicIEN")=CLINIEN
+24 SET APPTSTATDT=$$APPTSTATUS^SDES2GETSTATUS(APPTIEN,CLINIEN)
+25 SET APPTOBJ("Appointment",RECCNT,"CurrentStatus")=$PIECE(APPTSTATDT,U)
+26 SET APPTOBJ("Appointment",RECCNT,"Status")=$PIECE(APPTSTATDT,U)
+27 SET APPTOBJ("Appointment",RECCNT,"DesiredDateOfAppointment")=$$FMTISO^SDAMUTDT($GET(ARRAY40984(409.84,IENS,.2,"I")))
+28 SET APPTOBJ("Appointment",RECCNT,"StatusCancelDateTime")=$$FMTISO^SDAMUTDT($PIECE(APPTSTATDT,U,2),CLINIEN)
+29 SET APPTOBJ("Appointment",RECCNT,"EASTrackingNumber")=$GET(ARRAY40984(409.84,IENS,100,"I"))
+30 SET APPTOBJ("Appointment",RECCNT,"EndTime")=$$FMTISO^SDAMUTDT($GET(ARRAY40984(409.84,IENS,.02,"I")),CLINIEN)
+31 SET APPTOBJ("Appointment",RECCNT,"LengthOfAppt")=$GET(ARRAY40984(409.84,IENS,.18,"E"))
+32 KILL ARRAY40984(409.84,IENS,1,"I"),ARRAY40984(409.84,IENS,1,"E")
+33 IF $DATA(ARRAY40984(409.84,IENS,1))
MERGE APPTOBJ("Appointment",RECCNT,"Note")=ARRAY40984(409.84,IENS,1)
+34 IF '$DATA(APPTOBJ("Appointment",RECCNT,"Note"))
SET APPTOBJ("Appointment",RECCNT,"Note")=""
+35 SET APPREQIEN=$PIECE($GET(ARRAY40984(409.84,IENS,.22,"I")),";")
+36 SET APPREQPTR=$PIECE($GET(ARRAY40984(409.84,IENS,.22,"I")),";",2)
+37 IF APPREQPTR[403.5
SET ORIGAPPTREQTYP="R"
+38 IF APPREQPTR[123
SET ORIGAPPTREQTYP=$$GET1^DIQ(123,APPREQIEN,13,"I")
+39 IF APPREQPTR[409.85
SET ORIGAPPTREQTYP=$$GET1^DIQ(409.85,APPREQIEN,4,"I")
+40 SET APPTOBJ("Appointment",RECCNT,"OriginatingRequestType")=$GET(ORIGAPPTREQTYP)
+41 IF $GET(ARRAY40984(409.84,IENS,.16,"I"))'=""
Begin DoDot:1
+42 SET APPTOBJ("Appointment",RECCNT,"Provider","ID")=$GET(ARRAY40984(409.84,IENS,.16,"I"))
+43 SET APPTOBJ("Appointment",RECCNT,"Provider","Name")=$GET(ARRAY40984(409.84,IENS,.16,"E"))
+44 SET APPTOBJ("Appointment",RECCNT,"Provider","SecId")=$$GET1^DIQ(200,$GET(ARRAY40984(409.84,IENS,.16,"I")),205.1,"I")
End DoDot:1
+45 if ($GET(ARRAY40984(409.84,IENS,.16,"I"))="")
SET APPTOBJ("Appointment",RECCNT,"Provider",1)=""
+46 SET APPTOBJ("Appointment",RECCNT,"RequestIEN")=APPREQIEN
+47 SET APPTOBJ("Appointment",RECCNT,"RequestType")=$GET(ARRAY40984(409.84,IENS,.22,"E"))
+48 SET APPTOBJ("Appointment",RECCNT,"Resource","Name")=$GET(ARRAY40984(409.84,IENS,.07,"E"))
+49 SET APPTOBJ("Appointment",RECCNT,"Resource","ClinicIEN")=CLINIEN
+50 SET APPTOBJ("Appointment",RECCNT,"ResourceIEN")=RESOURCEIEN
+51 SET APPTOBJ("Appointment",RECCNT,"StartTimeFM")=$GET(ARRAY40984(409.84,IENS,.01,"I"))
+52 SET APPTOBJ("Appointment",RECCNT,"VVSApptID")=$GET(ARRAY40984(409.84,IENS,2,"I"))
+53 SET APPTOBJ("Appointment",RECCNT,"Walkin")=$GET(ARRAY40984(409.84,IENS,.13,"E"))
+54 SET APPTOBJ("Appointment",RECCNT,"MRTCFlag")=0
+55 if ((APPREQPTR[409.85)&($$GET1^DIQ(409.85,APPREQIEN,43.8)'=""))
SET APPTOBJ("Appointment",RECCNT,"MRTCFlag")=1
+56 SET APPTOBJ("Appointment",RECCNT,"DataEntryClerk")=$GET(ARRAY40984(409.84,IENS,.08,"E"))
+57 DO GETPATCOMMENTS(.APPTOBJ,APPTIEN,RECCNT)
+58 DO CHECKINSTEPS(.APPTOBJ,APPTIEN,RECCNT)
+59 DO GETNOTEAUDIT(.APPTOBJ,APPTIEN,RECCNT)
+60 QUIT
+61 ;
+1 NEW SUBIEN,COUNT
+2 SET SUBIEN=0
SET COUNT=0
+3 FOR
SET SUBIEN=$ORDER(^SDEC(409.84,APPTIEN,6,SUBIEN))
if 'SUBIEN
QUIT
Begin DoDot:1
+4 SET COUNT=COUNT+1
+5 SET APPTOBJ("Appointment",RECCNT,"PatientComments",COUNT)=$$GET1^DIQ(409.846,SUBIEN_","_APPTIEN_",",.01,"E")
End DoDot:1
+6 IF '$DATA(APPTOBJ("Appointment",RECCNT,"PatientComments"))
SET APPTOBJ("Appointment",RECCNT,"PatientComments",1)=""
+7 QUIT
+8 ;
CHECKINSTEPS(APPTOBJ,APPTIEN,RECCNT) ;
+1 NEW SDIEN,NUM,DATETIME
+2 SET (SDIEN,NUM)=0
+3 FOR
SET SDIEN=$ORDER(^SDEC(409.84,APPTIEN,3,SDIEN))
if 'SDIEN
QUIT
Begin DoDot:1
+4 SET NUM=NUM+1
+5 SET DATETIME=$$GET1^DIQ(409.843,SDIEN_","_APPTIEN_",",1,"I")
+6 SET APPTOBJ("Appointment",RECCNT,"CheckInSteps",NUM,"IEN")=SDIEN
+7 SET APPTOBJ("Appointment",RECCNT,"CheckInSteps",NUM,"Status")=$$GET1^DIQ(409.843,SDIEN_","_APPTIEN_",",.01,"E")
+8 SET APPTOBJ("Appointment",RECCNT,"CheckInSteps",NUM,"DateTime")=$$FMTISO^SDAMUTDT(DATETIME)
End DoDot:1
+9 IF '$DATA(APPTOBJ("Appointment",RECCNT,"CheckInSteps"))
SET APPTOBJ("Appointment",RECCNT,"CheckInSteps",1)=""
+10 QUIT
+11 ;
GETNOTEAUDIT(APPTOBJ,APPTIEN,RECCNT) ;
+1 NEW SUBIEN,COUNT
+2 SET SUBIEN=0
SET COUNT=0
+3 FOR
SET SUBIEN=$ORDER(^SDEC(409.84,APPTIEN,"NOTEAUD",SUBIEN))
if 'SUBIEN
QUIT
Begin DoDot:1
+4 SET COUNT=COUNT+1
+5 SET APPTOBJ("Appointment",RECCNT,"NoteAuditing",COUNT,"DateNoteAdded")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.847,SUBIEN_","_APPTIEN_",",.01,"I"))
+6 SET APPTOBJ("Appointment",RECCNT,"NoteAuditing",COUNT,"NoteAddedByDUZ")=$$GET1^DIQ(409.847,SUBIEN_","_APPTIEN_",",1,"I")
+7 SET APPTOBJ("Appointment",RECCNT,"NoteAuditing",COUNT,"NoteAddedByName")=$$GET1^DIQ(409.847,SUBIEN_","_APPTIEN_",",1,"E")
+8 SET APPTOBJ("Appointment",RECCNT,"NoteAuditing",COUNT,"Note")=$$GET1^DIQ(409.847,SUBIEN_","_APPTIEN_",",2,"I")
End DoDot:1
+9 IF '$DATA(APPTOBJ("Appointment",RECCNT,"NoteAuditing"))
SET APPTOBJ("Appointment",RECCNT,"NoteAuditing",1)=""
+10 QUIT
+11 ;
GET44RECORDIENS(CLINICIEN,APPTSTARTTIME,SDDFN,APPTOBJ) ;
+1 ;want to process through until we get to the correct appointment for time and clinic
+2 NEW FOUND,IENS44003,SUBIEN,APPTCNT,MATCH,CHECKIEN
+3 SET FOUND=0
SET APPTCNT=0
+4 SET SUBIEN=0
FOR
SET SUBIEN=$ORDER(^SC(CLINICIEN,"S",APPTSTARTTIME,1,SUBIEN))
if 'SUBIEN!($GET(FOUND)=1)
QUIT
Begin DoDot:1
+5 IF $$GET1^DIQ(44.003,SUBIEN_","_APPTSTARTTIME_","_CLINICIEN_",",.01,"I")=SDDFN
Begin DoDot:2
+6 SET CHECKIEN=SUBIEN_","_APPTSTARTTIME_","_CLINICIEN_","
+7 SET MATCH=$$MATCHAPPOINTMENT(.APPTOBJ,CHECKIEN)
+8 if 'MATCH
QUIT
+9 SET APPTCNT=APPTCNT+1
+10 SET IENS44003=SUBIEN_","_APPTSTARTTIME_","_CLINICIEN_","
SET FOUND=1
QUIT
End DoDot:2
End DoDot:1
+11 QUIT $GET(IENS44003)
+12 ;
MATCHAPPOINTMENT(APPTOBJ,CHECKIEN) ;
+1 if (APPTOBJ("Appointment",RECCNT,"CancelDateTime")="")&($$GET1^DIQ(44.003,CHECKIEN,310,"I")="C")
QUIT 0
+2 QUIT 1
+3 ;