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

SDESUNDOCHECKOUT.m

Go to the documentation of this file.
SDESUNDOCHECKOUT ;ALB/BLB,CGP - VISTA SCHEDULING RPCS - SDES UNDO CHECKOUT;JAN 25, 2023
 ;;5.3;Scheduling;**831,836**;Aug 13, 1993;Build 20
 ;;Per VHA Directive 6402, this routine should not be modified
 ; Reference to MAS PARAMETERS in ICR #483
 ; Reference to WARD LOCATION in ICR #1377
 ; Reference to MAS PARAMETERS in ICR #2296
 ; Reference to VISIT in ICR #2028
 ;
 Q
 ;
UNDOCHECKOUT(JSONRETURN,APPTIEN) ;
 N ERRORS,RETURN,APPTSUBIEN44,APPTSTARTTIME,DFN,CLINICIEN,RESOURCEIEN,SDATA,SDCIHDL
 ;
 D VALIDATE(.ERRORS,$G(APPTIEN))
 I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSONRETURN,.RETURN) Q
 ;
 S APPTSTARTTIME=$$GET1^DIQ(409.84,APPTIEN,.01,"I")
 S DFN=$$GET1^DIQ(409.84,APPTIEN,.05,"I")
 S RESOURCEIEN=$$GET1^DIQ(409.84,APPTIEN,.07,"I")
 S CLINICIEN=$$GET1^DIQ(409.831,RESOURCEIEN,.04,"I")
 S APPTSUBIEN44=$$FIND^SDESCHECKOUT(DFN,APPTSTARTTIME,CLINICIEN)
 S SDATA=APPTSUBIEN44_U_DFN_U_APPTSTARTTIME_U_CLINICIEN
 S SDCIHDL=$$HANDLE^SDAMEVT(1)
 ;
 D BEFOREEVENT($G(APPTSTARTTIME),$G(DFN),$G(CLINICIEN),$G(APPTSUBIEN44),SDCIHDL,.SDATA)
 ;
 D UNDO($G(APPTIEN),$G(CLINICIEN),$G(APPTSTARTTIME),$G(DFN))
 ;
 D AFTEREVENT($G(APPTSTARTTIME),$G(DFN),$G(CLINICIEN),$G(APPTSUBIEN44),SDCIHDL,.SDATA)
 ;
 S RETURN("UndoCheckOut",1)="Undo Check Out Completed." D BUILDJSON^SDESBUILDJSON(.JSONRETURN,.RETURN)
 ;
 Q
 ;
UNDO(APPTIEN,CLINICIEN,APPTSTARTTIME,DFN) ;
 N FDA84,ERR84,FDA44,ERR44,IENS44,ENCOUNTERIEN,VISITFILEIEN,FDA9000010,ERR9000010,FDA40968,ERR40968
 ;
 S FDA84(409.84,APPTIEN_",",.14)="@"
 S FDA84(409.84,APPTIEN_",",.08)=$G(DUZ)
 D FILE^DIE(,"FDA84","ERR84") K FDA84
 ;
 ;
 S IENS44=$$GET44RECORDIENS^SDESCANCELAPPTS(CLINICIEN,APPTSTARTTIME,DFN)
 I $G(IENS44) D
 .S FDA44(44.003,IENS44,303)="@"
 .S FDA44(44.003,IENS44,304)="@"
 .S FDA44(44.003,IENS44,306)="@"
 .D FILE^DIE(,"FDA44","ERR44") K FDA44
 ;
 ;
 S ENCOUNTERIEN=$$GETAPT^SDVSIT2(DFN,APPTSTARTTIME,CLINICIEN)
 S VISITFILEIEN=$$GET1^DIQ(409.68,ENCOUNTERIEN,.05,"I")
 I $D(^AUPNVSIT($G(VISITFILEIEN),0)) D
 .S FDA9000010(9000010,VISITFILEIEN_",",.18)="@"
 .D FILE^DIE(,"FDA9000010","ERR9000010") K FDA9000010
 ;
 ;
 I $D(^SCE($G(ENCOUNTERIEN),0)),$$GET1^DIQ(409.84,APPTIEN,.19,"I") D
 .S FDA40968(409.68,ENCOUNTERIEN_",",.07)="@"
 .S FDA40968(409.68,ENCOUNTERIEN_",",.12)=$$GET1^DIQ(409.84,APPTIEN,.19,"I")
 .S FDA40968(409.68,ENCOUNTERIEN_",",101)=$G(DUZ)
 .S FDA40968(409.68,ENCOUNTERIEN_",",102)=$$NOW^XLFDT
 .D FILE^DIE(,"FDA40968","ERR40968") K FDA40968
 ;
 Q
 ;
BEFOREEVENT(APPTSTARTTIME,DFN,CLINICIEN,APPTSUBIEN44,SDCIHDL,SDATA) ;
 D BEFORE^SDAMEVT(.SDATA,DFN,APPTSTARTTIME,CLINICIEN,APPTSUBIEN44,SDCIHDL)
 Q
 ;
AFTEREVENT(APPTSTARTTIME,DFN,CLINICIEN,APPTSUBIEN44,SDCIHDL,SDATA) ;
 D AFTER^SDAMEVT(.SDATA,DFN,APPTSTARTTIME,CLINICIEN,APPTSUBIEN44,SDCIHDL)
 D EVT^SDAMEVT(.SDATA,5,2,SDCIHDL) ;
 Q
 ;
VALIDATE(ERRORS,APPTIEN) ;
 D VALIDATEAPPT(.ERRORS,$G(APPTIEN))
 I $D(ERRORS) Q
 ;
 D ISAPPTCHECKEDOUT(.ERRORS,$G(APPTIEN))
 Q
 ;
ISAPPTCHECKEDOUT(ERRORS,APPTIEN) ;
 I '$$GET1^DIQ(409.84,APPTIEN,.14,"I") D ERRLOG^SDESJSON(.ERRORS,377)
 Q
 ;
VALIDATEAPPT(ERRORS,APPTIEN) ;
 I APPTIEN="" D ERRLOG^SDESJSON(.ERRORS,14)
 I APPTIEN'="",'$D(^SDEC(409.84,APPTIEN,0)) D ERRLOG^SDESJSON(.ERRORS,15)
 Q
 ;
VALIDATESUPERVIS(ERRORS) ;
 ;;Jira-4706 Acheron requested removal of requiered SD SUPERVISOR Key -CGP
 ;;I '$$KCHK^XUSRB("SD SUPERVISOR",DUZ) D ERRLOG^SDESJSON(.ERRORS,316)
 Q
 ;
BUILDJSON(JSONRETURN,RETURN) ;.
 N JSONERROR
 D ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERR")
 Q
 ;