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

SDESCHECKINSTEP.m

Go to the documentation of this file.
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
 ;