BEDDSYNC ;GDIT/HS/BEE-SYNC BEDD WITH AMER/PCC ; 08 Nov 2011 12:00 PM
;;2.0;BEDD DASHBOARD;;Jun 04, 2014;Build 13
;
;This routine is included in the BEDD XML 2.0 install and is not in the KIDS
;
Q
;
NEW AUPNVSIT
;
SYNC() ;EP - SYNC BEDD with AMER/PCC
;
I $G(AUPNVSIT)="" Q
;
NEW OBJID,EXEC,INJ,ISINJ,STS,AMERDA,INJCS,INJTWN,INJDT,INJMVC
NEW INJICO,INJIPO,INJSET,INJSAF
;
;Get the ER VISIT Id
S AMERDA=$O(^AMERVSIT("AD",AUPNVSIT,"")) Q:AMERDA=""
;
;Get the BEDD Object Id
S (ISINJ,INJCS,INJTWN,OBJID,INJDT,INJMVC,INJICO,INJIPO,INJSET,INJSAF)=""
S EXEC="S OBJID=$O(^BEDD.EDVISITI(""ADIdx"",AUPNVSIT,""""))" X EXEC
I OBJID="" Q
;
;SYNC up injury information
;
;Format Is Injury
S ISINJ=$$GET1^DIQ(9009080,AMERDA_",",3.1,"I"),ISINJ=$S(ISINJ=1:"YES",1:"NO")
;
;Open the class entry
S EXEC="S INJ=##CLASS(BEDD.EDVISIT).%OpenId("_OBJID_",0)" X EXEC
;
;Injury YES/NO
S EXEC="S INJ.Injury=ISINJ" X EXEC
;
;Injury Cause
S INJCS=$$GET1^DIQ(9009080,AMERDA_",",3.2,"I"),INJCS=$S(INJCS]"":INJCS,1:"@")
S EXEC="S INJ.PtInjury.InjCauseIEN=INJCS" X EXEC
;
;Injury Town Location
S INJTWN=$$GET1^DIQ(9009080,AMERDA_",",3.6,"I"),INJTWN=$S(INJTWN]"":INJTWN,1:"@")
S EXEC="S INJ.PtInjury.InjLocat=INJTWN" X EXEC
;
;Injury Date/Time
S INJDT=$$GET1^DIQ(9009080,AMERDA_",",3.4,"I"),INJDT=$S(INJDT]"":INJDT,1:"@")
S EXEC="S INJ.PtInjury.InjDtTm=INJDT" X EXEC
;
;Injury - MVC Location
S INJMVC=$$GET1^DIQ(9009080,AMERDA_",",13.1,"I"),INJMVC=$S(INJMVC]"":INJMVC,1:"@")
S EXEC="S INJ.PtInjury.MVCLoc=INJMVC" X EXEC
;
;Injury - Driver Insurance Company
S INJICO=$$GET1^DIQ(9009080,AMERDA_",",13.2,"I"),INJICO=$S(INJICO]"":INJICO,1:"@")
S EXEC="S INJ.PtInjury.AtFaultInsurance=INJICO" X EXEC
;
;Injury - Driver Insurance Policy
S INJIPO=$$GET1^DIQ(9009080,AMERDA_",",13.3,"I"),INJIPO=$S(INJIPO]"":INJIPO,1:"@")
S EXEC="S INJ.PtInjury.AtFaultInsPolicy=INJIPO" X EXEC
;
;Injury - Setting
S INJSET=$$GET1^DIQ(9009080,AMERDA_",",3.3,"I"),INJSET=$S(INJSET]"":INJSET,1:"@")
S EXEC="S INJ.PtInjury.InjSet=INJSET" X EXEC
;
;Injury - Safety Equipment
S INJSAF=$$GET1^DIQ(9009080,AMERDA_",",3.5,"I"),INJSAF=$S(INJSAF]"":INJSAF,1:"@")
S EXEC="S INJ.PtInjury.SafetyEquip=INJSAF" X EXEC
;
;Save the entry
S EXEC="S STS=INJ.%Save()" X EXEC
S INJ=""
;
Q
;
INJFLD(VIEN,FIELD,VALUE) ;Update the specific BEDD injury field
;
I $G(VIEN)="" Q
;
NEW OBJID,EXEC,INJ,STS,AUPNVSIT
;
;Get the BEDD Object Id
S (OBJID)=""
S EXEC="S OBJID=$O(^BEDD.EDVISITI(""ADIdx"",VIEN,""""))" X EXEC
I OBJID="" Q
;
;Format Injury
I (FIELD="INJ.Injury")!(FIELD="INJ.PtInjury.WrkRel") S VALUE=$S(VALUE=1:"YES",1:"NO")
;
;Open the entry
S EXEC="S INJ=##CLASS(BEDD.EDVISIT).%OpenId("_OBJID_",0)" X EXEC
;
;Assemble the entry to save
S EXEC="S "_FIELD_"="""_VALUE_"""" X EXEC
;
;Save the entry
S EXEC="S STS=INJ.%Save()" X EXEC
S INJ=""
;
;Flag visit as updated
S AUPNVSIT=VIEN D MOD^AUPNVSIT
Q
BEDDSYNC ;GDIT/HS/BEE-SYNC BEDD WITH AMER/PCC ; 08 Nov 2011 12:00 PM
+1 ;;2.0;BEDD DASHBOARD;;Jun 04, 2014;Build 13
+2 ;
+3 ;This routine is included in the BEDD XML 2.0 install and is not in the KIDS
+4 ;
+5 QUIT
+6 ;
+7 NEW AUPNVSIT
+8 ;
SYNC() ;EP - SYNC BEDD with AMER/PCC
+1 ;
+2 IF $GET(AUPNVSIT)=""
QUIT
+3 ;
+4 NEW OBJID,EXEC,INJ,ISINJ,STS,AMERDA,INJCS,INJTWN,INJDT,INJMVC
+5 NEW INJICO,INJIPO,INJSET,INJSAF
+6 ;
+7 ;Get the ER VISIT Id
+8 SET AMERDA=$ORDER(^AMERVSIT("AD",AUPNVSIT,""))
IF AMERDA=""
QUIT
+9 ;
+10 ;Get the BEDD Object Id
+11 SET (ISINJ,INJCS,INJTWN,OBJID,INJDT,INJMVC,INJICO,INJIPO,INJSET,INJSAF)=""
+12 SET EXEC="S OBJID=$O(^BEDD.EDVISITI(""ADIdx"",AUPNVSIT,""""))"
XECUTE EXEC
+13 IF OBJID=""
QUIT
+14 ;
+15 ;SYNC up injury information
+16 ;
+17 ;Format Is Injury
+18 SET ISINJ=$$GET1^DIQ(9009080,AMERDA_",",3.1,"I")
SET ISINJ=$SELECT(ISINJ=1:"YES",1:"NO")
+19 ;
+20 ;Open the class entry
+21 SET EXEC="S INJ=##CLASS(BEDD.EDVISIT).%OpenId("_OBJID_",0)"
XECUTE EXEC
+22 ;
+23 ;Injury YES/NO
+24 SET EXEC="S INJ.Injury=ISINJ"
XECUTE EXEC
+25 ;
+26 ;Injury Cause
+27 SET INJCS=$$GET1^DIQ(9009080,AMERDA_",",3.2,"I")
SET INJCS=$SELECT(INJCS]"":INJCS,1:"@")
+28 SET EXEC="S INJ.PtInjury.InjCauseIEN=INJCS"
XECUTE EXEC
+29 ;
+30 ;Injury Town Location
+31 SET INJTWN=$$GET1^DIQ(9009080,AMERDA_",",3.6,"I")
SET INJTWN=$SELECT(INJTWN]"":INJTWN,1:"@")
+32 SET EXEC="S INJ.PtInjury.InjLocat=INJTWN"
XECUTE EXEC
+33 ;
+34 ;Injury Date/Time
+35 SET INJDT=$$GET1^DIQ(9009080,AMERDA_",",3.4,"I")
SET INJDT=$SELECT(INJDT]"":INJDT,1:"@")
+36 SET EXEC="S INJ.PtInjury.InjDtTm=INJDT"
XECUTE EXEC
+37 ;
+38 ;Injury - MVC Location
+39 SET INJMVC=$$GET1^DIQ(9009080,AMERDA_",",13.1,"I")
SET INJMVC=$SELECT(INJMVC]"":INJMVC,1:"@")
+40 SET EXEC="S INJ.PtInjury.MVCLoc=INJMVC"
XECUTE EXEC
+41 ;
+42 ;Injury - Driver Insurance Company
+43 SET INJICO=$$GET1^DIQ(9009080,AMERDA_",",13.2,"I")
SET INJICO=$SELECT(INJICO]"":INJICO,1:"@")
+44 SET EXEC="S INJ.PtInjury.AtFaultInsurance=INJICO"
XECUTE EXEC
+45 ;
+46 ;Injury - Driver Insurance Policy
+47 SET INJIPO=$$GET1^DIQ(9009080,AMERDA_",",13.3,"I")
SET INJIPO=$SELECT(INJIPO]"":INJIPO,1:"@")
+48 SET EXEC="S INJ.PtInjury.AtFaultInsPolicy=INJIPO"
XECUTE EXEC
+49 ;
+50 ;Injury - Setting
+51 SET INJSET=$$GET1^DIQ(9009080,AMERDA_",",3.3,"I")
SET INJSET=$SELECT(INJSET]"":INJSET,1:"@")
+52 SET EXEC="S INJ.PtInjury.InjSet=INJSET"
XECUTE EXEC
+53 ;
+54 ;Injury - Safety Equipment
+55 SET INJSAF=$$GET1^DIQ(9009080,AMERDA_",",3.5,"I")
SET INJSAF=$SELECT(INJSAF]"":INJSAF,1:"@")
+56 SET EXEC="S INJ.PtInjury.SafetyEquip=INJSAF"
XECUTE EXEC
+57 ;
+58 ;Save the entry
+59 SET EXEC="S STS=INJ.%Save()"
XECUTE EXEC
+60 SET INJ=""
+61 ;
+62 QUIT
+63 ;
INJFLD(VIEN,FIELD,VALUE) ;Update the specific BEDD injury field
+1 ;
+2 IF $GET(VIEN)=""
QUIT
+3 ;
+4 NEW OBJID,EXEC,INJ,STS,AUPNVSIT
+5 ;
+6 ;Get the BEDD Object Id
+7 SET (OBJID)=""
+8 SET EXEC="S OBJID=$O(^BEDD.EDVISITI(""ADIdx"",VIEN,""""))"
XECUTE EXEC
+9 IF OBJID=""
QUIT
+10 ;
+11 ;Format Injury
+12 IF (FIELD="INJ.Injury")!(FIELD="INJ.PtInjury.WrkRel")
SET VALUE=$SELECT(VALUE=1:"YES",1:"NO")
+13 ;
+14 ;Open the entry
+15 SET EXEC="S INJ=##CLASS(BEDD.EDVISIT).%OpenId("_OBJID_",0)"
XECUTE EXEC
+16 ;
+17 ;Assemble the entry to save
+18 SET EXEC="S "_FIELD_"="""_VALUE_""""
XECUTE EXEC
+19 ;
+20 ;Save the entry
+21 SET EXEC="S STS=INJ.%Save()"
XECUTE EXEC
+22 SET INJ=""
+23 ;
+24 ;Flag visit as updated
+25 SET AUPNVSIT=VIEN
DO MOD^AUPNVSIT
+26 QUIT