SDESCHECKINSTEP ;ALB/LAB - SDES RPC Clone of SDESCKNSTEP ;Jan 28, 2022
;;5.3;Scheduling;**816**;Aug 13, 1993;Build 3
;;Per VHA Directive 6402, this routine should not be modified;
Q
;
GETAPPTCKNSTEPS(SDECY,IEN,EAS) ; Get a list of checkin statuses associated with an appointment IEN
N SDHASERR,SDCHECKIN
;
D VALIDATEAPPTIEN(.SDHASERR,$G(IEN))
D VALIDATEAS(.SDHASERR,.EAS)
I '$D(SDHASERR) D GETCKNLIST(.SDCHECKIN,IEN,EAS)
I '$D(SDHASERR),'$D(SDCHECKIN("ApptCheckInSteps")) D ERRLOG^SDESJSON(.SDHASERR,33)
I $D(SDHASERR) D
. S SDCHECKIN("ApptCheckInSteps",1)=""
. M SDCHECKIN=SDHASERR
D BUILDJSON(.SDECY,.SDCHECKIN)
Q
;
GETAPPTCKNSTEP(SDECY,IEN,STATUS,EAS) ; Get check-in status associated appointment IEN and passed in status
N SDCHECKIN,SIEN,STATPOINTER,STAT,DATETIME,SDHASERR
D VALIDATEAPPTIEN(.SDHASERR,$G(IEN))
D VALIDATEAS(.SDHASERR,.EAS)
D VALIDATESTATUS(.SDHASERR,$G(STATUS))
I '$D(SDHASERR) D
. D GETAPPTCHECKIN(.SDCHECKIN,.IEN,STATUS)
. I '$D(SDCHECKIN("ApptCheckInSteps")) D ERRLOG^SDESJSON(.SDHASERR,30) ;no status match found, will not pass back status
I $D(SDHASERR) D
. S SDCHECKIN("ApptCheckInSteps",1)=""
. M SDCHECKIN=SDHASERR
D BUILDJSON(.SDECY,.SDCHECKIN)
Q
;
GETAPPTCHECKIN(SDCHECKIN,IEN,STATUS) ;get appointment check in
N SIEN,STATPOINTER,STAT,DATETIME
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,"I")
.S DATETIME=$$FMTISO^SDAMUTDT(DATETIME)
.S EAS=$$GET1^DIQ(409.84,IEN,100,"E")
.D CKNBUILDER(.SDCHECKIN,STATPOINTER,STAT,DATETIME,"GETAPPTCKNSTEP")
Q
;
VALIDATESTATUS(SDERR,STATUS) ;validate the status sent in
I STATUS="" D ERRLOG^SDESJSON(.SDERR,38)
Q
;
BUILDJSON(APPTLISTJSON,APPTLISTARRAY) ;Convert data to JSON
N JSONERR
S JSONERR=""
D ENCODE^SDESJSON(.APPTLISTARRAY,.APPTLISTJSON,.JSONERR)
Q
;
GETCKNLIST(SDCHECKIN,IEN,EAS) ;get check in step
N SIEN,STATPOINTER,STAT,DATETIME,NUM
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,"I")
.S:DATETIME'="" DATETIME=$$FMTISO^SDAMUTDT(DATETIME)
.S EAS=$$GET1^DIQ(409.84,IEN,100,"E")
.D CKNBUILDER(.SDCHECKIN,STATPOINTER,STAT,DATETIME,"GETAPPTCKNSTEPS")
Q
;
VALIDATEAPPTIEN(SDERR,IEN) ;validate appointment IEN
; Validate IEN
I IEN="" D ERRLOG^SDESJSON(.SDERR,14)
I IEN'="",'$D(^SDEC(409.84,IEN,0)) D ERRLOG^SDESJSON(.SDERR,15)
Q
VALIDATEAS(SDERR,EAS) ;validate EAS
S EAS=$G(EAS)
I $L($G(EAS)) S EAS=$$EASVALIDATE^SDESUTIL(EAS)
I EAS=-1 D ERRLOG^SDESJSON(.SDERR,142)
Q
;
CKNBUILDER(SDCHECKIN,IEN,STATUS,DATETIME,TAG) ;build record
;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
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESCHECKINSTEP 4116 printed Sep 02, 2024@19:40:55 Page 2
SDESCHECKINSTEP ;ALB/LAB - SDES RPC Clone of SDESCKNSTEP ;Jan 28, 2022
+1 ;;5.3;Scheduling;**816**;Aug 13, 1993;Build 3
+2 ;;Per VHA Directive 6402, this routine should not be modified;
+3 QUIT
+4 ;
GETAPPTCKNSTEPS(SDECY,IEN,EAS) ; Get a list of checkin statuses associated with an appointment IEN
+1 NEW SDHASERR,SDCHECKIN
+2 ;
+3 DO VALIDATEAPPTIEN(.SDHASERR,$GET(IEN))
+4 DO VALIDATEAS(.SDHASERR,.EAS)
+5 IF '$DATA(SDHASERR)
DO GETCKNLIST(.SDCHECKIN,IEN,EAS)
+6 IF '$DATA(SDHASERR)
IF '$DATA(SDCHECKIN("ApptCheckInSteps"))
DO ERRLOG^SDESJSON(.SDHASERR,33)
+7 IF $DATA(SDHASERR)
Begin DoDot:1
+8 SET SDCHECKIN("ApptCheckInSteps",1)=""
+9 MERGE SDCHECKIN=SDHASERR
End DoDot:1
+10 DO BUILDJSON(.SDECY,.SDCHECKIN)
+11 QUIT
+12 ;
GETAPPTCKNSTEP(SDECY,IEN,STATUS,EAS) ; Get check-in status associated appointment IEN and passed in status
+1 NEW SDCHECKIN,SIEN,STATPOINTER,STAT,DATETIME,SDHASERR
+2 DO VALIDATEAPPTIEN(.SDHASERR,$GET(IEN))
+3 DO VALIDATEAS(.SDHASERR,.EAS)
+4 DO VALIDATESTATUS(.SDHASERR,$GET(STATUS))
+5 IF '$DATA(SDHASERR)
Begin DoDot:1
+6 DO GETAPPTCHECKIN(.SDCHECKIN,.IEN,STATUS)
+7 ;no status match found, will not pass back status
IF '$DATA(SDCHECKIN("ApptCheckInSteps"))
DO ERRLOG^SDESJSON(.SDHASERR,30)
End DoDot:1
+8 IF $DATA(SDHASERR)
Begin DoDot:1
+9 SET SDCHECKIN("ApptCheckInSteps",1)=""
+10 MERGE SDCHECKIN=SDHASERR
End DoDot:1
+11 DO BUILDJSON(.SDECY,.SDCHECKIN)
+12 QUIT
+13 ;
GETAPPTCHECKIN(SDCHECKIN,IEN,STATUS) ;get appointment check in
+1 NEW SIEN,STATPOINTER,STAT,DATETIME
+2 SET SIEN=0
+3 FOR
SET SIEN=$ORDER(^SDEC(409.84,IEN,3,SIEN))
if 'SIEN
QUIT
Begin DoDot:1
+4 SET STATPOINTER=$$GET1^DIQ(409.843,SIEN_","_IEN_",",.01,"I")
+5 ; no match
IF STATPOINTER'=STATUS
QUIT
+6 SET STAT=$$GET1^DIQ(409.842,STATPOINTER,.01,"E")
+7 SET DATETIME=$$GET1^DIQ(409.843,SIEN_","_IEN_",",1,"I")
+8 SET DATETIME=$$FMTISO^SDAMUTDT(DATETIME)
+9 SET EAS=$$GET1^DIQ(409.84,IEN,100,"E")
+10 DO CKNBUILDER(.SDCHECKIN,STATPOINTER,STAT,DATETIME,"GETAPPTCKNSTEP")
End DoDot:1
+11 QUIT
+12 ;
VALIDATESTATUS(SDERR,STATUS) ;validate the status sent in
+1 IF STATUS=""
DO ERRLOG^SDESJSON(.SDERR,38)
+2 QUIT
+3 ;
BUILDJSON(APPTLISTJSON,APPTLISTARRAY) ;Convert data to JSON
+1 NEW JSONERR
+2 SET JSONERR=""
+3 DO ENCODE^SDESJSON(.APPTLISTARRAY,.APPTLISTJSON,.JSONERR)
+4 QUIT
+5 ;
GETCKNLIST(SDCHECKIN,IEN,EAS) ;get check in step
+1 NEW SIEN,STATPOINTER,STAT,DATETIME,NUM
+2 SET SIEN=0
SET NUM=0
+3 FOR
SET SIEN=$ORDER(^SDEC(409.84,IEN,3,SIEN))
if 'SIEN
QUIT
Begin DoDot:1
+4 SET NUM=NUM+1
+5 SET STATPOINTER=$$GET1^DIQ(409.843,SIEN_","_IEN_",",.01,"I")
+6 SET STAT=$$GET1^DIQ(409.842,STATPOINTER,.01,"E")
+7 SET DATETIME=$$GET1^DIQ(409.843,SIEN_","_IEN_",",1,"I")
+8 if DATETIME'=""
SET DATETIME=$$FMTISO^SDAMUTDT(DATETIME)
+9 SET EAS=$$GET1^DIQ(409.84,IEN,100,"E")
+10 DO CKNBUILDER(.SDCHECKIN,STATPOINTER,STAT,DATETIME,"GETAPPTCKNSTEPS")
End DoDot:1
+11 QUIT
+12 ;
VALIDATEAPPTIEN(SDERR,IEN) ;validate appointment IEN
+1 ; Validate IEN
+2 IF IEN=""
DO ERRLOG^SDESJSON(.SDERR,14)
+3 IF IEN'=""
IF '$DATA(^SDEC(409.84,IEN,0))
DO ERRLOG^SDESJSON(.SDERR,15)
+4 QUIT
VALIDATEAS(SDERR,EAS) ;validate EAS
+1 SET EAS=$GET(EAS)
+2 IF $LENGTH($GET(EAS))
SET EAS=$$EASVALIDATE^SDESUTIL(EAS)
+3 IF EAS=-1
DO ERRLOG^SDESJSON(.SDERR,142)
+4 QUIT
+5 ;
CKNBUILDER(SDCHECKIN,IEN,STATUS,DATETIME,TAG) ;build record
+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 ;