BTIUPCC4 ; IHS/CIA/MGH - IHS PCC INPT OBJECTS ;13-Dec-2013 09:55;DU
;;1.0;TEXT INTEGRATION UTILITIES;**1004,1005,1006,1010,1012**;NOV 04, 2004;Build 45
;Patch 1005 added measurment list object
;Patch 1010 adds qualifiers
;==================================================================
LSTMEAS(DFN,TIUMSR,VAIN) ; -- returns most current measurement (internal values)
;Designed to return most recent vital signs for inpatients
NEW MSR,VDT,IEN,X,TIU,LINE,ARR,DATE,STOP,ISINP,QUALIF
S MSR=$O(^AUTTMSR("B",TIUMSR,0)) I MSR="" Q ""
;
;Check whether patient is an inpatient or not
I $G(VAIN(1)) D
.S STOP=(9999999-$P(VAIN(7),U,1)\1)+1
I 'STOP Q "Patient is not an inpatient" ;none to be found
S VDT=0
F S VDT=$O(^AUPNVMSR("AE",DFN,MSR,VDT)) Q:'VDT!(VDT>STOP) D
. S IEN=0
. F S IEN=$O(^AUPNVMSR("AE",DFN,MSR,VDT,IEN)) Q:'IEN D
.. K TIU D ENP^XBDIQ1(9000010.01,IEN,".03;.04;1201;2","TIU(","I")
.. ; value ^ visit ien ^ event date internal format
.. Q:TIU(2,"I")=1 ;Quit if entered in error
.. S QUALIF=$$QUAL^BTIULO7A(IEN)
.. S LINE=$G(TIU(.04))_U_$G(TIU(.03,"I"))_U_$G(TIU(1201,"I"))_U_QUALIF
.. S DATE=$S($G(TIU(1201,"I"))]"":TIU(1201,"I"),1:(9999999-$P(VDT,"."))_"."_$P(VDT,".",2))
.. S ARR(DATE,IEN)=LINE
;
I '$D(ARR)!($D(ARR)=0) S LINE="Not done while inpatient" Q LINE
S DATE=$O(ARR(""),-1),IEN=$O(ARR(DATE,""),-1),LINE=ARR(DATE,IEN)
K VAIN
Q $G(LINE)
;
LSTDATE(DATE1,DATE2,YES) ;EP -- returns event date or visit date;PATCH 1002 fixed typo
I 'YES Q "" ;no date asked for
;
;IHS/ITSC/LJF 02/24/2005 PATCH 1002 add parens around dates
;I $G(DATE2) Q " "_$$FMTE^XLFDT(DATE2) ;event date
;Q " "_$$GET1^DIQ(9000010,+DATE1,.01) ;visit date from visit ien
I $G(DATE2) Q " ("_$$FMTE^XLFDT(DATE2)_")" ;event date
I 'DATE1 Q " "
Q " ("_$$GET1^DIQ(9000010,+DATE1,.01)_")" ;visit date from visit ien
;
PAD(DATA,LENGTH) ; -- SUBRTN to pad length of data
Q $E(DATA_$$REPEAT^XLFSTR(" ",LENGTH),1,LENGTH)
;
SP(NUM) ; -- SUBRTN to pad spaces
Q $$PAD(" ",NUM)
MEASLST(DFN,TARGET) ;EP Get last of each type of vital
;Use the system list from the BEHOENVM VITAL LIST parameter
N ARRAY,MEAS,MITEM,MTYPE,CNT,TIUMSR
S CNT=0
D GETLST^XPAR(.ARRAY,"SYS","BEHOVM VITAL LIST","I")
S MEAS="" F S MEAS=$O(ARRAY(MEAS)) Q:MEAS="" D
.S MITEM=$G(ARRAY(MEAS))
.Q:MITEM=""
.S MTYPE=$P($G(^AUTTMSR(MITEM,0)),U,1)
.I MTYPE'="" D
..S TIUMSR=$$LASTMSR^BTIUPCC1(DFN,MTYPE,1,1)
..I TIUMSR'="" D
...S CNT=CNT+1
...S @TARGET@(CNT,0)=TIUMSR
I CNT=0 S @TARGET@(1,0)="No measurement data on file"
Q "~@"_$NA(@TARGET)
BTIUPCC4 ; IHS/CIA/MGH - IHS PCC INPT OBJECTS ;13-Dec-2013 09:55;DU
+1 ;;1.0;TEXT INTEGRATION UTILITIES;**1004,1005,1006,1010,1012**;NOV 04, 2004;Build 45
+2 ;Patch 1005 added measurment list object
+3 ;Patch 1010 adds qualifiers
+4 ;==================================================================
LSTMEAS(DFN,TIUMSR,VAIN) ; -- returns most current measurement (internal values)
+1 ;Designed to return most recent vital signs for inpatients
+2 NEW MSR,VDT,IEN,X,TIU,LINE,ARR,DATE,STOP,ISINP,QUALIF
+3 SET MSR=$ORDER(^AUTTMSR("B",TIUMSR,0))
IF MSR=""
QUIT ""
+4 ;
+5 ;Check whether patient is an inpatient or not
+6 IF $GET(VAIN(1))
Begin DoDot:1
+7 SET STOP=(9999999-$PIECE(VAIN(7),U,1)\1)+1
End DoDot:1
+8 ;none to be found
IF 'STOP
QUIT "Patient is not an inpatient"
+9 SET VDT=0
+10 FOR
SET VDT=$ORDER(^AUPNVMSR("AE",DFN,MSR,VDT))
IF 'VDT!(VDT>STOP)
QUIT
Begin DoDot:1
+11 SET IEN=0
+12 FOR
SET IEN=$ORDER(^AUPNVMSR("AE",DFN,MSR,VDT,IEN))
IF 'IEN
QUIT
Begin DoDot:2
+13 KILL TIU
DO ENP^XBDIQ1(9000010.01,IEN,".03;.04;1201;2","TIU(","I")
+14 ; value ^ visit ien ^ event date internal format
+15 ;Quit if entered in error
IF TIU(2,"I")=1
QUIT
+16 SET QUALIF=$$QUAL^BTIULO7A(IEN)
+17 SET LINE=$GET(TIU(.04))_U_$GET(TIU(.03,"I"))_U_$GET(TIU(1201,"I"))_U_QUALIF
+18 SET DATE=$SELECT($GET(TIU(1201,"I"))]"":TIU(1201,"I"),1:(9999999-$PIECE(VDT,"."))_"."_$PIECE(VDT,".",2))
+19 SET ARR(DATE,IEN)=LINE
End DoDot:2
End DoDot:1
+20 ;
+21 IF '$DATA(ARR)!($DATA(ARR)=0)
SET LINE="Not done while inpatient"
QUIT LINE
+22 SET DATE=$ORDER(ARR(""),-1)
SET IEN=$ORDER(ARR(DATE,""),-1)
SET LINE=ARR(DATE,IEN)
+23 KILL VAIN
+24 QUIT $GET(LINE)
+25 ;
LSTDATE(DATE1,DATE2,YES) ;EP -- returns event date or visit date;PATCH 1002 fixed typo
+1 ;no date asked for
IF 'YES
QUIT ""
+2 ;
+3 ;IHS/ITSC/LJF 02/24/2005 PATCH 1002 add parens around dates
+4 ;I $G(DATE2) Q " "_$$FMTE^XLFDT(DATE2) ;event date
+5 ;Q " "_$$GET1^DIQ(9000010,+DATE1,.01) ;visit date from visit ien
+6 ;event date
IF $GET(DATE2)
QUIT " ("_$$FMTE^XLFDT(DATE2)_")"
+7 IF 'DATE1
QUIT " "
+8 ;visit date from visit ien
QUIT " ("_$$GET1^DIQ(9000010,+DATE1,.01)_")"
+9 ;
PAD(DATA,LENGTH) ; -- SUBRTN to pad length of data
+1 QUIT $EXTRACT(DATA_$$REPEAT^XLFSTR(" ",LENGTH),1,LENGTH)
+2 ;
SP(NUM) ; -- SUBRTN to pad spaces
+1 QUIT $$PAD(" ",NUM)
MEASLST(DFN,TARGET) ;EP Get last of each type of vital
+1 ;Use the system list from the BEHOENVM VITAL LIST parameter
+2 NEW ARRAY,MEAS,MITEM,MTYPE,CNT,TIUMSR
+3 SET CNT=0
+4 DO GETLST^XPAR(.ARRAY,"SYS","BEHOVM VITAL LIST","I")
+5 SET MEAS=""
FOR
SET MEAS=$ORDER(ARRAY(MEAS))
IF MEAS=""
QUIT
Begin DoDot:1
+6 SET MITEM=$GET(ARRAY(MEAS))
+7 IF MITEM=""
QUIT
+8 SET MTYPE=$PIECE($GET(^AUTTMSR(MITEM,0)),U,1)
+9 IF MTYPE'=""
Begin DoDot:2
+10 SET TIUMSR=$$LASTMSR^BTIUPCC1(DFN,MTYPE,1,1)
+11 IF TIUMSR'=""
Begin DoDot:3
+12 SET CNT=CNT+1
+13 SET @TARGET@(CNT,0)=TIUMSR
End DoDot:3
End DoDot:2
End DoDot:1
+14 IF CNT=0
SET @TARGET@(1,0)="No measurement data on file"
+15 QUIT "~@"_$NAME(@TARGET)