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

AMQQMGR7.m

Go to the documentation of this file.
AMQQMGR7 ; IHS/CMI/THL - LAB STARTUP OVERFLOW ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;-----
SAVE(AMQQLDFN) ;EP;
 I '$D(^LAB(60,AMQQLDFN)) Q
 S %=$P(^LAB(60,AMQQLDFN,0),U,12)
 I %="" Q
 I $P($G(@(U_%_"0)")),U,5)="" Q
 I $P(^LAB(60,AMQQLDFN,0),U,3)="N" Q
 N AMQQLSS,AMQQLSSX,AMQQLSSN,X,Y,AMQQLAKA,AMQQLAKN,AMQQLSPX,AMQQLOFF,AMQQLSPC,AMQQLDS,AMQQLTYP
 S AMQQLAKA=$P(^LAB(60,AMQQLDFN,0),U)
 S AMQQLAKN=1
 S X=0
 F  S X=$O(^LAB(60,AMQQLDFN,5,X)) Q:'X  S Y=^(X,0),AMQQLAKA=AMQQLAKA_U_Y,AMQQLAKN=AMQQLAKN+1 ; GET AKAs
 S X=AMQQLDFN
 S AMQQLSS=""
 S AMQQLSSX=""
 S AMQQLSSN=0
 F  S X=$O(@TMP@(X)) Q:'X!(X>(AMQQLDFN+.99999))  D  ; GET SITE/SPECIMINES
 .S Y=$G(@TMP@("C",X))
 .I 'Y Q
 .I Y'=44,'$D(^LAB(60,AMQQLDFN,1,Y,0)) Q
 .I Y'=44,((Y<70)!(Y>79)) Q
 .I Y=44 S AMQQLSS=AMQQLSS_"UNKNOWN SITE/SPECIMEN"_U
 .E  S AMQQLSS=AMQQLSS_$P("BLOOD^URINE^SERUM^PLASMA^CSF^URETHRAL FLUID^PERITONEAL FLUID^PLEURAL FLUID^SYNOVIAL FLUID^CLOT",U,(Y-69))_U
 .S AMQQLSSN=AMQQLSSN+1
 .S AMQQLSSX=AMQQLSSX_Y_U
 I 'AMQQLSSN G LEXIT
 S AMQQLDS=0
 S %=$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,I)="UR "_Z
 Q
 ;
LTYPE I $O(^LAB(60,AMQQLDFN,200,0)) S AMQQLTYP="" Q
 S %=$P(^LAB(60,AMQQLDFN,0),U,12)
 I %="" G TF
 S %=U_%_"0)"
 I '$D(@%) G TF
 I $P(@%,U,3)[";Trace:" S AMQQLTYP=12 Q
 I ($P(@%,U,5,6)["Q9=")+($G(^(3))[" NUMBER ") S AMQQLTYP=9 Q
 I $P(@%,U,5,6)[" NUMBER " S AMQQLTYP=9 Q
 I $P(@%,U,3)[";Pos.:" S AMQQLTYP=11 Q
 I $G(AMQQLSTG)["TITRE"!($P(@%,U,5)["""""titre""""")!($G(^(3))["1:") S AMQQLTYP=15 Q
 I $P(@%,U,2)="S" S AMQQLTYP=6 Q
TF S AMQQLTYP=2
 Q
 ;
LSET ;
 I $D(AMQQLTRM) K AMQQLTRM Q
 K DIE,DIC,DINUM,DR,DA,DD,DO,DIK,DLAYGO
 N DIC,DIE,DR,DA,D,X,Y,AMQQI
 S (DIC,DIE)="^AMQQ(5,"
 S DIC(0)="L"
 S X=$P(AMQQLSTG,U)
 S DINUM=AMQQLDFN+1000+AMQQLOFF
 Q:$D(^AMQQ(5,DINUM))
 D FILE^DICN
 K DIE,DIC,DINUM,DR,DA,DD,DO,DIK,DLAYGO
 I Y=-1 Q
 S DA(1)=+Y
 S DIC=DIE_DA(1)_",1,"
 S DIC(0)="L"
 S DIC("P")=$P(^DD(9009075,.02,0),U,2)
 F AMQQI=1:1 S X=$P(AMQQLSTG,U,AMQQI) Q:X=""  D ^DIC
 S DR="1////P;1.1////V;3////3;4////9;19////C;20////M;41////"_AMQQLTYP_";42////"_AMQQLDFN_";43////"_AMQQLSPX_";44////"_AMQQLHN_";45////"_AMQQLHL_";46////"_AMQQLUNT
 I AMQQLOUT'="" S DR=DR_";47////^S X=AMQQLOUT"
 D ^DIE
 K DR,DIC,DIE,DQ,DR,DI,D1,D0
 W "."
 Q
 ;
RESCO ; RESTORE COMPANION LAB TESTS
 N DIC,X,Y,%,DA,AMQQLAB,AMQQCO
 I '$D(^UTILITY("AMQQ LC",$J)) Q
 S DIC(0)="L"
 S DIC("P")=$P($G(^DD(9009075,40,0)),U,2)
 S AMQQLAB=0
 F  S AMQQLAB=$O(^UTILITY("AMQQ LC",$J,AMQQLAB)) Q:'AMQQLAB  S AMQQCO=0 F  S AMQQCO=$O(^UTILITY("AMQQ LC",$J,AMQQLAB,AMQQCO)) Q:'AMQQCO  D ADD W "."
 K ^UTILITY("AMQQ LC",$J)
 Q
 ; 
COMP ; ADD COMPANION LAB TESTS
 W !,"Want to define new 'COMPANION' lab tests"
 S %=2
 D YN^DICN
 I %=2 Q
 S DIC("A")="Enter primary test name (the one that will have companions): "
PASK S DIC="^AMQQ(5,"
 S DIC(0)="AEQM"
 S DIC("S")="I Y>999"
 D ^DIC
 K DIC
 I Y=-1 Q
 S AMQQLAB=+Y
 D CLOOK
 S DIC("A")="Enter a companion test name: "
CASK S DIC="^LAB(60,",DIC(0)="AEQM"
 D ^DIC
 K DIC
 I Y=-1 G LOOP
 S AMQQCO=+Y
 D CADD
 S DIC("A")="Enter another companion test: "
 G CASK
LOOP W !
 S DIC("A")="Enter another primary test name: "
 G PASK
 ;
CADD N %,%Y,DIC,X,Y,DA
 W !,"Are you sure you want to add this companion test"
 S %=1
 D YN^DICN
 I %'=1 Q
 S DIC(0)="L"
 S DIC("P")=$P($G(^DD(9009075,40,0)),U,2)
ADD ;
 I '$D(^AMQQ(5,AMQQLAB,0)) Q
 S DA(1)=AMQQLAB
 S DIC="^AMQQ(5,"_DA(1)_",4.1,"
 S X="`"_AMQQCO
 D ^DIC
 Q
 ;
CLOOK ;
 N X,Y
 I '$O(^AMQQ(5,"LC",AMQQLAB,0)) Q
 W !!,"The following tests are already companions to ",$P($G(^AMQQ(5,AMQQLAB,0)),U)," =>",!
 S X=0
 F  S X=$O(^AMQQ(5,"LC",AMQQLAB,X)) Q:'X  D
 .S Y=$P($G(^LAB(60,+X,0)),U)
 .W:$L(Y) !?2,Y
 W !!
 Q