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

SDES2JSON.m

Go to the documentation of this file.
  1. SDES2JSON ;ALB/MGD - VISTA SCHEDULING JSON UTILITIES ;July 3, 2023
  1. ;;5.3;Scheduling;**853**;Aug 13, 1993;Build 9;Build 2
  1. ;;Per VHA Directive 6402, this routine should not be modified
  1. Q
  1. ; This routine documents the entry points for the new ??? GUI.
  1. ;
  1. BUILDJSON(SDRETURN,RETURN) ;
  1. N JSONERROR
  1. D ENCODE^XLFJSON("RETURN","SDRETURN","SDJSONERR")
  1. Q
  1. ;
  1. ENCODE(SDESINP,SDESOUT,SDESERR) ;
  1. ; Input: SDESINP = Required: Properly formatted input array to convert to JSON
  1. ; SDESOUT = Required: Name of string to return to Broker
  1. ; SDESERR = Optional: Name of string for error messages.
  1. ; Output:
  1. ; SDESOUT = JSON formatted string
  1. ; SDESERR = Still under development by Kernel
  1. ;
  1. ; Validate Input Parameters
  1. I '$D(SDESINP) D ERRLOG(.SDESINP,52,"Input Data Required.")
  1. D ENCODE^XLFJSON("SDESINP","SDESOUT","SDESERR")
  1. Q
  1. ;
  1. ; Error codes are located in the SDES ERROR CODES file #409.93
  1. ; Please do not duplicate error text. Use due diligence and look for
  1. ; the appropriate error prior to adding new entries.
  1. ;
  1. ERRLOG(SDESIN,SDESERRNUM,SDESOPTMSG,SDESRINFO) ;
  1. ; Input: SDESIN = Required: Array name with related data to be logged
  1. ; SDESERRNUM = Required: Error # to return
  1. ; SDESOPTMSG = Optional message string to append to existing error in table
  1. ; SDESRINFO = Optional message string with Routine^Tag info to append to existing error in table
  1. N SDESCNT
  1. S SDESOPTMSG=$G(SDESOPTMSG),SDESRINFO=$G(SDESRINFO)
  1. I '$D(SDESIN) S SDESIN("Error",0)=""
  1. S SDESERRNUM=$G(SDESERRNUM,0)
  1. S SDESCNT=$O(SDESIN("Error",""),-1)+1
  1. S SDESIN("Error",SDESCNT)=$$ERRLKUP(SDESERRNUM,SDESOPTMSG,SDESRINFO)
  1. K SDESIN("Error",0)
  1. Q
  1. ;
  1. ERRLKUP(SDNUM,SDESOPTMSG,SDESRINFO) ;
  1. N SDERRMSG,SDERRIEN
  1. S SDERRIEN=$O(^SDEC(409.93,"B",SDNUM,0))
  1. S SDERRMSG=$$GET1^DIQ(409.93,SDERRIEN,1,"E")
  1. I SDERRMSG="" S SDERRMSG="Invalid Error Number."
  1. I $G(SDESOPTMSG)'="" D
  1. . ;Strip off $C(30) and $c(31) that are part of non JSON error text
  1. . S SDESOPTMSG=$$CTRL^XMXUTIL1(SDESOPTMSG)
  1. . I $E(SDERRMSG,$L(SDERRMSG))="." S SDERRMSG=$E(SDERRMSG,1,$L(SDERRMSG)-1)
  1. . S SDERRMSG=SDERRMSG_": "_SDESOPTMSG
  1. I $E(SDERRMSG,$L(SDERRMSG))'="." S SDERRMSG=SDERRMSG_"."
  1. ; Add optional Debug info
  1. I SDESRINFO'="" S SDERRMSG=SDERRMSG_" Debug: "_SDESRINFO
  1. Q SDERRMSG