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

HMPPARAM.m

Go to the documentation of this file.
HMPPARAM ;SLC/AGP,ASMR/RRB,CK - Parameter routine;May 15, 2016 14:15
 ;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**1**;May 15, 2016;Build 4
 ;Per VA Directive 6402, this routine should not be modified.
 ;
 ; DE2818 - SQA findings. Newed HMPAR in GETPARAM +1.  RRB - 10/27/2015
 ; External References          DBIA#
 ; -------------------          -----
 ; ^XTV(8989.51                  2992
 ;
 Q
 ;
BLDENT(UID,ENTITY) ;
 ;urn:va:param:F484:1120:HMP USER PREF
 ;urn:va:param:F484:1120:HMP ROSTER PREF:13
 ;urn:va:param:F484:SYS:HMP USER PREF
 S ENTITY("uid")=UID
 I +$P(UID,":",5)>0 D  Q
 .S ENTITY("entity")="USR"
 .S ENTITY("entityId")=$P(UID,":",5)
 S ENTITY("entity")="SYS"
 Q
 ;
BUILDUID(VALUES,TYPE,ID) ;
 N DOMAIN
 S DOMAIN=$$SYS^HMPUTILS
 S VALUES("uid")="urn:va:"_TYPE_":"_DOMAIN_":"_ID
 Q
 ;
DELPARAM(RESULT,UID) ;
 N ARRAY,ENT,ENTITY,ENTVALUE,ERR,STR,HMPERR
 D BLDENT(UID,.ARRAY)
 ;delete old parameter
 S ENTITY=ARRAY("entity")
 S ENTVALUE=ARRAY("entityId")
 S ENT=$S($G(ENTVALUE)>0:ENTITY_".`"_ENTVALUE,1:ENTITY)
 I $G(ARRAY("uid"))="" Q
 I $G(ENT)="" Q
 D DEL^XPAR(ENT,"HMP PARAMETERS",ARRAY("uid"),.HMPERR)
 Q
 ;
GETALPAR(JSONRES,ENTITY,ENTVALUE,RETVALUE) ;
 N CNT,DECODE,ENT,GETVAL,INST,PARAM,RESULT,HMPERR,HMPLIST
 S ENT=$S($G(ENTVALUE)'="":ENTITY_".`"_ENTVALUE,1:ENTITY)
 D GETLST^XPAR(.HMPLIST,ENT,"HMP PARAMETERS","I")
 I HMPLIST=0 Q
 S GETVAL=$S(RETVALUE="true":1,1:0)
 I GETVAL=0 D   Q
 .S CNT=0,INST="" F  S INST=$O(HMPLIST(INST)) Q:INST=""  S JSONRES(CNT)=INST,CNT=CNT+1
 S CNT=0,INST="" F  S INST=$O(HMPLIST(INST)) Q:INST=""  D
 .S CNT=CNT+1
 .S RESULT("params",CNT,"uid")=INST
 .D GETPARAM(.PARAM,"HMP PARAMETERS",ENTITY,ENTVALUE,INST)
 .I '$D(PARAM) Q
 .M RESULT("params",CNT,"value",":")=PARAM
 .K PARAM
 I '$D(RESULT) Q ""
 S RESULT("success")="true"
 D ENCODE^HMPJSON("RESULT","JSONRES","HMPERR")
 I $D(HMPERR) K JSONRES S TXT(1)="Problem encoding results to json format." D SETERROR(.RESULT,.HMPERR,.TXT,.JSONRES) Q
 Q
 ;
GETPARAM(RESULT,NAME,ENTITY,ENTVALUE,INST) ; Get value for a param
 N CNT,ENT,FORMAT,IEN,HMPAR,HMPPAR,HMPERR
 ;S IEN=$O(^XTV(8989.51,"B",NAME,"")) Q:IEN'>0
 S FORMAT="I"
 ;D BLDLST^XPAREDIT(.HMPPAR,IEN
 S ENT=$S($G(ENTVALUE)'="":ENTITY_".`"_ENTVALUE,1:ENTITY)
 D GETWP^XPAR(.HMPAR,ENT,NAME,INST,.HMPERR)
 S CNT=0 F  S CNT=$O(HMPAR(CNT)) Q:CNT'>0  D
 .S RESULT(CNT)=HMPAR(CNT,0)
 Q
 ;
GETBYUID(RESULT,UID) ;
 N ENTITY
 D BLDENT(UID,.ENTITY)
 D GETPARAM(.RESULT,"HMP PARAMETERS",$G(ENTITY("entity")),$G(ENTITY("entityId")),$G(ENTITY("uid")))
 ;I $D(RESULT)<10 S RESULT(0)="{}"
 Q
 ;
PARSEJSN(VALUE,ARRAY,ERR) ;
 N ERROR,JSON,TXT
 D DECODE^HMPJSON("VALUE","ARRAY","ERROR")
 I $D(ERR) K ARRAY S TXT(1)="Problem decoding json value." D SETERROR(.VALUE,.ERROR,.TXT,.ERR) Q 0
 Q 1
 ;
PUTPARAM(RESULT,VALUE,ENTARR) ;
 N CNT,ENT,ENTITY,ENTVALUE,ERR,STR,HMPERR,X
 I $D(ENTARR)<10 I $$PARSEJSN(.VALUE,.ENTARR,.ERR)=0 M RESULT=ERR Q
 ;delete old parameter
 S ENTITY=ENTARR("entity")
 S ENTVALUE=ENTARR("entityId")
 S ENT=$S($G(ENTVALUE)>0:ENTITY_".`"_ENTVALUE,1:ENTITY)
 D DEL^XPAR(ENT,"HMP PARAMETERS",ENTARR("uid"),.HMPERR)
 S CNT=$O(VALUE(""),-1) I CNT="" S STR(1,0)=VALUE
 I CNT>0 F X=0:1:CNT S STR(X+1,0)=VALUE(X)
 D PUT^XPAR(ENT,"HMP PARAMETERS",ENTARR("uid"),.STR,.HMPERR)
 S RESULT(0)="{""success"":""true""}"
 Q
 ;
PUTBYUID(RESULT,UID,VALUE) ;
 N ENTITY
 D BLDENT(UID,.ENTITY)
 D PUTPARAM(.RESULT,.VALUE,.ENTITY)
 Q
 ;
SETERROR(INPDATA,ERRORMSG,TXT,OUTPUT) ;
 N ERRARR
 D SETERROR^HMPUTILS(.ERRARR,.ERRORMSG,.TXT,.INPDATA)
 D ENCODE^HMPJSON("ERRARR","OUTPUT","ERROR")
 Q