MDCLIOV ;HINES OIFO/DP - CliO Vitals Link;15 Nov 2010
;;1.0;CLINICAL PROCEDURES;**16**;Apr 01, 2004;Build 280
;Per VHA Directive 2004-038, this routine should not be modified.
;
; This routine uses the following IAs:
; #10104 - ^XLFSTR calls (supported)
; #1381 - GMRV VITAL MEASUREMENT (controlled subscription)
; #4504 - GEN. MED. REC. - VITALS (controlled subscription)
;
GETLIST ; Used to gather the list by patient/start/stop
; MDROOT and P2(0..n) passed in via the Script Engine
N MDPT,MDFR,MDTO,MDTYPE,MDDT,MDDA,MDABBV,MDMAP,MDTEST,MDRATE
S MDPT=P2(0),MDROOT=$NA(^TMP("MDCLIO",$J)) K @MDROOT
S MDFR=9999999-$$FMDT^MDCLIO(P2(2))-.0000001
S MDTO=9999999-$$FMDT^MDCLIO(P2(1))
F MDTYPE=0:0 S MDTYPE=$O(^GMR(120.5,"AA",MDPT,MDTYPE)) Q:'MDTYPE D
.F MDDT=MDFR:0 S MDDT=$O(^GMR(120.5,"AA",MDPT,MDTYPE,MDDT)) Q:'MDDT!(MDDT>MDTO) D
..F MDDA=0:0 S MDDA=$O(^GMR(120.5,"AA",MDPT,MDTYPE,MDDT,MDDA)) Q:'MDDA D
...S MDRATE=$$GET1^DIQ(120.5,MDDA_",",1.2)
...Q:"UNAVAILABLEPASSREFUSED"[$$UP^XLFSTR(MDRATE) ; First filter - these aren't observations
...I +MDRATE'=MDRATE D Q:'$D(MDRATE) ; If not numeric, pass it through a sanity check
....S MDABBV=$$GET1^DIQ(120.5,MDDA_",",".03:1")
....S MDMAP=$$GETMAP(MDABBV) I MDMAP="" K MDRATE Q ; No mapping, possibly a local addition
....S MDTEST=$P(MDMAP,";",6,$L(MDMAP)) Q:MDTEST=""
....I MDTEST]"" X MDTEST Q:$D(MDRATE) ; Run the test allow value if it passes
....K MDRATE ; It's a stinker :)
...S @MDROOT@(MDDA)=""
Q
;
GETLOG ; Get list of date/time pairs with data
; MDROOT and P2(0..n) passed in via the Script Engine
N MDPT,MDFR,MDTO,MDTYPE,MDDT,MDSTAT,MDDATE,MDDA
S MDPT=P2(0),MDROOT=$NA(^TMP("MDCLIO",$J)) K @MDROOT
S MDFR=9999999-$$FMDT^MDCLIO(P2(2))-.0000001
S MDTO=9999999-$$FMDT^MDCLIO(P2(1))
F MDTYPE=0:0 S MDTYPE=$O(^GMR(120.5,"AA",MDPT,MDTYPE)) Q:'MDTYPE D
.F MDDT=MDFR:0 S MDDT=$O(^GMR(120.5,"AA",MDPT,MDTYPE,MDDT)) Q:'MDDT!(MDDT>MDTO) D
..F MDDA=0:0 S MDDA=$O(^GMR(120.5,"AA",MDPT,MDTYPE,MDDT,MDDA)) Q:'MDDA D
...S MDRATE=$$GET1^DIQ(120.5,MDDA_",",1.2)
...Q:"UNAVAILABLEPASSREFUSED"[$$UP^XLFSTR(MDRATE) ; First filter - these aren't observations
...S MDSTAT=$S(+$$GET1^DIQ(120.5,MDDA_",",2,"I"):4,1:1)
...S MDDATE=+$E(9999999-MDDT,1,12)
...I '$D(@MDROOT@(MDSTAT,MDDATE)) S @MDROOT@(MDSTAT,MDDATE,MDDA)=""
Q
;
GETBYID ; Builds the IEN list from the Vitals ID's sent down
; P2(0..n) passed in via the Script Engine
; MDROOT overridden on purpose to pass back to the Script Engine
N MDID
S MDROOT=$NA(^TMP("MDCLIO",$J)) K @MDROOT
S MDID=""
F S MDID=$O(P2(MDID)) Q:MDID="" D:P2(MDID)]""
.S @MDROOT@(0,+$P(P2(MDID),"GMRV-",2))=""
Q
;
GETOBS ; Build the Vitals Sign as a CliO observation
; MDIENS is from the Script Engine as the current record being processed
N MDABBV,MDMAP,MDTERM,MDVAL,MDORD,MDQUAL,MDIEN,MDQIEN,MDVUID,MDGUID,MDCMT,MDSUPP
S MDCMT="Data retrieved from VistA Vitals Package"
D XMLDATA^MDCLIO("VITALS_IEN",+MDIENS)
S MDABBV=$$GET1^DIQ(120.5,MDIENS,"#.03:#1") Q:MDABBV=""
S MDMAP=$$GETMAP(MDABBV) Q:MDMAP=""
D XMLDATA^MDCLIO("STATUS",$S(+$$GET1^DIQ(120.5,MDIENS,2,"I"):4,1:1))
D XMLDATA^MDCLIO("VITALS_TERM",$$GET1^DIQ(120.5,MDIENS,.03))
S MDTERM=$P(MDMAP,";",4),MDTERM(0)=$O(^MDC(704.101,"PK",MDTERM,0))
D XMLDATA^MDCLIO("TERM_ID",MDTERM)
D XMLDATA^MDCLIO("TERM_NAME",$$GET1^DIQ(704.101,MDTERM(0)_",",.02))
;
; Value
;
S MDVAL=$$GET1^DIQ(120.5,MDIENS,1.2)
I $P(MDMAP,";",7)]"" X $P(MDMAP,";",7) ; Input transform from Vitals to CliO
D XMLDATA^MDCLIO("PRE_VALUE",MDVAL)
D:$P(^MDC(704.101,MDTERM(0),0),"^",6)=3 ; Picklist
.F MDORD=0:0 S MDORD=$O(^MDC(704.103,"PK",MDTERM(0),MDORD)) Q:'MDORD D
..F MDQUAL=0:0 S MDQUAL=$O(^MDC(704.103,"PK",MDTERM(0),MDORD,MDQUAL)) Q:'MDQUAL D
...Q:$P(^MDC(704.101,MDQUAL,0),"^",5)'=11
...S MDIEN=$O(^MDC(704.103,"PK",MDTERM(0),MDORD,MDQUAL,0))
...S:$P(^MDC(704.103,MDIEN,0),"^",4)=MDVAL MDVAL=$P(^MDC(704.101,MDQUAL,0),"^")
D XMLDATA^MDCLIO("SVALUE",MDVAL)
S MDSUPP=$$GET1^DIQ(120.5,MDIENS,1.4)
I MDSUPP]"" S MDCMT=MDCMT_", Supp O2 "_MDSUPP
;
; Check for High/Low values in the local params file
;
I $P(MDMAP,";",2)="BP" D:MDVAL?1.3N1"/"1.3N
.; BP needs a special checker
.I +MDVAL'<$$GET1^DIQ(120.57,"1,",5.7,"I") D XMLDATA^MDCLIO("RANGE",5) Q ; High Systolic
.I +MDVAL'>$$GET1^DIQ(120.57,"1,",5.8,"I") D XMLDATA^MDCLIO("RANGE",4) Q ; Low Systolic
.I +MDVAL'<$$GET1^DIQ(120.57,"1,",5.71,"I") D XMLDATA^MDCLIO("RANGE",5) Q ; High Diastolic
.I +MDVAL'>$$GET1^DIQ(120.57,"1,",5.81,"I") D XMLDATA^MDCLIO("RANGE",4) Q ; Low Diastolic
I $P(MDMAP,";",8) I MDVAL'<$$GET1^DIQ(120.57,"1,",$P(MDMAP,";",8),"I") D XMLDATA^MDCLIO("RANGE",5)
I $P(MDMAP,";",9) I MDVAL'>$$GET1^DIQ(120.57,"1,",$P(MDMAP,";",9),"I") D XMLDATA^MDCLIO("RANGE",4)
;
; Qualifiers
;
I $P(MDMAP,";",5)]"" D
.D XMLDATA^MDCLIO("UNIT_ID",$P(MDMAP,";",5))
F MDQIEN=0:0 S MDQIEN=$O(^GMR(120.5,+MDIENS,5,MDQIEN)) Q:'MDQIEN D
.S MDQUAL=+$G(^GMR(120.5,+MDIENS,5,MDQIEN,0)) Q:'MDQUAL
.S MDVUID=$$GET1^DIQ(120.52,MDQUAL_",",99.99)
.I 'MDVUID D Q
..S MDCMT=MDCMT_", missing VUID in Vitals "_$$GET1^DIQ(120.505,MDQIEN_","_MDIENS,.01)_" ("_MDQIEN_")"
.S MDGUID=$$GETGUID(MDVUID)
.I MDGUID="" D Q
..S MDCMT=MDCMT_", no mapping for "_$$GET1^DIQ(120.505,MDQIEN_","_MDIENS,.01)_" ("_MDQIEN_")"
.S MDIEN=$O(^MDC(704.101,"PK",MDGUID,0)) Q:'MDIEN
.D XMLDATA^MDCLIO($$GET1^DIQ(704.101,MDIEN_",",".05:.02"),$$GET1^DIQ(704.101,MDIEN_",",.01))
;
; Source
;
D XMLDATA^MDCLIO("SOURCE",$$VITALSID^MDCLIO())
;
; Comment
;
D XMLDATA^MDCLIO("COMMENT",MDCMT)
;
Q
;
GETGUID(Y) ; Returns the GUID for the current VUID
S X=+$O(^MDC(704.101,"VUID",Y,0)) Q:'X ""
Q $P(^MDC(704.101,X,0),"^",1)
;
GETNAME(Y) ; Returns the name of a term from GUID
Q:Y="" Y
S Y=$O(^MDC(704.101,"PK",Y,0)) Q:'Y ""
Q $P(^MDC(704.101,Y,0),"^",2)
;
GETMAP(ABBV) ; Returns the mapping string
N MDMAP
Q:ABBV="" ""
S MDMAP=""
F Y=1:1 S X=$T(MAP+Y) Q:$P(X,";",3)="***" S:$P(X,";",4)=ABBV MDMAP=$P($T(MAP+Y),";",3,20)
Q MDMAP
;
DISPMAP ; Displays the mapping below in readable format
N MDMAP
F Y=1:1 S MDMAP=$P($T(MAP+Y),";",3,30) Q:$P(MDMAP,";",1)="***" D
.W !!!,"---------------------------------------------------------------------"
.W !,"VITALS"
.W !," Name: ",$P(MDMAP,";",1)
.W !," Abbv: ",$P(MDMAP,";",2)
.W !," VUID: ",$P(MDMAP,";",3)
.W !," High Fld: ",$$GET1^DID(120.57,$P(MDMAP,";",8),"","LABEL")," = ",$$GET1^DIQ(120.57,"1,",$P(MDMAP,";",8),"I")
.W !," Low Fld: ",$$GET1^DID(120.57,$P(MDMAP,";",9),"","LABEL")," = ",$$GET1^DIQ(120.57,"1,",$P(MDMAP,";",9),"I")
.W !
.W !,"CLIO"
.W !," TERM_ID: ",$P(MDMAP,";",4)
.W !," TERM_NAME: ",$$GETNAME($P(MDMAP,";",4))
.W !," UNIT_ID: ",$P(MDMAP,";",5)
.W !," UNIT_NAME: ",$$GETNAME($P(MDMAP,";",5))
.W !," VALIDITY CHECK:"
.W !," ",$P(MDMAP,";",6)
.W !," CLIO TRANSFORM:"
.W !," ",$P(MDMAP,";",7)
Q
;
MAP ; Contains the mappings from Vitals to CliO - vital;abbv;vuid;term_guid;unit_guid;Validity Check;CliO Transform;Param Field Hi;Param Field Lo
;;ABDOMINAL GIRTH;AG;4536404;{F70E6642-2719-22BE-BE87-DEF0A884F177};{9CB32FC9-4130-11F8-E750-AF1415556705};
;;AUDIOMETRY;AUD;4688718;{FFD29134-8BB2-248E-0412-93C2C08B076F};;K:MDRATE'?.N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/" MDRATE
;;BLOOD PRESSURE;BP;4500634;{B15F2DF6-CE99-B847-FE6B-3D5F174A2BCD};;K:MDRATE'?1.3N1"/"1.3N&(MDRATE'?1.3N1"/"1.3N1"/"1.3N) MDRATE
;;CENTRAL VENOUS PRESSURE;CVP;4688719;{D30F98A7-4C5D-12E8-AB4D-9C85A4332EC3};{F7030BB1-AD2C-15F6-FF41-6DA893C851C1};;;6.1;6.2
;;CIRCUMFERENCE/GIRTH;CG;4688720;{92A124D4-B75F-9FD9-1A51-605887BCEA79};{9CB32FC9-4130-11F8-E750-AF1415556705};
;;FETAL HEART TONES;FT;4688721;{A2E22A44-E924-ADDE-2B8E-0251666B4DE6};{8319B3B0-0F31-1393-154D-59A86692D637};
;;FUNDAL HEIGHT;FH;4688722;{EEAB8762-624F-7BA3-4001-114FD229BA69};{9CB32FC9-4130-11F8-E750-AF1415556705};
;;HEAD CIRCUMFERENCE;HC;4536405;{33827E3C-5DBB-083C-D8BE-4DFD7D42071F};{9CB32FC9-4130-11F8-E750-AF1415556705};
;;HEARING;HE;4688723;{813CCC94-3D64-5093-BC6C-053EFD9948F9};;K:MDRATE'?1"N"!(MDRATE'?1"A") MDRATE
;;HEIGHT;HT;4688724;{B440216B-0FB3-1950-7859-7C1BE398FE4A};{9CB32FC9-4130-11F8-E750-AF1415556705};
;;PAIN;PN;4500635;{47A83DEA-BA95-38AD-DF2E-1F209122E684};;S:MDRATE="*" MDRATE=99 K:'MDRATE MDRATE;S:MDVAL="*" MDVAL=99
;;PULSE;P;4500636;{FCA63B76-EF4C-EBE5-33C1-F1EEBD7A7BC4};{8319B3B0-0F31-1393-154D-59A86692D637};;;5.3;5.4
;;PULSE OXIMETRY;PO2;4500637;{5F84DD55-3CCF-094C-2536-B51EB7FAD999};{0B3163CE-2C5C-B196-DBBE-A1BC6A970B2A};;;;6.3
;;RESPIRATION;R;4688725;{973ED2C0-0625-7DF9-17DC-8FFF7E376F23};{DCF89527-FFAE-F68E-0871-602F3C32DDB1};;;5.5;5.6
;;TEMPERATURE;T;4500638;{0F33223E-DF2C-6B8B-5201-5E091C5F9065};{59FC6CA4-9389-B770-5A9C-8C5A38C572D8};;;5.1;5.2
;;TONOMETRY;TON;4688726;{C06989EF-4B0F-4941-B1A7-FA9D81A480FF};{57CF7550-FD97-351E-DF60-56F8F68BE7C6};
;;VISION CORRECTED;VC;4688727;{ED022AC1-EBE4-E708-684D-63D00628A94C};{66D6F7EC-3884-4790-AC35-10B2AE84257F};
;;VISION UNCORRECTED;VU;4688728;{BEA5E565-D728-F5B3-0A3A-0528C42A45C4};{66D6F7EC-3884-4790-AC35-10B2AE84257F};
;;WEIGHT;WT;4500639;{CD2D8263-6B71-0E1C-0AFE-87B4B2C12632};{F9CBB050-E809-52FF-6C2D-51B7E9557F98};
;;***
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMDCLIOV 9384 printed Dec 13, 2024@01:42:23 Page 2
MDCLIOV ;HINES OIFO/DP - CliO Vitals Link;15 Nov 2010
+1 ;;1.0;CLINICAL PROCEDURES;**16**;Apr 01, 2004;Build 280
+2 ;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
+4 ; This routine uses the following IAs:
+5 ; #10104 - ^XLFSTR calls (supported)
+6 ; #1381 - GMRV VITAL MEASUREMENT (controlled subscription)
+7 ; #4504 - GEN. MED. REC. - VITALS (controlled subscription)
+8 ;
GETLIST ; Used to gather the list by patient/start/stop
+1 ; MDROOT and P2(0..n) passed in via the Script Engine
+2 NEW MDPT,MDFR,MDTO,MDTYPE,MDDT,MDDA,MDABBV,MDMAP,MDTEST,MDRATE
+3 SET MDPT=P2(0)
SET MDROOT=$NAME(^TMP("MDCLIO",$JOB))
KILL @MDROOT
+4 SET MDFR=9999999-$$FMDT^MDCLIO(P2(2))-.0000001
+5 SET MDTO=9999999-$$FMDT^MDCLIO(P2(1))
+6 FOR MDTYPE=0:0
SET MDTYPE=$ORDER(^GMR(120.5,"AA",MDPT,MDTYPE))
if 'MDTYPE
QUIT
Begin DoDot:1
+7 FOR MDDT=MDFR:0
SET MDDT=$ORDER(^GMR(120.5,"AA",MDPT,MDTYPE,MDDT))
if 'MDDT!(MDDT>MDTO)
QUIT
Begin DoDot:2
+8 FOR MDDA=0:0
SET MDDA=$ORDER(^GMR(120.5,"AA",MDPT,MDTYPE,MDDT,MDDA))
if 'MDDA
QUIT
Begin DoDot:3
+9 SET MDRATE=$$GET1^DIQ(120.5,MDDA_",",1.2)
+10 ; First filter - these aren't observations
if "UNAVAILABLEPASSREFUSED"[$$UP^XLFSTR(MDRATE)
QUIT
+11 ; If not numeric, pass it through a sanity check
IF +MDRATE'=MDRATE
Begin DoDot:4
+12 SET MDABBV=$$GET1^DIQ(120.5,MDDA_",",".03:1")
+13 ; No mapping, possibly a local addition
SET MDMAP=$$GETMAP(MDABBV)
IF MDMAP=""
KILL MDRATE
QUIT
+14 SET MDTEST=$PIECE(MDMAP,";",6,$LENGTH(MDMAP))
if MDTEST=""
QUIT
+15 ; Run the test allow value if it passes
IF MDTEST]""
XECUTE MDTEST
if $DATA(MDRATE)
QUIT
+16 ; It's a stinker :)
KILL MDRATE
End DoDot:4
if '$DATA(MDRATE)
QUIT
+17 SET @MDROOT@(MDDA)=""
End DoDot:3
End DoDot:2
End DoDot:1
+18 QUIT
+19 ;
GETLOG ; Get list of date/time pairs with data
+1 ; MDROOT and P2(0..n) passed in via the Script Engine
+2 NEW MDPT,MDFR,MDTO,MDTYPE,MDDT,MDSTAT,MDDATE,MDDA
+3 SET MDPT=P2(0)
SET MDROOT=$NAME(^TMP("MDCLIO",$JOB))
KILL @MDROOT
+4 SET MDFR=9999999-$$FMDT^MDCLIO(P2(2))-.0000001
+5 SET MDTO=9999999-$$FMDT^MDCLIO(P2(1))
+6 FOR MDTYPE=0:0
SET MDTYPE=$ORDER(^GMR(120.5,"AA",MDPT,MDTYPE))
if 'MDTYPE
QUIT
Begin DoDot:1
+7 FOR MDDT=MDFR:0
SET MDDT=$ORDER(^GMR(120.5,"AA",MDPT,MDTYPE,MDDT))
if 'MDDT!(MDDT>MDTO)
QUIT
Begin DoDot:2
+8 FOR MDDA=0:0
SET MDDA=$ORDER(^GMR(120.5,"AA",MDPT,MDTYPE,MDDT,MDDA))
if 'MDDA
QUIT
Begin DoDot:3
+9 SET MDRATE=$$GET1^DIQ(120.5,MDDA_",",1.2)
+10 ; First filter - these aren't observations
if "UNAVAILABLEPASSREFUSED"[$$UP^XLFSTR(MDRATE)
QUIT
+11 SET MDSTAT=$SELECT(+$$GET1^DIQ(120.5,MDDA_",",2,"I"):4,1:1)
+12 SET MDDATE=+$EXTRACT(9999999-MDDT,1,12)
+13 IF '$DATA(@MDROOT@(MDSTAT,MDDATE))
SET @MDROOT@(MDSTAT,MDDATE,MDDA)=""
End DoDot:3
End DoDot:2
End DoDot:1
+14 QUIT
+15 ;
GETBYID ; Builds the IEN list from the Vitals ID's sent down
+1 ; P2(0..n) passed in via the Script Engine
+2 ; MDROOT overridden on purpose to pass back to the Script Engine
+3 NEW MDID
+4 SET MDROOT=$NAME(^TMP("MDCLIO",$JOB))
KILL @MDROOT
+5 SET MDID=""
+6 FOR
SET MDID=$ORDER(P2(MDID))
if MDID=""
QUIT
if P2(MDID)]""
Begin DoDot:1
+7 SET @MDROOT@(0,+$PIECE(P2(MDID),"GMRV-",2))=""
End DoDot:1
+8 QUIT
+9 ;
GETOBS ; Build the Vitals Sign as a CliO observation
+1 ; MDIENS is from the Script Engine as the current record being processed
+2 NEW MDABBV,MDMAP,MDTERM,MDVAL,MDORD,MDQUAL,MDIEN,MDQIEN,MDVUID,MDGUID,MDCMT,MDSUPP
+3 SET MDCMT="Data retrieved from VistA Vitals Package"
+4 DO XMLDATA^MDCLIO("VITALS_IEN",+MDIENS)
+5 SET MDABBV=$$GET1^DIQ(120.5,MDIENS,"#.03:#1")
if MDABBV=""
QUIT
+6 SET MDMAP=$$GETMAP(MDABBV)
if MDMAP=""
QUIT
+7 DO XMLDATA^MDCLIO("STATUS",$SELECT(+$$GET1^DIQ(120.5,MDIENS,2,"I"):4,1:1))
+8 DO XMLDATA^MDCLIO("VITALS_TERM",$$GET1^DIQ(120.5,MDIENS,.03))
+9 SET MDTERM=$PIECE(MDMAP,";",4)
SET MDTERM(0)=$ORDER(^MDC(704.101,"PK",MDTERM,0))
+10 DO XMLDATA^MDCLIO("TERM_ID",MDTERM)
+11 DO XMLDATA^MDCLIO("TERM_NAME",$$GET1^DIQ(704.101,MDTERM(0)_",",.02))
+12 ;
+13 ; Value
+14 ;
+15 SET MDVAL=$$GET1^DIQ(120.5,MDIENS,1.2)
+16 ; Input transform from Vitals to CliO
IF $PIECE(MDMAP,";",7)]""
XECUTE $PIECE(MDMAP,";",7)
+17 DO XMLDATA^MDCLIO("PRE_VALUE",MDVAL)
+18 ; Picklist
if $PIECE(^MDC(704.101,MDTERM(0),0),"^",6)=3
Begin DoDot:1
+19 FOR MDORD=0:0
SET MDORD=$ORDER(^MDC(704.103,"PK",MDTERM(0),MDORD))
if 'MDORD
QUIT
Begin DoDot:2
+20 FOR MDQUAL=0:0
SET MDQUAL=$ORDER(^MDC(704.103,"PK",MDTERM(0),MDORD,MDQUAL))
if 'MDQUAL
QUIT
Begin DoDot:3
+21 if $PIECE(^MDC(704.101,MDQUAL,0),"^",5)'=11
QUIT
+22 SET MDIEN=$ORDER(^MDC(704.103,"PK",MDTERM(0),MDORD,MDQUAL,0))
+23 if $PIECE(^MDC(704.103,MDIEN,0),"^",4)=MDVAL
SET MDVAL=$PIECE(^MDC(704.101,MDQUAL,0),"^")
End DoDot:3
End DoDot:2
End DoDot:1
+24 DO XMLDATA^MDCLIO("SVALUE",MDVAL)
+25 SET MDSUPP=$$GET1^DIQ(120.5,MDIENS,1.4)
+26 IF MDSUPP]""
SET MDCMT=MDCMT_", Supp O2 "_MDSUPP
+27 ;
+28 ; Check for High/Low values in the local params file
+29 ;
+30 IF $PIECE(MDMAP,";",2)="BP"
if MDVAL?1.3N1"/"1.3N
Begin DoDot:1
+31 ; BP needs a special checker
+32 ; High Systolic
IF +MDVAL'<$$GET1^DIQ(120.57,"1,",5.7,"I")
DO XMLDATA^MDCLIO("RANGE",5)
QUIT
+33 ; Low Systolic
IF +MDVAL'>$$GET1^DIQ(120.57,"1,",5.8,"I")
DO XMLDATA^MDCLIO("RANGE",4)
QUIT
+34 ; High Diastolic
IF +MDVAL'<$$GET1^DIQ(120.57,"1,",5.71,"I")
DO XMLDATA^MDCLIO("RANGE",5)
QUIT
+35 ; Low Diastolic
IF +MDVAL'>$$GET1^DIQ(120.57,"1,",5.81,"I")
DO XMLDATA^MDCLIO("RANGE",4)
QUIT
End DoDot:1
+36 IF $PIECE(MDMAP,";",8)
IF MDVAL'<$$GET1^DIQ(120.57,"1,",$PIECE(MDMAP,";",8),"I")
DO XMLDATA^MDCLIO("RANGE",5)
+37 IF $PIECE(MDMAP,";",9)
IF MDVAL'>$$GET1^DIQ(120.57,"1,",$PIECE(MDMAP,";",9),"I")
DO XMLDATA^MDCLIO("RANGE",4)
+38 ;
+39 ; Qualifiers
+40 ;
+41 IF $PIECE(MDMAP,";",5)]""
Begin DoDot:1
+42 DO XMLDATA^MDCLIO("UNIT_ID",$PIECE(MDMAP,";",5))
End DoDot:1
+43 FOR MDQIEN=0:0
SET MDQIEN=$ORDER(^GMR(120.5,+MDIENS,5,MDQIEN))
if 'MDQIEN
QUIT
Begin DoDot:1
+44 SET MDQUAL=+$GET(^GMR(120.5,+MDIENS,5,MDQIEN,0))
if 'MDQUAL
QUIT
+45 SET MDVUID=$$GET1^DIQ(120.52,MDQUAL_",",99.99)
+46 IF 'MDVUID
Begin DoDot:2
+47 SET MDCMT=MDCMT_", missing VUID in Vitals "_$$GET1^DIQ(120.505,MDQIEN_","_MDIENS,.01)_" ("_MDQIEN_")"
End DoDot:2
QUIT
+48 SET MDGUID=$$GETGUID(MDVUID)
+49 IF MDGUID=""
Begin DoDot:2
+50 SET MDCMT=MDCMT_", no mapping for "_$$GET1^DIQ(120.505,MDQIEN_","_MDIENS,.01)_" ("_MDQIEN_")"
End DoDot:2
QUIT
+51 SET MDIEN=$ORDER(^MDC(704.101,"PK",MDGUID,0))
if 'MDIEN
QUIT
+52 DO XMLDATA^MDCLIO($$GET1^DIQ(704.101,MDIEN_",",".05:.02"),$$GET1^DIQ(704.101,MDIEN_",",.01))
End DoDot:1
+53 ;
+54 ; Source
+55 ;
+56 DO XMLDATA^MDCLIO("SOURCE",$$VITALSID^MDCLIO())
+57 ;
+58 ; Comment
+59 ;
+60 DO XMLDATA^MDCLIO("COMMENT",MDCMT)
+61 ;
+62 QUIT
+63 ;
GETGUID(Y) ; Returns the GUID for the current VUID
+1 SET X=+$ORDER(^MDC(704.101,"VUID",Y,0))
if 'X
QUIT ""
+2 QUIT $PIECE(^MDC(704.101,X,0),"^",1)
+3 ;
GETNAME(Y) ; Returns the name of a term from GUID
+1 if Y=""
QUIT Y
+2 SET Y=$ORDER(^MDC(704.101,"PK",Y,0))
if 'Y
QUIT ""
+3 QUIT $PIECE(^MDC(704.101,Y,0),"^",2)
+4 ;
GETMAP(ABBV) ; Returns the mapping string
+1 NEW MDMAP
+2 if ABBV=""
QUIT ""
+3 SET MDMAP=""
+4 FOR Y=1:1
SET X=$TEXT(MAP+Y)
if $PIECE(X,";",3)="***"
QUIT
if $PIECE(X,";",4)=ABBV
SET MDMAP=$PIECE($TEXT(MAP+Y),";",3,20)
+5 QUIT MDMAP
+6 ;
DISPMAP ; Displays the mapping below in readable format
+1 NEW MDMAP
+2 FOR Y=1:1
SET MDMAP=$PIECE($TEXT(MAP+Y),";",3,30)
if $PIECE(MDMAP,";",1)="***"
QUIT
Begin DoDot:1
+3 WRITE !!!,"---------------------------------------------------------------------"
+4 WRITE !,"VITALS"
+5 WRITE !," Name: ",$PIECE(MDMAP,";",1)
+6 WRITE !," Abbv: ",$PIECE(MDMAP,";",2)
+7 WRITE !," VUID: ",$PIECE(MDMAP,";",3)
+8 WRITE !," High Fld: ",$$GET1^DID(120.57,$PIECE(MDMAP,";",8),"","LABEL")," = ",$$GET1^DIQ(120.57,"1,",$PIECE(MDMAP,";",8),"I")
+9 WRITE !," Low Fld: ",$$GET1^DID(120.57,$PIECE(MDMAP,";",9),"","LABEL")," = ",$$GET1^DIQ(120.57,"1,",$PIECE(MDMAP,";",9),"I")
+10 WRITE !
+11 WRITE !,"CLIO"
+12 WRITE !," TERM_ID: ",$PIECE(MDMAP,";",4)
+13 WRITE !," TERM_NAME: ",$$GETNAME($PIECE(MDMAP,";",4))
+14 WRITE !," UNIT_ID: ",$PIECE(MDMAP,";",5)
+15 WRITE !," UNIT_NAME: ",$$GETNAME($PIECE(MDMAP,";",5))
+16 WRITE !," VALIDITY CHECK:"
+17 WRITE !," ",$PIECE(MDMAP,";",6)
+18 WRITE !," CLIO TRANSFORM:"
+19 WRITE !," ",$PIECE(MDMAP,";",7)
End DoDot:1
+20 QUIT
+21 ;
MAP ; Contains the mappings from Vitals to CliO - vital;abbv;vuid;term_guid;unit_guid;Validity Check;CliO Transform;Param Field Hi;Param Field Lo
+1 ;;ABDOMINAL GIRTH;AG;4536404;{F70E6642-2719-22BE-BE87-DEF0A884F177};{9CB32FC9-4130-11F8-E750-AF1415556705};
+2 ;;AUDIOMETRY;AUD;4688718;{FFD29134-8BB2-248E-0412-93C2C08B076F};;K:MDRATE'?.N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/".N1"/" MDRATE
+3 ;;BLOOD PRESSURE;BP;4500634;{B15F2DF6-CE99-B847-FE6B-3D5F174A2BCD};;K:MDRATE'?1.3N1"/"1.3N&(MDRATE'?1.3N1"/"1.3N1"/"1.3N) MDRATE
+4 ;;CENTRAL VENOUS PRESSURE;CVP;4688719;{D30F98A7-4C5D-12E8-AB4D-9C85A4332EC3};{F7030BB1-AD2C-15F6-FF41-6DA893C851C1};;;6.1;6.2
+5 ;;CIRCUMFERENCE/GIRTH;CG;4688720;{92A124D4-B75F-9FD9-1A51-605887BCEA79};{9CB32FC9-4130-11F8-E750-AF1415556705};
+6 ;;FETAL HEART TONES;FT;4688721;{A2E22A44-E924-ADDE-2B8E-0251666B4DE6};{8319B3B0-0F31-1393-154D-59A86692D637};
+7 ;;FUNDAL HEIGHT;FH;4688722;{EEAB8762-624F-7BA3-4001-114FD229BA69};{9CB32FC9-4130-11F8-E750-AF1415556705};
+8 ;;HEAD CIRCUMFERENCE;HC;4536405;{33827E3C-5DBB-083C-D8BE-4DFD7D42071F};{9CB32FC9-4130-11F8-E750-AF1415556705};
+9 ;;HEARING;HE;4688723;{813CCC94-3D64-5093-BC6C-053EFD9948F9};;K:MDRATE'?1"N"!(MDRATE'?1"A") MDRATE
+10 ;;HEIGHT;HT;4688724;{B440216B-0FB3-1950-7859-7C1BE398FE4A};{9CB32FC9-4130-11F8-E750-AF1415556705};
+11 ;;PAIN;PN;4500635;{47A83DEA-BA95-38AD-DF2E-1F209122E684};;S:MDRATE="*" MDRATE=99 K:'MDRATE MDRATE;S:MDVAL="*" MDVAL=99
+12 ;;PULSE;P;4500636;{FCA63B76-EF4C-EBE5-33C1-F1EEBD7A7BC4};{8319B3B0-0F31-1393-154D-59A86692D637};;;5.3;5.4
+13 ;;PULSE OXIMETRY;PO2;4500637;{5F84DD55-3CCF-094C-2536-B51EB7FAD999};{0B3163CE-2C5C-B196-DBBE-A1BC6A970B2A};;;;6.3
+14 ;;RESPIRATION;R;4688725;{973ED2C0-0625-7DF9-17DC-8FFF7E376F23};{DCF89527-FFAE-F68E-0871-602F3C32DDB1};;;5.5;5.6
+15 ;;TEMPERATURE;T;4500638;{0F33223E-DF2C-6B8B-5201-5E091C5F9065};{59FC6CA4-9389-B770-5A9C-8C5A38C572D8};;;5.1;5.2
+16 ;;TONOMETRY;TON;4688726;{C06989EF-4B0F-4941-B1A7-FA9D81A480FF};{57CF7550-FD97-351E-DF60-56F8F68BE7C6};
+17 ;;VISION CORRECTED;VC;4688727;{ED022AC1-EBE4-E708-684D-63D00628A94C};{66D6F7EC-3884-4790-AC35-10B2AE84257F};
+18 ;;VISION UNCORRECTED;VU;4688728;{BEA5E565-D728-F5B3-0A3A-0528C42A45C4};{66D6F7EC-3884-4790-AC35-10B2AE84257F};
+19 ;;WEIGHT;WT;4500639;{CD2D8263-6B71-0E1C-0AFE-87B4B2C12632};{F9CBB050-E809-52FF-6C2D-51B7E9557F98};
+20 ;;***