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

GMVHS.m

Go to the documentation of this file.
  1. GMVHS ;HIOFO/FT-RETURN PATIENT DATA UTILITY ;10/3/07
  1. ;;5.0;GEN. MED. REC. - VITALS;**3,23**;Oct 31, 2002;Build 25
  1. ;
  1. ; This routine uses the following IAs:
  1. ; #4290 - ^PXRMINDX global (controlled)
  1. ; #10040 - FILE 44 references (supported)
  1. ; #10103 - ^XLFDT calls (supported)
  1. ; #10104 - ^XLFSTR calls (supported)
  1. ;
  1. ; This routine supports the following IAs:
  1. ; EN1 - 4791 (private)
  1. ;
  1. EN1 ; Entry to gather patient's vital/measurement data
  1. ; Input variables
  1. ;
  1. ; DFN = Entry number of patient in Patient file. (Required)
  1. ; GMRVSTR = types of vital/measurements desired. Use the abbreviations
  1. ; found in the Vital Type (120.51) file. For multiple
  1. ; vitals, use the ; as a delimiter. (Required)
  1. ; GMRVSTR(0) = GMRVSTDT^GMRVENDT^GMRVOCC^GMRVSORD
  1. ; where GMRVSTDT = The start date/time that the utility will
  1. ; use in obtaining patient data. (Required)
  1. ; GMRVENDT = The end date/time that the utility will use
  1. ; to stop the search. (Required)
  1. ; GMRVOCC = The number of occurrences of the data that
  1. ; is desired by the search. (Required)
  1. ; GMRVSORD = The sort order desired in output. 0 will sort
  1. ; the data by vital type, then by date/time entered.
  1. ; 1 will sort the data by date/time entered, then by
  1. ; vital type. (REQUIRED)
  1. ; GMRVSTR("LT") = ^TYP1^[TYP2^...] (OPTIONAL)
  1. ; THIS VARIABLE IS AN ^ DELIMITED LIST OF HOSPITAL LOCATION
  1. ; TYPES TO EXTRACT MEASUREMENT DATA FOR. E.G., ^C^M^, WILL
  1. ; EXTRACT DATA FOR ONLY THOSE MEASUREMENTS TAKEN ON CLINICS
  1. ; OR MODULES.
  1. ;
  1. ; Output variables:
  1. ;
  1. ; The utility will create an array with the desired information. The
  1. ; array structure will be as follows if '$P(GMRVSTR(0),U,4):
  1. ; ^UTILITY($J,"GMRVD",GMRVTYP,GMRVRDT,GMRVIEN)=GMRVDATA
  1. ; or if $P(GMRVSTR(0),U,4) then the following will be returned:
  1. ; ^UTILITY($J,"GMRVD",GMRVRDT,GMRVTYP,GMRVIEN)=GMRVDATA
  1. ; where GMRVRDT = Reverse FileMan date/time.
  1. ; 9999999-Date/time vital/measurement was taken.
  1. ; GMRVTYP = The abbreviation used in the GMRVSTR string for the
  1. ; type of vital/measurement taken.
  1. ; GMRVIEN = Entry number in FILE 120.5 or
  1. ; pseudo entry number for File 704.117
  1. ;
  1. ; $P(GMRVDATA,"^",1) = date/time of the reading (FileMan internal)
  1. ; $P(GMRVDATA,"^",2) = Patient (#2) number (i.e., DFN)
  1. ; $P(GMRVDATA,"^",3) = vital type ien (File 120.51)
  1. ; $P(GMRVDATA,"^",4) = date/time of data entry (FileMan internal)
  1. ; $P(GMRVDATA,"^",5) = hospital location ien (File 44)
  1. ; $P(GMRVDATA,"^",6) = user ien (File 200)
  1. ; $P(GMRVDATA,"^",7) = always null
  1. ; $P(GMRVDATA,"^",8) = reading (e.g., 98.6, Unavailable)
  1. ; $P(GMRVDATA,"^",9) = always null
  1. ; $P(GMRVDATA,"^",10) = the first qualifier
  1. ; $P(GMRVDATA,"^",11) = the second qualifier
  1. ; $P(GMRVDATA,"^",12)= "*" for abnormal measurement, otherwise = ""
  1. ; $P(GMRVDATA,"^",13)= values in centigrade for T; kilos for WT;
  1. ; centimeters for HT and Circumference/Girth;
  1. ; and mmHg for CVP
  1. ; $P(GMRVDATA,"^",14)= Body Mass Index
  1. ; $P(GMRVDATA,"^",15)= L/Min of supplemental O2
  1. ; $P(GMRVDATA,"^",16)= % of supplemental O2
  1. ; $P(GMRVDATA,"^",17)= all qualifiers delimited by semi-colons
  1. ; The variable GMRVSTR will be killed upon exit.
  1. ;
  1. Q:'$D(GMRVSTR(0))!'($D(GMRVSTR)#2)!'($D(DFN)#2)
  1. Q:DFN'>0
  1. I $G(GMRVSTR("LT"))="" S GMRVSTR("LT")="" ;hospital location list
  1. HSKPING ; Housekeeping
  1. K ^UTILITY($J,"GMRVD")
  1. N GMVABNML,GMVDATA,GMVEND,GMVHTIEN,GMVID,GMVIEN,GMVLOOP,GMVMAX,GMVOCC,GMVRATE,GMVSORD,GMVSTART,GMVTIEN,GMVTYPE,GMVWTIEN
  1. D RANGE^GMVHS1
  1. F GMVLOOP=1:1:$L(GMRVSTR,";") D
  1. .S GMVTYPE=$P(GMRVSTR,";",GMVLOOP)
  1. .Q:GMVTYPE=""
  1. .S GMVMAX(GMVTYPE)=0
  1. .Q
  1. S GMVOCC=$P(GMRVSTR(0),U,3) ;max # of occurrences
  1. S GMVSORD=$P(GMRVSTR(0),U,4) ;sort order
  1. S GMVID=0 ;substitute IEN for GUID
  1. S GMVWTIEN=$$GETTYPEI("WT"),GMVHTIEN=$$GETTYPEI("HT")
  1. F GMRVSTR(1)=1:1:$L(GMRVSTR,";") S GMVTYPE=$P(GMRVSTR,";",GMRVSTR(1)) I $L(GMVTYPE) S GMVSTART=$S($P(GMRVSTR(0),U,1)>0:$P(GMRVSTR(0),U,1),1:0),GMVEND=$S($P(GMRVSTR(0),U,2):$P(GMRVSTR(0),U,2)+.000001,1:$$NOW^XLFDT()) D GETDATE
  1. K GMRVSTR
  1. Q
  1. GETDATE ; Loop thru PXRMINDX xref
  1. S GMVTIEN=$O(^GMRD(120.51,"C",GMVTYPE,0)) ;vital type ien
  1. Q:'GMVTIEN
  1. S GMVLOOP=GMVEND
  1. F S GMVLOOP=$O(^PXRMINDX(120.5,"PI",DFN,GMVTIEN,GMVLOOP),-1) Q:GMVLOOP<GMVSTART!(GMVLOOP'>0)!(GMVMAX(GMVTYPE)'<GMVOCC) D GETNODE
  1. Q
  1. GETNODE ; Get patient record
  1. N GMVCLIO,GMVQLIST,GMVQLOOP,GMVQNAME
  1. S GMVIEN=0
  1. F S GMVIEN=$O(^PXRMINDX(120.5,"PI",DFN,GMVTIEN,GMVLOOP,GMVIEN)) Q:$L(GMVIEN)'>0!(GMVMAX(GMVTYPE)'<GMVOCC) D
  1. .I GMVIEN=+GMVIEN D
  1. ..D F1205^GMVUTL(.GMVCLIO,GMVIEN)
  1. .I GMVIEN'=+GMVIEN D
  1. ..D CLIO^GMVUTL(.GMVCLIO,GMVIEN)
  1. .S GMVCLIO(0)=$G(GMVCLIO(0)),GMVCLIO(5)=$G(GMVCLIO(5))
  1. .I GMVCLIO(0)=""!($P(GMVCLIO(0),U,8)="") Q
  1. .I $L(GMRVSTR("LT")) Q:$P(GMVCLIO(0),U,5)'>0 Q:GMRVSTR("LT")'[("^"_$$GET1^DIQ(44,$P(GMVCLIO(0),U,5)_",",2,"I")_"^") ;hospital location check
  1. .S GMVMAX(GMVTYPE)=GMVMAX(GMVTYPE)+1
  1. .S GMVRATE=$P(GMVCLIO(0),U,8)
  1. .D ZERONODE
  1. .S GMVQLIST=""
  1. .F GMVQLOOP=1:1 Q:$P($G(GMVCLIO(5)),U,GMVQLOOP)="" D
  1. ..S GMVQNAME=$$FIELD^GMVGETQL($P(GMVCLIO(5),U,GMVQLOOP),1,"E")
  1. ..I GMVQNAME=""!(GMVQNAME=-1) Q
  1. ..S GMVQLIST=GMVQLIST_$S(GMVQLIST'="":";",1:"")_GMVQNAME
  1. .S $P(GMVDATA,U,17)=GMVQLIST
  1. .S $P(GMVDATA,U,10)=$P(GMVQLIST,";",1)
  1. .S $P(GMVDATA,U,11)=$P(GMVQLIST,";",2)
  1. .I GMVTYPE="PO2" D PO2($P(GMVCLIO(0),U,10))
  1. .D METRIC
  1. .D:$P(GMVCLIO(0),U,3)=GMVWTIEN BMI ;calculate BMI for weight
  1. .D:$$TEXT^GMVHS1(GMVRATE) ABNORMAL^GMVHS1
  1. .I GMVIEN=+GMVIEN S GMVID=GMVIEN
  1. .I GMVIEN'=+GMVIEN S GMVID=GMVID+1
  1. .D SET
  1. .Q
  1. Q
  1. GETTYPEI(GMVTIEN) ; Return vital type (120.51) ien
  1. ; GMVTIEN = vital type abbreviation
  1. S GMVTIEN=$G(GMVTIEN)
  1. I GMVTIEN="" Q 0
  1. Q $O(^GMRD(120.51,"C",GMVTIEN,0))
  1. ;
  1. ZERONODE ; Get zero node data
  1. S GMVDATA=$P($G(GMVCLIO(0)),U,1,8)_"^^^^^^^^^"
  1. Q
  1. PO2(X) ; Get flow rate and liters/minute for Pulse Oximetry reading
  1. N GMVCONC,GMVFLOW
  1. S (GMVFLOW,GMVCONC)=""
  1. I X["%" D
  1. .S GMVCONC=$P(X,"%")
  1. .I GMVCONC["l/min" S GMVCONC=$P(GMVCONC,"l/min",2)
  1. I X["l/min" D
  1. .S GMVFLOW=$P(X,"l/min")
  1. .I GMVFLOW["%" S GMVFLOW=$P(GMVFLOW,"%",2)
  1. S GMVFLOW=$$STRIP^XLFSTR(GMVFLOW," ")
  1. S GMVCONC=$$STRIP^XLFSTR(GMVCONC," ")
  1. S $P(GMVDATA,U,15)=GMVFLOW
  1. S $P(GMVDATA,U,16)=GMVCONC
  1. Q
  1. METRIC ; Calculate metric value for temperature, height, weight and
  1. ; circumference/girth
  1. N GMVMETRC
  1. S GMVMETRC=""
  1. Q:'$$TEXT^GMVHS1(GMVRATE) ;quit if not a numeric reading
  1. I GMVTYPE="T" D
  1. .S GMVMETRC=$J(GMVRATE-32*5/9,0,1)
  1. .Q
  1. I GMVTYPE="HT" D
  1. .S GMVMETRC=$J(2.54*GMVRATE,0,2)
  1. .Q
  1. I GMVTYPE="WT" D
  1. .S GMVMETRC=$J(GMVRATE*.45359237,0,2)
  1. .Q
  1. I GMVTYPE="CG" D
  1. .S GMVMETRC=$J(2.54*GMVRATE,0,2)
  1. .Q
  1. I GMVTYPE="CVP" D
  1. .S GMVMETRC=$J(GMVRATE/1.36,0,2)
  1. .Q
  1. I GMVMETRC]"" S $P(GMVDATA,U,13)=GMVMETRC
  1. Q
  1. BMI ; Calculate Body Mass Index
  1. N GMVBMI
  1. S GMVBMI=""
  1. S GMVBMI=$$CALCBMI^GMVHS1(GMVCLIO(0))
  1. S $P(GMVDATA,U,14)=GMVBMI
  1. Q
  1. SET ; Set UTILITY($J,"GMRVD") node
  1. S:'GMVSORD ^UTILITY($J,"GMRVD",GMVTYPE,9999999-GMVLOOP,GMVID)=GMVDATA
  1. S:GMVSORD ^UTILITY($J,"GMRVD",9999999-GMVLOOP,GMVTYPE,GMVID)=GMVDATA
  1. Q