BTIULO17 ; IHS/MSC/JS - Problem/Visit Objects ;16-Sep-2013 15:46;DU
;;1.0;TEXT INTEGRATION UTILITIES;**1012**;MAR 20, 2013;Build 45
;Obects for visit-related anti-coag data
Q
;
VIDT(DFN,TARGET) ; Anticoag for current visit
N ARRAY,PRIEN,IEN,VCNT,CNT,EDATE,SIGN,STAT,NARR,VST,X
I $T(GETVAR^CIAVMEVT)="" S @TARGET@(1,0)="Invalid context variables" Q "~@"_$NA(@TARGET)
S CNT=0
S VST=$$GETVAR^CIAVMEVT("ENCOUNTER.ID.ALTERNATEVISITID",,"CONTEXT.ENCOUNTER")
I VST="" S @TARGET@(1,0)="Invalid visit" Q "~@"_$NA(@TARGET)
S X="BEHOENCX" X ^%ZOSF("TEST") I $T S VST=+$$VSTR2VIS^BEHOENCX(DFN,VST) I VST<1 S @TARGET@(1,0)="Invalid context variables" Q "~@"_$NA(@TARGET)
K @TARGET
S IEN="" F S IEN=$O(^AUPNVACG("AD",VST,IEN)) Q:IEN="" D
.Q:$$GET1^DIQ(9000010.51,IEN,1.01)'=""
.D DATA(IEN)
I CNT=0 S @TARGET@(1,0)="No Anticoag for this visit"
Q "~@"_$NA(@TARGET)
;
LAST(DFN,TARGET,NUM) ; Last V anti-coag for this patient
N IEN,FOUND,CNT,CNT2
I $G(NUM)="" S NUM=1
S CNT=0,CNT2=1
I $T(GETVAR^CIAVMEVT)="" S @TARGET@(1,0)="Invalid context variables" Q "~@"_$NA(@TARGET)
K @TARGET
S IEN=$C(0) F S IEN=$O(^AUPNVACG("AC",DFN,IEN),-1) Q:IEN=""!(CNT2>NUM) D
.Q:$$GET1^DIQ(9000010.51,IEN,1.01)'=""
.S CNT2=CNT2+1 D DATA(IEN)
I CNT=0 S @TARGET@(1,0)="No Anti-coag entries"
Q "~@"_$NA(@TARGET)
DATA(DFN) ;Get the data for the anticoag entry
N EVDT,WAR,GOAL,MAX,MIN,DUR,START,STOP,COMM,STRING,STRING,COMMENT,END,STRING2
S STRING2=""
S EVDT=$$GET1^DIQ(9000010.51,IEN,1201)
I EVDT="" S EVDT=$$GET1^DIQ(9000010.51,IEN,.03)
S WAR=$$GET1^DIQ(9000010.51,IEN,.01)
S GOAL=$$GET1^DIQ(9000010.51,IEN,.04)
S MIN=$$GET1^DIQ(9000010.51,IEN,.05)
S MAX=$$GET1^DIQ(9000010.51,IEN,.06)
S DUR=$$GET1^DIQ(9000010.51,IEN,.07)
S START=$$GET1^DIQ(9000010.51,IEN,.08)
S END=$$GET1^DIQ(9000010.51,IEN,.09)
S COMMENT=$$GET1^DIQ(9000010.51,IEN,1101)
S CNT=CNT+1
S @TARGET@(CNT,0)="Date: "_EVDT_" Warfarin: "_WAR
S CNT=CNT+1
S STRING="Goal: "_GOAL
I MIN'="" S STRING=STRING_" Min: "_MIN
I MAX'="" S STRING=STRING_" Max: "_MAX
S @TARGET@(CNT,0)=STRING
S CNT=CNT+1
S @TARGET@(CNT,0)="Duration: "_DUR
I START'="" S STRING2="Start "_START
I END'="" S STRING2=STRING2_" End: "_END
I STRING2'="" S CNT=CNT+1 S @TARGET@(CNT,0)=STRING2
I COMMENT'="" S CNT=CNT+1 S @TARGET@(CNT,0)="Comment: "_COMMENT
S CNT=CNT+1 S @TARGET@(CNT,0)=""
Q
BTIULO17 ; IHS/MSC/JS - Problem/Visit Objects ;16-Sep-2013 15:46;DU
+1 ;;1.0;TEXT INTEGRATION UTILITIES;**1012**;MAR 20, 2013;Build 45
+2 ;Obects for visit-related anti-coag data
+3 QUIT
+4 ;
VIDT(DFN,TARGET) ; Anticoag for current visit
+1 NEW ARRAY,PRIEN,IEN,VCNT,CNT,EDATE,SIGN,STAT,NARR,VST,X
+2 IF $TEXT(GETVAR^CIAVMEVT)=""
SET @TARGET@(1,0)="Invalid context variables"
QUIT "~@"_$NAME(@TARGET)
+3 SET CNT=0
+4 SET VST=$$GETVAR^CIAVMEVT("ENCOUNTER.ID.ALTERNATEVISITID",,"CONTEXT.ENCOUNTER")
+5 IF VST=""
SET @TARGET@(1,0)="Invalid visit"
QUIT "~@"_$NAME(@TARGET)
+6 SET X="BEHOENCX"
XECUTE ^%ZOSF("TEST")
IF $TEST
SET VST=+$$VSTR2VIS^BEHOENCX(DFN,VST)
IF VST<1
SET @TARGET@(1,0)="Invalid context variables"
QUIT "~@"_$NAME(@TARGET)
+7 KILL @TARGET
+8 SET IEN=""
FOR
SET IEN=$ORDER(^AUPNVACG("AD",VST,IEN))
IF IEN=""
QUIT
Begin DoDot:1
+9 IF $$GET1^DIQ(9000010.51,IEN,1.01)'=""
QUIT
+10 DO DATA(IEN)
End DoDot:1
+11 IF CNT=0
SET @TARGET@(1,0)="No Anticoag for this visit"
+12 QUIT "~@"_$NAME(@TARGET)
+13 ;
LAST(DFN,TARGET,NUM) ; Last V anti-coag for this patient
+1 NEW IEN,FOUND,CNT,CNT2
+2 IF $GET(NUM)=""
SET NUM=1
+3 SET CNT=0
SET CNT2=1
+4 IF $TEXT(GETVAR^CIAVMEVT)=""
SET @TARGET@(1,0)="Invalid context variables"
QUIT "~@"_$NAME(@TARGET)
+5 KILL @TARGET
+6 SET IEN=$CHAR(0)
FOR
SET IEN=$ORDER(^AUPNVACG("AC",DFN,IEN),-1)
IF IEN=""!(CNT2>NUM)
QUIT
Begin DoDot:1
+7 IF $$GET1^DIQ(9000010.51,IEN,1.01)'=""
QUIT
+8 SET CNT2=CNT2+1
DO DATA(IEN)
End DoDot:1
+9 IF CNT=0
SET @TARGET@(1,0)="No Anti-coag entries"
+10 QUIT "~@"_$NAME(@TARGET)
DATA(DFN) ;Get the data for the anticoag entry
+1 NEW EVDT,WAR,GOAL,MAX,MIN,DUR,START,STOP,COMM,STRING,STRING,COMMENT,END,STRING2
+2 SET STRING2=""
+3 SET EVDT=$$GET1^DIQ(9000010.51,IEN,1201)
+4 IF EVDT=""
SET EVDT=$$GET1^DIQ(9000010.51,IEN,.03)
+5 SET WAR=$$GET1^DIQ(9000010.51,IEN,.01)
+6 SET GOAL=$$GET1^DIQ(9000010.51,IEN,.04)
+7 SET MIN=$$GET1^DIQ(9000010.51,IEN,.05)
+8 SET MAX=$$GET1^DIQ(9000010.51,IEN,.06)
+9 SET DUR=$$GET1^DIQ(9000010.51,IEN,.07)
+10 SET START=$$GET1^DIQ(9000010.51,IEN,.08)
+11 SET END=$$GET1^DIQ(9000010.51,IEN,.09)
+12 SET COMMENT=$$GET1^DIQ(9000010.51,IEN,1101)
+13 SET CNT=CNT+1
+14 SET @TARGET@(CNT,0)="Date: "_EVDT_" Warfarin: "_WAR
+15 SET CNT=CNT+1
+16 SET STRING="Goal: "_GOAL
+17 IF MIN'=""
SET STRING=STRING_" Min: "_MIN
+18 IF MAX'=""
SET STRING=STRING_" Max: "_MAX
+19 SET @TARGET@(CNT,0)=STRING
+20 SET CNT=CNT+1
+21 SET @TARGET@(CNT,0)="Duration: "_DUR
+22 IF START'=""
SET STRING2="Start "_START
+23 IF END'=""
SET STRING2=STRING2_" End: "_END
+24 IF STRING2'=""
SET CNT=CNT+1
SET @TARGET@(CNT,0)=STRING2
+25 IF COMMENT'=""
SET CNT=CNT+1
SET @TARGET@(CNT,0)="Comment: "_COMMENT
+26 SET CNT=CNT+1
SET @TARGET@(CNT,0)=""
+27 QUIT