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

SDES2UNDOCHKOUT.m

Go to the documentation of this file.
SDES2UNDOCHKOUT ;ALB/ANU/TJB - VISTA SCHEDULING RPCS - SDES2 UNDO CHECKOUT ;APR 08, 2024
 ;;5.3;Scheduling;**877**;Aug 13, 1993;Build 14
 ;;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
 ; INPUT
 ;
 ; SDCONTEXT("ACHERON AUDIT ID") = Up to 40 Character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
 ; SDCONTEXT("USER DUZ") = The DUZ of the user taking action in the calling application.
 ; SDCONTEXT("USER SECID") = The SECID of the user taking action in the calling application.
 ; SDCONTEXT("PATIENT DFN") = The DFN/IEN of the target patient from the calling application.
 ; SDCONTEXT("PATIENT ICN") = The ICN of the target patient from the calling application.
 ; SDINPUT("APPOINTMENT IEN") = (Required) Appointment IEN
 ;
UNDOCHECKOUT(JSONRETURN,SDCONTEXT,SDINPUT) ;
 N ERRORS,SDRETURN,PARAMETERS,SDDUZ
 D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
 I $D(ERRORS) S ERRORS("UndoCheckOut",1)="" D BUILDJSON^SDES2JSON(.JSONRETURN,.ERRORS) Q
 S PARAMETERS=$$VALPARAMS(.SDINPUT,.ERRORS)
 I $D(ERRORS) S ERRORS("UndoCheckOut",1)="" D BUILDJSON^SDES2JSON(.JSONRETURN,.ERRORS) Q
 ;
 S SDDUZ=$S(+$G(SDCONTEXT("USER DUZ")):+SDCONTEXT("USER DUZ"),1:$G(DUZ))
 D UNDOCKOUT(.SDRETURN,PARAMETERS,SDDUZ)
 I '$D(SDRETURN) S SDRETURN("UndoCheckOut",1)=""
 D BUILDJSON^SDES2JSON(.JSONRETURN,.SDRETURN)
 Q
 ;
VALPARAMS(PARAMS,SDERRORS) ; Validate
 N SDIEN,SDCHECKDT
 ;
 ; Validate Appointment IEN
 S SDIEN=$G(PARAMS("APPOINTMENT IEN"))
 I '$G(SDIEN) D ERRLOG^SDES2JSON(.SDERRORS,14) Q 0
 I '$D(^SDEC(409.84,SDIEN,0)) D ERRLOG^SDES2JSON(.SDERRORS,15) Q 0 ;invalid appt IEN
 S SDCHECKDT=$$GET1^DIQ(409.84,SDIEN,.14,"I")
 I 'SDCHECKDT D ERRLOG^SDES2JSON(.SDERRORS,377) Q 0
 I $$FMDIFF^XLFDT(DT,SDCHECKDT,1)'=0 D ERRLOG^SDES2JSON(.SDERRORS,47,"Undo Checkout must be performed same calendar day as checkout") Q 0
 ;
 Q:$D(SDERRORS) 0
 Q SDIEN
 ;
UNDOCKOUT(SDRETURN,APPTIEN,SDDUZ) ;
 N ERRORS,APPTSUBIEN44,APPTSTARTTIME,DFN,CLINICIEN,RESOURCEIEN,SDATA,SDCIHDL
 ;
 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),SDDUZ)
 D AFTEREVENT($G(APPTSTARTTIME),$G(DFN),$G(CLINICIEN),$G(APPTSUBIEN44),SDCIHDL,.SDATA)
 ;
 S SDRETURN("UndoCheckOut","UndoCheckOutCompleted")=1
 Q
 ;
UNDO(APPTIEN,CLINICIEN,APPTSTARTTIME,DFN,SDDUZ) ;
 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(SDDUZ)
 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(SDDUZ)
 .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
 ;