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
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESGETCANCMT 1970 printed Nov 22, 2024@18:06:41 Page 2
SDESGETCANCMT ;ALB/ANU - VISTA SCHEDULING RPCS ;NOV 22, 2022
+1 ;;5.3;Scheduling;**831**;Aug 13, 1993;Build 4
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ;External References
+5 ;-------------------
+6 ; Reference to $$GETS^DIQ,$$GETS1^DIQ in ICR #2056
+7 ;
+8 QUIT
+9 ;
CANCMTGET(JSONRETURN,TYPE) ;return entries from the SDEC CANCELLATION COMMENT file (#409.88)
+1 ;INPUT:
+2 ; TYPE = "NATIONAL" or "LOCAL" [REQUIRED]
+3 ;RETURN:
+4 ; List of canned comment hashtags, type and text equivalent
+5 ;
+6 NEW ISTYPEVALID,RETURN,ERRORS,HASFIELDS,RETURN,ELGFIELDSARRARY
+7 ;
+8 SET ISTYPEVALID=$$VALIDATETYPE(.ERRORS,$GET(TYPE))
+9 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
DO BUILDJSON^SDESBUILDJSON(.JSONRETURN,.RETURN)
QUIT
+10 ;
+11 IF '$DATA(ERRORS)
SET HASFIELDS=$$CANCMT(.ELGFIELDSARRAY,$GET(TYPE))
+12 IF HASFIELDS
MERGE RETURN=ELGFIELDSARRAY
+13 ;
+14 DO BUILDJSON^SDESBUILDJSON(.JSONRETURN,.RETURN)
+15 DO CLEANUP
+16 QUIT
+17 ;
VALIDATETYPE(ERRORS,TYPE) ;
+1 ; Missing Type
IF TYPE=""
DO ERRLOG^SDESJSON(.ERRORS,378)
QUIT 0
+2 ; Invalid Type
IF TYPE'="NATIONAL"
IF TYPE'="LOCAL"
DO ERRLOG^SDESJSON(.ERRORS,379)
QUIT 0
+3 QUIT 1
+4 ;
CANCMT(ELGARRAY,TYPE) ; return entries from the SDEC CANCELLATION COMMENT file (#409.88)
+1 ;
+2 NEW SDIEN,SDESI,SDECTAG,HASDATA
+3 SET SDESI=0
SET SDECTAG=""
+4 ; Scan SDEC CANCELLATION COMMENT file (#409.88) in hash tag (field #.01) order and load in output array.
+5 ;
FOR
SET SDECTAG=$ORDER(^SDEC(409.88,"B",SDECTAG))
if SDECTAG=""
QUIT
SET SDIEN=0
FOR
SET SDIEN=$ORDER(^SDEC(409.88,"B",SDECTAG,SDIEN))
if 'SDIEN
QUIT
Begin DoDot:1
+6 ;
IF TYPE="NATIONAL"
if $PIECE(^SDEC(409.88,SDIEN,0),U,3)'=1
QUIT
+7 ;
IF TYPE="LOCAL"
if $PIECE(^SDEC(409.88,SDIEN,0),U,3)=1
QUIT
+8 ;
+9 SET SDESI=SDESI+1
+10 SET ELGARRAY("CancellationComment",SDESI,"CancellationCommentHashtag")=SDECTAG
+11 SET ELGARRAY("CancellationComment",SDESI,"Type")=TYPE
+12 SET ELGARRAY("CancellationComment",SDESI,"CancellationCommentText")=$PIECE(^SDEC(409.88,SDIEN,0),U,2)
End DoDot:1
+13 SET HASDATA=($DATA(ELGARRAY)>1)
+14 QUIT HASDATA
+15 ;
CLEANUP ;
+1 KILL ISTYPEVALID,ERRORS
+2 KILL RETURN,HASFIELDS,ELGFIELDSARRAY,ELGRETURN
+3 QUIT
+4 ;