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

GMRAPHR2.m

Go to the documentation of this file.
GMRAPHR2 ;HIRMFO/WAA,FT-ADD/DELETE/EDIT SUSPECT DRUGS ;9/11/96  10:49
 ;;4.0;Adverse Reaction Tracking;**5**;Mar 29, 1996
EN1 ;
 Q:GMRAOUT
 W @IOF N DIE,DA,GMRAXXX,GMRAX,GMRAGHC
 K ^UTILITY("PSG",$J),^UTILITY("PSIV",$J),GMRARRAY
 S GMRADT=$P(^GMR(120.85,GMRAPA1,0),U)
 D ^GMRADSP7 G:'GMRAPA EXIT
SELECT W ! D LST
 ;SELECT ACTION
 K DIR S DIR(0)="SOBA^A:ADD;D:DELETE;E:EDIT",DIR("A")="Select Action (A/D/E): "
 S DIR("?")="ENTER A TO ADD A NEW DRUG, D TO DELETE A DRUG OR E TO EDIT"
 D ^DIR K DIR I "^^"[Y S GMRAOUT=$L(Y) G EXIT
 S GMRASEL=Y
 I GMRASEL="A" S GMRALOOK=0 W ! D ADD K GMRALOOK G:GMRAOUT EXIT K GMRALOOK G SELECT
 I GMRASEL="D" W ! D DEL G:GMRAOUT EXIT G SELECT
 I GMRASEL="E" W ! D EDIT G:GMRAOUT EXIT G SELECT
 G SELECT
EDIT ;EDIT A DRUG
 I '$O(^GMR(120.85,GMRAPA1,3,0)) W !,?3,"YOU CANNOT EDIT WHEN THERE IS NO DATA ON FILE.",$C(7) Q
EDITLST ; DISPLAY TO EDIT FIELD
 W !,"Select the DRUG RX you want to edit:",!
 D LST
EEDT K DA,DO,DIC,DIE,DLAYGO,DR
 S DA(1)=GMRAPA1,DIC="^GMR(120.85,"_DA(1)_",3,",DIC(0)="AMQEZ" D ^DIC K DIC
 I $D(DUOUT)!($D(DTOUT))!(Y=-1) S GMRAOUT=1 G QE
 S GMRASUS=+Y
 S DA(1)=GMRAPA1,DIE="^GMR(120.85,"_DA(1)_",3,",DA=+Y,DR=".01;1;1.5;2;3;4;S X=X;5;S X=X;6;7;8;9;10;10.1;10.2" D ^DIE
 I $D(DUOUT)!($D(DTOUT))!('$D(DA))!($D(Y)) G QE
 K GMRAX,DA,DIE,DR,DIC,DLAYGO D EN1^GMRAPEL0
QE K GMRAX,DA,DIE,DR,DIC,DLAYGO,GMRASUS
 Q
ADD ;SELECTION OF A DRUG OR ENTER A NEW DRUG
 D DISP^GMRAPHR0 I GMRAOUT S GMRAOUT=GMRAOUT-1 Q:GMRAOUT
 K % I '$D(GMRARRAY) D ADD2 S GMRAOUT=GMRAOUT-1 Q:GMRAOUT!(X="")!($D(Y))  G ADD
ADDED W !,"Enter the number(s) of the RX/DRUG to ADD or ""N"" for NEW: "
 R GMRAX:DTIME S:'$T GMRAX="^^" I "^^"[GMRAX S GMRAOUT=$L(GMRAX) Q
 I "??"[GMRAX W !,"ENTER THE NUMBER(S) OF THE ENTRY YOU WANT OR ""N"" FOR A NEW DRUG" G:$L(GMRAX)=1 ADDED G ADD
 I GMRAX="n" S GMRAX="N"
 I GMRAX="N" D ADD2 Q:X=""  G ADD
 I '$$VALST(GMRAX,"PH") W !,$C(7),"INVALID SELECTION PLEASE SELECT ONE OF THE DRUGS LISTED OR ""N"" FOR A NEW DRUG" G ADD
 S GMRALST=0 F  S GMRALST=$O(GMRALST(GMRALST)) Q:GMRALST<1  S GMRAX=GMRALST D  Q:GMRAOUT
 .S X=$P(GMRARRAY("PH",GMRAX),U,2)
 .I $D(^GMR(120.85,GMRAPA1,3,"B",X)) D  Q:GMRAOUT!(%-1)  K %
 ..W !,"You already have a ",X," DRUG on file."
 ..S %=2 F  W !,"Do You still want to add this one" D YN^DICN S:%=-1 %=2,GMRAOUT=1 Q:%  W !,"ENTER YES TO ADD THE DRUG or NO TO SELECT ANOTHER"
 ..Q
 .K DD,DO
 .I '$O(^GMR(120.85,GMRAPA1,3,0)) S ^(0)="^120.8503^^"
 .S DA(1)=GMRAPA1,DIC="^GMR(120.85,"_GMRAPA1_",3,",DIC(0)="L",DLAYGO=120.85 D FILE^DICN
 .I $G(DTOUT,0)!($G(DUOUT)) K DIC,DTOUT,DUOUT S GMRAOUT=1 Q
 .Q:(+Y<1)
 .S DA=+Y,DIE=DIC K DIC
 .I $P(GMRARRAY("PH",GMRAX),U)="OP" S DR="1.5////"_$E($P(GMRARRAY("PH",GMRAX),U,3),1,30)_";10////"_$P(GMRARRAY("PH",GMRAX),U,4)
 .I $P(GMRARRAY("PH",GMRAX),U)="D" D
 ..S DR="1////"_$P(GMRARRAY("PH",GMRAX),U,3)_";2////"_$P(GMRARRAY("PH",GMRAX),U,4)
 ..S DR=DR_";4////"_$P(GMRARRAY("PH",GMRAX),U,6)_";5////"_$P(GMRARRAY("PH",GMRAX),U,7)
 ..Q
 .I $P(GMRARRAY("PH",GMRAX),U)="IV" D
 ..S DR="1////"_$P(GMRARRAY("PH",GMRAX),U,3)_";2////IV"
 ..S DR=DR_";4////"_$P(GMRARRAY("PH",GMRAX),U,6)_";5////"_$P(GMRARRAY("PH",GMRAX),U,7)
 ..Q
 .S GMRASUS=DA D ^DIE K DIE,DA,DR,GMRAX
 .I '$D(DUOUT)!($D(DTOUT)) N X D EN1^GMRAPEL0
 .K GMRASUS Q
 Q
ADD2 ;
 K DD,DO
 I '$O(^GMR(120.85,GMRAPA1,3,0)) S ^(0)="^120.8503^^"
 S $P(^GMR(120.85,GMRAPA1,3,0),"^",2)="120.8503O"
 S DA(1)=GMRAPA1,DIC="^GMR(120.85,"_GMRAPA1_",3,",DIC(0)="AEMLQZ",DLAYGO=120.85 D ^DIC
 S $P(^GMR(120.85,GMRAPA1,3,0),"^",2)="120.8503"
 I $D(DUOUT)!$D(DTOUT) S GMRAOUT=1 I $D(DTOUT) S GMRAOUT=GMRAOUT+1
 I GMRAOUT!(+Y<1) K DIC,DA Q
 S DA=+Y K DIC
 S DA(1)=GMRAPA1,DIE="^GMR(120.85,"_GMRAPA1_",3,",DLAYGO=120.85,DR="1:10.2" D ^DIE
 I '$D(Y)!$G(DTOUT) S GMRAOUT=1 I $G(DTOUT) S GMRAOUT=GMRAOUT+1
 S X=$P($G(^GMR(120.85,GMRAPA1,3,DA,0)),U,1)
 I 'GMRAOUT N X S GMRASUS=DA D EN1^GMRAPEL0
 K DA,DIE,DLAYGO,DR,GMRASUS
 Q
DEL ;
 I '$D(^GMR(120.85,GMRAPA1,3,0)) W !,"THERE ARE NO DRUG SELECTED FOR THIS PATIENT" Q
 K DA,DO,DIC,DIE,DLAYGO,DR
 S DA(1)=GMRAPA1,DIC="^GMR(120.85,"_DA(1)_",3,",DIC(0)="AMQEZ" D ^DIC
 I $D(DUOUT)!($D(DTOUT))!(Y=-1) S GMRAOUT=1 G DQ
 K DIC,DA,DO
 S DA(1)=GMRAPA1,DIK="^GMR(120.85,"_DA(1)_",3,",DA=+Y D ^DIK
DQ K DIC,DIC,DA,DO,DLAYGO,DIK,Y
 Q
LST I '$O(^GMR(120.85,GMRAPA1,3,0)) W !,"THIS PATIENT HAS NO SUSPECTED AGENTS ON FILE" Q
 W !,"This patient has the following Drugs selected: ",!
 S GMRAX=0 F GMRAXX=1:1  S GMRAX=$O(^GMR(120.85,GMRAPA1,3,GMRAX)) Q:GMRAX<1  W !,?10,$P(^(GMRAX,0),U)
 Q
EXIT ;EXIT LINE
 K DIR,Y,GMRASEL,GMRABGDT,GMRAENDT,^UTILITY("PSG",$J),^UTILITY("PSIV",$J),GMRARRAY
 Q
VALST(LST,SUB) ; GIVEN LST, THIS FUNCTION RETURNS 1 IF LIST VALID, ELSE 0
 N X,Y,Z,A
 K GMRALST
 S Z=1 F X=1:1:$L(LST,",") S Y=$P(LST,",",X) D  Q:'Z
 .I Y'?1N.N,Y'?1N.N1"-"1N.N S Z=0 Q
 .I Y?1N.N S Y=Y_"-"_Y
 .F A=$P(Y,"-"):1:$P(Y,"-",2) S:'$D(GMRARRAY(SUB,A)) Z=0 Q:'Z  S GMRALST(A)=""
 .Q
 K:'Z GMRALST
 Q Z