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

ECOBL.m

Go to the documentation of this file.
  1. ECOBL ;BP/CMF - List object
  1. ;;2.0;EVENT CAPTURE;**100**;8 May 96;Build 21
  1. ;@author - Chris Flegel
  1. ;@date - 17 May 2009
  1. ;@version - 1.0
  1. ;;
  1. Q
  1. ;;private methods
  1. ADD(RESULT,HANDLE,VALUE) ; add simple list item
  1. N ITEM,X
  1. D PARSE("Handle",HANDLE)
  1. D GET(.ITEM,HANDLE,"Pu","Count")
  1. S ITEM=ITEM+1
  1. S @HANDLE@("Pr","list",ITEM)=VALUE
  1. D METHOD(.X,HANDLE_".Criteria.SetLastItem."_ITEM)
  1. D METHOD(.X,HANDLE_".Criteria.SetLastValue."_VALUE)
  1. D SET(.X,HANDLE,"Pu","Count",ITEM)
  1. D METHOD(.X,HANDLE_".Criteria.Index."_ITEM)
  1. S RESULT=ITEM
  1. Q
  1. ;;
  1. CLEAR(RESULT,HANDLE,PARAMS) ; restore to default state
  1. D METHOD(.RESULT,HANDLE_".Criteria.Clear")
  1. K @HANDLE@("Pr","list")
  1. D SET(.RESULT,HANDLE,"Pu","Count",0)
  1. Q
  1. ;;
  1. COLLECT(RESULT,HANDLE,CHILD) ; add a child object to the list
  1. N ITEM
  1. D PARSE("Handle",HANDLE)
  1. D ADD(.ITEM,HANDLE,CHILD)
  1. S @HANDLE@("Pr","list","Handle",CHILD)=ITEM
  1. S RESULT=ITEM
  1. Q
  1. ;;
  1. FIRST(RESULT,HANDLE,PARAMS) ;
  1. D METHOD(.RESULT,HANDLE_".Criteria.First")
  1. Q
  1. ;;
  1. FIND(RESULT,HANDLE,PARAMS) ;
  1. D METHOD(.RESULT,HANDLE_".Criteria.Find."_PARAMS)
  1. Q
  1. ;;
  1. FIND1(RESULT,HANDLE,PARAMS) ;
  1. D METHOD(.RESULT,HANDLE_".Criteria.Find1."_PARAMS)
  1. Q
  1. ;;
  1. ;;
  1. GET(RESULT,HANDLE,SCOPE,PROPERTY) ;
  1. ; if unique get methods, call them first, else call parent
  1. D GET^ECOB(.RESULT,HANDLE,SCOPE,PROPERTY)
  1. Q
  1. ;;
  1. GETITEM(RESULT,HANDLE,ITEM) ; get simple list item
  1. N NAME,COUNT
  1. D PARSE("Handle",HANDLE)
  1. S RESULT=$G(@HANDLE@("Pr","list",ITEM))
  1. Q
  1. ;;
  1. INFO(RESULT,HANDLE,PARAMS) ;
  1. N NAME,COUNT,ITEMS,I,OUT,JUSTIFY,OFFSET
  1. D PARSE("Offset",PARAMS)
  1. D METHOD(.ITEMS,HANDLE_".ShowCount."_JUSTIFY)
  1. D METHOD(.OUT,HANDLE_".First")
  1. F Q:+OUT=-1 D
  1. .W !,$J(OUT,OFFSET)
  1. .D METHOD(.OUT,HANDLE_".Next")
  1. .Q
  1. Q
  1. ;;
  1. ISHANDLE(HANDLE,VALUE) ; is value a collected handle
  1. Q:(HANDLE="")!(VALUE="") 0
  1. Q $D(@HANDLE@("Pr","list","Handle",VALUE))
  1. ;
  1. LAST(RESULT,HANDLE,PARAMS) ; get the last referenced item from the list
  1. D METHOD(.RESULT,HANDLE_".Criteria.Last")
  1. Q
  1. ;;
  1. NEXT(RESULT,HANDLE,PARAMS) ; get the next item from the list
  1. D METHOD(.RESULT,HANDLE_".Criteria.Next")
  1. Q
  1. ;;
  1. SET(RESULT,HANDLE,SCOPE,PROPERTY,VALUE) ;
  1. ; if unique set methods, call them first, else call parent
  1. D SET^ECOB(.RESULT,HANDLE,SCOPE,PROPERTY,VALUE)
  1. Q
  1. ;;
  1. SETITEM(RESULT,HANDLE,ITEM,VALUE) ; set simple list item
  1. N NAME,COUNT,X
  1. D PARSE("Handle",HANDLE)
  1. I '$D(@HANDLE@("Pr","list",ITEM)) D Q
  1. .S RESULT="-1^Item "_ITEM_" does not exist"
  1. S @HANDLE@("Pr","list",ITEM)=VALUE
  1. D SET(.RESULT,HANDLE,"Pr","last",ITEM)
  1. D METHOD(.X,HANDLE_".Criteria.Index."_ITEM)
  1. Q
  1. ;;
  1. SHOW(RESULT,HANDLE,SCOPE,PROPERTY,JUSTIFY) ; parent method
  1. D SHOW^ECOB(.RESULT,HANDLE,SCOPE,PROPERTY,JUSTIFY)
  1. Q
  1. ;;
  1. PARSE(PARSE,VALUE) ;
  1. I PARSE="Child" D Q
  1. .S CHILD=$P(VALUE,"Handle.",2)
  1. .Q
  1. I PARSE="Count" D Q
  1. .S COUNT=$P(VALUE,".",2)
  1. .Q
  1. I PARSE="Get" D Q
  1. .S PROPERTY=$P(VALUE,".",3)
  1. .S PROPERTY=$P(VALUE,"Get",2)
  1. .Q
  1. I PARSE="Handle" D Q
  1. .S HANDLE=$P(VALUE,".")
  1. .Q
  1. I PARSE="Justify" D Q
  1. .S JUSTIFY=$S(+VALUE:+VALUE,1:0)
  1. .Q
  1. I PARSE="Method" D Q
  1. .S METHOD=$P(VALUE,".",2)
  1. .Q
  1. I PARSE="Offset" D Q
  1. .S JUSTIFY=$S(+VALUE:+VALUE,1:0)
  1. .S OFFSET=JUSTIFY+5
  1. .Q
  1. I PARSE="Params" D Q
  1. .S PARAMS=$P(VALUE,".",3,99)
  1. .Q
  1. I PARSE="Set" D Q
  1. .S PROPERTY=$P(VALUE,".",3)
  1. .S PROPERTY=$P(PROPERTY,"Set",2)
  1. .Q
  1. I PARSE="SetItem" D Q
  1. .S SETITEM=+$P(VALUE,".")
  1. .S SETVALUE=$P(VALUE,".",2)
  1. .Q
  1. I PARSE="SetValue" D Q
  1. .S SETVALUE=$P(VALUE,".",4)
  1. .Q
  1. Q
  1. ;;
  1. PROPERTY(HANDLE,SCOPE,PROPERTY,VALUE) ; parent method
  1. D PROPERTY^ECOB(HANDLE,SCOPE,PROPERTY,VALUE)
  1. Q
  1. ;;
  1. ECOBC(RESULT,HANDLE,PROPERTY,ARGUMENT) ; handler for Criteria
  1. N CHILD
  1. D GET(.CHILD,HANDLE,"Pr",PROPERTY)
  1. D METHOD^ECOBC(.RESULT,CHILD_"."_ARGUMENT)
  1. Q
  1. ;;
  1. ;; public methods
  1. CREATE(NAME) ;
  1. ; call parent first
  1. N HANDLE,CHILD,COUNT,X
  1. S HANDLE=$$CREATE^ECOB(NAME)
  1. D PROPERTY(HANDLE,"Pu","Count",0)
  1. D PROPERTY(HANDLE,"Pr","list",0)
  1. D PROPERTY(HANDLE,"Pr","last","")
  1. D SELF^ECOB(.X,HANDLE,"EC LIST","Basic list","METHOD^ECOBL(.RESULT,ARGUMENT)","ECOB2")
  1. ; complex properties last
  1. S CHILD=$$CREATE^ECOBC(NAME)
  1. D COLLECT^ECOB(HANDLE,CHILD,"Pr","Criteria")
  1. D SET^ECOB(.X,CHILD,"Pr","_collector",HANDLE)
  1. ;
  1. Q HANDLE
  1. ;;
  1. DESTROY(HANDLE) ;
  1. ; call parent last
  1. N CHILD
  1. D GET(.CHILD,HANDLE,"Pr","Criteria")
  1. D DESTROY^ECOBC(CHILD)
  1. Q $$DESTROY^ECOB2(HANDLE)
  1. ;;
  1. METHOD(RESULT,ARGUMENT) ;
  1. ; argument= handle.method.(additional.params...)
  1. N HANDLE,METHOD,PARAMS
  1. D PARSE("Handle",ARGUMENT)
  1. D PARSE("Method",ARGUMENT)
  1. D PARSE("Params",ARGUMENT)
  1. I METHOD="Add" D ADD(.RESULT,HANDLE,PARAMS) Q
  1. I METHOD="Clear" D CLEAR(.RESULT,HANDLE,PARAMS) Q
  1. I METHOD="Criteria" D ECOBC(.RESULT,HANDLE,METHOD,PARAMS) Q
  1. I METHOD="Collect" D COLLECT(.RESULT,HANDLE,PARAMS) Q
  1. I METHOD="Find" D FIND(.RESULT,HANDLE,PARAMS) Q
  1. I METHOD="Find1" D FIND1(.RESULT,HANDLE,PARAMS) Q
  1. I METHOD="First" D FIRST(.RESULT,HANDLE,PARAMS) Q
  1. I METHOD="GetItem" D GETITEM(.RESULT,HANDLE,PARAMS) Q
  1. I METHOD="Info" D INFO(.RESULT,HANDLE,PARAMS) Q
  1. I METHOD="IsHandle" S RESULT=$$ISHANDLE(HANDLE,PARAMS) Q
  1. I METHOD="Last" D LAST(.RESULT,HANDLE,PARAMS) Q
  1. I METHOD="Next" D NEXT(.RESULT,HANDLE,PARAMS) Q
  1. ; development methods last
  1. I METHOD="SetItem" D Q
  1. .N SETITEM,SETVALUE
  1. .D PARSE("SetItem",PARAMS)
  1. .D SETITEM(.RESULT,HANDLE,SETITEM,SETVALUE)
  1. .Q
  1. D METHOD^ECOB2(.RESULT,ARGUMENT)
  1. Q
  1. ;;