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

GMRAHDR.m

Go to the documentation of this file.
  1. GMRAHDR ;SLC/DAN - HDR CALLS FOR ART ;01/13/2014 07:54
  1. ;;4.0;Adverse Reaction Tracking;**18,24,26,42,46**;Mar 29, 1996;Build 62
  1. ;
  1. ;The variable GMRADONT can be set before making a call to this
  1. ;routine if you'd like to be able to change data but not have it
  1. ;sent to the HDR. If GMRADONT has a positive value then nothing
  1. ;will be queued to be sent to the HDR.
  1. ;A check will also be made for the existence of XDRDVALF to indicate
  1. ;whether a patient merge is taking place. If so, then data isn't
  1. ;sent to the HDR.
  1. ;
  1. SETADR ;Call here when updating data
  1. N IEN,OIEN
  1. I $G(GMRADONT)!($G(XDRDVALF)=1) Q ;Don't send HDR information if variable is set
  1. S IEN=$S($D(DA)=1:DA,1:DA($O(DA("?"),-1)))
  1. I +$P($G(^GMR(120.8,IEN,0)),U,12)=0 Q ;Stop if it isn't signed off yet
  1. I $$TESTPAT^VADPT($P(^GMR(120.8,IEN,0),U)) Q ;24 Don't send data for test patients
  1. D TASK("ADR",IEN) ;26 Schedule entry to be sent to HDR
  1. I $P($G(^GMR(120.8,IEN,0)),U,6)="o" S OIEN=+$O(^GMR(120.85,"C",IEN,0)) I $D(^GMR(120.85,OIEN,0)),'+$G(^GMR(120.8,IEN,"ER")) D TASK("OBS",OIEN) ;If observed reaction, send observed data on sign off
  1. Q
  1. ;
  1. KILLADR ;Call here when data is deleted
  1. N IEN
  1. I $G(GMRADONT)!($G(XDRDVALF)=1) Q ;Don't send data to HDR if variable is set
  1. S IEN=$S($D(DA)=1:DA,1:DA($O(DA("?"),-1)))
  1. I $P($G(^GMR(120.8,IEN,0)),U,12)=0 Q ;Stop if it isn't signed off yet
  1. I $$TESTPAT^VADPT($P(^GMR(120.8,IEN,0),U)) Q ;24 Don't send data for test patients
  1. D TASK("ADR",IEN) ;26 Schedule entry to be sent to the HDR
  1. Q
  1. ;
  1. SETAA ;Action taken when assessment is changed
  1. I $G(GMRADONT)!($G(XDRDVALF)=1) Q ;Don't send data if variable is set
  1. I $$TESTPAT^VADPT(DA) Q ;24 Don't send data for test patients
  1. D TASK("ASMT",DA)
  1. Q
  1. ;
  1. KILLAA ;Action taken when value is deleted
  1. I $G(GMRADONT)!($G(XDRDVALF)=1) Q ;Don't send data to HDR if variable is set
  1. I $$TESTPAT^VADPT(DA) Q ;24 Don't send data for test patients
  1. D TASK("ASMT",DA)
  1. Q
  1. ;
  1. SETOB ;Make call to HDR when observation data is added or edited
  1. N IEN,AIEN
  1. I $G(GMRADONT)!($G(XDRDVALF)=1) Q ;Don't send data to HDR if variable is set
  1. S IEN=$S($D(DA)=1:DA,1:DA($O(DA("?"),-1)))
  1. S AIEN=+$P($G(^GMR(120.85,IEN,0)),U,15) Q:'+AIEN ;Stop if there's no related reaction
  1. I $P($G(^GMR(120.8,AIEN,0)),U,12)=0 Q ;Stop if related reaction not signed off
  1. I $$TESTPAT^VADPT($P(^GMR(120.8,AIEN,0),U)) Q ;24 Don't send data for test patients
  1. D TASK("OBS",IEN)
  1. Q
  1. ;
  1. KILLOB ;Action upon deletion of observation data
  1. N IEN,AIEN
  1. I $G(GMRADONT)!($G(XDRDVALF)=1) Q ;Don't send data to HDR if variable is set
  1. S IEN=$S($D(DA)=1:DA,1:DA($O(DA("?"),-1)))
  1. S AIEN=+$P($G(^GMR(120.85,IEN,0)),U,15) Q:'AIEN ;Quit if there's no related reaction
  1. I +$P($G(^GMR(120.8,AIEN,0)),U,12)=0 Q ;Quit if related reaction not signed off
  1. I $$TESTPAT^VADPT($P(^GMR(120.8,AIEN,0),U)) Q ;24 Don't send data for test patients
  1. D TASK("OBS",IEN)
  1. Q
  1. ;
  1. TASK(TYPE,IEN) ;Create task, if needed, and add entry to list of items to be sent to HDR
  1. N ZTRTN,ZTDESC,ZTDTH,ZTSK,ZTIO
  1. F L +^XTMP("GMRAHDR"):1 Q:$T ;Control global so no new entries are added
  1. ;Check if task exists, if so and it's older than 10 minutes and it's not scheduled to run, get a new task. Added w/patch 42
  1. I $D(^XTMP("GMRAHDR","TASK")) I $$FMDIFF^XLFDT($$NOW^XLFDT,$P(^XTMP("GMRAHDR",0),U,2),2)>600 I '$$TSKOK(+$G(^XTMP("GMRAHDR","TASK"))) K ^XTMP("GMRAHDR","TASK") ;42
  1. I '$D(^XTMP("GMRAHDR")) S ^XTMP("GMRAHDR",0)=$$FMADD^XLFDT(DT,30)_U_$$NOW^XLFDT_U_"Send allergy data to HDR"
  1. I '$D(^XTMP("GMRAHDR","TASK")) D
  1. .S ZTRTN="DQ^GMRAHDR",ZTDESC="Transmit allergy data to HDR",ZTDTH=$$HADD^XLFDT($H,,,2),ZTIO="" D ^%ZTLOAD S ^XTMP("GMRAHDR","TASK")=ZTSK
  1. S ^XTMP("GMRAHDR",TYPE,IEN)="" ;Store off entry to be sent later
  1. L -^XTMP("GMRAHDR") ;Release lock
  1. Q
  1. ;
  1. DQ ;Send data to HDR
  1. N GMRAERR,TYPE,IEN,A
  1. F L +^XTMP("GMRAHDR"):1 Q:$T ;Get control of global
  1. F TYPE="ADR","ASMT","OBS" I $D(^XTMP("GMRAHDR",TYPE)) D
  1. .S IEN=0 F S IEN=$O(^XTMP("GMRAHDR",TYPE,IEN)) Q:'+IEN I $L($T(QUEUE^VDEFQM)) S A=$$QUEUE^VDEFQM("ORU^R01","SUBTYPE="_$S(TYPE="ADR":"ALGY",TYPE="ASMT":"ADAS",1:"ADRA")_"^IEN="_IEN,.GMRAERR)
  1. K ^XTMP("GMRAHDR")
  1. L -^XTMP("GMRAHDR")
  1. Q
  1. ;
  1. TSKOK(ZTSK) ;Check to see if task is active. Section added in patch 42
  1. D ISQED^%ZTLOAD
  1. Q +ZTSK(0)
  1. HDRDATA() ;RETRIEVE HDR DATA
  1. ;RETURN: -1 => HDR DOES NOT EXIST OR IS NOT AVAILABLE
  1. ; # => NUMBER OF RETRIEVED REACTIONS
  1. N RETURN
  1. Q:'$L($T(HAVEHDR^ORRDI1)) -1
  1. Q:'$$HAVEHDR^ORRDI1 -1
  1. S RETURN=$$GET^ORRDI1(DFN,"ART")
  1. Q RETURN