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

GMRAPER2.m

Go to the documentation of this file.
GMRAPER2 ;HIRMFO/WAA CENTRAL ENTRY FOR REACTIONS ;17-Aug-2011 14:49;DU
 ;;4.0;Adverse Reaction Tracking;**1002,1003**;Mar 29, 1996;Build 18
 ;IHS/MSC/MGH added source of information
EN1(GMRAIEN,GMRAFILE,GMRAOUT,GMRAODT) ; ENTRY TO EDIT THE OBSERVED A/AR DATA
 ; INPUT
 ;   GMRAPIEN = THE INTERNAL ENTRY NUMBER FOR THE REACTION
 ;   GMRAFILE = THE FILE NUMBER OF THE ENTRY IE 120.9 OR 120.85
 ;    GMRAODT = THE OBSERVED DATE OF THE REACTION (OPTIONAL)
 ;OUTOUT
 ;    GMRAOUT = IF 0 USER EXITED NORMALY
 ;
 N DFN,GMRAOTH,GMRAX,GMRAY,GMRASITE,GMRANDT,GMRAREAC,GMRARECN
 N GMRARPR,GMRACHC,GMRAR10,GMRAASK,GMRADATE
 S GMRAODT=$G(GMRAODT)
 ; v--> define other entry
 D SITE^GMRAUTL S GMRAY=GMRASITE ; Get site parameters
SITE ; v--> Load predefined sign and symptoms from SITE FILE
 F GMRAX=1:1:10 D
 .S X=$S($D(^GMRD(120.84,GMRAY,1,GMRAX,0)):$P(^(0),U),1:"")
 .S Y=$S($D(^GMRD(120.83,+X,0)):^(0),1:""),GMRAR10(GMRAX)=$S(X'=""!(Y'=""):X_U_Y,1:"")
 .Q
 S GMRAOTH=$G(GMRAOTH,$O(^GMRD(120.83,"B","OTHER REACTION",0)))
 ;Process what file
 I GMRAFILE=120.8 S GMRAND=10 D PAT
 I GMRAFILE=120.85 S GMRAND=2 D ADR
 D LOAD(GMRAIEN,GMRAFILE,GMRAND)
 S GMRADATE="",GMRSRC=""
 D EN1^GMRAPER0 G:GMRAOUT EXIT
 N GMRAFLG S GMRAFLG=0
 S:'$D(^GMR(GMRAFILE,GMRAIEN,GMRAND,0)) ^(0)=$S(GMRAFILE="120.8":"^120.81P^^",1:"^120.8502P^^")
 ; v--Add S/S that are in file 120.82
 ;IHS/MSC/MGH add source to reaction
 F GMRAREC=0:0 S GMRAREC=$O(GMRARAD(GMRAREC)) Q:GMRAREC'>0  D
 .S X=GMRAREC_"^^"_DUZ_U_$P(GMRARAD(GMRAREC),U,2)
 .S X2=$P(GMRAWHO(GMRAREC),U,2) D ADREAC S GMRAFLG=1
 ; v--Add Other S/S Freetext
 S GMRAREC="" F GMRAX=0:0 S GMRAREC=$O(GMRAROT(GMRAREC)) Q:GMRAREC=""  S X=GMRAOTH_U_GMRAREC_U_DUZ_U_$P(GMRAROT(GMRAREC),U,2) D ADREAC S GMRAFLG=1
 ; v--Delete a S/S
 S DA(1)=GMRAIEN,DIK="^GMR("_GMRAFILE_","_DA(1)_","_GMRAND_","
 S GMRAREC=0 F  S GMRAREC=$O(GMRARDL(GMRAREC)) Q:GMRAREC'>0  S DA=0 F  S DA=$O(^GMR(GMRAFILE,DA(1),GMRAND,"B",GMRAREC,DA)) Q:DA<1  D ^DIK S GMRAFLG=1
 ; v--delete other S/S entries
 S DA(1)=GMRAIEN,DIK="^GMR("_GMRAFILE_","_DA(1)_","_GMRAND_","
 S GMRAREC="" F  S GMRAREC=$O(GMRAROTD(GMRAREC)) Q:GMRAREC=""  S DA=0 F  S DA=$O(^GMR(GMRAFILE,DA(1),GMRAND,"B",GMRAOTH,DA)) Q:DA'>0  I $D(^GMR(GMRAFILE,DA(1),GMRAND,DA,0)),$P(^(0),U,2)=GMRAREC D ^DIK S GMRAFLG=1
 I GMRAFLG D:GMRAFILE'=120.85 EN1^GMRAPTB
 Q
ADREAC ; ADD ENTRY TO SIGNS/SYMPTOMS MULTIPLE
 S GMRAZN=$P(^GMR(GMRAFILE,GMRAIEN,GMRAND,0),U,3,4),DA=$P(GMRAZN,U)+1 F DA=DA:1 Q:'$D(^GMR(GMRAFILE,GMRAIEN,GMRAND,DA,0))
 S ^GMR(GMRAFILE,GMRAIEN,GMRAND,DA,0)=X
 S DA(1)=GMRAIEN
 S DIK="^GMR("_GMRAFILE_",DA(1),"_GMRAND_","  D IX1^DIK S $P(^GMR(GMRAFILE,GMRAIEN,GMRAND,0),U,3,4)=DA_U_($P(GMRAZN,U,2)+1)
 ;IHS/MSC/MGH Added source for reaction
 I +X2 D
 .S DIE="^GMR(120.8,GMRAIEN,GMRAND,"
 .S DA(1)=GMRAIEN,DR="9999999.11///^S X=X2"
 .D ^DIE
 .K DIE,DR
 Q
PAT ;This is to process entries in file 120.8 on the 10 mutli.
 S GMRAPA=GMRAIEN
 N DFN S DFN=$P($G(^GMR(120.8,GMRAPA,0)),U) I 'DFN W !,"BAD DATA CONTACT IRM",$C(7) S GMRAOUT=1 Q  ; Validate entry
 S GMRAPA(0)=^GMR(120.8,GMRAPA,0)
 Q
ADR ;This is to load the data in 120.85 on the 2 Multi.
 S GMRANDT=1
 S GMRAPA1=GMRAIEN
 S GMRAPA1(0)=$G(^GMR(120.85,GMRAPA1,0)) I GMRAPA1(0)="" W !,"BAD DATA CONTACT IRM",$C(7) S GMRAOUT=1 Q  ; Validate entry
 S GMRAPA=$P(GMRAPA1(0),U,15),GMRAPA(0)=$G(^GMR(120.8,GMRAPA,0))  I GMRAPA="" W !,"BAD DATA CONTACT IRM",$C(7) S GMRAOUT=1 Q  ; Validate entry
 Q
LOAD(GMRAIEN,GMRAFILE,GMRAND) ;
 ;Load existing entries in the given file
 ;INPUT:
 ;     GMRAIEN IS THE IEN OF THE FILE THAT IS BEING EDITED
 ;     GMRAFILE IS THE FILE NUMBER
 ;     GMRAND IS THE NODE MULTI
 ;OUTPUT
 ;
 N X,Y,Z
 S GMRAX=0  F  S GMRAX=$O(^GMR(GMRAFILE,GMRAIEN,GMRAND,GMRAX)) Q:GMRAX<1  D
 .S Y=$S($D(^GMR(GMRAFILE,GMRAIEN,GMRAND,GMRAX,0)):^(0),1:"")
 .S X=$S(+Y=GMRAOTH:$P(Y,U,2),$D(^GMRD(120.83,+Y,0)):$P(^GMRD(120.83,+Y,0),U),1:"")
 .;Patch 1003 IHS/MSC/MGH
 .I X'="",Y'="" D
 ..S GMRARPR(X,+Y)=X_U_$P(Y,U,3)_U_$P(Y,U,4)
 ..S Z=$S($D(^GMR(GMRAFILE,GMRAIEN,GMRAND,GMRAX,9999999.11)):^(9999999.11),1:"")
 ..I Z'="" S GMRARPR(X,+Y)=GMRARPR(X,+Y)_U_$P(Z,U,1)
 .Q
 Q
EXIT ;KILL CLEAN
 Q
SOURCE() ;Get the source
 N DA,DIC,DR,Y
 S DIC=90460.05
 S DIC(0)="AEMQ"
 S DIC("S")="I $P(^(0),U,2)=""S"""
 S DIC("A")="Select source: "
 D ^DIC  I $D(DIRUT) K DIRUT Q -1
 Q Y