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

AMQQSL.m

Go to the documentation of this file.
AMQQSL ; IHS/CMI/THL - UTILITY FOR EXPORT/IMPORT SCRIPTS ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;-----
 ;
EXPORT(AMQQSDA,AMQQSNAM,AMQQOF,AMQQIF) ;EP;
 ;TO EXPORT QMAN QUERY FROM QUERY CLONING
 ;AMQQSDA - IEN OF THE QMAN SCRIPT
 ;AMQQSNAM - NAME OF THE QMAN SCRIPT
 ;AMQQOF - NAME OF THE OUTPUT FILE
 ;AMQQIF - NAME OF THE INPUT FILE
 I AMQQSDA=""!(AMQQSNAM="")!(AMQQOF="")!(AMQQIF="") S BQCERR="Missing data for Qman Query Export" Q
 D REAL
 N X,Y,Z
 U IO W AMQQIF,!
 U IO W AMQQSNAM,!
 S X=0
 F  S X=$O(^AMQQ(2,AMQQSDA,2,X)) Q:'X  D
 .S Y=$G(^AMQQ(2,AMQQSDA,2,X,0))
 .Q:Y=""
 .U IO W Y,!
 U IO W "**",!
 Q
IMPORT() ;EP;TO IMPORT AND RUN SCRIPT FROM QUERY CLONING
 N AMQQH
 S AMQQH=$H
 I '$D(ZTQUEUED) U 0 W !!,"One moment please..."
 U IO R X:1
 Q:X=""!(X="**") ""
 S ^TMP("AMQQ EXTERNAL SCRIPT",$J,AMQQH,"FILE NAME")=X
 U IO R X:1
 Q:X=""!(X="**") ""
 S ^TMP("AMQQ EXTERNAL SCRIPT",$J,AMQQH,"SCRIPT NAME")=X_"-QC"
 S I=0
 F  R X:1 Q:X=""!(X="**")  D
 .S I=I+1
 .S ^TMP("AMQQ EXTERNAL SCRIPT",$J,AMQQH,I)=X
 Q:'$D(^TMP("AMQQ EXTERNAL SCRIPT",$J,AMQQH))
 K DIE,DIC,DINUM,DR,DA,DD,DO,DIK,DLAYGO
 S X=^TMP("AMQQ EXTERNAL SCRIPT",$J,AMQQH,"SCRIPT NAME")
 S DIC="^AMQQ(2,"
 S DIC(0)="L"
 S DIC("DR")="4////"_^TMP("AMQQ EXTERNAL SCRIPT",$J,AMQQH,"FILE NAME")
 D FILE^DICN
 K DIE,DIC,DINUM,DR,DA,DD,DO,DIK,DLAYGO
 Q:+Y<1 ""
 S AMQQSDA=+Y
 S (X,I)=0
 F  S X=$O(^TMP("AMQQ EXTERNAL SCRIPT",$J,AMQQH,X)) Q:'X  D
 .Q:$G(^TMP("AMQQ EXTERNAL SCRIPT",$J,AMQQH,X))=""
 .S ^AMQQ(2,AMQQSDA,2,X,0)=^TMP("AMQQ EXTERNAL SCRIPT",$J,AMQQH,X)
 .S I=X
 S ^AMQQ(2,AMQQSDA,2,0)="^^"_I_U_I_U_DT
 I '$D(ZTQUEUED) U 0 W !!,"QMAN File import completed."
 D POINTER
 Q AMQQSDA
 ;
REPORT(AMQQSDA) ;EP;RUN QMAN SCRIPT FROM QUERY CLONING
 ;AMQQSDA - IEN OF QMAN SCRIPT
 ;AMQQFILE - HOST FILE NAME FOR THE SCRIPT
 S AMQQFILE=$$IFILE(AMQQSDA)
 Q:AMQQFILE="" ""
 S AMQQYY=AMQQSDA
 K AMQV,^UTILITY("AMQQ",$J),^UTILITY("AMQQ TAX",$J)
 D RESTORE^AMQQCMPS
 Q:'$D(AMQV(1)) ""
 S AMQQCCLS=$E($P(AMQV(0),"AMQQCCLS=""",2))
 S AMQV("OPTION")="LIST"
 D DOIT^AMQQCMPL
 Q AMQQFILE
 ;
IFILE(AMQQSDA) ;EP;TO DETERMINE THE NAME OF THE HOST FILE TO BE CREATED FOR THE
 ;QMAN REPORT
 ;AMQQSDA - IEN OF QMAN SCRIPT
 S AMQQFILE=$P($G(^AMQQ(2,+AMQQSDA,0)),U,4)
 Q AMQQFILE
 ;
REAL ;CONVERT SCRIPT POINTER VALUES TO REAL VALUES
 N X,Y,Z,ZZ
 K ^TMP("QMAN SCRIPT",$J)
 S X=0
 F  S X=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