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

ORWRP4V.m

Go to the documentation of this file.
  1. ORWRP4V ; slc/dcm - OE/RR HDR Report Extract RPC's Vitals;9/21/05 13:21
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**215,243**;Dec 17, 1997;Build 242
  1. VS ;Vitals code for HDR
  1. N I,IFN,IFN1,IFN2,X,X1,X2,X4,X5,XIFN,ORX,COL,CODE,I1,CNT,%DT,FAC,FACU,NODE,QUALIF,METHOD,UNIT
  1. K ^TMP("ORXS",$J)
  1. S IFN=""
  1. F S IFN=$O(^XTMP(HANDLE,"D",IFN)) Q:IFN="" S XIFN=^(IFN) D
  1. . S X11=$P(XIFN,"^",11),X12=$P(XIFN,"^",12),X2=$P(XIFN,"^",2),FACU=X12
  1. . I X12="",X11,X11'=200 S FACU=$O(^DIC(4,"D",X11,0)) I FACU S FACU=$P(^DIC(4,FACU,0),"^")
  1. . I '$L(FACU) S FACU=$S($L($P(XIFN,"^",2)):$P(XIFN,"^",2),1:"Unknown")
  1. . S $P(XIFN,"^",2)=FACU,X4=$P($P(XIFN,"^",4),":",1,2),X5=$P($P(XIFN,"^",5),"~",2)
  1. . I $P(XIFN,"^",10)'="W",$L(X5) D
  1. .. S X4=9999999-$$SETDATE^ORWRP4(X4)
  1. .. I X4=9999999 F I=.01:.01 S X4=X4+I I '$D(^TMP("ORXS",$J,FACU,X4)) Q
  1. .. S ^TMP("ORXS",$J,FACU,X4)=$P(XIFN,"^",2),^TMP("ORXS",$J,FACU,X4,X5,IFN)=XIFN
  1. K ^TMP("ORXS1",$J),^TMP("ORXS2",$J)
  1. S FAC="",CNT=-1
  1. F S FAC=$O(^TMP("ORXS",$J,FAC)) Q:FAC="" S IFN="" F S IFN=$O(^TMP("ORXS",$J,FAC,IFN)) Q:IFN="" S NODE=^(IFN) D
  1. . D XVSET("1^"_$P(NODE,"^"),1,FAC,IFN,NODE) ;Facility
  1. . I $P(IFN,".")'=9999999 D XVSET("2^"_$$DATE^ORDVU(9999999-IFN),2,FAC,IFN,NODE) ; Measurement Date/Time
  1. . I $P(IFN,".")=9999999 D XVSET("2^"_" ",2,FAC,IFN,NODE) ; Measurement Date/Time = ""
  1. . S IFN1=""
  1. . F S IFN1=$O(^TMP("ORXS",$J,FAC,IFN,IFN1)) Q:IFN1="" S IFN2="" F S IFN2=$O(^TMP("ORXS",$J,FAC,IFN,IFN1,IFN2)) Q:IFN2="" S X=^(IFN2) D
  1. .. I $$UPPER^ORU(IFN1)="TEMPERATURE" D XVSET("3^"_$P(X,"^",6),3,FAC,IFN,X) D METH(X)
  1. .. I $$UPPER^ORU(IFN1)="PULSE" D XVSET("4^"_$P(X,"^",6),4,FAC,IFN,X) D METH(X)
  1. .. I $$UPPER^ORU(IFN1)="RESPIRATION" D XVSET("5^"_$P(X,"^",6),5,FAC,IFN,X) D METH(X)
  1. .. I $$UPPER^ORU(IFN1)="BLOOD PRESSURE" D XVSET("6^"_$P(X,"^",6),6,FAC,IFN,X) D METH(X)
  1. .. I $$UPPER^ORU(IFN1)="HEIGHT" D XVSET("7^"_$P(X,"^",6),7,FAC,IFN,X) D METH(X)
  1. .. I $$UPPER^ORU(IFN1)="WEIGHT" D XVSET("8^"_$P(X,"^",6),8,FAC,IFN,X) D METH(X)
  1. .. I $$UPPER^ORU(IFN1)="PAIN" D XVSET("9^"_$P(X,"^",6),9,FAC,IFN,X) D METH(X)
  1. .. I $$UPPER^ORU(IFN1)="PULSE OXIMETRY" D
  1. ... D XVSET("10^"_$P(X,"^",6),10,FAC,IFN,X) D METH(X)
  1. ... F I=1:1:2 D
  1. .... I $L($P(X,"^",13)),$P($P($P(X,"^",13),"|",I)," ",2)["l/min" D XVSET("13^"_$P($P($P(X,"^",13),"|",I)," "),13,FAC,IFN,X) ;Flow Rate
  1. .... I $L($P(X,"^",13)),$P($P($P(X,"^",13),"|",I)," ",2)["%" D XVSET("14^"_$P($P($P(X,"^",13),"|",I)," "),14,FAC,IFN,X) ;O2 Concentration
  1. .. I $$UPPER^ORU(IFN1)="CENTRAL VENOUS PRESSURE" D XVSET("11^"_$P(X,"^",6),11,FAC,IFN,X) D METH(X)
  1. .. I $$UPPER^ORU(IFN1)="CIRCUMFERENCE/GIRTH" D XVSET("12^"_$P(X,"^",6),12,FAC,IFN,X) D METH(X)
  1. S FAC=""
  1. F S FAC=$O(^TMP("ORXS2",$J,"METH",FAC)) Q:FAC="" S IFN="" F S IFN=$O(^TMP("ORXS2",$J,"METH",FAC,IFN)) Q:IFN="" S METHOD=^(IFN,1),DATA=^(0) D
  1. .I $L(METHOD) S X=METHOD D
  1. .. D XVSET("16^"_X,16,FAC,IFN,DATA) ;Methods
  1. S FAC=""
  1. F S FAC=$O(^TMP("ORXS2",$J,"QUAL",FAC)) Q:FAC="" S IFN="" F S IFN=$O(^TMP("ORXS2",$J,"QUAL",FAC,IFN)) Q:IFN="" S QUALIF=^(IFN,1),DATA=^(0) D
  1. .I $L(QUALIF) S X=QUALIF D
  1. .. D XVSET("15^"_X,15,FAC,IFN,DATA) ;Qualifiers
  1. S FAC=""
  1. F S FAC=$O(^TMP("ORXS2",$J,"UNIT",FAC)) Q:FAC="" S IFN="" F S IFN=$O(^TMP("ORXS2",$J,"UNIT",FAC,IFN)) Q:IFN="" S UNIT=^(IFN,1),DATA=^(0) D
  1. .I $L(UNIT) S X=UNIT D
  1. .. D XVSET("17^"_X,17,FAC,IFN,DATA) ;Units
  1. K ^XTMP(HANDLE,"D")
  1. S FAC="",CNT=-1
  1. F S FAC=$O(^TMP("ORXS1",$J,FAC)) Q:FAC="" S IFN="" F S IFN=$O(^TMP("ORXS1",$J,FAC,IFN)) Q:IFN="" S IFN1="" D
  1. . F S IFN1=$O(^TMP("ORXS1",$J,FAC,IFN,IFN1)) Q:IFN1="" S X=^(IFN1) D
  1. .. S CNT=CNT+1,^XTMP(HANDLE,"D",CNT)=X
  1. K ^TMP("ORXS",$J),^TMP("ORXS1",$J),^TMP("ORXS2",$J)
  1. Q
  1. METH(DATA) ;Get Methods, Units & Qualifiers
  1. Q:'$D(DATA)
  1. N X,D,T
  1. S X=$P($P(DATA,"^",3),"~",2),D=$P($G(DATA),"^",4),T=$P($P(DATA,"^",5),"~",2)
  1. I $L(X),$L(T),$L(D) S METHOD=$G(^TMP("ORXS2",$J,"METH",FAC,IFN,1)),METHOD=$S($L(METHOD):METHOD_" | "_T_":",1:T_":")_X,^TMP("ORXS2",$J,"METH",FAC,IFN,1)=METHOD,^(0)=DATA
  1. S X=$P($P(DATA,"^",8),"~",2)
  1. I $L(X),$L(T),$L(D) S QUALIF=$G(^TMP("ORXS2",$J,"QUAL",FAC,IFN,1)),QUALIF=$S($L(QUALIF):QUALIF_" | "_T_":",1:T_":")_X,^TMP("ORXS2",$J,"QUAL",FAC,IFN,1)=QUALIF,^(0)=DATA
  1. S X=$P($P(DATA,"^",7),"~",2)
  1. I $L(X),$L(T),$L(D) S UNIT=$G(^TMP("ORXS2",$J,"UNIT",FAC,IFN,1)),UNIT=$S($L(UNIT):UNIT_" | "_T_":",1:T_":")_X,^TMP("ORXS2",$J,"UNIT",FAC,IFN,1)=UNIT,^(0)=DATA
  1. Q
  1. XVSET(X,IFN,FAC,IDT,NODE) ;Setup Vitals nodes
  1. Q:'$D(X) Q:'$L($G(IDT))
  1. N SAVE,OIDT
  1. S SAVE=X
  1. I '$L($G(IFN)) S CNT=CNT+1,^TMP("ORXS1",$J,IDT,FAC,CNT)=$$ESCP^ORWRP4(SAVE) Q
  1. I $D(^TMP("ORXS1",$J,IDT,FAC,IFN)) D Q ;Get data where item, facility, date/time are the same
  1. . S OIDT=IDT
  1. . F S IDT=IDT+.0001 Q:'$D(^TMP("ORXS1",$J,IDT,IFN))
  1. . I '$D(^TMP("ORXS1",$J,IDT,FAC,IFN)) D
  1. .. S ^TMP("ORXS1",$J,IDT,FAC,1)=$$ESCP^ORWRP4("1^"_$P($G(NODE),"^",2)) ;Facility
  1. .. S ^TMP("ORXS1",$J,IDT,FAC,2)=$$ESCP^ORWRP4("2^"_$$DATE^ORDVU($$SETDATE^ORWRP4($P($G(NODE),"^",4)))) ;Date/Time
  1. . S ^TMP("ORXS1",$J,IDT,FAC,IFN)=$$ESCP^ORWRP4(SAVE),IDT=OIDT
  1. S ^TMP("ORXS1",$J,IDT,FAC,IFN)=$$ESCP^ORWRP4(SAVE)
  1. Q