VistA-WorldVistAEHR/r/ADVERSE_REACTION_TRACKING-G.../GMRAU851.m

59 lines
3.6 KiB
Mathematica

GMRAU851 ;HIRMFO/RFM,WAA-UTILITIES FOR FILE 120.85 ;12/22/04 11:02
;;4.0;Adverse Reaction Tracking;**21**;Mar 29, 1996
HLP ;
N DIR
I '$D(^GMR(120.8,"B",DFN)) W !?4,"There are no reactions on file for this patient." Q
D HLP12085(DFN,"$$OBSDRG^GMRAU85(GMRAX)")
Q
HLP12085(DFN,SCR) ; THIS WILL LIST ENTRIES FOR PATIENT (DFN) IN FILE
; 120.85. AN OPTIONAL SCREEN (SCR), EXECUTABLE BOOLEAN FXN, WILL BE
; USED TO SCREEN OUT ENTRIES, WHILE USING SCREEN, GMRAX WILL BE 120.8
; IEN. GMRAOUT WILL BE SET TRUE IF ^/TIME OUT.
N GMRAL,GMRAX,GMRAY
I $G(SCR)="" S SCR="SCR=SCR"
S GMRAX="" F S GMRAX=$O(^GMR(120.8,"B",DFN,GMRAX)) Q:GMRAX'>0 S GMRAY=$P($G(^GMR(120.8,GMRAX,0)),U,2) I GMRAY]"",@SCR S GMRAL(GMRAY,GMRAX)=""
W #,!!,"CHOOSE FROM:" S GMRAY="" F Q:GMRAOUT S GMRAY=$O(GMRAL(GMRAY)) Q:GMRAY="" S GMRAX="" F S GMRAX=$O(GMRAL(GMRAY,GMRAX)) Q:GMRAX'>0 D Q:GMRAOUT
. I $Y>(IOSL-3) D ENDPG^GMRADSP3 Q:GMRAOUT W #
. W !?3,GMRAY
. Q
Q
HLP1 ;
I '$D(^GMR(120.85,"C",GMRAPA)) W !?4,"There are no observed date/times on file for this reaction." Q
S X="??",DIC="^GMR(120.85,",DIC(0)="EQ",DIC("S")="I $P(^(0),U,2)=DFN,$P(^(0),U,15)=GMRAPA",DIC("W")="" D ^DIC K DIC
Q
RXN ;ENTRY TO EDIT THE OBSERVED A/AR DATA
N GMRAR0 ;21
S GMRANDT=1
S GMRAPA=$P($G(^GMR(120.85,GMRAPA1,0)),U,15),GMRAPA(0)=$G(^GMR(120.8,GMRAPA,0))
S GMRAOTH=$O(^GMRD(120.83,"B","OTHER REACTION",0))
F GMRAX=0:0 S GMRAX=$O(^GMR(120.85,GMRAPA1,2,GMRAX)) Q:GMRAX'>0 S Y=$S($D(^GMR(120.85,GMRAPA1,2,GMRAX,0)):^(0),1:""),X=$S(+Y=GMRAOTH:$P(Y,"^",2),$D(^GMRD(120.83,+Y,0)):$P(^(0),"^"),1:"") I X'="",Y'="" S GMRARPR(X,+Y)=X_"^"_$P(Y,"^",3)
D SITE^GMRAUTL
S GMRAY=GMRASITE
I GMRAY>0 F GMRAX=1:1:10 S X=$S($D(^GMRD(120.84,GMRAY,1,GMRAX,0)):$P(^(0),"^"),1:""),Y=$S($D(^GMRD(120.83,+X,0)):^(0),1:""),GMRAR10(GMRAX)=$S(X'=""!(Y'=""):X_"^"_Y,1:"")
D EN1^GMRAPER0 Q:GMRAOUT S:'$D(^GMR(120.85,GMRAPA1,2,0)) ^(0)="^120.8502P^^" S:'$D(^GMR(120.8,GMRAPA,10,0)) ^(0)="^120.81P^^" ;21
F GMRAREC=0:0 S GMRAREC=$O(GMRARAD(GMRAREC)) Q:GMRAREC'>0 S GMRAR0=GMRAREC_"^^"_DUZ D ADREAC ;21
S GMRAREC="" F GMRAX=0:0 S GMRAREC=$O(GMRAROT(GMRAREC)) Q:GMRAREC="" S GMRAR0=GMRAOTH_"^"_GMRAREC_"^"_DUZ D ADREAC ;21
F GMRAREC=0:0 S GMRAREC=$O(GMRARDL(GMRAREC)) Q:GMRAREC'>0 D DELREAC ;21
S GMRAREC="" F GMRAX=0:0 S GMRAREC=$O(GMRAROTD(GMRAREC)) Q:GMRAREC="" D DELREACO ;21
Q
ADREAC ; ADD ENTRY TO SIGNS/SYMPTOMS MULTIPLE
S GMRAZN=$P(^GMR(120.85,GMRAPA1,2,0),"^",3,4),DA=$P(GMRAZN,"^")+1 F DA=DA:1 Q:'$D(^GMR(120.85,GMRAPA1,2,DA,0))
S ^GMR(120.85,GMRAPA1,2,DA,0)=GMRAR0 S DIK="^GMR(120.85,DA(1),2,",DA(1)=GMRAPA1 D IX1^DIK S $P(^GMR(120.85,GMRAPA1,2,0),"^",3,4)=DA_"^"_($P(GMRAZN,"^",2)+1)
S GMRAZN=$P(^GMR(120.8,GMRAPA,10,0),"^",3,4),DA=$P(GMRAZN,"^")+1 F DA=DA:1 Q:'$D(^GMR(120.8,GMRAPA,10,DA,0)) ;21
S ^GMR(120.8,GMRAPA,10,DA,0)=GMRAR0_"^"_DT S DIK="^GMR(120.8,DA(1),10,",DA(1)=GMRAPA D IX1^DIK S $P(^GMR(120.8,GMRAPA,10,0),"^",3,4)=DA_"^"_($P(GMRAZN,"^",2)+1) ;21
Q
;
DELREAC ;Delete reactions from 120.85 and 120.8 entire section added in patch 21
S DA(1)=GMRAPA1,DIK="^GMR(120.85,"_DA(1)_",2,"
F DA=0:0 S DA=$O(^GMR(120.85,DA(1),2,"B",GMRAREC,DA)) Q:DA'>0 D ^DIK
S DA(1)=GMRAPA,DIK="^GMR(120.8,"_DA(1)_",10,"
F DA=0:0 S DA=$O(^GMR(120.8,DA(1),10,"B",GMRAREC,DA)) Q:DA'>0 D ^DIK
Q
;
DELREACO ;Delete free text reactions, added in 21
S DA(1)=GMRAPA1,DIK="^GMR(120.85,"_DA(1)_",2,"
F DA=0:0 S DA=$O(^GMR(120.85,DA(1),2,"B",GMRAOTH,DA)) Q:DA'>0 I $D(^GMR(120.85,DA(1),2,DA,0)),$P(^(0),U,2)=GMRAREC D ^DIK
S DA(1)=GMRAPA,DIK="^GMR(120.8,"_DA(1)_",10,"
F DA=0:0 S DA=$O(^GMR(120.8,DA(1),10,"B",GMRAOTH,DA)) Q:DA'>0 I $D(^GMR(120.8,DA(1),10,DA,0)),$P(^(0),U,2)=GMRAREC D ^DIK
Q