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

SDESCKNSTEP.m

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