SDESCKNSTEP ;ALB/BLB,TAW,MGD - VISTA SCHEDULING RPCS ;July 19, 2022
;;5.3;Scheduling;**788,790,792,800,805,807,819,820**;Aug 13, 1993;Build 10
;;Per VHA Directive 2004-038, this routine should not be modified;
Q
SETAPPTCKNSTEP(SDECY,IEN,STATUS,EAS) ; File check-in status and date/time in 409.843,.01/1
N STATPOINTER,SIEN,DATETIME,FDA,SDCHECKIN
I '$G(IEN) S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,14),BUILDER Q
I '$D(^SDEC(409.84,IEN,0)) S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,15),BUILDER Q ;invalid appt IEN
I $G(STATUS)="" S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,38),BUILDER Q
I '$D(^SDEC(409.842,STATUS,0)) S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,37),BUILDER Q
I $$GET1^DIQ(409.84,IEN,.17,"E")["CANCEL" S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,31),BUILDER Q ;appt status is "C" (canceled)
S EAS=$TR($G(EAS),"^"," ")
I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL(EAS)
I EAS=-1 S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,142),BUILDER Q
S SIEN=0,STATPOINTER=0
F S SIEN=$O(^SDEC(409.84,IEN,3,SIEN)) Q:'SIEN!(STATPOINTER=STATUS) D
.S STATPOINTER=$$GET1^DIQ(409.843,SIEN_","_IEN_",",.01,"I")
I STATPOINTER=STATUS S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,32),BUILDER Q ; duplicate status entry, will not file
S DATETIME=$$NOW^XLFDT
S FDA(409.843,"+1,"_IEN_",",.01)=STATUS
S FDA(409.843,"+1,"_IEN_",",1)=DATETIME
D UPDATE^DIE(,"FDA",,"ERR") K FDA
S FDA(409.84,IEN_",",100)=$G(EAS)
D FILE^DIE(,"FDA") K FDA
I '$D(ERR) D Q
.S SDCHECKIN("ApptCheckInSteps","FilingSuccess")=1 D BUILDER
.I STATUS=6 D
..D CHECKIN(IEN)
I $D(ERR) D ERRLOG^SDESJSON(.SDCHECKIN,36) D BUILDER
Q
;
CHECKIN(IEN) ;
S DATETIME=$$NOW^XLFDT,DATETIME=$$FMTE^XLFDT(DATETIME)
D CHECKIN^SDEC25(.SDECY,IEN,DATETIME,,,"FALSE",,"FALSE",,,"FALSE","FALSE")
Q
;
GETAPPTCKNSTEP(SDECY,IEN,STATUS,EAS) ; Get check-in status associated appointment IEN and passed in status
N SDCHECKIN,SIEN,STATPOINTER,STAT,DATETIME
I '$G(IEN) S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,14),BUILDER Q
I $G(STATUS)="" S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,38),BUILDER Q
I '$D(^SDEC(409.84,IEN,0)) S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,15),BUILDER Q ;invalid appt IEN
S EAS=$G(EAS,"")
I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL(EAS)
I EAS=-1 S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,142),BUILDER Q
;
S SIEN=0
F S SIEN=$O(^SDEC(409.84,IEN,3,SIEN)) Q:'SIEN D
.S STATPOINTER=$$GET1^DIQ(409.843,SIEN_","_IEN_",",.01,"I")
.I STATPOINTER'=STATUS Q ; no match
.S STAT=$$GET1^DIQ(409.842,STATPOINTER,.01,"E")
.S DATETIME=$$GET1^DIQ(409.843,SIEN_","_IEN_",",1,"E"),DATETIME=$$FMTE^XLFDT(DATETIME)
.S EAS=$$GET1^DIQ(409.84,IEN,100,"E")
.D CKNBUILDER(STATPOINTER,STAT,DATETIME,"GETAPPTCKNSTEP")
I '$D(SDCHECKIN("ApptCheckInSteps")) S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,30) ;no status match found, will not pass back status
D BUILDER
Q
GETAPPTCKNSTEPS(SDECY,IEN,EAS) ; Get a list of checkin statuses associated with an appointment IEN
N SDCHECKIN,SIEN,STATPOINTER,STAT,DATETIME,NUM
I '$G(IEN) S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,14),BUILDER Q
I '$D(^SDEC(409.84,IEN,0)) S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,15),BUILDER Q ;invalid appt IEN
S EAS=$G(EAS,"")
I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL(EAS)
I EAS=-1 S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,142),BUILDER Q
S SIEN=0,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"),DATETIME=$$FMTE^XLFDT(DATETIME)
.S EAS=$$GET1^DIQ(409.84,IEN,100,"E")
.D CKNBUILDER(STATPOINTER,STAT,DATETIME,"GETAPPTCKNSTEPS")
.D BUILDER
I '$D(SDCHECKIN("ApptCheckInSteps")) S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,33),BUILDER Q ;no statuses found, will not pass back list
Q
SETCKNSTEP(SDECY,STATUS,EAS) ;create new status entry in check-in step status file
N FDA,SDCHECKIN,IEN,ENTRY
I $G(STATUS)="" S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,38),BUILDER Q
I $L(STATUS)<3!($L(STATUS)>30) S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,39),BUILDER Q
I STATUS'?.E1A.E!(STATUS?1P.E) S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,41),BUILDER Q
S EAS=$G(EAS,"")
I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL(EAS)
I EAS=-1 S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,142),BUILDER Q
S IEN=0,ENTRY=""
F S IEN=$O(^SDEC(409.842,IEN)) Q:'IEN!(STATUS=ENTRY) D
.S ENTRY=$$GET1^DIQ(409.842,IEN,.01,"E")
I STATUS=ENTRY S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,32),BUILDER Q ; duplicate status entry, will not file
S FDA(409.842,"+1,",.01)=STATUS
D UPDATE^DIE(,"FDA",,"ERR") K FDA,ERR
I '$D(ERR) S SDCHECKIN("CheckInSteps",0,"FilingSuccess")=1 D BUILDER Q
I $D(ERR) D ERRLOG^SDESJSON(.SDCHECKIN,34),BUILDER
Q
EDITCKNSTEP(SDECY,IEN,STATUS,EAS) ; edit entry in check-in step status file
N FDA,SDCHECKIN,ENTRY,SIEN
I '$G(IEN) S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,40),BUILDER Q
I $G(STATUS)="" S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,38),BUILDER Q
I STATUS'="@",$L(STATUS)<3!($L(STATUS)>30) S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,39),BUILDER Q
I STATUS'="@",STATUS'?.E1A.E!(STATUS?1P.E) S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,41),BUILDER Q
I '$D(^SDEC(409.842,IEN,0)) S SDCHECKIN("ApptCheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,37),BUILDER Q
S EAS=$G(EAS,"")
I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL(EAS)
I EAS=-1 S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,142),BUILDER Q
;
S SIEN=0,ENTRY=""
F S SIEN=$O(^SDEC(409.842,SIEN)) Q:'SIEN!(STATUS=ENTRY) D
.S ENTRY=$$GET1^DIQ(409.842,SIEN,.01,"E")
I STATUS=ENTRY S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,32),BUILDER Q ; duplicate status entry, will not file
S FDA(409.842,IEN_",",.01)=STATUS
D FILE^DIE(,"FDA","ERR") K FDA
I '$D(ERR) S SDCHECKIN("CheckInSteps",0,"FilingSuccess")=1 D BUILDER Q
I $D(ERR) D ERRLOG^SDESJSON(.SDCHECKIN,35),BUILDER
Q
GETCKNSTEP(SDECY,IEN,EAS) ;get status from check-in step status file
N SDCHECKIN,STATUS
I '$G(IEN) S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,40),BUILDER Q
S EAS=$G(EAS,"")
I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL(EAS)
I EAS=-1 S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,142),BUILDER Q
S STATUS=$$GET1^DIQ(409.842,IEN,.01,"E")
D CKNBUILDER(IEN,STATUS,"","GETCKNSTEP")
I $G(STATUS)="" S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,37),BUILDER Q
D BUILDER
Q
GETCKNSTEPS(SDECY,EAS) ;
N SDCHECKIN,IEN,NUM
S EAS=$G(EAS,"")
I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL(EAS)
I EAS=-1 S SDCHECKIN("CheckInSteps")="" D ERRLOG^SDESJSON(.SDCHECKIN,142),BUILDER Q
S IEN=0,NUM=0
F S IEN=$O(^SDEC(409.842,IEN)) Q:'IEN D
.S NUM=NUM+1
.S STATUS=$$GET1^DIQ(409.842,IEN,.01,"E")
.D CKNBUILDER(IEN,STATUS,"","GETCKNSTEPS")
.D BUILDER
Q
BUILDER ;
D ENCODE^XLFJSON("SDCHECKIN","SDECY","ERR")
Q
CKNBUILDER(IEN,STATUS,DATETIME,TAG) ;
;single appt check-in step
I $G(TAG)="GETAPPTCKNSTEP" D
.S SDCHECKIN("ApptCheckInSteps","IEN")=$G(IEN)
.S SDCHECKIN("ApptCheckInSteps","Status")=$G(STATUS)
.S SDCHECKIN("ApptCheckInSteps","DateTime")=$G(DATETIME)
.S SDCHECKIN("ApptCheckInSteps","EASTrackingNumber")=$G(EAS)
I $G(TAG)="GETAPPTCKNSTEP",$D(SDCHECKIN("ApptCheckInSteps")) Q
;list of appt check-in steps
I $G(TAG)="GETAPPTCKNSTEPS" D
.S SDCHECKIN("ApptCheckInSteps",NUM,"IEN")=$G(IEN)
.S SDCHECKIN("ApptCheckInSteps",NUM,"Status")=$G(STAT)
.S SDCHECKIN("ApptCheckInSteps",NUM,"DateTime")=$G(DATETIME)
.S SDCHECKIN("ApptCheckInSteps",NUM,"EASTrackingNumber")=$G(EAS)
I $G(TAG)="GETAPPTCKNSTEPS",$D(SDCHECKIN("ApptCheckInSteps")) Q
;single check-in step
I $G(TAG)="GETCKNSTEP" D
.S SDCHECKIN("CheckInSteps","IEN")=$G(IEN)
.S SDCHECKIN("CheckInSteps",0,"Status")=STATUS
I $G(TAG)="GETCKNSTEP",$D(SDCHECKIN("CheckInSteps")) Q
;list of check-in steps
I $G(TAG)="GETCKNSTEPS" D
.S SDCHECKIN("CheckInSteps",NUM,"IEN")=$G(IEN)
.S SDCHECKIN("CheckInSteps",NUM,"Status")=STATUS
I $G(TAG)="GETCKNSTEPS",$D(SDCHECKIN("CheckInSteps")) Q
Q
;
HASCKNSTEP(IEN,STATUS) ;
; Function will confirm if a STATUS is on the Appointment IEN
; IEN - IEN from SDEC Appointment
; STATUS - IEN from SDEC CHECK-IN STEP STATUS
N SIEN,RET
S (SIEN,RET)=0
F S SIEN=$O(^SDEC(409.84,IEN,3,SIEN)) Q:'SIEN D Q:RET
.I STATUS=$P($G(^SDEC(409.84,IEN,3,SIEN,0)),"^",1) S RET=1
Q RET
;
LASTCKNSTEP(IEN) ;
; Function will return the last Check In Step on the Appointment IEN
; IEN - IEN from SDEC Appointment
N SIEN,RET,STEP
S (SIEN,RET)=""
S SIEN=$O(^SDEC(409.84,IEN,3,9999999999),-1)
IF +SIEN S STEP=$P($G(^SDEC(409.84,IEN,3,SIEN,0)),"^",1),RET=$$GET1^DIQ(409.842,STEP,.01,"E")
Q RET
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESCKNSTEP 9329 printed Nov 22, 2024@18:06 Page 2
SDESCKNSTEP ;ALB/BLB,TAW,MGD - VISTA SCHEDULING RPCS ;July 19, 2022
+1 ;;5.3;Scheduling;**788,790,792,800,805,807,819,820**;Aug 13, 1993;Build 10
+2 ;;Per VHA Directive 2004-038, this routine should not be modified;
+3 QUIT
SETAPPTCKNSTEP(SDECY,IEN,STATUS,EAS) ; File check-in status and date/time in 409.843,.01/1
+1 NEW STATPOINTER,SIEN,DATETIME,FDA,SDCHECKIN
+2 IF '$GET(IEN)
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,14)
DO BUILDER
QUIT
+3 ;invalid appt IEN
IF '$DATA(^SDEC(409.84,IEN,0))
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,15)
DO BUILDER
QUIT
+4 IF $GET(STATUS)=""
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,38)
DO BUILDER
QUIT
+5 IF '$DATA(^SDEC(409.842,STATUS,0))
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,37)
DO BUILDER
QUIT
+6 ;appt status is "C" (canceled)
IF $$GET1^DIQ(409.84,IEN,.17,"E")["CANCEL"
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,31)
DO BUILDER
QUIT
+7 SET EAS=$TRANSLATE($GET(EAS),"^"," ")
+8 IF $LENGTH(EAS)
SET EAS=$$EASVALIDATE^SDESUTIL(EAS)
+9 IF EAS=-1
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,142)
DO BUILDER
QUIT
+10 SET SIEN=0
SET STATPOINTER=0
+11 FOR
SET SIEN=$ORDER(^SDEC(409.84,IEN,3,SIEN))
if 'SIEN!(STATPOINTER=STATUS)
QUIT
Begin DoDot:1
+12 SET STATPOINTER=$$GET1^DIQ(409.843,SIEN_","_IEN_",",.01,"I")
End DoDot:1
+13 ; duplicate status entry, will not file
IF STATPOINTER=STATUS
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,32)
DO BUILDER
QUIT
+14 SET DATETIME=$$NOW^XLFDT
+15 SET FDA(409.843,"+1,"_IEN_",",.01)=STATUS
+16 SET FDA(409.843,"+1,"_IEN_",",1)=DATETIME
+17 DO UPDATE^DIE(,"FDA",,"ERR")
KILL FDA
+18 SET FDA(409.84,IEN_",",100)=$GET(EAS)
+19 DO FILE^DIE(,"FDA")
KILL FDA
+20 IF '$DATA(ERR)
Begin DoDot:1
+21 SET SDCHECKIN("ApptCheckInSteps","FilingSuccess")=1
DO BUILDER
+22 IF STATUS=6
Begin DoDot:2
+23 DO CHECKIN(IEN)
End DoDot:2
End DoDot:1
QUIT
+24 IF $DATA(ERR)
DO ERRLOG^SDESJSON(.SDCHECKIN,36)
DO BUILDER
+25 QUIT
+26 ;
CHECKIN(IEN) ;
+1 SET DATETIME=$$NOW^XLFDT
SET DATETIME=$$FMTE^XLFDT(DATETIME)
+2 DO CHECKIN^SDEC25(.SDECY,IEN,DATETIME,,,"FALSE",,"FALSE",,,"FALSE","FALSE")
+3 QUIT
+4 ;
GETAPPTCKNSTEP(SDECY,IEN,STATUS,EAS) ; Get check-in status associated appointment IEN and passed in status
+1 NEW SDCHECKIN,SIEN,STATPOINTER,STAT,DATETIME
+2 IF '$GET(IEN)
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,14)
DO BUILDER
QUIT
+3 IF $GET(STATUS)=""
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,38)
DO BUILDER
QUIT
+4 ;invalid appt IEN
IF '$DATA(^SDEC(409.84,IEN,0))
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,15)
DO BUILDER
QUIT
+5 SET EAS=$GET(EAS,"")
+6 IF $LENGTH(EAS)
SET EAS=$$EASVALIDATE^SDESUTIL(EAS)
+7 IF EAS=-1
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,142)
DO BUILDER
QUIT
+8 ;
+9 SET SIEN=0
+10 FOR
SET SIEN=$ORDER(^SDEC(409.84,IEN,3,SIEN))
if 'SIEN
QUIT
Begin DoDot:1
+11 SET STATPOINTER=$$GET1^DIQ(409.843,SIEN_","_IEN_",",.01,"I")
+12 ; no match
IF STATPOINTER'=STATUS
QUIT
+13 SET STAT=$$GET1^DIQ(409.842,STATPOINTER,.01,"E")
+14 SET DATETIME=$$GET1^DIQ(409.843,SIEN_","_IEN_",",1,"E")
SET DATETIME=$$FMTE^XLFDT(DATETIME)
+15 SET EAS=$$GET1^DIQ(409.84,IEN,100,"E")
+16 DO CKNBUILDER(STATPOINTER,STAT,DATETIME,"GETAPPTCKNSTEP")
End DoDot:1
+17 ;no status match found, will not pass back status
IF '$DATA(SDCHECKIN("ApptCheckInSteps"))
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,30)
+18 DO BUILDER
+19 QUIT
GETAPPTCKNSTEPS(SDECY,IEN,EAS) ; Get a list of checkin statuses associated with an appointment IEN
+1 NEW SDCHECKIN,SIEN,STATPOINTER,STAT,DATETIME,NUM
+2 IF '$GET(IEN)
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,14)
DO BUILDER
QUIT
+3 ;invalid appt IEN
IF '$DATA(^SDEC(409.84,IEN,0))
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,15)
DO BUILDER
QUIT
+4 SET EAS=$GET(EAS,"")
+5 IF $LENGTH(EAS)
SET EAS=$$EASVALIDATE^SDESUTIL(EAS)
+6 IF EAS=-1
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,142)
DO BUILDER
QUIT
+7 SET SIEN=0
SET NUM=0
+8 FOR
SET SIEN=$ORDER(^SDEC(409.84,IEN,3,SIEN))
if 'SIEN
QUIT
Begin DoDot:1
+9 SET NUM=NUM+1
+10 SET STATPOINTER=$$GET1^DIQ(409.843,SIEN_","_IEN_",",.01,"I")
+11 SET STAT=$$GET1^DIQ(409.842,STATPOINTER,.01,"E")
+12 SET DATETIME=$$GET1^DIQ(409.843,SIEN_","_IEN_",",1,"E")
SET DATETIME=$$FMTE^XLFDT(DATETIME)
+13 SET EAS=$$GET1^DIQ(409.84,IEN,100,"E")
+14 DO CKNBUILDER(STATPOINTER,STAT,DATETIME,"GETAPPTCKNSTEPS")
+15 DO BUILDER
End DoDot:1
+16 ;no statuses found, will not pass back list
IF '$DATA(SDCHECKIN("ApptCheckInSteps"))
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,33)
DO BUILDER
QUIT
+17 QUIT
SETCKNSTEP(SDECY,STATUS,EAS) ;create new status entry in check-in step status file
+1 NEW FDA,SDCHECKIN,IEN,ENTRY
+2 IF $GET(STATUS)=""
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,38)
DO BUILDER
QUIT
+3 IF $LENGTH(STATUS)<3!($LENGTH(STATUS)>30)
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,39)
DO BUILDER
QUIT
+4 IF STATUS'?.E1A.E!(STATUS?1P.E)
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,41)
DO BUILDER
QUIT
+5 SET EAS=$GET(EAS,"")
+6 IF $LENGTH(EAS)
SET EAS=$$EASVALIDATE^SDESUTIL(EAS)
+7 IF EAS=-1
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,142)
DO BUILDER
QUIT
+8 SET IEN=0
SET ENTRY=""
+9 FOR
SET IEN=$ORDER(^SDEC(409.842,IEN))
if 'IEN!(STATUS=ENTRY)
QUIT
Begin DoDot:1
+10 SET ENTRY=$$GET1^DIQ(409.842,IEN,.01,"E")
End DoDot:1
+11 ; duplicate status entry, will not file
IF STATUS=ENTRY
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,32)
DO BUILDER
QUIT
+12 SET FDA(409.842,"+1,",.01)=STATUS
+13 DO UPDATE^DIE(,"FDA",,"ERR")
KILL FDA,ERR
+14 IF '$DATA(ERR)
SET SDCHECKIN("CheckInSteps",0,"FilingSuccess")=1
DO BUILDER
QUIT
+15 IF $DATA(ERR)
DO ERRLOG^SDESJSON(.SDCHECKIN,34)
DO BUILDER
+16 QUIT
EDITCKNSTEP(SDECY,IEN,STATUS,EAS) ; edit entry in check-in step status file
+1 NEW FDA,SDCHECKIN,ENTRY,SIEN
+2 IF '$GET(IEN)
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,40)
DO BUILDER
QUIT
+3 IF $GET(STATUS)=""
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,38)
DO BUILDER
QUIT
+4 IF STATUS'="@"
IF $LENGTH(STATUS)<3!($LENGTH(STATUS)>30)
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,39)
DO BUILDER
QUIT
+5 IF STATUS'="@"
IF STATUS'?.E1A.E!(STATUS?1P.E)
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,41)
DO BUILDER
QUIT
+6 IF '$DATA(^SDEC(409.842,IEN,0))
SET SDCHECKIN("ApptCheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,37)
DO BUILDER
QUIT
+7 SET EAS=$GET(EAS,"")
+8 IF $LENGTH(EAS)
SET EAS=$$EASVALIDATE^SDESUTIL(EAS)
+9 IF EAS=-1
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,142)
DO BUILDER
QUIT
+10 ;
+11 SET SIEN=0
SET ENTRY=""
+12 FOR
SET SIEN=$ORDER(^SDEC(409.842,SIEN))
if 'SIEN!(STATUS=ENTRY)
QUIT
Begin DoDot:1
+13 SET ENTRY=$$GET1^DIQ(409.842,SIEN,.01,"E")
End DoDot:1
+14 ; duplicate status entry, will not file
IF STATUS=ENTRY
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,32)
DO BUILDER
QUIT
+15 SET FDA(409.842,IEN_",",.01)=STATUS
+16 DO FILE^DIE(,"FDA","ERR")
KILL FDA
+17 IF '$DATA(ERR)
SET SDCHECKIN("CheckInSteps",0,"FilingSuccess")=1
DO BUILDER
QUIT
+18 IF $DATA(ERR)
DO ERRLOG^SDESJSON(.SDCHECKIN,35)
DO BUILDER
+19 QUIT
GETCKNSTEP(SDECY,IEN,EAS) ;get status from check-in step status file
+1 NEW SDCHECKIN,STATUS
+2 IF '$GET(IEN)
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,40)
DO BUILDER
QUIT
+3 SET EAS=$GET(EAS,"")
+4 IF $LENGTH(EAS)
SET EAS=$$EASVALIDATE^SDESUTIL(EAS)
+5 IF EAS=-1
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,142)
DO BUILDER
QUIT
+6 SET STATUS=$$GET1^DIQ(409.842,IEN,.01,"E")
+7 DO CKNBUILDER(IEN,STATUS,"","GETCKNSTEP")
+8 IF $GET(STATUS)=""
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,37)
DO BUILDER
QUIT
+9 DO BUILDER
+10 QUIT
GETCKNSTEPS(SDECY,EAS) ;
+1 NEW SDCHECKIN,IEN,NUM
+2 SET EAS=$GET(EAS,"")
+3 IF $LENGTH(EAS)
SET EAS=$$EASVALIDATE^SDESUTIL(EAS)
+4 IF EAS=-1
SET SDCHECKIN("CheckInSteps")=""
DO ERRLOG^SDESJSON(.SDCHECKIN,142)
DO BUILDER
QUIT
+5 SET IEN=0
SET NUM=0
+6 FOR
SET IEN=$ORDER(^SDEC(409.842,IEN))
if 'IEN
QUIT
Begin DoDot:1
+7 SET NUM=NUM+1
+8 SET STATUS=$$GET1^DIQ(409.842,IEN,.01,"E")
+9 DO CKNBUILDER(IEN,STATUS,"","GETCKNSTEPS")
+10 DO BUILDER
End DoDot:1
+11 QUIT
BUILDER ;
+1 DO ENCODE^XLFJSON("SDCHECKIN","SDECY","ERR")
+2 QUIT
CKNBUILDER(IEN,STATUS,DATETIME,TAG) ;
+1 ;single appt check-in step
+2 IF $GET(TAG)="GETAPPTCKNSTEP"
Begin DoDot:1
+3 SET SDCHECKIN("ApptCheckInSteps","IEN")=$GET(IEN)
+4 SET SDCHECKIN("ApptCheckInSteps","Status")=$GET(STATUS)
+5 SET SDCHECKIN("ApptCheckInSteps","DateTime")=$GET(DATETIME)
+6 SET SDCHECKIN("ApptCheckInSteps","EASTrackingNumber")=$GET(EAS)
End DoDot:1
+7 IF $GET(TAG)="GETAPPTCKNSTEP"
IF $DATA(SDCHECKIN("ApptCheckInSteps"))
QUIT
+8 ;list of appt check-in steps
+9 IF $GET(TAG)="GETAPPTCKNSTEPS"
Begin DoDot:1
+10 SET SDCHECKIN("ApptCheckInSteps",NUM,"IEN")=$GET(IEN)
+11 SET SDCHECKIN("ApptCheckInSteps",NUM,"Status")=$GET(STAT)
+12 SET SDCHECKIN("ApptCheckInSteps",NUM,"DateTime")=$GET(DATETIME)
+13 SET SDCHECKIN("ApptCheckInSteps",NUM,"EASTrackingNumber")=$GET(EAS)
End DoDot:1
+14 IF $GET(TAG)="GETAPPTCKNSTEPS"
IF $DATA(SDCHECKIN("ApptCheckInSteps"))
QUIT
+15 ;single check-in step
+16 IF $GET(TAG)="GETCKNSTEP"
Begin DoDot:1
+17 SET SDCHECKIN("CheckInSteps","IEN")=$GET(IEN)
+18 SET SDCHECKIN("CheckInSteps",0,"Status")=STATUS
End DoDot:1
+19 IF $GET(TAG)="GETCKNSTEP"
IF $DATA(SDCHECKIN("CheckInSteps"))
QUIT
+20 ;list of check-in steps
+21 IF $GET(TAG)="GETCKNSTEPS"
Begin DoDot:1
+22 SET SDCHECKIN("CheckInSteps",NUM,"IEN")=$GET(IEN)
+23 SET SDCHECKIN("CheckInSteps",NUM,"Status")=STATUS
End DoDot:1
+24 IF $GET(TAG)="GETCKNSTEPS"
IF $DATA(SDCHECKIN("CheckInSteps"))
QUIT
+25 QUIT
+26 ;
HASCKNSTEP(IEN,STATUS) ;
+1 ; Function will confirm if a STATUS is on the Appointment IEN
+2 ; IEN - IEN from SDEC Appointment
+3 ; STATUS - IEN from SDEC CHECK-IN STEP STATUS
+4 NEW SIEN,RET
+5 SET (SIEN,RET)=0
+6 FOR
SET SIEN=$ORDER(^SDEC(409.84,IEN,3,SIEN))
if 'SIEN
QUIT
Begin DoDot:1
+7 IF STATUS=$PIECE($GET(^SDEC(409.84,IEN,3,SIEN,0)),"^",1)
SET RET=1
End DoDot:1
if RET
QUIT
+8 QUIT RET
+9 ;
LASTCKNSTEP(IEN) ;
+1 ; Function will return the last Check In Step on the Appointment IEN
+2 ; IEN - IEN from SDEC Appointment
+3 NEW SIEN,RET,STEP
+4 SET (SIEN,RET)=""
+5 SET SIEN=$ORDER(^SDEC(409.84,IEN,3,9999999999),-1)
+6 IF +SIEN
SET STEP=$PIECE($GET(^SDEC(409.84,IEN,3,SIEN,0)),"^",1)
SET RET=$$GET1^DIQ(409.842,STEP,.01,"E")
+7 QUIT RET