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

AMQQSQL.m

Go to the documentation of this file.
AMQQSQL ; IHS/CMI/THL - SUBQUERY DESCRIPTIVE LIST ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;-----
 I $D(AMQQXX) Q
 N AMQQSQLS
LIST S AMQQSQLS="W ?"_$S($D(AMQQGVF):6,1:(3*AMQQUSQL+6))_","""
EN1 ; ENTRY POINT FROM AMQQSQP
 I '$D(AMQQSQCT),$D(AMQQSBCT) S AMQQSQCT=AMQQSBCT ; &&&
 I $D(^UTILITY("AMQQ",$J,"SQ",AMQQSQNN,"NULL"))!($G(X)="NULL") S AMQQSQLS=AMQQSQLS_"'NULL' (None meet criteria)" G LS
 I AMQQSQCT="B","EV"[AMQQSQST,AMQQSQST'="" D BP G LS
 S %=AMQQSQCT
 D @$S($D(AMQQSQLF):"MULT",%="D":"DT^AMQQSQL1",%="B":"VAL",%="C":"COMP",%="O":"ORD",%="T":"LEAST",%="R":"REL",%="L":"LINK",%="V":"VIS",%="M":"MULT",%="S":"SET",1:"NOSQL")
 I $D(AMQQNOSQ)!($G(AMQQSQLS)[";*;") K AMQQNOSQ Q  ; &&&
LS I '$D(AMQQNOSQ) S ^UTILITY("AMQQ",$J,"SQL",AMQQSQNN,AMQQSQFN)=AMQQSQLS_""""
EXIT K %,A,B,C,E,F,G,H,S,T,Z,AMQQNOSQ
 Q
 ;
NOSQL S AMQQNOSQ=""
 Q
 ;
VAL N X,Y,Z,A S X=AMQQSQCV
 I AMQQSQCV["~",AMQQSQTP="E" D BP Q
 I AMQQSQCV[";" S:$D(AMQQSQNT) AMQQSQLS=AMQQSQLS_"NOT " S AMQQSQLS=AMQQSQLS_"BETWEEN "_$P(AMQQSQCV,";")_" and "_$P(AMQQSQCV,";",2) Q
 S A=$S($E(AMQQSQBS)="'":$E(AMQQSQBS,2,99),1:AMQQSQBS)
 S Y=$F("[]=?$#><",A)-1
 S Z=$P("CONTAINS^FOLLOWS^EQUALS^PATTERN MATCH^STARTS WITH^ENDS WITH^GREATER THAN^LESS THAN",U,Y)
 I $D(AMQQSQNT) S Z=$S(Y<7:"DOES ",1:"")_"NOT "_$P("CONTAIN^FOLLOW^EQUAL^PATTERN MATCH^START WITH^END WITH^GREATER THAN^LESS THAN",U,Y)
 S AMQQSQLS=AMQQSQLS_Z_" "
 S:AMQQSQST="T" AMQQSQLS=AMQQSQLS_"1:"
 S AMQQSQLS=AMQQSQLS_AMQQSQCV
 Q
 ;
 ;
BP N A,B,C,E,X,F,G,H,T,Z
 S Y=AMQQSQCV
 I Y=">:0~>:0~!" S AMQQSQLS=AMQQSQLS_"all values""" Q
 I AMQQSQSN=253 S F="S",G="D",T="" G BP1
 S F="R"
 S G="L"
 S T="20/"
BP1 S Z=$P(Y,"~")
 S A=$P(Z,":")
 S B=$P(Z,":",2)
 S C=$P(Z,":",3)
 S E=$P(Z,":",4)
 S AMQQSQLS=AMQQSQLS_F
 S:C="" AMQQSQLS=AMQQSQLS_A_T_B
 S:C'="" AMQQSQLS=AMQQSQLS_" "_T_B_"-"_E
 S H=$S($P(Y,"~",3)="&":" and ",1:" or "),AMQQSQLS=AMQQSQLS_H_G
 S Z=$P(Y,"~",2),A=$P(Z,":")
 S B=$P(Z,":",2)
 S C=$P(Z,":",3)
 S E=$P(Z,":",4)
 S:C="" AMQQSQLS=AMQQSQLS_A_T_B
 S:C'="" AMQQSQLS=AMQQSQLS_" "_T_B_"-"_E
 Q
 ;
LEAST I AMQQSQNM["_" S AMQQSQLS=AMQQSQLS_$P(AMQQSQNM,"_")_AMQQSQCV_$P(AMQQSQNM,"_",2) Q
ORD S AMQQSQLS=AMQQSQLS_AMQQSQNM_" "_AMQQSQCV
 Q
 ;
COMP S AMQQSQLS=AMQQSQLS_AMQQSQNM
 Q
 ;
REL S AMQQSQLS=AMQQSQLS_"DURING THE SPECIFIED AGE WINDOW"
 Q
 ;
 S X=AMQQQ,Y=$P(X,U,3)
 I X[";;;NULL" S AMQQSQLS=AMQQSQLS_$P(X,U,2)_" IS 'NULL'" Q
 I X[";;;EXIST" S AMQQSQLS=AMQQSQLS_$P(X,U,2)_" IS NOT 'NULL'" Q
 D VIS1
 Q
 ;
VIS N X,Y
 S X=AMQQQ,Y=$P(X,U,3)
 I AMQQQ["NULL" S AMQQSQLS=AMQQSQLS_$P(X,U,2)_" IS 'NULL'" Q
VIS1 I "GL"[Y D ZSET^AMQQATL1 S AMQQSQLS=AMQQSQLS_$P(X,U,2)_$G(Z) Q
 I Y="D" D DATE^AMQQSQL1 Q
 I Y="S" D SET^AMQQSQL1 Q
 I Y="F" D FREE^AMQQSQL1 Q
 I $P(X,U,8)="><" S AMQQSQLS=AMQQSQLS_$P(X,U,2)_" BETWEEN "_+$P(X,U,9)_" AND "_$P($P(X,U,9),";",2) Q
 S AMQQSQLS=AMQQSQLS_$P(X,U,2)_" "_$P(X,U,8)_" "_$P(X,U,9)
 ; INSERT OTHER TYPES HERE
 Q
 ;
MULT S AMQQZSQL=AMQQSQNN_U_AMQQSQFN_U_(AMQQUSQN+1)
 K AMQQSQLF
 S AMQQSQLS=AMQQSQLS_$P(AMQQSQSQ,U,6)_" ENTERED "
 I $P(AMQQSQSQ,U,7),$G(AMQQSQN),$G(AMQQSQSN),$D(^AMQQ(5,AMQQSQN,5)),$D(^AMQQ(5,AMQQSQSN,5)),$P(^(5),U,2),$P(^(5),U,2)=$P(^AMQQ(5,AMQQSQN,5),U,2) S AMQQSQLS=AMQQSQLS_"DURING THIS "_$P(AMQQSQSQ,U,5) Q
 I $P(AMQQSQSQ,U,7) S AMQQSQLS=AMQQSQLS_"ON THE SAME VISIT AS EA. "_$P(AMQQSQSQ,U,5) Q
 N X,Y
 S X=$P(AMQQSQSQ,U,3)
 S Y=$P(AMQQSQSQ,U,4)
 I X["0 DAY " S X="THE SAME DAY"
 I Y["0 DAY " S Y="THE SAME DAY AS"
 S AMQQSQLS=AMQQSQLS_"FROM "_X_" TO "_Y_" EA. "_$P(AMQQSQSQ,U,5)
 Q
 ;
SET N %,S,A,B
 I AMQQLINK>1000!((AMQQLINK>689.9999)&(AMQQLINK<706)) S S=$G(^AMQQ(1,AMQQLINK,4,1,1)),S=$P(S,"S Y=""",2),S=$P(S,""",X=$F") G SET1
 S %=$P($G(^AMQQ(5,AMQQSQSN,0)),U,5)
 I % S:%=9 %=AMQQSQSN+($J/100000) S %=$P($G(^AMQQ(1,%,0)),U,6) I % S %="^DD("_%_",0)" I $D(@%) S S=";"_$P(^(0),U,3)
SET1 S A=";"_AMQQSQCV_":"
 S A=$F(S,A)
 I A S B=$P($E(S,A,999),";")
 S AMQQSQLS=AMQQSQLS_"Result is "_$S($G(AMQQSQBS)="'=":"not ",1:"")_$G(B)
 Q
 ;