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

SDESGETCANCMT.m

Go to the documentation of this file.
SDESGETCANCMT ;ALB/ANU - VISTA SCHEDULING RPCS ;NOV 22, 2022
 ;;5.3;Scheduling;**831**;Aug 13, 1993;Build 4
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 ;External References
 ;-------------------
 ; Reference to $$GETS^DIQ,$$GETS1^DIQ in ICR #2056
 ;
 Q
 ;
CANCMTGET(JSONRETURN,TYPE) ;return entries from the SDEC CANCELLATION COMMENT file (#409.88)
 ;INPUT:
 ;  TYPE = "NATIONAL" or "LOCAL" [REQUIRED]
 ;RETURN:
 ;  List of canned comment hashtags, type and text equivalent 
 ;
 N ISTYPEVALID,RETURN,ERRORS,HASFIELDS,RETURN,ELGFIELDSARRARY
 ;
 S ISTYPEVALID=$$VALIDATETYPE(.ERRORS,$G(TYPE))
 I $D(ERRORS) M RETURN=ERRORS D BUILDJSON^SDESBUILDJSON(.JSONRETURN,.RETURN) Q
 ;
 I '$D(ERRORS) S HASFIELDS=$$CANCMT(.ELGFIELDSARRAY,$G(TYPE))
 I HASFIELDS M RETURN=ELGFIELDSARRAY
 ;
 D BUILDJSON^SDESBUILDJSON(.JSONRETURN,.RETURN)
 D CLEANUP
 Q
 ;
VALIDATETYPE(ERRORS,TYPE) ;
 I TYPE="" D ERRLOG^SDESJSON(.ERRORS,378) Q 0 ; Missing Type
 I TYPE'="NATIONAL",TYPE'="LOCAL" D ERRLOG^SDESJSON(.ERRORS,379) Q 0 ; Invalid Type
 Q 1
 ;
CANCMT(ELGARRAY,TYPE) ; return entries from the SDEC CANCELLATION COMMENT file (#409.88)
 ;
 N SDIEN,SDESI,SDECTAG,HASDATA
 S SDESI=0,SDECTAG=""
 ;  Scan SDEC CANCELLATION COMMENT file (#409.88) in hash tag (field #.01) order and load in output array.
 F  S SDECTAG=$O(^SDEC(409.88,"B",SDECTAG)) Q:SDECTAG=""  S SDIEN=0 F  S SDIEN=$O(^SDEC(409.88,"B",SDECTAG,SDIEN)) Q:'SDIEN  D  ;
 .I TYPE="NATIONAL" Q:$P(^SDEC(409.88,SDIEN,0),U,3)'=1  ;
 .I TYPE="LOCAL" Q:$P(^SDEC(409.88,SDIEN,0),U,3)=1  ;
 .;
 .S SDESI=SDESI+1
 .S ELGARRAY("CancellationComment",SDESI,"CancellationCommentHashtag")=SDECTAG
 .S ELGARRAY("CancellationComment",SDESI,"Type")=TYPE
 .S ELGARRAY("CancellationComment",SDESI,"CancellationCommentText")=$P(^SDEC(409.88,SDIEN,0),U,2)
 S HASDATA=($D(ELGARRAY)>1)
 Q HASDATA
 ;
CLEANUP ;
 K ISTYPEVALID,ERRORS
 K RETURN,HASFIELDS,ELGFIELDSARRAY,ELGRETURN
 Q
 ;