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

SDESCANCELRSNS.m

Go to the documentation of this file.
SDESCANCELRSNS ;ALB/JAS,LAB - SDES GET CANCEL REASONS RPC ;Dec 6, 2023
 ;;5.3;Scheduling;**836,845,867**;Aug 13, 1993;Build 8
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
GETCANCELRSNS(CANCELRSNSRET,REASONSTAT) ; GET CANCEL REASONS from file 409.2
 ; INPUT:  REASONSTAT - (optional) Flag: show inactive  0=active only (default); 1=show active and inactive
 ;
 N CANCREASONNAME,CANCREASONREC,CANCREASONTYP,HASFIELDS,RETURN,RETCOUNT
 S (CANCREASONNAME,CANCREASONREC,CANCREASONTYP,HASFIELDS,RETURN)="",RETCOUNT=1
 ;
 ; Check input parameter flag
 ;
 S:($G(REASONSTAT)="") REASONSTAT=0  ;default to active only if no input value
 I "01"'[$G(REASONSTAT) D
 . D ERRLOG^SDESJSON(.SDESERR,267) M RETURN=SDESERR  ;invalid parameter flag value
 ;
 ; Loop through file 409.2's "NAME" x-ref
 ;
 I '$D(RETURN("Error")) D
 . F  S CANCREASONNAME=$O(^SD(409.2,"B",CANCREASONNAME)) Q:CANCREASONNAME=""  D
 . . S CANCREASONREC=$O(^SD(409.2,"B",CANCREASONNAME,""))
 . . S HASFIELDS=$$GETREASONFIELDS(.RSNFIELDSARRAY,CANCREASONREC,REASONSTAT,RETCOUNT)
 . . I HASFIELDS M RETURN=RSNFIELDSARRAY S RETCOUNT=RETCOUNT+1
 ;
 D BUILDJSON^SDESBUILDJSON(.CANCELRSNSRET,.RETURN)
 D CLEANUP
 Q
 ;
GETREASONFIELDS(CANCELREASON,CANCREASONIEN,REASONSTAT,RETCOUNT) ; GET CANCEL REASON FIELDS
 ;
 N DIQERROR,FILENUMBER,FIELDNUMBERS,HASDATA,RSNIENSTRING,REASONFIELDS
 S DIQERROR=""
 S FILENUMBER=409.2
 S FIELDNUMBERS=".01;2;4;5;6"
 S RSNIENSTRING=CANCREASONIEN_","
 ;
 D GETS^DIQ(FILENUMBER,CANCREASONIEN,FIELDNUMBERS,"IE","REASONFIELDS","DIQERROR")
 ;
 I DIQERROR S CANCELREASON("Error",1)=DIQERROR
 I 'DIQERROR D
 .I 'REASONSTAT,$G(REASONFIELDS(FILENUMBER,RSNIENSTRING,4,"I")) Q
 .S CANCELREASON("CancelReasons",RETCOUNT,"ReasonIEN")=CANCREASONIEN
 .S CANCELREASON("CancelReasons",RETCOUNT,"ReasonName")=$G(REASONFIELDS(FILENUMBER,RSNIENSTRING,.01,"E"))
 .S CANCELREASON("CancelReasons",RETCOUNT,"ReasonType")=$G(REASONFIELDS(FILENUMBER,RSNIENSTRING,2,"E"))
 .S CANCELREASON("CancelReasons",RETCOUNT,"ReasonSystemUse")=$G(REASONFIELDS(FILENUMBER,RSNIENSTRING,6,"E"))
 .S CANCELREASON("CancelReasons",RETCOUNT,"ReopenRequestUponCancel")=$G(REASONFIELDS(FILENUMBER,RSNIENSTRING,5,"E"))
 S HASDATA=$D(CANCELREASON)>1
 Q HASDATA
 ;
CLEANUP ; Cleanup variables arrays to prevent leaking
 ;
 K DIQERROR,ERRORFLAG,FIELDNUMBERS,FILENUMBER,HASDATA,HASFIELDS
 K REASONFIELDS,RETCOUNT,RETURN,RSNFIELDSARRAY,RSNIENSTRING,SDESERR
 Q