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

BGOVAST.m

Go to the documentation of this file.
BGOVAST ; IHS/BAO/TMD - Manage V ASTHMA ;08-Jul-2013 14:14;DU
 ;;1.1;BGO COMPONENTS;**1,3,6,10,11,13**;Mar 20, 2007;Build 16
 ;---------------------------------------------
 ; Get V Asthma entries by individual entry, visit, or patient
 ;  INP = Patient IEN [1] ^ V File IEN [2] ^ Visit IEN [3]
GET(RET,INP) ;EP
 D VFGET^BGOUTL2(.RET,INP,$$FNUM,".03;.04;.05;.06;.07;.08;.09;.11;.12;1201;1204")
 Q
 ;Get last asthma control data for a patient
 ;INP = Patient IEN [1]
 ;Ret=Paient [1] ^Visit IEN [2] ^ date [3] ^control [4]
GET2(RET,INP) ;EP
 N DFN,ADT,CONTROL,IEN,X,VST,DTE
 S CONTROL=""
 S DFN=$P(INP,U,1)
 S ADT="" S ADT=$O(^AUPNVAST("AAC",DFN,ADT)) Q:ADT=""  D
 .S IEN="" S IEN=$O(^AUPNVAST("AAC",DFN,ADT,IEN),-1) Q:IEN=""  D
 ..S CONTROL=$G(^AUPNVAST("AAC",DFN,ADT,IEN))
 S X=$S(CONTROL="W":"WELL CONTROLLED",CONTROL="N":"NOT WELL CONTROLLED",CONTROL="V":"VERY POORLY CONTROLLED",1:"")
 S VST=$$GET1^DIQ(9000010.41,IEN,.03,"I")
 S DTE=$$GET1^DIQ(9000010.41,IEN,.03,"E")
 S RET=DFN_U_VST_U_DTE_U_X
 Q
 ;Get asthma registry entry
GETREG(RET,DFN) ;EP
 S RET=$$GETREC^BGOUTL(90181.01,DFN,".02;.06;.07;.08;.12")
 Q
 ; Fetch asthma registry note
GETNOTE(RET,DFN) ;EP
 K RET
 I '$D(^BATREG(DFN,0)) S RET(0)=$$ERR^BGOUTL(1071) Q
 I $$GET1^DIQ(90181.01,DFN,1100,"","RET")
 Q
 ; Add/edit V Asthma Registry entry
 ;  INP = V File IEN [1] ^ Visit IEN [2] ^ Asthma Status [4]
SET(RET,INP) ;EP
 N VIEN,FNUM,VFIEN,VIEN,VFNEW,FDA
 S RET="",FNUM=$$FNUM
 S VFIEN=+INP
 S VFNEW='VFIEN
 S VIEN=$P(INP,U,2)
 S RET=$$CHKVISIT^BGOUTL(VIEN)
 Q:RET
 I 'VFIEN S VFIEN=$O(^AUPNVAST("AD",VIEN,VFIEN),-1)
 I 'VFIEN D  Q:'VFIEN
 .D VFNEW^BGOUTL2(.RET,FNUM,1,VIEN)
 .S:RET>0 VFIEN=RET,RET=""
 S FDA=$NA(FDA(FNUM,VFIEN_","))
 S @FDA@(.14)=$P(INP,U,3)
 S @FDA@(1204)="`"_DUZ
 S @FDA@(1201)="N"
 ;IHS/MSC/MGH new fields patch 11
 I VFNEW D
 .S @FDA@(1216)="N"
 .S @FDA@(1217)="`"_DUZ
 S @FDA@(1218)="N"
 S @FDA@(1219)="`"_DUZ
 S RET=$$UPDATE^BGOUTL(.FDA,"E")
 I RET,VFNEW,$$DELETE^BGOUTL(FNUM,VFIEN)
 D:'RET VFEVT^BGOUTL2(FNUM,VFIEN,'VFNEW)
 S:'RET RET=VFIEN
 Q
 ; Add/edit Asthma Registry entry
 ;  INP = Patient IEN [1] ^ Status [2] ^ Last Visit Date [3] ^ Date Due [4] ^ Next Appt Date [5] ^
 ;        Case Manager [6] ^ Note [7]
SETREG(RET,INP) ;EP
 N DFN,IENS,FDA,NOTE
 S DFN=+INP
 S IENS=$S($D(^BATREG(DFN)):DFN_",",1:"+1,")
 S FDA=$NA(FDA(90181.01,IENS))
 S:$E(IENS)="+" @FDA@(.01)="`"_DFN
 S @FDA@(.02)=$P(INP,U,2)
 S @FDA@(.06)=$P(INP,U,3)
 ;S @FDA@(.07)=$P(INP,U,4)
 S:$P(INP,U,3) @FDA@(.07)=$$FMADD^XLFDT($P(INP,U,3),180)
 S @FDA@(.08)=$P(INP,U,5)
 S @FDA@(.12)=$$PTR($P(INP,U,6))
 S NOTE=$P(INP,U,7)
 S @FDA@(1100)=$$TOWP^BGOUTL("NOTE")
 S RET=$$UPDATE^BGOUTL(.FDA,"E")
 Q
PTR(X) Q $S($L(X):"`"_X,1:"")
 ; Delete a V Allergy entry
DEL(RET,VFIEN) ;EP
 D VFDEL^BGOUTL2(.RET,$$FNUM,VFIEN)
 Q
 ;Get RED and YELLOW zone data
 ;INP = Patient IEN [1]
 ;Ret= RED [1] ^ RED ZONE [2] ^ DATE [3]
GETZONE(RET,INP) ;EP
 N DFN,EDT,ADT,CONTROL,IEN,YDT,RDT,DTE,VST,RED,YELLOW,CNT
 S CNT=0
 S RET=$$TMPGBL^BGOUTL
 S (RED,YELLOW)=""
 S DFN=$P(INP,U,1)
 S ADT="" F  S ADT=$O(^AUPNVAST("AA",DFN,ADT)) Q:ADT=""  D
 .S IEN="" F  S IEN=$O(^AUPNVAST("AA",DFN,ADT,IEN),-1) Q:IEN=""  D
 ..S EDT=$P($G(^AUPNVAST(IEN,12)),U,1)
 ..I EDT="" D
 ...S VST=$P($G(^AUPNVAST(IEN,0)),U,3)
 ...S EDT=$P($G(^AUPNVSIT(VST,0)),U,1)
 ..S RED=$P($G(^AUPNVAST(IEN,13)),U,1),RDT=9999999-ADT
 ..S YELLOW=$P($G(^AUPNVAST(IEN,11)),U,1),YDT=9999999-ADT
 ..Q:RED=""&(YELLOW="")
 ..S CNT=CNT+1 S @RET@(CNT)=IEN_U_"RED"_U_RED_U_EDT
 ..S CNT=CNT+1 S @RET@(CNT)=IEN_U_"YELL0W"_U_YELLOW_U_EDT
 Q
SETZONE(RET,DFN,VIEN,INP) ;EP to set red and yellow zone instructions
 N RET,FNUM,VFIEN,INSTR,DATA,OLDR,OLDY
 S RET="",FNUM=$$FNUM
 S RET=$$CHKVISIT^BGOUTL(VIEN,DFN)
 Q:RET
 S VFIEN="" S VFIEN=$O(^AUPNVAST("AD",VIEN,VFIEN),-1)
 S VFNEW='VFIEN
 ;If RED and YELLOW already set for this visit, make a new entry
 I VFIEN D
 .S OLDR=$$GET1^DIQ(9000010.41,VFIEN,1301)
 .S OLDY=$$GET1^DIQ(9000010.41,VFIEN,1101)
 .I (OLDR'="")!(OLDY'="") S VFIEN=""
 I 'VFIEN D  Q:'VFIEN
 .D VFNEW^BGOUTL2(.RET,FNUM,1,VIEN)
 .S:RET>0 VFIEN=RET,RET=""
 S FDA=$NA(FDA(FNUM,VFIEN_","))
 S INSTR="" F  S INSTR=$O(INP(INSTR)) Q:INSTR=""  D
 .S DATA=$G(INP(INSTR))
 .I $P(DATA,U,2)="" S $P(DATA,U,2)="@"
 .I $P(DATA,U,1)="R" S @FDA@(1301)=$P(DATA,U,2)
 .I $P(DATA,U,1)="Y" S @FDA@(1101)=$P(DATA,U,2)
 S @FDA@(1204)="`"_DUZ
 S @FDA@(1201)="N"
 I VFNEW D
 .S @FDA@(1216)="N"
 .S @FDA@(1217)="`"_DUZ
 S @FDA@(1218)="N"
 S @FDA@(1219)="`"_DUZ
 S RET=$$UPDATE^BGOUTL(.FDA,"E")
 I RET,VFNEW,$$DELETE^BGOUTL(FNUM,VFIEN)
 D:'RET VFEVT^BGOUTL2(FNUM,VFIEN,'VFNEW)
 S:'RET RET=VFIEN
 Q
 ; Asthma education topic IEN
EDTOP() Q $O(^AUTTEDT("B","ASM-SMP",0))
 ; Return V File #
FNUM() Q 9000010.41