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

IBDFRPC2.m

Go to the documentation of this file.
  1. IBDFRPC2 ;ALB/AAS - Return list of selections, broker call ;29-JAN-96
  1. ;;3.0;AUTOMATED INFO COLLECTION SYS;**34,38**;APR 24, 1997
  1. ;
  1. SEL(RESULT,IBDF) ; -- Procedure
  1. ; -- called by ibdfrpc1, returns list for one selection list
  1. ; see ibdfrpc1 for complete input/output lists
  1. ; -- Input IBDF("IEN") := pointer to selection list (357.2)
  1. ; IBDF("PI") := pointer to package interface (357.6) (optional)
  1. ; IBDF("DFN") := pointer to patient (2) (optional)
  1. ; IBDF("CLINIC") := pointer to clinic (44) (optional)
  1. ;
  1. N OTEXT,TEXT,SC,TERM,COUNT,DCODE,SECOND,THIRD
  1. I $E($G(RESULT),1)="^" S ARRY=RESULT
  1. E S ARRY="RESULT"
  1. S COUNT=+$G(@ARRY@(0))
  1. ;
  1. S @ARRY@(0)="List not found"
  1. G:'$G(IBDF("IEN")) SELQ
  1. G:$G(^IBE(357.2,IBDF("IEN"),0))="" SELQ
  1. ;K ^TMP("IBD-DUP",$J)
  1. ;
  1. ; -- copy list
  1. I '$G(IBDF("RULE-ONLY")) D COPYLIST(.RESULT,IBDF("IEN"),.COUNT)
  1. ;I COUNT D URH
  1. ;
  1. S @ARRY@(0)=COUNT_"^LIST^"
  1. D GETQLF
  1. SELQ Q
  1. ;
  1. GETQLF ; -- add selection rule and qualifiers from marking area
  1. ; subcolumns to results(0) node, but only for bubbles
  1. N SC,NODE,BUBB,BUBBCNT
  1. S SC=0,BUBBCNT=0,BUBB=$O(^IBE(357.91,"B","BUBBLE (use for scanning)",0)) Q:'BUBB
  1. F S SC=$O(^IBE(357.2,IBDF("IEN"),2,SC)) Q:'SC D
  1. .S NODE=$G(^IBE(357.2,IBDF("IEN"),2,SC,0))
  1. .I $P(NODE,"^",4)=2,$P(NODE,"^",6)=BUBB S BUBBCNT=BUBBCNT+1,@ARRY@(0)=@ARRY@(0)_$P($G(^IBD(357.98,+$P(NODE,"^",9),0)),"^")_";;"_+$P(NODE,"^",10)_"::"
  1. ;
  1. ; -- if no bubbles then kill off array, leave zero node for reports
  1. I BUBBCNT<1 S SC=@ARRY@(0) K @ARRY S @ARRY@(0)="0^"_$P(SC,"^",2,3) S $P(@ARRY@(0),"^",4)=1
  1. Q
  1. ;
  1. COPYLIST(RESULT,LIST,COUNT) ;copies the entries from LIST to @ARY, starting subscript at COUNT+1
  1. ;
  1. N SLCTN,SUBCOL,TEXT,IEN,NODE,TSUBCOL,NOTREAL,GROUP,ORDER,HDR,CSUBCOL,DCODE,QUANTITY,SECOND,THIRD
  1. ;
  1. I $E($G(RESULT),1)="^" S ARRY=RESULT
  1. E S ARRY="RESULT"
  1. ;
  1. S SUBCOL=$$SUBCOL(LIST),TSUBCOL=+SUBCOL,CSUBCOL=+$P(SUBCOL,"^",2)
  1. ;
  1. S PRNT=""
  1. F S PRNT=$O(^IBE(357.4,"APO",LIST,PRNT)) Q:PRNT="" D
  1. . S GROUP=""
  1. . F S GROUP=$O(^IBE(357.4,"APO",LIST,PRNT,GROUP)) Q:GROUP="" D
  1. .. S HDR=$P($G(^IBE(357.4,GROUP,0)),"^")
  1. .. I $P($G(^IBE(357.4,GROUP,0)),"^",4)="I" S HDR=" "
  1. .. I HDR="BLANK" S HDR=" "
  1. .. S COUNT=COUNT+1,@ARRY@(COUNT)=HDR_"^^^^^^0"
  1. .. S ORDER=""
  1. .. F S ORDER=$O(^IBE(357.3,"APO",LIST,GROUP,ORDER)) Q:ORDER="" D
  1. ... S SLCTN=0
  1. ... F S SLCTN=$O(^IBE(357.3,"APO",LIST,GROUP,ORDER,SLCTN)) Q:'SLCTN D
  1. .... S (TEXT,DCODE,OTEXT,TERM,NOTREAL,IEN,SECOND,THIRD)=""
  1. .... S NODE=$G(^IBE(357.3,SLCTN,0)),IEN=$P(NODE,"^")
  1. .... S QUANTITY=$P(NODE,"^",9)
  1. .... ;
  1. .... ; -- handle place holder as headers
  1. .... S NOTREAL=$P(NODE,"^",2)
  1. .... I NOTREAL,$P(NODE,"^",6)'="" D Q
  1. ..... I $P(NODE,"^",7) S COUNT=COUNT+1,HDR=$P(NODE,"^",6),@ARRY@(COUNT)=HDR_"^^^^^^0" Q
  1. ..... I $P(NODE,"^",8) S COUNT=COUNT+1,HDR=" ",@ARRY@(COUNT)=HDR_"^^^^^^0" Q
  1. .....;
  1. .... ; -- find text for entry
  1. .... S SUBCOL=$O(^IBE(357.3,SLCTN,1,"B",+TSUBCOL,0))
  1. .... S NODE=$G(^IBE(357.3,+SLCTN,1,+SUBCOL,0))
  1. .... S:$P(NODE,"^")=TSUBCOL TEXT=$P(NODE,"^",2)
  1. .... ;
  1. .... ; -- find display code for entry
  1. .... S SUBCOL=$O(^IBE(357.3,+SLCTN,1,"B",+CSUBCOL,0))
  1. .... S NODE=$G(^IBE(357.3,+SLCTN,1,+SUBCOL,0))
  1. .... S:$P(NODE,"^")=CSUBCOL DCODE=$P(NODE,"^",2)
  1. .... ;
  1. .... ; -- find optional caption and lexicon pointer
  1. .... S NODE=$G(^IBE(357.3,SLCTN,2))
  1. .... S OTEXT=$P(NODE,"^"),TERM=$P(NODE,"^",2)
  1. .... ;
  1. .... ; -- find optional second and third codes
  1. .... S SECOND=$P(NODE,"^",3),THIRD=$P(NODE,"^",4)
  1. .... ;
  1. .... ; -- add to array. Is dup ien or ien+text???
  1. .... I $L(TEXT) S COUNT=COUNT+1 D BLDA Q
  1. .... ;I $L(TEXT),'$D(IBDUP(IEN_"^"_TEXT)) S COUNT=COUNT+1,IBDUP(IEN_"^"_TEXT)="" D BLDA Q ;this line checks ien+text for duplicates
  1. ;
  1. K ^TMP("IBD-DUP",$J)
  1. Q
  1. ;
  1. SUBCOL(LIST) ; -- function
  1. ; -- returns the subcolumn containing the text
  1. ; input LIST := selection list internal entry
  1. ; -- Assumes data returned by the package interface, piece 2 is the description
  1. ;
  1. N SC,TSUBCOL,CSUBCOL
  1. S (TSUBCOL,CSUBCOL)=""
  1. S SC=0
  1. F S SC=$O(^IBE(357.2,LIST,2,SC)) Q:'SC D
  1. .Q:$P($G(^IBE(357.2,LIST,2,SC,0)),"^",4)=2 ;is a marking area
  1. .I $P($G(^IBE(357.2,LIST,2,SC,0)),"^",5)=2 S TSUBCOL=$P(^(0),"^") Q ;data piece 2 is usually text subcol
  1. .I $P($G(^IBE(357.2,LIST,2,SC,0)),"^",5)=1 S CSUBCOL=$P(^(0),"^") Q ; data piece 1 is always code
  1. .I TSUBCOL="",$P($G(^IBE(357.2,LIST,2,SC,0)),"^",5)>2 S TSUBCOL=$P(^(0),"^") Q ; -- see if other than data piece two is text subcolumn
  1. .I CSUBCOL="",$P($G(^IBE(357.2,LIST,2,SC,0)),"^",5)>2 S CSUBCOL=$P(^(0),"^") Q
  1. Q TSUBCOL_"^"_CSUBCOL
  1. ;
  1. BLDA ; -- build results array
  1. S @ARRY@(COUNT)=TEXT ;B ;;
  1. S $P(@ARRY@(COUNT),"^",2)=$G(DCODE)
  1. S $P(@ARRY@(COUNT),"^",3)=$S($G(NOTREAL):"",1:$G(IEN))
  1. S $P(@ARRY@(COUNT),"^",4)=""
  1. S $P(@ARRY@(COUNT),"^",5)=$G(OTEXT)
  1. S $P(@ARRY@(COUNT),"^",6)=$G(TERM)
  1. S $P(@ARRY@(COUNT),"^",7)=$S($G(NOTREAL):0,1:1)
  1. S $P(@ARRY@(COUNT),"^",9)=$G(QUANTITY)
  1. S $P(@ARRY@(COUNT),"^",10)=$G(SECOND)
  1. S $P(@ARRY@(COUNT),"^",11)=$G(THIRD)
  1. ;--added for slctn to be passed also
  1. S $P(@ARRY@(COUNT),"^",12)=$G(SLCTN)
  1. Q
  1. ;
  1. URH ; -- UnReferenced Headers removal
  1. ; if a header doesn't have any data under it, then remove the header
  1. N X,HDR
  1. S X=0 F S X=$O(@ARRY@(X)) Q:'X D
  1. .I '$D(HDR),$P(@ARRY@(X),"^",1)="" S HDR=X Q ;find a header
  1. .I $P(@ARRY@(X),"^",1)="" K HDR Q ; is item under header
  1. .I $D(HDR),$P(@ARRY@(X),"^",1)="" K @ARRY@(HDR) S COUNT=COUNT-1,HDR=X ;hdr doesn't have any items, kill hdr node and reset header to next header
  1. I $D(HDR) S X=$O(@ARRY@(""),-1) I $P(@ARRY@(X),"^",1)="" K @ARRY@(X) S COUNT=COUNT-1,HDR=X ;last item in list is a header
  1. Q
  1. ;
  1. DYN(RESULT,IBDF) ; -- Procedure
  1. ; -- called by ibdfrpc1 to return selection list for dynamic selections
  1. ; see ibdfrpc1 for complete input/output lists
  1. ; -- Input IBDF("PI") := pointer to package interface (357.6)
  1. ; IBDF("IEN") := pointer to selection list (357.2)
  1. ; IBDF("DFN") := pointer to patient (2) (optional for provider selections)
  1. ; IBDF("CLINIC") := pointer to clinic (44) (optional for active problem selections)
  1. ;
  1. N PI,DFN,CNT,COUNT,NAME,RTN,IBARY,IBCLINIC
  1. I $E($G(RESULT),1)="^" S ARRY=RESULT
  1. E S ARRY="RESULT"
  1. S COUNT=+$G(@ARRY@(0))
  1. I '$G(IBDF("DFN")) S @ARRY@(0)="-1^Patient not defined" G DYNQ
  1. I $G(^DPT(+IBDF("DFN"),0))="" S @ARRY@(0)="-1^Patient not Found" G DYNQ
  1. S DFN=+$G(IBDF("DFN"))
  1. I $G(IBDF("RULE-ONLY")) G RULE
  1. ;
  1. S @ARRY@(0)="List not found"
  1. G:'$G(IBDF("IEN")) SELQ
  1. G:$G(^IBE(357.2,IBDF("IEN"),0))="" DYNQ
  1. ;
  1. S @ARRY@(0)="-1^Package Interface Not found"
  1. S PI=$G(^IBE(357.6,+$G(IBDF("PI")),0)) I PI="" G DYNQ
  1. ;
  1. S IBCLINIC=$G(IBDF("CLINIC"))
  1. I +IBCLINIC'=IBCLINIC,IBCLINIC'="" S IBCLINIC=$O(^SC("B",IBCLINIC,0))
  1. I +IBCLINIC=0 S @ARRY@(0)="Clinic Not Specified"
  1. ;
  1. S NAME=$P(PI,"^"),RTN=$P(PI,"^",2,3) I RTN=""!(RTN="^") G DYNQ
  1. I NAME["ACTIVE PROBLEM" S NAME="GMP SELECT PATIENT ACTIVE PROBLEMS"
  1. S IBARY="^TMP(""IB"",$J,""INTERFACES"","""_NAME_""")"
  1. D @RTN
  1. ;
  1. S @ARRY@(0)=+$G(@IBARY@(0))_"^LIST^"
  1. RULE I $G(IBDF("RULE-ONLY")) S @ARRY@(0)="1^DYNLIST^"
  1. ;G DYNQ:@ARRY@(0)<1
  1. D GETQLF
  1. G:$G(IBDF("RULE-ONLY")) DYNQ
  1. ;
  1. S CNT=0 F S CNT=$O(@IBARY@(CNT)) Q:'CNT D
  1. .Q:$G(@IBARY@(CNT))=""
  1. .;
  1. .; -- Process provider lists
  1. .I NAME["PROVIDER" D Q
  1. ..I IBCLINIC<1 Q
  1. ..S @ARRY@(CNT)=$P(@IBARY@(CNT),"^",2)_"^^"_$P(@IBARY@(CNT),"^",1)_"^^^^1" Q
  1. .;
  1. .; -- process patient active problem lists
  1. .I NAME["ACTIVE PROBLEMS" D Q
  1. ..S @ARRY@(CNT)=$P(@IBARY@(CNT),"^",2)_"^"_$P(@IBARY@(CNT),"^",3)_"^"_+@IBARY@(CNT)_"^^^^1"
  1. .I '$D(@ARRY@(CNT)) S @ARRY@(CNT)=@IBARY@(CNT)
  1. ;
  1. DYNQ Q
  1. ;
  1. ; -- here are some sample tests for different lists
  1. TEST K VAR,IBDF
  1. S IBDF("IEN")=489
  1. D SEL(.VAR,.IBDF)
  1. X "ZW VAR"
  1. Q
  1. ;
  1. TEST1 K VAR,IBDF
  1. S IBDF("IEN")=488
  1. D SEL(.VAR,.IBDF)
  1. X "ZW VAR"
  1. Q
  1. ;
  1. TESTD ; -- Test dynamic
  1. K VAR,IBDF
  1. ;S IBDF("PI")=71,IBDF("IEN")=103 ;provider, 1577 FEX
  1. ;S IBDF("PI")=73 ;patient active problems
  1. ;S IBDF("CLINIC")=300
  1. S IBDF("PI")=7,IBDF("IEN")=14 ;provider, 1577 FEX
  1. ;S IBDF("PI")=73 ;patient active problems
  1. S IBDF("DFN")=7169761
  1. S IBDF("CLINIC")=88
  1. D DYN(.VAR,.IBDF)
  1. X "ZW VAR"