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

AMQQMUL2.m

Go to the documentation of this file.
AMQQMUL2 ; IHS/CMI/THL - COLLECTS MULTIPLE VALUES FOR VISITS ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;-----
VAR F I=1:1:19 D
 .S X=$P("GR;ID;ST;FIN;LAST;VAL1;VAL2;UATN;MLT;T;NVAR;FVAR;ITR;NNA;STRT;MSS;MPC;MULZ;USQN",";",I)
 .S @("AMQQ"_X)=$P(AMQQX,";",I)
 S AMQQ=U_AMQQGR_"(""AA"","_AMQP(0)_")"
 S AMQQSPEC=""
 I '$D(AMQQAG) S AMQQAG="AG"
 I '$D(@AMQQ) S AMQT(AMQQT)=0 G NULL
 S AMQQMSS=+AMQQMSS
 S AMQQMPC=AMQQMPC+'AMQQMPC
 S AMQQHOLD=0
 S AMQT(AMQQT)=0
 S AMQQLCNT=0
 S AMQQSPEC=""
 I AMQQVAL1["~~" S AMQQSPEC=AMQQVAL2,AMQQVAL2=$P(AMQQVAL1,"~~",2),AMQQVAL1=$P(AMQQVAL1,"~~")
 K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN)
 I $E(AMQQST)?1P,'$D(AMQQSQVN) D REL^AMQQMULS
 I AMQQMULZ S AMQQMUNV=AMQQNVAR,AMQQMUFV=AMQQFVAR,AMQQMULL=AMQQMULZ
RUN D INC
SQ I $D(AMQV("SQ")) D ^AMQQMULS
 I $D(^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN)),AMQQSPEC="NULL" K ^(AMQQUATN) G EXIT
 I $D(^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,1)) S AMQP(AMQQFVAR)=$P(^(1),U)
 I $D(^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN)) G TRUE
NULL I AMQQSPEC="NULL"!(AMQQSPEC="ANY") S ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,1)="-",AMQP(AMQQFVAR)="-",AMQT(AMQQT)=1
 G EXIT
TRUE I AMQQSPEC="EXISTS" K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN) S ^(AMQQUATN,1)="+",AMQP(AMQQFVAR)="+"
 S AMQT(AMQQT)=1
EXIT I AMQQAG="SAG" K ^UTILITY("AMQQ",$J,"SAG",AMQQUATN)
 D EXIT3^AMQQKILL
 Q
 ;
INC I AMQQ["AUPNVSIT" S AMQQVDAT=9999999-$P(AMQQFIN,".")
 E  S AMQQVDAT=9999999-AMQQFIN
INCDATE S AMQQVDAT=$O(@AMQQ@(AMQQVDAT))
 I AMQQVDAT'=+AMQQVDAT Q
 I AMQQ["AUPNVSIT" Q:(9999999-$P(AMQQVDAT,"."))<$P(AMQQST,".")  G:$P(AMQQVDAT,".",2)']$P(AMQQST,".",2)&((9999999-$P(AMQQVDAT,"."))=$P(AMQQST,".")) INCDATE
 E  I (9999999-AMQQVDAT)'>AMQQST Q
 S AMQQVSIT=0
INCITEM S (AMQQVNO,AMQQVSIT)=$O(@AMQQ@(AMQQVDAT,AMQQVSIT))
 I 'AMQQVSIT G INCDATE
 I $P($G(^AUPNVSIT(AMQQVSIT,0)),U,11) G INCITEM
 I 'AMQQMSS,AMQQMPC=1 S AMQQVALU=(9999999-$P(AMQQVDAT,".")) D S1 G CNT
 S %=U_AMQQGR_"("_AMQQVSIT_","_AMQQMSS_")"
 I $D(@%) S AMQQVALU=$P(^(AMQQMSS),U,AMQQMPC) D SET I 1
 E  G INCITEM
CNT I AMQQLCNT=AMQQLAST D LASTEVAL^AMQQMULT I $D(AMQQQUIT) K AMQQQUIT Q
 I AMQQSPEC="EXISTS"!(AMQQSPEC="NULL"),AMQQLCNT,'$D(AMQV("SQ")) S AMQQLCNT=-1 Q
 G INCITEM
 ;
SET I AMQQVALU="",$L(AMQQVAL1)>1,AMQQNNA'=5 Q
 I AMQQITR'="" S X=AMQQVALU X AMQQITR S AMQQVALU=X
 I $D(AMQQNNA),AMQQNNA>1 X "I 0" D ^AMQQMULN D:$T S1 Q
 I AMQQVAL2'=+AMQQVAL2 D TEXT^AMQQFAN D:$T S1 Q
 S AMQQVALU=+AMQQVALU
 I AMQQVAL1>AMQQVAL2,AMQQVALU<AMQQVAL2!(AMQQVALU>AMQQVAL1) D S1 Q
 I AMQQVALU=AMQQVAL1,AMQQVALU=AMQQVAL2 D S1 Q
 I AMQQVALU>AMQQVAL1,AMQQVALU<AMQQVAL2 D S1
 Q
 ;
S1 S AMQQLCNT=AMQQLCNT+1
 S AMQQHOLD=AMQQHOLD+1
 S ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,AMQQHOLD)=AMQQVALU_U_(9999999-$P(AMQQVDAT,"."))_U_AMQQVSIT_U_AMQQVNO
 Q
 ;
LASTEVAL ;EVALUATE 'LAST' CONDITION
 K AMQQQUIT
 S AMQP(1)=AMQQVSIT
 X AMQV("QQ",1,1)
 I '$G(AMQT(1)) S AMQQLAST=AMQQLAST+1 Q
 S AMQQQUIT=""
 Q