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

AMQQSQ.m

Go to the documentation of this file.
AMQQSQ ; IHS/CMI/THL - SUBQUERY MANAGER ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;-----
 ; WHEN YOU CALL THIS ROUTINE, YOU MUST HAVE THE FOLLOWING VARIABLES:
 ;   AMQQSQAN (SQ SUBJECT)
 ;   AMQQUSQL (LEVEL)
 ;   AMQQSQAA (PARENT SQ OR AMQQUATN)
 ;   AMQQSQSN (SUBJECT NUMBER)
 ;   AMQQSQST (SUBJECT TYPE)
 ;   AMQQUSQN HOLDS THE ABSOLUTE SUBQUERY NUMBER
 ;   AMQQSQNN HOLDS THE CURRENT AMQQUSQN AT THAT LEVEL
 ;   AMQQUQQN HOLDS THE 'QQ' NUMBER
RUN D VAR
 I $P(^AMQQ(1,AMQQLINK,0),U,5)'=20 W:'$D(AMQQXX) !!,$S(AMQQCCLS="V":"Note: This visit may have ",1:"SUBQUERY: Analysis of "),"multiple ",AMQQSQSZ,"S",!
 E  D ^AMQQSQIM I $D(AMQQQUIT) G EXIT
 D GET
EXIT K %,AMQQAFN,AMQQNMAS
NOTSTD D SQKILL^AMQQKILL
 Q
 ;
VAR S (AMQQQ,AMQQMULT)=""
 I AMQQSQST'="L",AMQQSQST'="I",AMQQSQST'="G" S AMQQCOMP=";;"
 S (AMQQSQFN,AMQQSQFR)=0
 I $D(AMQQYYMI) Q
 S AMQQNAR=$S($D(AMQQONE):AMQQONE,1:"ea. patient")
 S %=AMQQSQAN
 S %=$P(%,",")
 S %=$P(%," (")
 S %=$P(%,"(")
 S AMQQSQSJ=%
 S AMQQSQSZ=$S($E(%,$L(%))="Y":($E(%,1,$L(%)-1)_"IE"),%="DIAGNOSIS":"DIAGNOSE",%="PROBLEM LIST DIAGNOSIS":"PROBLEM LIST DIAGNOSE",%="HEALTH FACTORS":"HEALTH FACTOR",$E(%,$L(%))="S":(%_"E"),1:%)
 Q
 ;
GET S AMQQSQFN=AMQQSQFN+1
 I AMQQSQFN=1 S %=+$G(^AMQQ(5,AMQQSQSN,5)) I %,$P(^(5),U,4) K AMQQSQUF D ^AMQQSQUP G:$D(AMQQSQUF) G1 D CANCEL Q
 D ^AMQQSQA
 I $D(AMQQSQNV) K AMQQSQNV S AMQQSQFN=AMQQSQFN-1 G GET
 I $D(AMQQSQQT) K AMQQSQQT D:AMQQUSQL=1 SQR Q
 I $D(AMQQQUIT),AMQQSQFN>1 K AMQQQUIT D CANCEL Q
 I $D(AMQQQUIT) Q
G1 K AMQQSQUF
 D ^AMQQSQS
 I $D(AMQQSQSQ) D RECURSE
 I $D(AMQQSQQF) D QQ
 I $D(AMQQSQNF) Q
 I $D(AMQQSQCF) S AMQQNMAS=""
 I '$D(AMQQXX),AMQQSQFN>1 W !! F %=0:0 S %=$O(^UTILITY("AMQQ",$J,"SQL",AMQQSQNN,%)) Q:'%  W ! X ^(%)
 G GET
 ;
CANCEL W !!,$S(AMQQUSQL=1:"ATTRIBUTE ",1:"SUBQUERY "),"CANCELLED!!!",!!,*7
 S AMQQSQJ1="CLEANUP^AMQQSQ"
 D TREE2^AMQQSQT
 S AMQQCOMP=""
 I AMQQUSQL=1 K ^UTILITY("AMQQ",$J,"Q",AMQQUATN) S AMQQUATN=AMQQUATN-1,AMQQXSQF=""
 Q
 ;
CLEANUP K ^UTILITY("AMQQ",$J,$S(AMQQTLVL=1:"SQXQ",1:"SQXS"),AMQQSQN1,AMQQSQN2)
 N %
 F %="SQ","SQL" K ^UTILITY("AMQQ",$J,%,AMQQSQN2)
 Q
 ;
SQR S AMQQSQFR=0
 I AMQQSQFN=1 Q
CHECK I '$G(AMQQSQNN) S %=$G(AMQQCOMP) I '+%,$P(%,";",4)="" S AMQQSQFR=1 Q
 I $D(^UTILITY("AMQQ",$J,"SQ",AMQQSQNN,"NULL")) S AMQQSQFR=6 Q
 F %=0:0 S %=$O(^UT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