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

SDES2NOSHOW.m

Go to the documentation of this file.
SDES2NOSHOW ;ALB/BLB,BLB/JAS - SDES2 NO-SHOW ; Mar 18, 2024@10:30am
 ;;5.3;Scheduling;**871,875**;Aug 13, 1993;Build 25
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 Q
 ;
NOSHOW(JSON,SDCONTEXT,NOSHOW) ;
 N ERRORS,RETURN,DATA,APPTIEN,DFN,PARENTREQUEST,APPTDATETIME,CLINICIEN,EVENT,USERID,REQUESTTYPE,REQUESTIEN,CLINICAPPTIEN,RECALL
 ;
 D VALIDATE(.SDCONTEXT,$G(NOSHOW("APPOINTMENT IEN")))
 I $D(ERRORS) S ERRORS("NoShow",1)="" D BUILDJSON^SDESBUILDJSON(.JSON,.ERRORS) Q
 ;
 D POPULATE(.NOSHOW,.SDCONTEXT,.APPTIEN,.DFN,.APPTDATETIME,.CLINICIEN,.USERID,.REQUESTTYPE,.REQUESTIEN,.CLINICAPPTIEN,,,,.PARENTREQUEST)
 ;
 D EVENTHANDLER1(.DATA,DFN,APPTDATETIME,CLINICIEN,.EVENT,CLINICAPPTIEN)
 ;
 D NOSHOW40984(APPTIEN,USERID)
 D NOSHOW2(APPTDATETIME,DFN,USERID)
 ;
 I REQUESTTYPE="APPT" D NOSHOW40985(REQUESTIEN,PARENTREQUEST)
 I REQUESTTYPE="RECALL" D REOPEN^SDESRECALLREQ(.RECALL,APPTIEN,,,,1)
 I REQUESTTYPE="CONSULT" D NOSHOW^SDCNSLT(CLINICIEN,APPTDATETIME,DFN,REQUESTIEN,CLINICAPPTIEN)
 ;
 ;
 D EVENTHANDLER2(.DATA,DFN,APPTDATETIME,CLINICIEN,.EVENT,CLINICAPPTIEN)
 ;
 S RETURN("NoShow",1)="No-show complete."
 D BUILDJSON^SDESBUILDJSON(.JSON,.RETURN)
 Q
 ;
NOSHOW40984(APPTIEN,USERID) ;
 N FDA,IENS
 ;
 S IENS=APPTIEN_","
 S FDA(409.84,IENS,.1)=1
 S FDA(409.84,IENS,.101)=$$NOW^XLFDT
 S FDA(409.84,IENS,.102)=USERID
 S FDA(409.84,IENS,.17)="N"
 D FILE^DIE(,"FDA") K FDA
 Q
 ;
NOSHOW2(APPTDATETIME,DFN,USERID) ;
 N FDA,IENS
 ;
 S IENS=APPTDATETIME_","_DFN_","
 S FDA(2.98,IENS,3)="N"
 S FDA(2.98,IENS,14)=USERID
 S FDA(2.98,IENS,15)=$$NOW^XLFDT
 D FILE^DIE(,"FDA") K FDA
 Q
 ;
NOSHOW40985(REQUESTIEN,PARENTREQUEST) ;
 N FDA,IENS
 ;
 S IENS=REQUESTIEN_","
 S FDA(409.85,IENS,49)=1
 S FDA(409.85,IENS,19)=""
 S FDA(409.85,IENS,20)=""
 S FDA(409.85,IENS,21)=""
 S FDA(409.85,IENS,23)="O"
 D FILE^DIE(,"FDA") K FDA
 ;
 I $G(PARENTREQUEST),$$GET1^DIQ(409.85,PARENTREQUEST,23,"I")="C" D
 .S FDA(409.85,PARENTREQUEST_",",23)="O"
 .D FILE^DIE(,"FDA","ERROR") K FDA
 Q
 ;
VALIDATE(SDCONTEXT,APPTIEN) ;
 D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
 D VALFILEIEN^SDES2VALUTIL(,.ERRORS,409.84,APPTIEN,1,,14,15)
 I $D(ERRORS) Q
 ;
 I $$GET1^DIQ(409.84,APPTIEN,.1,"I") D ERRLOG^SDESJSON(.ERRORS,367)
 I $$NOW^XLFDT<$$GET1^DIQ(409.84,APPTIEN,.01,"I") D ERRLOG^SDESJSON(.ERRORS,369)
 Q
 ;
GET44APPTIEN(CLINICIEN,APPTDATETIME,DFN) ;
 N FOUND,SUBIEN,RECORDIEN
 S FOUND=0,RECORDIEN=""
 S SUBIEN=0
 F  S SUBIEN=$O(^SC(CLINICIEN,"S",APPTDATETIME,1,SUBIEN)) Q:'SUBIEN!($G(FOUND)=1)  D
 .I $$GET1^DIQ(44.003,SUBIEN_","_APPTDATETIME_","_CLINICIEN_",",310)="CANCELLED" Q
 .I $$GET1^DIQ(44.003,SUBIEN_","_APPTDATETIME_","_CLINICIEN_",",.01,"I")=DFN D
 ..S RECORDIEN=SUBIEN,FOUND=1
 Q RECORDIEN
 ;
EVENTHANDLER1(DATA,DFN,APPTDATETIME,CLINICIEN,EVENT,CLINICAPPTIEN) ;
 S DATA=CLINICAPPTIEN_U_DFN_U_APPTDATETIME_U_CLINICIEN
 S EVENT=$$HANDLE^SDAMEVT(1)
 D BEFORE^SDAMEVT(.DATA,DFN,APPTDATETIME,CLINICIEN,CLINICAPPTIEN,EVENT)
 Q
 ;
EVENTHANDLER2(DATA,DFN,APPTDATETIME,CLINICIEN,EVENT,CLINICAPPTIEN) ;
 D AFTER^SDAMEVT(.DATA,DFN,APPTDATETIME,CLINICIEN,CLINICAPPTIEN,EVENT)
 D EVT^SDAMEVT(.DATA,3,2,EVENT) ;
 I $$GETAPT^SDESCHECKOUT(DFN,APPTDATETIME,CLINICIEN) D
 .D EN^SDCODEL($$GETAPT^SDESCHECKOUT(DFN,APPTDATETIME,CLINICIEN),2,"","NOSHOW")
 Q
 ;
POPULATE(NOSHOW,SDCONTEXT,APPTIEN,DFN,APPTDATETIME,CLINICIEN,USERID,REQUESTTYPE,REQUESTIEN,CLINICAPPTIEN,PROVIDER,NOTE,RESOURCE,PARENTREQUEST) ;
 S APPTIEN=$G(NOSHOW("APPOINTMENT IEN"))
 S DFN=$$GET1^DIQ(409.84,APPTIEN,.05,"I")
 S APPTDATETIME=$$GET1^DIQ(409.84,APPTIEN,.01,"I")
 S CLINICIEN=$$GET1^DIQ(409.831,$$GET1^DIQ(409.84,APPTIEN,.07,"I"),.04,"I")
 S USERID=$S($G(SDCONTEXT("USER DUZ"))'="":SDCONTEXT("USER DUZ"),1:DUZ)
 S REQUESTTYPE=$$GET1^DIQ(409.84,APPTIEN,.22)
 S REQUESTIEN=$P($$GET1^DIQ(409.84,APPTIEN,.22,"I"),";")
 S CLINICAPPTIEN=$$GET44APPTIEN(CLINICIEN,APPTDATETIME,DFN)
 S PROVIDER=$$GET1^DIQ(409.84,APPTIEN,.16,"I")
 S NOTE=$$GET1^DIQ(409.84,APPTIEN,1,"E")
 S RESOURCE=$$GET1^DIQ(409.84,APPTIEN,.07,"I")
 S PARENTREQUEST=$$GET1^DIQ(409.85,REQUESTIEN,43.8,"I")
 Q
 ;