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

AMQQN2.m

Go to the documentation of this file.
AMQQN2 ; IHS/CMI/THL - TEMP ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
VAR N A,S
 S A=X
 S S=" "
 N %,X,Y,Z
RUN D ATT
 I $G(Y)=-1 S AMQQFAIL=5 G EXIT
 I A="",$D(AMQQONE),"GL"[$P(^AMQQ(4,AMQQNTYP,0),U) S A="= ALL"
 I A="" S AMQQNCND="",AMQQNVAL=""
 E  D COND I Y=-1 S AMQQFAIL=5 G EXIT
 I $G(AMQQNSUB)'="" D SUB I Y=-1 S AMQQFAIL=6 G EXIT
EXIT K AMQQNI,AMQQNOTF,AMQQNTYP,AMQQNII,%,A,S
 Q
 ;
ATT S DIC="^AMQQ(5,"
 S DIC(0)="ES"
 S DIC("S")="I $P(^(0),U,2)=AMQQCCLS"
 F AMQQNI=1:1:$L(A,S)-1 S X=$P(A,S,AMQQNI,AMQQNI+1) Q:X=""  S:$E(X,$L(X))="S" X=$E(X,1,$L(X)-1) S D="C" I X'=+X D IX^DIC I Y'=-1 S X=$P(A,S,AMQQNI,AMQQNI+1) D ATTSET G ATTEXIT
 F AMQQNI=1:1 S X=$P(A,S,AMQQNI) Q:X=""  S:$E(X,$L(X))="S" X=$E(X,1,$L(X)-1) S D="C" I X'="LAST",X'=+X D IX^DIC I Y'=-1 S X=$P(A,S,AMQQNI) D ATTSET Q
ATTEXIT K DIC
 Q
 ;
ATTSET D ^AMQQSEC
 I Y=-1 S AMQQNSF="" H 2 Q
 S AMQQNSUB=$P(A,X)
 S %=$L(AMQQNSUB)
 I $E(AMQQNSUB,%)=" " S AMQQNSUB=$E(AMQQNSUB,1,%-1)
 S A=$P(A,X,2,99)
 I $E(A)=S S A=$E(A,2,999)
 S AMQQNATT=Y
 S AMQQATN=+Y
 S AMQQATNM=$P(Y,U,2)
 S AMQQLINK=$P(^AMQQ(5,+Y,0),U,5)
 I 'AMQQLINK S Y=-1 Q
 I AMQQATN>1000 D ^AMQQATAL
 W $C(13),?79,$C(13)
 S %=$P(^AMQQ(5,+Y,0),U,5)
 S:%=9 %=+Y+($J/100000)
 S AMQQNTYP=$P(^AMQQ(1,%,0),U,5)
 S AMQQCTXS=$P(^(0),U,7)
 Q
 ;
COND S %=$P(^AMQQ(4,AMQQNTYP,0),U)
 I "GL"[% D TAX Q
 S %=$P(A,S)
 I "^IS^WAS^ARE^WERE^"[(U_%_U) S AMQQNISF="",A=$P(A,S,2,99) G COND
 I "^`^NOT^"[% S AMQQNOTF="",A=$P(A,S,2,99)
C1 S DIC="^AMQQ(5,"
 S DIC(0)="ES"
 I 'AMQQCTXS S DIC("S")="I $P(^(0),U,3)=AMQQNTYP" G C2
 I $G(AMQQNSUB)'="" S DIC("S")="I $P(^(0),U,21)="_AMQQNTYP G C2
 S AMQQSQST=$P(^AMQQ(4,AMQQNTYP,0),U)
 D DICS^AMQQSQAC
C2 S %=$L(A,S)
 I %>3 S %=3
 S AMQQNII=%
 F AMQQNI=AMQQNII:-1:1 S X=$P(A,S,1,AMQQNI),D="C" D IX^DIC I Y'=-1 Q
 W $C(13),?79,$C(13)
 K DIC
 I Y=-1,$D(AMQQNISF) K AMQQNISF S A="= "_A G C1
 I Y=-1 Q
 S AMQQNVAL=$P(A," ",AMQQNI+1,99)
 S AMQQNCND=Y
 S %=$L(AMQQNVAL,S)
 I %>1,$P(AMQQNVAL,S,%-1)=+$P(AMQQNVAL,S,%-1) S AMQQNVAL=$P(AMQQNVAL,S,1,%-1)
 I $D(AMQQNOTF) K AMQQNOTF S $P(AMQQNCND,U,3)="'"
 I $G(AMQQNVAL)'="" D VAL
 Q
 ;
TAX F %="IS","WAS","ARE","WERE" I $P(A," ")=% S A="= "_$P(A," ",2,99)
 S AMQQNVAL=$P(A,"= ",2)
 S AMQQNTAX=AMQQNVAL
 K AMQQTAX
 S %=^AMQQ(5,+Y,0)
 S AMQQLINK=$P(%,U,5)
 S AMQQTNAR=$P(%,U,15)
 S AMQQTDIC=U_$P(%,U,16)
 S AMQQTLOK=U_$P(%,U,18)
 S AMQQTTX=""
 S:$D(^AMQQ(5,+Y,3)) AMQQTTX=^(3)
 D ^AMQQTX
 W $C(13),?79,$C(13)
 I '$D(AMQQTAX) S AMQQFAIL=8 Q
 S AMQQNCND=$S(AMQQCTXS:"MTAX",1:"TAX")
 S AMQQNVAL=AMQQTAX
 I $D(AMQQXXXX),AMQQXXXX["'="!(AMQQXXXX[" NOT ") S ^UTILITY("AMQQ TAX",$J,AMQQTAX,"--")=""
 Q
 ;
SUB S A=AMQQNSUB
 S DIC="^AMQQ(5,"
 S DIC(0)="ES"
 S DIC("S")="I $P(^(0),U,20)=""C""!($P(^(0),U,20)=""O""),$P(^(0),U,21)="_AMQQNTYP_"!($P(^(0),U,21)=16)"
 S %=$L(A,S)
 I %>3 S %=3
 S AMQQNII=%
 F AMQQNI=AMQQNII:-1:1 S X=$P(A,S,1,AMQQNI),D="C" D IX^DIC I Y'=-1 Q
 W $C(13),?79,$C(13)
 K DIC
 I Y=-1 S AMQQFAIL=10 Q
 S X=$P(A,S,1,AMQQNI)
 S %=$P(A,X,2)
 S AMQQNSTP=$P(^AMQQ(5,+Y,0),U,20)
 S %=$TR(%," ","")
 I AMQQNSTP="C",%'="" S AMQQFAIL=10 Q
 I AMQQNSTP="C",$G(AMQQNCND)="MTAX" S AMQQFAIL=10 Q
 I AMQQNSTP="C" S AMQQNSCD=Y Q
 I %="" S %=1
 I %'=+% S AMQQFAIL=10 Q
 S AMQQNSCD=Y
 S AMQQNSVL=%
 Q
 ;
VAL K AMQQCOMP
 S X=AMQQNVAL
 S AMQQFTYP=$P(^AMQQ(4,AMQQNTYP,0),U)
 S AMQQNOCO=1
 S AMQQSYMB=$P(^AMQQ(5,AMQQATN,0),U,6)
 I AMQQCTXS S %=$P(^AMQQ(5,+AMQQNCND,0),U,21),AMQQFTYP=$P(^AMQQ(4,%,0),U)
 I $D(AMQQNV2) S X=X_";"_AMQQNV2,AMQQNOCO=2 K AMQQNV2
 D ^AMQQAV
 I $G(AMQQCOMP)="" S AMQQFAIL=6 Q
 S AMQQNVAL=AMQQCOMP
 K AMQQCOMP
 Q
 ;