ORDV04A ; SLC/DAN/dcm - OE/RR ;7/30/01 14:33
;;3.0;ORDER ENTRY/RESULTS REPORTING;**109,243**;Dec 17,1997;Build 242
;
Q
ENSR ; Entry point for component
;External calls to ^GMTSROB, ^DIQ, ^GMTSORC, ^DIWP
;External references to ^SRF, ^DD, ^ICPT
N GMIDT,GMN,SURG
I '$D(^SRF("B",DFN)) Q
S GMN=0 F S GMN=$O(^SRF("B",DFN,GMN)) Q:GMN'>0 D SORT
I '$D(SURG) Q
S GMIDT=0 F S GMIDT=$O(SURG(GMIDT)) Q:GMIDT'>0!(ORCNT'<ORMAX) S GMN=SURG(GMIDT) D EXTRCT
Q
;
SORT ; Sort surgeries by inverted date
N GMDT
S GMDT=$P(^SRF(GMN,0),U,9) I GMDT>ORDBEG&(GMDT<ORDEND) D
. F Q:'$D(SURG(9999999-GMDT)) S GMDT=GMDT+.0001
. S SURG(9999999-GMDT)=GMN
Q
EXTRCT ; Extract surgical case record
N X,GMI,GMDT,OPPRC,POSDX,PREDX,SPEC,STATUS,SURGEON,VER
N DCTDTM,TRSDTM,Y,C,DIWL,DIWF,ORSITE,ORMORE,SITE
S ORCNT=ORCNT+1,ORMORE=0
S GMDT=$$DATE^ORDVU($P(^SRF(GMN,0),U,9))
D STATUS^GMTSROB S:'$D(STATUS) STATUS="UNKNOWN"
S X=$P(^SRF(GMN,0),U,4) I X>0 S Y=X,C=$P(^DD(130,.04,0),U,2) D Y^DIQ S SPEC=Y K Y
I $D(^SRF(GMN,.1)) S X=$P(^SRF(GMN,.1),U,4) I X>0 S Y=X,C=$P(^DD(130,.14,0),U,2) D Y^DIQ S SURGEON=Y K Y
S VER=$S($G(^SRF(GMN,"VER"))'="Y":"(Unverified)",1:"")
S PREDX(0)=$S($G(^SRF(GMN,33))]"":$P(^(33),U),1:"") S GMI=0 F S GMI=$O(^SRF(GMN,14,GMI)) Q:GMI'>0 S PREDX(GMI)=$P(^SRF(GMN,14,GMI,0),U)
S POSDX(0)=$S($G(^SRF(GMN,34))]"":$P(^(34),U),1:"") S GMI=0 F S GMI=$O(^SRF(GMN,15,GMI)) Q:GMI'>0 S POSDX(GMI)=$P(^SRF(GMN,15,GMI,0),U)
S OPPRC(0)=$P($G(^SRF(GMN,"OP")),U,1,2) S:$P(OPPRC(0),U,2)]"" $P(OPPRC(0),U,2)=$P($$CPT^ICPTCOD($P($G(^SRF(GMN,"OP")),U,2)),U,3) D
. S GMI=0 F S GMI=$O(^SRF(GMN,13,GMI)) Q:GMI'>0 S OPPRC(GMI)=$P($G(^SRF(GMN,13,GMI,0)),U)_U_$G(^SRF(GMN,13,GMI,2)) S:$P(OPPRC(GMI),U,2)]"" $P(OPPRC(GMI),U,2)=$P($$CPT^ICPTCOD($P($G(^SRF(GMN,13,GMI,2)),U)),U,3)
S X=$P($G(^SRF(GMN,31)),U,6) S:X>0 DCTDTM=$$DATE^ORDVU(X)
S X=$P($G(^SRF(GMN,31)),U,7) S:X>0 TRSDTM=$$DATE^ORDVU(X)
S DIWL=0,DIWF="N",ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3)
K ^UTILITY($J,"W")
I $D(^SRF(GMN,12)) F GMI=1:1:$P(^SRF(GMN,12,0),U,4) S X=^SRF(GMN,12,GMI,0) D ^DIWP
S SITE=ORSITE
S ^TMP("ORDATA",$J,GMIDT,"WP",1)="1^"_SITE ;Station ID
S ^TMP("ORDATA",$J,GMIDT,"WP",2)="2^"_GMDT ; date
;
; Operative Procedure(s)
S GMI="" F S GMI=$O(OPPRC(GMI)) Q:GMI="" D S:GMI ORMORE=1
. S ^TMP("ORDATA",$J,GMIDT,"WP",3,GMI)="3^"_$P(OPPRC(GMI),U)_$S($P(OPPRC(GMI),U,2)]"":" - "_$P(OPPRC(GMI),U,2),1:"")
;
S ^TMP("ORDATA",$J,GMIDT,"WP",4)="4^"_$G(SPEC) ;surgical specialty
;
S ^TMP("ORDATA",$J,GMIDT,"WP",5)="5^"_$G(SURGEON) ; surgeon
S ^TMP("ORDATA",$J,GMIDT,"WP",6)="6^"_$G(STATUS) ; op status
;
; Pre-operative diagnosis
S GMI="" F S GMI=$O(PREDX(GMI)) Q:GMI="" D S:GMI ORMORE=1
. S ^TMP("ORDATA",$J,GMIDT,"WP",7,GMI)="7^"_PREDX(GMI)
;
; Post-operative diagnosis
S GMI="" F S GMI=$O(POSDX(GMI)) Q:GMI="" D S:GMI ORMORE=1
. S ^TMP("ORDATA",$J,GMIDT,"WP",8,GMI)="8^"_POSDX(GMI)
;
; Lab work? Y/N
S ^TMP("ORDATA",$J,GMIDT,"WP",9)="9^"_$S($O(^SRF(GMN,9,0)):"Yes",1:"No")
S ^TMP("ORDATA",$J,GMIDT,"WP",10)="10^"_$G(DCTDTM) ; dictation time
S ^TMP("ORDATA",$J,GMIDT,"WP",11)="11^"_$G(TRSDTM) ; transcription time
;
; surgeon's dictation
I $D(^UTILITY($J,"W")) D S ORMORE=1
. K ^TMP("ORHSSRT",$J)
. F GMI=1:1:^UTILITY($J,"W",DIWL) D
.. S ^TMP("ORHSSRT",$J,GMIDT,"WP",GMI)=^UTILITY($J,"W",DIWL,GMI,0)
. D SPMRG^ORDVU($NA(^TMP("ORHSSRT",$J,GMIDT,"WP")),$NA(^TMP("ORDATA",$J,GMIDT,"WP",12)),12)
. K ^UTILITY($J,"W")
. K ^TMP("ORHSSRT",$J)
I ORMORE S ^TMP("ORDATA",$J,GMIDT,"WP",13)="13^[+]" ;flag for detail
Q
VS ;Continuation of Vitals Extract (from ORDV04)
;Calls GMRVUT0
I $L($T(GCPR^OMGCOAS1)) D Q ; OMGCOAS1 routine only on Station 200
. D GCPR^OMGCOAS1(DFN,"VIT",ORDBEG,ORDEND,ORMAX)
. S ROOT=$NA(^TMP("ORDATA",$J))
N ORDT,I,TYPE,IEN,GMRVSTR,ORSITE,SITE,PLACE,GO,X,QUALIF,NODE,UNITS,UCNT,QCNT,ORI
Q:'$L(OREXT)
S GO=$P(OREXT,";")_"^"_$P(OREXT,";",2)
Q:'$L($T(@GO))
K ^UTILITY($J,"GMRVD"),^TMP("ORDATA",$J)
S GMRVSTR="T;P;R;BP;HT;WT;PN;PO2;CVP;CG",GMRVSTR(0)=ORDBEG_"^"_ORDEND_"^"_ORMAX_"^"_1
S ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3)
D @GO
S ORDT=0
F I=1:1 S ORDT=$O(^UTILITY($J,"GMRVD",ORDT)) Q:'+ORDT!(I>ORMAX) D ;DBIA 4791
. S SITE=$S($L($G(^TMP("GMRVD",$J,ORDT,"facility"))):^("facility"),1:ORSITE)
. S ^TMP("ORDATA",$J,"WP",ORDT,1)="1^"_SITE
. S ^TMP("ORDATA",$J,"WP",ORDT,2)="2^"_$$DATE^ORDVU(9999999-ORDT) ;date vitals taken
. K UNITS,QUALIF
. S TYPE="",(UCNT,QCNT)=1,UNITS(UCNT)="",QUALIF(QCNT)="",QUALIF=""
. F S TYPE=$O(^UTILITY($J,"GMRVD",ORDT,TYPE)) Q:TYPE="" D
.. S IEN=$O(^UTILITY($J,"GMRVD",ORDT,TYPE,0)) Q:'IEN S NODE=$G(^(IEN))
.. S PLACE=$S(TYPE="T":3,TYPE="P":4,TYPE="R":5,TYPE="BP":6,TYPE="HT":7,TYPE="WT":8,TYPE="PN":9,TYPE="PO2":10,TYPE="CVP":11,TYPE="CG":12,1:0)
.. I PLACE S ^TMP("ORDATA",$J,"WP",ORDT,PLACE)=PLACE_"^"_$P(NODE,"^",8) ;Get value of vitals from global
.. S X=$$UNITMAP(TYPE) S:$L(UNITS(UCNT))>60 UCNT=UCNT+1,UNITS(UCNT)="" S UNITS(UCNT)=$S($L(UNITS(UCNT)):UNITS(UCNT)_","_$$MAP(TYPE)_":",1:$$MAP(TYPE)_":")_X ;Units
.. I TYPE="PO2" D
... I $L($P(NODE,"^",15)) S ^TMP("ORDATA",$J,"WP",ORDT,13)=13_"^"_$P($G(^UTILITY($J,"GMRVD",ORDT,TYPE,IEN)),"^",15) ; Flow Rate
... I $L($P(NODE,"^",16)) S ^TMP("ORDATA",$J,"WP",ORDT,14)=14_"^"_$P($G(^UTILITY($J,"GMRVD",ORDT,TYPE,IEN)),"^",16) ; O2 Concentration
.. I $L($P(NODE,"^",17)) S X=$P(NODE,"^",17) D
... I QUALIF'[($$MAP(TYPE)_":"_X) D
.... S QUALIF=$S($L(QUALIF):QUALIF_" , "_$$MAP(TYPE)_":",1:$$MAP(TYPE)_":")_X ; Qualifier
.... S:$L(QUALIF(QCNT))>60 QCNT=QCNT+1,QUALIF(QCNT)=""
.... S QUALIF(QCNT)=$S($L(QUALIF(QCNT)):QUALIF(QCNT)_" , "_$$MAP(TYPE)_":",1:$$MAP(TYPE)_":")_X ; Qualifier
.. I TYPE="WT",$L($P(NODE,"^",14)) D
... S ^TMP("ORDATA",$J,"WP",ORDT,16)=16_"^"_$P(NODE,"^",14) ; BMI
. I $O(QUALIF(0)) D
.. S ORI=0 F S ORI=$O(QUALIF(ORI)) Q:'ORI D
... S ^TMP("ORDATA",$J,"WP",ORDT,15,ORI)="15^"_QUALIF(ORI)
. I $O(UNITS(0)) D
.. S ORI=0 F S ORI=$O(UNITS(ORI)) Q:'ORI D
... S ^TMP("ORDATA",$J,"WP",ORDT,17,ORI)="17^"_UNITS(ORI)
K ^UTILITY($J,"GMRVD")
S ROOT=$NA(^TMP("ORDATA",$J))
Q
MAP(TEXT) ;Map test code to abbreviation
Q:'$L($G(TEXT)) ""
I TEXT="T" Q "TEMP"
I TEXT="P" Q "PULSE"
I TEXT="R" Q "RESP"
I TEXT="BP" Q "BP"
I TEXT="HT" Q "HT"
I TEXT="WT" Q "WT"
I TEXT="PN" Q "PAIN"
I TEXT="PO2" Q "POx"
I TEXT="CVP" Q "CVP"
I TEXT="CG" Q "C/G"
Q TEXT
UNITMAP(TEXT) ;Map units to abbreviation
Q:'$L($G(TEXT)) ""
I TEXT="T" Q "F"
I TEXT="P" Q "/min"
I TEXT="R" Q " /min"
I TEXT="BP" Q "mmHg"
I TEXT="HT" Q "in"
I TEXT="WT" Q "lb"
I TEXT="PN" Q ""
I TEXT="PO2" Q "%SpO2"
I TEXT="CVP" Q "cmH2O"
I TEXT="CG" Q " in"
Q ""
ORDV04A ; SLC/DAN/dcm - OE/RR ;7/30/01 14:33
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**109,243**;Dec 17,1997;Build 242
+2 ;
+3 QUIT
ENSR ; Entry point for component
+1 ;External calls to ^GMTSROB, ^DIQ, ^GMTSORC, ^DIWP
+2 ;External references to ^SRF, ^DD, ^ICPT
+3 NEW GMIDT,GMN,SURG
+4 IF '$DATA(^SRF("B",DFN))
QUIT
+5 SET GMN=0
FOR
SET GMN=$ORDER(^SRF("B",DFN,GMN))
IF GMN'>0
QUIT
DO SORT
+6 IF '$DATA(SURG)
QUIT
+7 SET GMIDT=0
FOR
SET GMIDT=$ORDER(SURG(GMIDT))
IF GMIDT'>0!(ORCNT'<ORMAX)
QUIT
SET GMN=SURG(GMIDT)
DO EXTRCT
+8 QUIT
+9 ;
SORT ; Sort surgeries by inverted date
+1 NEW GMDT
+2 SET GMDT=$PIECE(^SRF(GMN,0),U,9)
IF GMDT>ORDBEG&(GMDT<ORDEND)
Begin DoDot:1
+3 FOR
IF '$DATA(SURG(9999999-GMDT))
QUIT
SET GMDT=GMDT+.0001
+4 SET SURG(9999999-GMDT)=GMN
End DoDot:1
+5 QUIT
EXTRCT ; Extract surgical case record
+1 NEW X,GMI,GMDT,OPPRC,POSDX,PREDX,SPEC,STATUS,SURGEON,VER
+2 NEW DCTDTM,TRSDTM,Y,C,DIWL,DIWF,ORSITE,ORMORE,SITE
+3 SET ORCNT=ORCNT+1
SET ORMORE=0
+4 SET GMDT=$$DATE^ORDVU($PIECE(^SRF(GMN,0),U,9))
+5 DO STATUS^GMTSROB
IF '$DATA(STATUS)
SET STATUS="UNKNOWN"
+6 SET X=$PIECE(^SRF(GMN,0),U,4)
IF X>0
SET Y=X
SET C=$PIECE(^DD(130,.04,0),U,2)
DO Y^DIQ
SET SPEC=Y
KILL Y
+7 IF $DATA(^SRF(GMN,.1))
SET X=$PIECE(^SRF(GMN,.1),U,4)
IF X>0
SET Y=X
SET C=$PIECE(^DD(130,.14,0),U,2)
DO Y^DIQ
SET SURGEON=Y
KILL Y
+8 SET VER=$SELECT($GET(^SRF(GMN,"VER"))'="Y":"(Unverified)",1:"")
+9 SET PREDX(0)=$SELECT($GET(^SRF(GMN,33))]"":$PIECE(^(33),U),1:"")
SET GMI=0
FOR
SET GMI=$ORDER(^SRF(GMN,14,GMI))
IF GMI'>0
QUIT
SET PREDX(GMI)=$PIECE(^SRF(GMN,14,GMI,0),U)
+10 SET POSDX(0)=$SELECT($GET(^SRF(GMN,34))]"":$PIECE(^(34),U),1:"")
SET GMI=0
FOR
SET GMI=$ORDER(^SRF(GMN,15,GMI))
IF GMI'>0
QUIT
SET POSDX(GMI)=$PIECE(^SRF(GMN,15,GMI,0),U)
+11 SET OPPRC(0)=$PIECE($GET(^SRF(GMN,"OP")),U,1,2)
IF $PIECE(OPPRC(0),U,2)]""
SET $PIECE(OPPRC(0),U,2)=$PIECE($$CPT^ICPTCOD($PIECE($GET(^SRF(GMN,"OP")),U,2)),U,3)
Begin DoDot:1
+12 SET GMI=0
FOR
SET GMI=$ORDER(^SRF(GMN,13,GMI))
IF GMI'>0
QUIT
SET OPPRC(GMI)=$PIECE($GET(^SRF(GMN,13,GMI,0)),U)_U_$GET(^SRF(GMN,13,GMI,2))
IF $PIECE(OPPRC(GMI),U,2)]""
SET $PIECE(OPPRC(GMI),U,2)=$PIECE($$CPT^ICPTCOD($PIECE($GET(^SRF(GMN,13,GMI,2)),U)),U,3)
End DoDot:1
+13 SET X=$PIECE($GET(^SRF(GMN,31)),U,6)
IF X>0
SET DCTDTM=$$DATE^ORDVU(X)
+14 SET X=$PIECE($GET(^SRF(GMN,31)),U,7)
IF X>0
SET TRSDTM=$$DATE^ORDVU(X)
+15 SET DIWL=0
SET DIWF="N"
SET ORSITE=$$SITE^VASITE
SET ORSITE=$PIECE(ORSITE,"^",2)_";"_$PIECE(ORSITE,"^",3)
+16 KILL ^UTILITY($JOB,"W")
+17 IF $DATA(^SRF(GMN,12))
FOR GMI=1:1:$PIECE(^SRF(GMN,12,0),U,4)
SET X=^SRF(GMN,12,GMI,0)
DO ^DIWP
+18 SET SITE=ORSITE
+19 ;Station ID
SET ^TMP("ORDATA",$JOB,GMIDT,"WP",1)="1^"_SITE
+20 ; date
SET ^TMP("ORDATA",$JOB,GMIDT,"WP",2)="2^"_GMDT
+21 ;
+22 ; Operative Procedure(s)
+23 SET GMI=""
FOR
SET GMI=$ORDER(OPPRC(GMI))
IF GMI=""
QUIT
Begin DoDot:1
+24 SET ^TMP("ORDATA",$JOB,GMIDT,"WP",3,GMI)="3^"_$PIECE(OPPRC(GMI),U)_$SELECT($PIECE(OPPRC(GMI),U,2)]"":" - "_$PIECE(OPPRC(GMI),U,2),1:"")
End DoDot:1
IF GMI
SET ORMORE=1
+25 ;
+26 ;surgical specialty
SET ^TMP("ORDATA",$JOB,GMIDT,"WP",4)="4^"_$GET(SPEC)
+27 ;
+28 ; surgeon
SET ^TMP("ORDATA",$JOB,GMIDT,"WP",5)="5^"_$GET(SURGEON)
+29 ; op status
SET ^TMP("ORDATA",$JOB,GMIDT,"WP",6)="6^"_$GET(STATUS)
+30 ;
+31 ; Pre-operative diagnosis
+32 SET GMI=""
FOR
SET GMI=$ORDER(PREDX(GMI))
IF GMI=""
QUIT
Begin DoDot:1
+33 SET ^TMP("ORDATA",$JOB,GMIDT,"WP",7,GMI)="7^"_PREDX(GMI)
End DoDot:1
IF GMI
SET ORMORE=1
+34 ;
+35 ; Post-operative diagnosis
+36 SET GMI=""
FOR
SET GMI=$ORDER(POSDX(GMI))
IF GMI=""
QUIT
Begin DoDot:1
+37 SET ^TMP("ORDATA",$JOB,GMIDT,"WP",8,GMI)="8^"_POSDX(GMI)
End DoDot:1
IF GMI
SET ORMORE=1
+38 ;
+39 ; Lab work? Y/N
+40 SET ^TMP("ORDATA",$JOB,GMIDT,"WP",9)="9^"_$SELECT($ORDER(^SRF(GMN,9,0)):"Yes",1:"No")
+41 ; dictation time
SET ^TMP("ORDATA",$JOB,GMIDT,"WP",10)="10^"_$GET(DCTDTM)
+42 ; transcription time
SET ^TMP("ORDATA",$JOB,GMIDT,"WP",11)="11^"_$GET(TRSDTM)
+43 ;
+44 ; surgeon's dictation
+45 IF $DATA(^UTILITY($JOB,"W"))
Begin DoDot:1
+46 KILL ^TMP("ORHSSRT",$JOB)
+47 FOR GMI=1:1:^UTILITY($JOB,"W",DIWL)
Begin DoDot:2
+48 SET ^TMP("ORHSSRT",$JOB,GMIDT,"WP",GMI)=^UTILITY($JOB,"W",DIWL,GMI,0)
End DoDot:2
+49 DO SPMRG^ORDVU($NAME(^TMP("ORHSSRT",$JOB,GMIDT,"WP")),$NAME(^TMP("ORDATA",$JOB,GMIDT,"WP",12)),12)
+50 KILL ^UTILITY($JOB,"W")
+51 KILL ^TMP("ORHSSRT",$JOB)
End DoDot:1
SET ORMORE=1
+52 ;flag for detail
IF ORMORE
SET ^TMP("ORDATA",$JOB,GMIDT,"WP",13)="13^[+]"
+53 QUIT
VS ;Continuation of Vitals Extract (from ORDV04)
+1 ;Calls GMRVUT0
+2 ; OMGCOAS1 routine only on Station 200
IF $LENGTH($TEXT(GCPR^OMGCOAS1))
Begin DoDot:1
+3 DO GCPR^OMGCOAS1(DFN,"VIT",ORDBEG,ORDEND,ORMAX)
+4 SET ROOT=$NAME(^TMP("ORDATA",$JOB))
End DoDot:1
QUIT
+5 NEW ORDT,I,TYPE,IEN,GMRVSTR,ORSITE,SITE,PLACE,GO,X,QUALIF,NODE,UNITS,UCNT,QCNT,ORI
+6 IF '$LENGTH(OREXT)
QUIT
+7 SET GO=$PIECE(OREXT,";")_"^"_$PIECE(OREXT,";",2)
+8 IF '$LENGTH($TEXT(@GO))
QUIT
+9 KILL ^UTILITY($JOB,"GMRVD"),^TMP("ORDATA",$JOB)
+10 SET GMRVSTR="T;P;R;BP;HT;WT;PN;PO2;CVP;CG"
SET GMRVSTR(0)=ORDBEG_"^"_ORDEND_"^"_ORMAX_"^"_1
+11 SET ORSITE=$$SITE^VASITE
SET ORSITE=$PIECE(ORSITE,"^",2)_";"_$PIECE(ORSITE,"^",3)
+12 DO @GO
+13 SET ORDT=0
+14 ;DBIA 4791
FOR I=1:1
SET ORDT=$ORDER(^UTILITY($JOB,"GMRVD",ORDT))
IF '+ORDT!(I>ORMAX)
QUIT
Begin DoDot:1
+15 SET SITE=$SELECT($LENGTH($GET(^TMP("GMRVD",$JOB,ORDT,"facility"))):^("facility"),1:ORSITE)
+16 SET ^TMP("ORDATA",$JOB,"WP",ORDT,1)="1^"_SITE
+17 ;date vitals taken
SET ^TMP("ORDATA",$JOB,"WP",ORDT,2)="2^"_$$DATE^ORDVU(9999999-ORDT)
+18 KILL UNITS,QUALIF
+19 SET TYPE=""
SET (UCNT,QCNT)=1
SET UNITS(UCNT)=""
SET QUALIF(QCNT)=""
SET QUALIF=""
+20 FOR
SET TYPE=$ORDER(^UTILITY($JOB,"GMRVD",ORDT,TYPE))
IF TYPE=""
QUIT
Begin DoDot:2
+21 SET IEN=$ORDER(^UTILITY($JOB,"GMRVD",ORDT,TYPE,0))
IF 'IEN
QUIT
SET NODE=$GET(^(IEN))
+22 SET PLACE=$SELECT(TYPE="T":3,TYPE="P":4,TYPE="R":5,TYPE="BP":6,TYPE="HT":7,TYPE="WT":8,TYPE="PN":9,TYPE="PO2":10,TYPE="CVP":11,TYPE="CG":12,1:0)
+23 ;Get value of vitals from global
IF PLACE
SET ^TMP("ORDATA",$JOB,"WP",ORDT,PLACE)=PLACE_"^"_$PIECE(NODE,"^",8)
+24 ;Units
SET X=$$UNITMAP(TYPE)
IF $LENGTH(UNITS(UCNT))>60
SET UCNT=UCNT+1
SET UNITS(UCNT)=""
SET UNITS(UCNT)=$SELECT($LENGTH(UNITS(UCNT)):UNITS(UCNT)_","_$$MAP(TYPE)_":",1:$$MAP(TYPE)_":")_X
+25 IF TYPE="PO2"
Begin DoDot:3
+26 ; Flow Rate
IF $LENGTH($PIECE(NODE,"^",15))
SET ^TMP("ORDATA",$JOB,"WP",ORDT,13)=13_"^"_$PIECE($GET(^UTILITY($JOB,"GMRVD",ORDT,TYPE,IEN)),"^",15)
+27 ; O2 Concentration
IF $LENGTH($PIECE(NODE,"^",16))
SET ^TMP("ORDATA",$JOB,"WP",ORDT,14)=14_"^"_$PIECE($GET(^UTILITY($JOB,"GMRVD",ORDT,TYPE,IEN)),"^",16)
End DoDot:3
+28 IF $LENGTH($PIECE(NODE,"^",17))
SET X=$PIECE(NODE,"^",17)
Begin DoDot:3
+29 IF QUALIF'[($$MAP(TYPE)_":"_X)
Begin DoDot:4
+30 ; Qualifier
SET QUALIF=$SELECT($LENGTH(QUALIF):QUALIF_" , "_$$MAP(TYPE)_":",1:$$MAP(TYPE)_":")_X
+31 IF $LENGTH(QUALIF(QCNT))>60
SET QCNT=QCNT+1
SET QUALIF(QCNT)=""
+32 ; Qualifier
SET QUALIF(QCNT)=$SELECT($LENGTH(QUALIF(QCNT)):QUALIF(QCNT)_" , "_$$MAP(TYPE)_":",1:$$MAP(TYPE)_":")_X
End DoDot:4
End DoDot:3
+33 IF TYPE="WT"
IF $LENGTH($PIECE(NODE,"^",14))
Begin DoDot:3
+34 ; BMI
SET ^TMP("ORDATA",$JOB,"WP",ORDT,16)=16_"^"_$PIECE(NODE,"^",14)
End DoDot:3
End DoDot:2
+35 IF $ORDER(QUALIF(0))
Begin DoDot:2
+36 SET ORI=0
FOR
SET ORI=$ORDER(QUALIF(ORI))
IF 'ORI
QUIT
Begin DoDot:3
+37 SET ^TMP("ORDATA",$JOB,"WP",ORDT,15,ORI)="15^"_QUALIF(ORI)
End DoDot:3
End DoDot:2
+38 IF $ORDER(UNITS(0))
Begin DoDot:2
+39 SET ORI=0
FOR
SET ORI=$ORDER(UNITS(ORI))
IF 'ORI
QUIT
Begin DoDot:3
+40 SET ^TMP("ORDATA",$JOB,"WP",ORDT,17,ORI)="17^"_UNITS(ORI)
End DoDot:3
End DoDot:2
End DoDot:1
+41 KILL ^UTILITY($JOB,"GMRVD")
+42 SET ROOT=$NAME(^TMP("ORDATA",$JOB))
+43 QUIT
MAP(TEXT) ;Map test code to abbreviation
+1 IF '$LENGTH($GET(TEXT))
QUIT ""
+2 IF TEXT="T"
QUIT "TEMP"
+3 IF TEXT="P"
QUIT "PULSE"
+4 IF TEXT="R"
QUIT "RESP"
+5 IF TEXT="BP"
QUIT "BP"
+6 IF TEXT="HT"
QUIT "HT"
+7 IF TEXT="WT"
QUIT "WT"
+8 IF TEXT="PN"
QUIT "PAIN"
+9 IF TEXT="PO2"
QUIT "POx"
+10 IF TEXT="CVP"
QUIT "CVP"
+11 IF TEXT="CG"
QUIT "C/G"
+12 QUIT TEXT
UNITMAP(TEXT) ;Map units to abbreviation
+1 IF '$LENGTH($GET(TEXT))
QUIT ""
+2 IF TEXT="T"
QUIT "F"
+3 IF TEXT="P"
QUIT "/min"
+4 IF TEXT="R"
QUIT " /min"
+5 IF TEXT="BP"
QUIT "mmHg"
+6 IF TEXT="HT"
QUIT "in"
+7 IF TEXT="WT"
QUIT "lb"
+8 IF TEXT="PN"
QUIT ""
+9 IF TEXT="PO2"
QUIT "%SpO2"
+10 IF TEXT="CVP"
QUIT "cmH2O"
+11 IF TEXT="CG"
QUIT " in"
+12 QUIT ""