BEHOGMEA ;IHS/MSC/MGH - APIs for Measurement Graphing. ;29-Jun-2015 09:58;PLS
;;1.1;BEH COMPONENTS;**021002**;Sep 08, 2007
Q
;===============================================================
VMEA(MEADATA,MEAIEN,MEAIB) ;Return data for a specified V Measurement entry.
; Input:
; MEADATA = Array name passed by reference (required)
; MEAIEN = IEN for FILE 9000010.01 (required)
; MEAIB = "I" for Internal value only
; "B" for Internal and External values (default = B)
;
; If MEAIB = "I", then
; Output = MEADATA(n)=internal value
;
; If MEAIB = "B", then
; Output: MEADATA(n)=internal value^external value
;
; where:
; MEADATA(1)=.01 (DATE/TIME VITALS TAKEN)
; MEADATA(2)=.02 (PATIENT)
; MEADATA(3)=.03 (VITAL TYPE)
; MEADATA(4)=.04 (DATE/TIME VITALS ENTERED)
; MEADATA(5)=.05 (HOSPITAL LOCATION)
; MEADATA(6)=.06 (ENTERED BY)
; MEADATA(7)=1.2 (RATE)
; MEADATA(8)=1.4 (SUPPLEMENTAL O2)
; MEADATA(9)=2 (ENTERED IN ERROR)
; MEADATA(10)=3 (ERROR ENTERED BY)
; MEADATA(11,n)=4 (REASON ENTERED IN ERROR) <--multiple
; MEADATA(12,n)=5 (QUALIFIER) <--multiple
;
; If the lookup failed then: MEADATA(1)=-1^error text
;
N MEACNT,MEAIEN1,MEALIST,MEALEN,MEALOOP,MEATEMP,TEMP,TEMP2,TEMP12,VISIT,TEMP5,TP,EM
K MEADATA
I $G(MEAIB)'="I",$G(MEAIB)'="B" S MEAIB="B"
I $G(MEAIEN)="" S MEADATA(1)="-1^Record Number is Null" Q
I MEAIEN=+MEAIEN D
.S TEMP=$G(^AUPNVMSR(MEAIEN,0))
.S TEMP2=$G(^AUPNVMSR(MEAIEN,2))
.S TEMP12=$G(^AUPNVMSR(MEAIEN,12))
.S TEMP5=$G(^AUPNVMSR(MEAIEN,5))
.S VISIT=$P(TEMP,U,3)
I TEMP="" D Q
.S MEADATA(1)="-1^The entry does not exist"
.Q
;
S MEADATA(1)=$P(TEMP12,U,1) ;Date/time taken
;Event date/time not entered
I MEADATA(1)="" D
.I +VISIT D
..S MEADATA(1)=$P($G(^AUPNVSIT(VISIT,0)),U,1)
I MEAIB="B" S MEADATA(1)=$P(MEADATA(1),U,1)_U_$$FMTE^XLFDT(MEADATA(1),"M")
S MEADATA(2)=$P(TEMP,U,2) ;Patient
I MEAIB="B" S MEADATA(2)=$P(MEADATA(2),U,1)_U_$$EXTERNAL^DILFD(9000010.01,.02,"",$P(MEADATA(2),U,1),.EM)
S CHK=$P(TEMP,U,1)
S MEADATA(3)=$P($G(^AUTTMSR(CHK,0)),U,2)
;S MEADATA(3)=$P(TEMP,U,1) ;Vital Type
I MEAIB="B" S MEADATA(3)=$P(MEADATA(3),U,1)_U_$$EXTERNAL^DILFD(9000010.01,.01,"",$P(MEADATA(3),U,1),.EM)
S MEADATA(4)=$P(TEMP,U,7) ;Time entered
I MEADATA(4)="" D
.S MEADATA(4)=MEADATA(1)
I MEAIB="B" S MEADATA(4)=MEADATA(4)_U_$$FMTE^XLFDT(MEADATA(4),"M")
S MEADATA(5)=$P($G(^AUPNVSIT(VISIT,0)),U,22)
I '$D(^SC(+MEADATA(5),0)) S MEADATA(5)=0
I MEAIB="B" S MEADATA(5)=$P(MEADATA(5),U,1)_U_$$EXTERNAL^DILFD(9000010,.22,"",MEADATA(5),.EM)
S MEADATA(6)=$P(TEMP,U,8)
I MEADATA(6)="" S MEADATA(6)=$P(TEMP12,U,4)
I MEAIB="B" S MEADATA(6)=$P(MEADATA(6),U,1)_U_$$EXTERNAL^DILFD(9000010.01,.08,"",$P(MEADATA(6),U,1),.EM)
S MEADATA(7)=$P(TEMP,U,4)
I MEAIB="B" S MEADATA(7)=$P(TEMP,U,4)_U_MEADATA(7)
S MEADATA(8)=$P(TEMP,U,10)
I MEAIB="B" S MEADATA(8)=$P(TEMP,U,10)_U_MEADATA(8)
S MEADATA(9)=$P(TEMP2,U,1)
I MEAIB="B" D
.I MEADATA(9)="" S MEADATA(9)="^"
.E S MEADATA(9)=$P(MEADATA(9),U,1)_U_$$EXTERNAL^DILFD(9000010.01,2,"",$P(MEADATA(9),U,1),.EM)
S MEADATA(10)=$P(TEMP2,U,2)
I MEAIB="B" S MEADATA(10)=$P(MEADATA(10),U,1)_U_$$EXTERNAL^DILFD(9000010.01,3,"",$P(MEADATA(10),U,1),.EM)
S MEACNT=0
S MEALIST=0 F S MEALIST=$O(^AUPNVMSR(MEAIEN,2.1,MEALIST)) Q:'+MEALIST D
.S MEACNT=MEACNT+1
.S MEADATA(11,MEACNT)=$G(^AUPNVMSR(MEAIEN,2.1,MEALIST,0))
I MEACNT=0 S MEADATA(11,1)=""
S MEALOOP=0,MEACNT=0
F S MEALOOP=$O(^AUPNVMSR(MEAIEN,5,MEALOOP)) Q:'+MEALOOP D
.S MEACNT=MEACNT+1
.S MEADATA(12,MEACNT)=$G(^AUPNVMSR(MEAIEN,5,MEALOOP,0))
I MEACNT=0 S MEADATA(12,1)=""
;
;loop through entered-in-error reason multiple
I MEAIB="B" D
.S (MEACNT,MEAIEN1)=0
.F S MEAIEN1=$O(MEADATA(11,MEAIEN1)) Q:'MEAIEN1 D
..S TP=$P(MEADATA(11,MEAIEN1),U,1)
..Q:'TP
..S MEADATA(11,MEAIEN1)=TP_U_$$EXTERNAL^DILFD(9000010.014,.01,"",TP,.EM)
..S MEACNT=1
.I MEACNT=0 S MEADATA(11,1)="^"
.;loop through qualifier multiple
.S (MEACNT,MEAIEN1)=0
.F S MEAIEN1=$O(MEADATA(12,MEAIEN1)) Q:'MEAIEN1 D
..S TP=+$P(MEADATA(12,MEAIEN1),U,1)
..Q:'TP
..S MEADATA(12,MEAIEN1)=TP_U_$P($G(^GMRD(120.52,+TP,0)),U,1)
..S MEACNT=1
.I MEACNT=0 S MEADATA(12,1)="^"
Q
VAL(VAL) ;Get name from .02 field
Q $P($G(^AUTTMSR(VAL,0)),U,2)
;
BEHOGMEA ;IHS/MSC/MGH - APIs for Measurement Graphing. ;29-Jun-2015 09:58;PLS
+1 ;;1.1;BEH COMPONENTS;**021002**;Sep 08, 2007
+2 QUIT
+3 ;===============================================================
VMEA(MEADATA,MEAIEN,MEAIB) ;Return data for a specified V Measurement entry.
+1 ; Input:
+2 ; MEADATA = Array name passed by reference (required)
+3 ; MEAIEN = IEN for FILE 9000010.01 (required)
+4 ; MEAIB = "I" for Internal value only
+5 ; "B" for Internal and External values (default = B)
+6 ;
+7 ; If MEAIB = "I", then
+8 ; Output = MEADATA(n)=internal value
+9 ;
+10 ; If MEAIB = "B", then
+11 ; Output: MEADATA(n)=internal value^external value
+12 ;
+13 ; where:
+14 ; MEADATA(1)=.01 (DATE/TIME VITALS TAKEN)
+15 ; MEADATA(2)=.02 (PATIENT)
+16 ; MEADATA(3)=.03 (VITAL TYPE)
+17 ; MEADATA(4)=.04 (DATE/TIME VITALS ENTERED)
+18 ; MEADATA(5)=.05 (HOSPITAL LOCATION)
+19 ; MEADATA(6)=.06 (ENTERED BY)
+20 ; MEADATA(7)=1.2 (RATE)
+21 ; MEADATA(8)=1.4 (SUPPLEMENTAL O2)
+22 ; MEADATA(9)=2 (ENTERED IN ERROR)
+23 ; MEADATA(10)=3 (ERROR ENTERED BY)
+24 ; MEADATA(11,n)=4 (REASON ENTERED IN ERROR) <--multiple
+25 ; MEADATA(12,n)=5 (QUALIFIER) <--multiple
+26 ;
+27 ; If the lookup failed then: MEADATA(1)=-1^error text
+28 ;
+29 NEW MEACNT,MEAIEN1,MEALIST,MEALEN,MEALOOP,MEATEMP,TEMP,TEMP2,TEMP12,VISIT,TEMP5,TP,EM
+30 KILL MEADATA
+31 IF $GET(MEAIB)'="I"
IF $GET(MEAIB)'="B"
SET MEAIB="B"
+32 IF $GET(MEAIEN)=""
SET MEADATA(1)="-1^Record Number is Null"
QUIT
+33 IF MEAIEN=+MEAIEN
Begin DoDot:1
+34 SET TEMP=$GET(^AUPNVMSR(MEAIEN,0))
+35 SET TEMP2=$GET(^AUPNVMSR(MEAIEN,2))
+36 SET TEMP12=$GET(^AUPNVMSR(MEAIEN,12))
+37 SET TEMP5=$GET(^AUPNVMSR(MEAIEN,5))
+38 SET VISIT=$PIECE(TEMP,U,3)
End DoDot:1
+39 IF TEMP=""
Begin DoDot:1
+40 SET MEADATA(1)="-1^The entry does not exist"
+41 QUIT
End DoDot:1
QUIT
+42 ;
+43 ;Date/time taken
SET MEADATA(1)=$PIECE(TEMP12,U,1)
+44 ;Event date/time not entered
+45 IF MEADATA(1)=""
Begin DoDot:1
+46 IF +VISIT
Begin DoDot:2
+47 SET MEADATA(1)=$PIECE($GET(^AUPNVSIT(VISIT,0)),U,1)
End DoDot:2
End DoDot:1
+48 IF MEAIB="B"
SET MEADATA(1)=$PIECE(MEADATA(1),U,1)_U_$$FMTE^XLFDT(MEADATA(1),"M")
+49 ;Patient
SET MEADATA(2)=$PIECE(TEMP,U,2)
+50 IF MEAIB="B"
SET MEADATA(2)=$PIECE(MEADATA(2),U,1)_U_$$EXTERNAL^DILFD(9000010.01,.02,"",$PIECE(MEADATA(2),U,1),.EM)
+51 SET CHK=$PIECE(TEMP,U,1)
+52 SET MEADATA(3)=$PIECE($GET(^AUTTMSR(CHK,0)),U,2)
+53 ;S MEADATA(3)=$P(TEMP,U,1) ;Vital Type
+54 IF MEAIB="B"
SET MEADATA(3)=$PIECE(MEADATA(3),U,1)_U_$$EXTERNAL^DILFD(9000010.01,.01,"",$PIECE(MEADATA(3),U,1),.EM)
+55 ;Time entered
SET MEADATA(4)=$PIECE(TEMP,U,7)
+56 IF MEADATA(4)=""
Begin DoDot:1
+57 SET MEADATA(4)=MEADATA(1)
End DoDot:1
+58 IF MEAIB="B"
SET MEADATA(4)=MEADATA(4)_U_$$FMTE^XLFDT(MEADATA(4),"M")
+59 SET MEADATA(5)=$PIECE($GET(^AUPNVSIT(VISIT,0)),U,22)
+60 IF '$DATA(^SC(+MEADATA(5),0))
SET MEADATA(5)=0
+61 IF MEAIB="B"
SET MEADATA(5)=$PIECE(MEADATA(5),U,1)_U_$$EXTERNAL^DILFD(9000010,.22,"",MEADATA(5),.EM)
+62 SET MEADATA(6)=$PIECE(TEMP,U,8)
+63 IF MEADATA(6)=""
SET MEADATA(6)=$PIECE(TEMP12,U,4)
+64 IF MEAIB="B"
SET MEADATA(6)=$PIECE(MEADATA(6),U,1)_U_$$EXTERNAL^DILFD(9000010.01,.08,"",$PIECE(MEADATA(6),U,1),.EM)
+65 SET MEADATA(7)=$PIECE(TEMP,U,4)
+66 IF MEAIB="B"
SET MEADATA(7)=$PIECE(TEMP,U,4)_U_MEADATA(7)
+67 SET MEADATA(8)=$PIECE(TEMP,U,10)
+68 IF MEAIB="B"
SET MEADATA(8)=$PIECE(TEMP,U,10)_U_MEADATA(8)
+69 SET MEADATA(9)=$PIECE(TEMP2,U,1)
+70 IF MEAIB="B"
Begin DoDot:1
+71 IF MEADATA(9)=""
SET MEADATA(9)="^"
+72 IF '$TEST
SET MEADATA(9)=$PIECE(MEADATA(9),U,1)_U_$$EXTERNAL^DILFD(9000010.01,2,"",$PIECE(MEADATA(9),U,1),.EM)
End DoDot:1
+73 SET MEADATA(10)=$PIECE(TEMP2,U,2)
+74 IF MEAIB="B"
SET MEADATA(10)=$PIECE(MEADATA(10),U,1)_U_$$EXTERNAL^DILFD(9000010.01,3,"",$PIECE(MEADATA(10),U,1),.EM)
+75 SET MEACNT=0
+76 SET MEALIST=0
FOR
SET MEALIST=$ORDER(^AUPNVMSR(MEAIEN,2.1,MEALIST))
IF '+MEALIST
QUIT
Begin DoDot:1
+77 SET MEACNT=MEACNT+1
+78 SET MEADATA(11,MEACNT)=$GET(^AUPNVMSR(MEAIEN,2.1,MEALIST,0))
End DoDot:1
+79 IF MEACNT=0
SET MEADATA(11,1)=""
+80 SET MEALOOP=0
SET MEACNT=0
+81 FOR
SET MEALOOP=$ORDER(^AUPNVMSR(MEAIEN,5,MEALOOP))
IF '+MEALOOP
QUIT
Begin DoDot:1
+82 SET MEACNT=MEACNT+1
+83 SET MEADATA(12,MEACNT)=$GET(^AUPNVMSR(MEAIEN,5,MEALOOP,0))
End DoDot:1
+84 IF MEACNT=0
SET MEADATA(12,1)=""
+85 ;
+86 ;loop through entered-in-error reason multiple
+87 IF MEAIB="B"
Begin DoDot:1
+88 SET (MEACNT,MEAIEN1)=0
+89 FOR
SET MEAIEN1=$ORDER(MEADATA(11,MEAIEN1))
IF 'MEAIEN1
QUIT
Begin DoDot:2
+90 SET TP=$PIECE(MEADATA(11,MEAIEN1),U,1)
+91 IF 'TP
QUIT
+92 SET MEADATA(11,MEAIEN1)=TP_U_$$EXTERNAL^DILFD(9000010.014,.01,"",TP,.EM)
+93 SET MEACNT=1
End DoDot:2
+94 IF MEACNT=0
SET MEADATA(11,1)="^"
+95 ;loop through qualifier multiple
+96 SET (MEACNT,MEAIEN1)=0
+97 FOR
SET MEAIEN1=$ORDER(MEADATA(12,MEAIEN1))
IF 'MEAIEN1
QUIT
Begin DoDot:2
+98 SET TP=+$PIECE(MEADATA(12,MEAIEN1),U,1)
+99 IF 'TP
QUIT
+100 SET MEADATA(12,MEAIEN1)=TP_U_$PIECE($GET(^GMRD(120.52,+TP,0)),U,1)
+101 SET MEACNT=1
End DoDot:2
+102 IF MEACNT=0
SET MEADATA(12,1)="^"
End DoDot:1
+103 QUIT
VAL(VAL) ;Get name from .02 field
+1 QUIT $PIECE($GET(^AUTTMSR(VAL,0)),U,2)
+2 ;