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

MDCLIOV.m

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