GMRAPHR1 ;HIRMFO/WAA,FT-ADD/DELETE/EDIT CONCOMITANT DRUGS ;4/6/05 14:18
;;4.0;Adverse Reaction Tracking;**5,23**;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)="SOMBA^A:ADD;D:DELETE;E:EDIT",DIR("A")="Select Action (A/D/E): "
S DIR("?",1)="ENTER A TO ADD A NEW DRUG, D TO DELETE A DRUG OR"
S DIR("?")="E TO EDIT A DRUG ON FILE FOR THIS PATIENT"
D ^DIR I "^^"[Y S GMRAOUT=$L(Y) G EXIT
S GMRASEL=Y K DIR
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,13,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)_",13,",DIC(0)="AMQEZ" D ^DIC K DIC
I $D(DUOUT)!($D(DTOUT))!(Y=-1) S GMRAOUT=1 G QE
S DA(1)=GMRAPA1,DIE="^GMR(120.85,"_DA(1)_",13,",DA=+Y,DR=".01;1;2;3;4" D ^DIE
QE K GMRAX,DA,DIE,DR,DIC,DLAYGO
Q
ADD ;SELECT ON OF THE DRUG OR FREE TEXT
D DISP^GMRAPHR0 I GMRAOUT S GMRAOUT=GMRAOUT-1 Q:GMRAOUT
K % I '$D(GMRARRAY) D ADD2 Q:X=""!(X="^") G ADD
ADDED W !,"Enter the number(s) of the 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^GMRAPHR2(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,13,"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,13,0)) S ^(0)="^120.8513^^"
.S DA(1)=GMRAPA1,DIC="^GMR(120.85,"_GMRAPA1_",13,",DIC(0)="L",DLAYGO=120.85 D FILE^DICN Q:(+Y<1)
.S DA=+Y,DIE=DIC K DIC
.I $P(GMRARRAY("PH",GMRAX),U)="OP" S DR="3////"_$P(GMRARRAY("PH",GMRAX),U,4)_";4////"_$E($P(GMRARRAY("PH",GMRAX),U,3),1,30)
.I $P(GMRARRAY("PH",GMRAX),U)="D" D
..S DR="1////"_$P(GMRARRAY("PH",GMRAX),U,6)_";2////"_$P($P(GMRARRAY("PH",GMRAX),U,7),".") ;23 Only get date
..S DR=DR_";4////"_$P(GMRARRAY("PH",GMRAX),U,3)_" "_$P(GMRARRAY("PH",GMRAX),U,4)_" "_$P(GMRARRAY("PH",GMRAX),U,5)
..Q
.I $P(GMRARRAY("PH",GMRAX),U)="IV" D
..S DR="1////"_$P(GMRARRAY("PH",GMRAX),U,6)_";2////"_$P($P(GMRARRAY("PH",GMRAX),U,7),".") ;23 Get date not time
..S DR=DR_";4////"_$P(GMRARRAY("PH",GMRAX),U,3)_" IV "_$P(GMRARRAY("PH",GMRAX),U,4)_" "_$P(GMRARRAY("PH",GMRAX),U,5)
..Q
.D ^DIE K DIE,DA,DR,GMRAX
.Q
;G ADD
Q
ADD2 ;
I '$O(^GMR(120.85,GMRAPA1,13,0)) S ^(0)="^120.8513^^"
S DA=GMRAPA1,DIE="^GMR(120.85,",DLAYGO=120.85,DR="13" D ^DIE
K DIE,DA,DR
Q
DEL ;
I '$D(^GMR(120.85,GMRAPA1,13,0)) W !,"THERE ARE NO DRUGS SELECTED FOR THIS PATIENT." Q
K DA,DO,DIC,DIE,DLAYGO,DR
S DA(1)=GMRAPA1,DIC="^GMR(120.85,"_DA(1)_",13,",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)_",13,",DA=+Y D ^DIK W "DELETED.."
DQ K DIC,DIC,DA,DO,DLAYGO,DIK,Y
Q
LST I '$O(^GMR(120.85,GMRAPA1,13,0)) W !,"THIS PATIENT HAS NO CONCOMITANT DRUGS 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,13,GMRAX)) Q:GMRAX<1 W !,?10,$P(^(GMRAX,0),U)
W ! K GMRAXX,GMRAX
Q
EXIT ;EXIT LINE
K DIR,Y,GMRALST,GMRASEL,GMRABGDT,GMRAENDT,^UTILITY("PSG",$J),^UTILITY("PSIV",$J),GMRARRAY
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMRAPHR1 4099 printed Dec 13, 2024@01:40:11 Page 2
GMRAPHR1 ;HIRMFO/WAA,FT-ADD/DELETE/EDIT CONCOMITANT DRUGS ;4/6/05 14:18
+1 ;;4.0;Adverse Reaction Tracking;**5,23**;Mar 29, 1996
EN1 ;
+1 if GMRAOUT
QUIT
+2 WRITE @IOF
NEW DIE,DA,GMRAXXX,GMRAX,GMRAGHC
+3 KILL ^UTILITY("PSG",$JOB),^UTILITY("PSIV",$JOB),GMRARRAY
+4 SET GMRADT=$PIECE(^GMR(120.85,GMRAPA1,0),U)
+5 DO ^GMRADSP7
if 'GMRAPA
GOTO EXIT
SELECT WRITE !
DO LST
+1 ;SELECT ACTION
+2 KILL DIR
SET DIR(0)="SOMBA^A:ADD;D:DELETE;E:EDIT"
SET DIR("A")="Select Action (A/D/E): "
+3 SET DIR("?",1)="ENTER A TO ADD A NEW DRUG, D TO DELETE A DRUG OR"
+4 SET DIR("?")="E TO EDIT A DRUG ON FILE FOR THIS PATIENT"
+5 DO ^DIR
IF "^^"[Y
SET GMRAOUT=$LENGTH(Y)
GOTO EXIT
+6 SET GMRASEL=Y
KILL DIR
+7 IF GMRASEL="A"
SET GMRALOOK=0
WRITE !
DO ADD
KILL GMRALOOK
if GMRAOUT
GOTO EXIT
KILL GMRALOOK
GOTO SELECT
+8 IF GMRASEL="D"
WRITE !
DO DEL
if GMRAOUT
GOTO EXIT
GOTO SELECT
+9 IF GMRASEL="E"
WRITE !
DO EDIT
if GMRAOUT
GOTO EXIT
GOTO SELECT
+10 GOTO SELECT
EDIT ;EDIT A DRUG
+1 IF '$ORDER(^GMR(120.85,GMRAPA1,13,0))
WRITE !,?3,"YOU CANNOT EDIT WHEN THERE IS NO DATA ON FILE.",$CHAR(7)
QUIT
EDITLST ; DISPLAY TO EDIT FIELD
+1 WRITE !,"Select the DRUG RX you want to edit:",!
+2 DO LST
EEDT KILL DA,DO,DIC,DIE,DLAYGO,DR
+1 SET DA(1)=GMRAPA1
SET DIC="^GMR(120.85,"_DA(1)_",13,"
SET DIC(0)="AMQEZ"
DO ^DIC
KILL DIC
+2 IF $DATA(DUOUT)!($DATA(DTOUT))!(Y=-1)
SET GMRAOUT=1
GOTO QE
+3 SET DA(1)=GMRAPA1
SET DIE="^GMR(120.85,"_DA(1)_",13,"
SET DA=+Y
SET DR=".01;1;2;3;4"
DO ^DIE
QE KILL GMRAX,DA,DIE,DR,DIC,DLAYGO
+1 QUIT
ADD ;SELECT ON OF THE DRUG OR FREE TEXT
+1 DO DISP^GMRAPHR0
IF GMRAOUT
SET GMRAOUT=GMRAOUT-1
if GMRAOUT
QUIT
+2 KILL %
IF '$DATA(GMRARRAY)
DO ADD2
if X=""!(X="^")
QUIT
GOTO ADD
ADDED WRITE !,"Enter the number(s) of the DRUG to ADD or ""N"" for NEW: "
+1 READ GMRAX:DTIME
if '$TEST
SET GMRAX="^^"
IF "^^"[GMRAX
SET GMRAOUT=$LENGTH(GMRAX)
QUIT
+2 IF "??"[GMRAX
WRITE !,"ENTER THE NUMBER(S) OF THE ENTRY YOU WANT OR ""N"" FOR A NEW DRUG"
if $LENGTH(GMRAX)=1
GOTO ADDED
GOTO ADD
+3 IF GMRAX="n"
SET GMRAX="N"
+4 IF GMRAX="N"
DO ADD2
if X=""
QUIT
GOTO ADD
+5 IF '$$VALST^GMRAPHR2(GMRAX,"PH")
WRITE !,$CHAR(7),"INVALID SELECTION PLEASE SELECT ONE OF THE DRUGS LISTED OR ""N"" FOR A NEW DRUG"
GOTO ADD
+6 SET GMRALST=0
FOR
SET GMRALST=$ORDER(GMRALST(GMRALST))
if GMRALST<1
QUIT
SET GMRAX=GMRALST
Begin DoDot:1
+7 SET X=$PIECE(GMRARRAY("PH",GMRAX),U,2)
+8 IF $DATA(^GMR(120.85,GMRAPA1,13,"B",X))
Begin DoDot:2
+9 WRITE !,"You already have a ",X," drug on file."
+10 SET %=2
FOR
WRITE !,"Do You still want to add this one"
DO YN^DICN
if %=-1
SET %=2
SET GMRAOUT=1
if %
QUIT
WRITE !,"ENTER YES TO ADD THE DRUG or NO TO SELECT ANOTHER"
+11 QUIT
End DoDot:2
if GMRAOUT!(%-1)
QUIT
KILL %
+12 KILL DD,DO
+13 IF '$ORDER(^GMR(120.85,GMRAPA1,13,0))
SET ^(0)="^120.8513^^"
+14 SET DA(1)=GMRAPA1
SET DIC="^GMR(120.85,"_GMRAPA1_",13,"
SET DIC(0)="L"
SET DLAYGO=120.85
DO FILE^DICN
if (+Y<1)
QUIT
+15 SET DA=+Y
SET DIE=DIC
KILL DIC
+16 IF $PIECE(GMRARRAY("PH",GMRAX),U)="OP"
SET DR="3////"_$PIECE(GMRARRAY("PH",GMRAX),U,4)_";4////"_$EXTRACT($PIECE(GMRARRAY("PH",GMRAX),U,3),1,30)
+17 IF $PIECE(GMRARRAY("PH",GMRAX),U)="D"
Begin DoDot:2
+18 ;23 Only get date
SET DR="1////"_$PIECE(GMRARRAY("PH",GMRAX),U,6)_";2////"_$PIECE($PIECE(GMRARRAY("PH",GMRAX),U,7),".")
+19 SET DR=DR_";4////"_$PIECE(GMRARRAY("PH",GMRAX),U,3)_" "_$PIECE(GMRARRAY("PH",GMRAX),U,4)_" "_$PIECE(GMRARRAY("PH",GMRAX),U,5)
+20 QUIT
End DoDot:2
+21 IF $PIECE(GMRARRAY("PH",GMRAX),U)="IV"
Begin DoDot:2
+22 ;23 Get date not time
SET DR="1////"_$PIECE(GMRARRAY("PH",GMRAX),U,6)_";2////"_$PIECE($PIECE(GMRARRAY("PH",GMRAX),U,7),".")
+23 SET DR=DR_";4////"_$PIECE(GMRARRAY("PH",GMRAX),U,3)_" IV "_$PIECE(GMRARRAY("PH",GMRAX),U,4)_" "_$PIECE(GMRARRAY("PH",GMRAX),U,5)
+24 QUIT
End DoDot:2
+25 DO ^DIE
KILL DIE,DA,DR,GMRAX
+26 QUIT
End DoDot:1
if GMRAOUT
QUIT
+27 ;G ADD
+28 QUIT
ADD2 ;
+1 IF '$ORDER(^GMR(120.85,GMRAPA1,13,0))
SET ^(0)="^120.8513^^"
+2 SET DA=GMRAPA1
SET DIE="^GMR(120.85,"
SET DLAYGO=120.85
SET DR="13"
DO ^DIE
+3 KILL DIE,DA,DR
+4 QUIT
DEL ;
+1 IF '$DATA(^GMR(120.85,GMRAPA1,13,0))
WRITE !,"THERE ARE NO DRUGS SELECTED FOR THIS PATIENT."
QUIT
+2 KILL DA,DO,DIC,DIE,DLAYGO,DR
+3 SET DA(1)=GMRAPA1
SET DIC="^GMR(120.85,"_DA(1)_",13,"
SET DIC(0)="AMQEZ"
DO ^DIC
+4 IF $DATA(DUOUT)!($DATA(DTOUT))!(Y=-1)
SET GMRAOUT=1
GOTO DQ
+5 KILL DIC,DA,DO
+6 SET DA(1)=GMRAPA1
SET DIK="^GMR(120.85,"_DA(1)_",13,"
SET DA=+Y
DO ^DIK
WRITE "DELETED.."
DQ KILL DIC,DIC,DA,DO,DLAYGO,DIK,Y
+1 QUIT
LST IF '$ORDER(^GMR(120.85,GMRAPA1,13,0))
WRITE !,"THIS PATIENT HAS NO CONCOMITANT DRUGS ON FILE"
QUIT
+1 WRITE !!,"This patient has the following Drugs selected: ",!
+2 SET GMRAX=0
FOR GMRAXX=1:1
SET GMRAX=$ORDER(^GMR(120.85,GMRAPA1,13,GMRAX))
if GMRAX<1
QUIT
WRITE !,?10,$PIECE(^(GMRAX,0),U)
+3 WRITE !
KILL GMRAXX,GMRAX
+4 QUIT
EXIT ;EXIT LINE
+1 KILL DIR,Y,GMRALST,GMRASEL,GMRABGDT,GMRAENDT,^UTILITY("PSG",$JOB),^UTILITY("PSIV",$JOB),GMRARRAY
+2 QUIT