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

BPXRMLAB.m

Go to the documentation of this file.
  1. BPXRMLAB ; IHS/MSC/MGH - Use V Labs in reminder resolution. ;25-Nov-2013 14:52;DU
  1. ;;2.0;CLINICAL REMINDERS;**1001**;Feb 04, 2005;Build 21
  1. ;===================================================================
  1. VLAB(DFN,TEST,DATE,VALUE,TEXT) ;EP
  1. N BPXTRM
  1. Q:TEST=""
  1. S BPXTRM="" S BPXTRM=$O(^PXRMD(811.5,"B",TEST,BPXTRM))
  1. I BPXTRM="" S TEST=0,DATE=DT,TEXT="Reminder term does not exist" Q
  1. D GETVAR(BPXTRM)
  1. Q
  1. GETVAR(BPXTRM) ;EP
  1. ;Get the needed data from the reminder term. This includes
  1. ;the test name(s) and the value to search for
  1. N X,Y,BPXFIND,BPXTYPE,BPXOFF,BPXFILE,BPXRESLT,BPXCNT,BPXTEST
  1. K ^TMP("PXRMLAB",$J)
  1. S BPXCNT=0,BPXRESLT=0
  1. S BPXFIND=0 F S BPXFIND=$O(^PXRMD(811.5,BPXTRM,20,BPXFIND)) Q:BPXFIND=""!(BPXFIND?1A.A)!(BPXRESLT=1) D
  1. .S BPXTYPE=$P($G(^PXRMD(811.5,BPXTRM,20,BPXFIND,0)),U,1)
  1. .S BPXTEST=$P(BPXTYPE,";",1),BPXFILE=$P(BPXTYPE,";",2)
  1. .;This needs to be a term of laboratory tests
  1. .Q:BPXFILE'="LAB(60,"
  1. .S BPXOFF=$P($G(^PXRMD(811.5,BPXTRM,20,BPXFIND,0)),U,8)
  1. .;Call next routine with patient,start and stop dates,test name
  1. .D RESULT(DFN,BPXTEST)
  1. ;Loop through results and return most recent
  1. S BPXRESLT="" S BPXRESLT=$O(^TMP("PXRMLAB",$J,BPXRESLT))
  1. I BPXRESLT="" S TEST=0,VALUE=TEST
  1. I +BPXRESLT D
  1. .S TEST=1,VALUE=$P($G(^TMP("PXRMLAB",$J,BPXRESLT)),U,6)
  1. .S DATE=$P($G(^TMP("PXRMLAB",$J,BPXRESLT)),U,5)
  1. .S TEXT=$P($G(^TMP("PXRMLAB",$J,BPXRESLT)),U,2)
  1. Q
  1. RESULT(DFN,LABIEN) ;EP
  1. ;EP Find a patients labs in the V LAB file
  1. ;Get up to ten results of the specified lab test
  1. ;If the result has an associated LR ACCESSION NUMBER quit
  1. ;If not, add it to the array to be used in the reminder
  1. ;===================================================================
  1. N VLIEN,INVDATE,TEMP,COUNT
  1. S INVDATE="",COUNT=0
  1. F S INVDATE=$O(^AUPNVLAB("AA",DFN,LABIEN,INVDATE)) Q:INVDATE=""!(COUNT>10) D
  1. .S VLIEN="" F S VLIEN=$O(^AUPNVLAB("AA",DFN,LABIEN,INVDATE,VLIEN)) Q:VLIEN="" D
  1. ..S TEMP=$G(^AUPNVLAB(VLIEN,0))
  1. ..I TEMP'="" D STORE
  1. Q
  1. STORE ;Store the needed data into TMP for use in reminders
  1. N FLAG,UNITS,TEMP1,TEMP2,VAL,EVDT,VIEN
  1. S COUNT=COUNT+1
  1. S TEMP1=$G(^AUPNVLAB(VLIEN,11))
  1. S VAL=$P(TEMP,U,4) I VAL="" S VAL="pending"
  1. S FLAG=$P(TEMP,U,5)
  1. S UNITS=$P(TEMP1,U,1)
  1. S VIEN=$P(TEMP,U,3)
  1. S EVDT=$$GET1^DIQ(9000010.09,VLIEN,1201,"I")
  1. I EVDT="" S EVDT=$$GET1^DIQ(9000010,VIEN,.01,"I")
  1. S TEMP2=LABIEN_U_VAL_U_FLAG_U_UNITS_U_EVDT
  1. S $P(TEMP2,U,6)=$P($G(^LAB(60,LABIEN,.1)),"^")
  1. S ^TMP("PXRMLAB",$J,INVDATE)=TEMP2
  1. Q