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

AMQQMULT.m

Go to the documentation of this file.
AMQQMULT ;IHS/CMI/THL - COLLECTS MULTIPLE VALUES ;
 ;;2.0;IHS PCC SUITE;**2,4**;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)
 I '$D(AMQQAG) S AMQQAG="AG"
 I '$D(AMQQSQVN) S AMQQ=U_AMQQGR_"(""AA"",AMQP(0))"
 E  S AMQQ=U_AMQQGR_"(""AD"","_AMQQSQVN_")",%=+^AUPNVSIT(AMQQSQVN,0) G:'% EXIT S AMQQVDAT=(9999999-%)\1
 S AMQQSPEC=""
 I AMQQVAL1["~~" S AMQQSPEC=AMQQVAL2,AMQQVAL2=$P(AMQQVAL1,"~~",2),AMQQVAL1=$P(AMQQVAL1,"~~")
 I AMQQVAL2="ANY"!((AMQQVAL1=-999999999)&(AMQQVAL2=999999999)) S AMQQAAFL=""
 S AMQQMSS=+AMQQMSS
 S AMQQMPC=$S(AMQQMPC:AMQQMPC,1:4)
 S AMQQHOLD=0
 S AMQT(AMQQT)=0
 S AMQQIDN=0
 S AMQQLCNT=0
 K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN)
 I $E(AMQQST)?1P,'$D(AMQQSQVN) D REL^AMQQMULS
 I AMQQMULZ S AMQQMUNV=AMQQNVAR,AMQQMUFV=AMQQFVAR,AMQQMULL=AMQQMULZ
 I $D(AMQQB) S %=AMQQB,AMQQBOOL=$P(%,";"),AMQQVAL3=$P(%,";",2),AMQQVAL4=$P(%,";",3)
 I $D(AMQQSQVN),AMQQID[":" G:$D(@AMQQ) RUN S AMQT(AMQQT)=0 G NULL
 I '$D(AMQQSQVN),AMQQID'[":",'$D(@AMQQ@(AMQQID\1)),AMQQ["VLAB" S AMQT(AMQQT)=0 G NULL
 I $G(AMQQSPEC)="EXISTS",AMQQSTRT=2,'AMQQST,'AMQQUSQN,AMQQFIN=9999999,AMQQLAST=9999999 S ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,1)="+",AMQP(AMQQFVAR)="+",AMQT(AMQQT)=1 G EXIT
RUN D ID
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",$G(AMQQVAL2)'="ANY"
 E  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
 ;
ID I AMQQID'[":" S AMQQIDX=AMQQID D INC Q
 F  S AMQQIDN=AMQQIDN+1,AMQQIDX=$P(AMQQID,":",AMQQIDN) Q:AMQQIDX=""  D INC I AMQQLCNT=-1 Q
 Q
 ;
INC I AMQQGR="AUPNVLAB",AMQQIDX["." S AMQQLSS=+$P(AMQQIDX,".",2,99),AMQQIDX=AMQQIDX\1
 I $D(AMQQSQVN) S AMQQVNO=0 D VINC Q
 I '$D(@AMQQ@(AMQQIDX)) Q
 S AMQQVDAT=9999999-AMQQFIN
INCDATE S AMQQVDAT=$O(@AMQQ@(AMQQIDX,AMQQVDAT))
 I AMQQVDAT'=+AMQQVDAT Q
 I (9999999-AMQQVDAT)<AMQQST Q
 S AMQQVNO=0
INCITEM S AMQQVNO=$O(@AMQQ@(AMQQIDX,AMQQVDAT,AMQQVNO))
 I 'AMQQVNO G INCDATE
 ;IHS/CMI/LAB - EXCLUDE MEASUREMENTS ENTERED IN ERROR
 ;S %=U_AMQQGR_"("_AMQQVNO_","_AMQQMSS_")" G:'$D(@%) INCITEM G:'$D(^(0)) INCITEM I AMQQGR="AUPNVLAB" D LABSITE I $G(AMQQLSS1)="UNSPECIFIED SOURCE" G INCITEM
 S %=U_AMQQGR_"("_AMQQVNO_","_AMQQMSS_")"
 I AMQQGR="AUPNVMSR" G:$P($G(^AUPNVMSR(+AMQQVNO,2)),U,1) INCITEM  ;if entered in error skip it
 G:'$D(@%) INCITEM G:'$D(^(0)) INCITEM I AMQQGR="AUPNVLAB" D LABSITE I $G(AMQQLSS1)="UNSPECIFIED SOURCE" G INCITEM
 S AMQQVALU=$P(@%,U,AMQQMPC)
 S AMQQVSIT=$P(^(0),U,3)
 S AMQQXXXX=AMQQMPC_U_%_U_@%
 I AMQQGR="AUPNVXAM"!(AMQQGR="AUPNVNTS"),AMQQVXAM'="ALL",AMQQVXAM'=AMQQVALU Q  ;PATCH XXX
 D SET
CNT I AMQQLCNT=AMQQLAST D LASTEVAL I $D(AMQQQUIT) K AMQQQUIT Q
 I AMQQSPEC="EXISTS"!(AMQQSPEC="NULL"),AMQQLCNT,'$D(AMQV("SQ")) S AMQQLCNT=-1 Q
 G INCITEM
 ;
SET I AMQQVAL1="A",AMQQGR="AUPNVIMM",AMQQVALU="" S AMQQVALU=$P($G(^AUTTIMM(AMQQIDX,0)),U,2)_" +" G S1
 I AMQQVALU="",$D(AMQQAAFL) S AMQQVALU=" " D S1 Q
 I "<>"[$E(AMQQVALU) S AMQQGTLT=$E(AMQQVALU),AMQQVALU=$E(AMQQVALU,2,99)
 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 $D(AMQQB) X "I 0" D BP^AMQQMULN D:$T S1 Q
 I AMQQVAL2'=+AMQQVAL2 D TEXT^AMQQFAN D:$T S1 Q
 S AMQQVALU=$S(AMQQVALU="":" ",1:+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 %=""
 I AMQQGR="AUPNVLAB" S %=$P($G(^AUPNVLAB(AMQQVNO,0)),U,5) I $G(AMQQLSS)=44 S %="" ;_"  "_AMQQLSS1
 I AMQQGR="AUPNVDXP" S %=$P($G(^AUPNVDXP(AMQQVNO,0)),U,5)
 I AMQQVALU'=" ",%]"" S AMQQVALU=AMQQVALU_" "_% S AMQQLDFN=AMQQIDX
 I $D(AMQQGTLT) S AMQQVALU=AMQQGTLT_AMQQVALU K AMQQGTLT
 S ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,AMQQHOLD)=AMQQVALU_U_(9999999-AMQQVDAT)_U_AMQQVSIT_U_AMQQVNO
 Q
 ;
VINC S AMQQVNO=$O(@AMQQ@(AMQQVNO))
 I 'AMQQVNO Q
 S %=U_AMQQGR_"("_AMQQVNO_","_AMQQMSS_")"
 I $D(@%),$D(^(0)),$P(^(0),U)=AMQQIDX S AMQQVALU=$P(^(AMQQMSS),U,AMQQMPC),AMQQVSIT=$P(^(0),U,3) D SET I 1
 E  G VINC
 I AMQQLCNT=AMQQLAST Q
 I AMQQSPEC="EXISTS"!(AMQQSPEC="NULL"),AMQQLCNT S AMQQLCNT=-1 Q
 G VINC
 ;
LABSITE ;
 N %,X
 S AMQQLSS1="NO SITE SPECIMEN"
 Q:'$D(AMQQLSS)
 I AMQQLSS=44 S:$P($G(^AUPNVLAB(+$G(AMQQVNO),11)),U,3) AMQQLSS1="UNSPECIFIED SOURCE" Q
 I $G(AMQQIDX),$D(^AMQQ(5,(AMQQIDX+1000.44),0)),AMQQLSS'=44,'$P($G(^AUPNVLAB(+$G(AMQQVNO),11)),U,3) S AMQQLSS1="UNSPECIFIED SOURCE" Q
 F %=1:1 S X=+$P(AMQQLSS,".",%) Q:'X  I X=$P($G(^AUPNVLAB(AMQQVNO,11)),U,3) S:$G(^LAB(61,X,0))'="" AMQQLSS1=$P(^LAB(61,X,0),U) Q
 Q
 ;
LASTEVAL ;EP;EVALUATE 'LAST' CONDITION
 K AMQQQUIT
 I '$D(AMQV("QQ",1,1)) S AMQQQUIT="" Q
 I AMQV("QQ",1,1)["%=+$G(^AUPNVSIT(" S AMQQQUIT="" Q
 K AMQQQUIT
 S AMQP(1)=AMQQVSIT
 X AMQV("QQ",1,1)
 I '$G(AMQT(1)) S AMQQLAST=AMQQLAST+1 Q
 S AMQQQUIT=""
 Q