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.
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};
 ;;***