BGOICDPR ; IHS/BAO/TMD - ICD PREFERENCES MANAGER ;14-Mar-2013 11:07;DU
;;1.1;BGO COMPONENTS;**1,3,5,8,12**;Mar 20, 2007;Build 5
; Validate an ICD9 code
VALIDATE(RET,IEN,CODE) ;EP
I 'IEN,$G(CODE)'="" D
.N X,LP
.S IEN=-1,RET=-1
.F LP=0,1 D Q:RET'<0
..F X=0:0 S X=$O(^ICD9("AB",CODE_$S(LP:" ",1:""),X)) Q:'X D Q:RET'<0
...S IEN=X
...S RET=$$CHKICD^BGOVPOV(IEN)
.S:IEN<0 RET=$$ERR^BGOUTL(1029,CODE)
E I 'IEN S RET=$$ERR^BGOUTL(1030)
E S RET=$$CHKICD^BGOVPOV(IEN)
S:RET'<0 RET=""
Q
; Return long name for an ICD9 code
GETLNAME(RET,IEN) ;EP
I 'IEN S RET=$$ERR^BGOUTL(1030)
E D
.I $$AICD^BGOUTL2 S RET=$$LD^ICDEX(80,IEN,DT)
.E S RET=$P($G(^ICD9(+IEN,1)),U)
Q
; Return categories matching specified criteria
; INP = Category IEN [1] ^ Hospital Location IEN [2] ^ Provider IEN [3] ^ Manager IEN [4] ^ Show All [5]
GETCATS(RET,INP) ;EP
D GETCATS^BGOPFUTL(.RET,INP,90362.35)
Q
; Returns list of ICD9s for specified category
; INP = Category IEN [1] ^ Group [2] ^ Visit IEN [3] ^ Display Freq Order [4]
; Returns list of records in the format
; ICD9 IEN [1] ^ ICD9 Code [2] ^ ICD9 Text [3] ^ Short Text [4] ^ Freq [5] ^
; VPOV IEN [6] ^ Rank [7] ^ Pref IEN [8] ^ Long Text [9]
GETITEMS(RET,INP) ;EP
N PX,I,J,FREQ,VIEN,GRP,CAT,LONG,VPX,FREQ,CNT,RANK,IEN
S RET=$$TMPGBL^BGOUTL
S CAT=+INP
I 'CAT S @RET@(1)=$$ERR^BGOUTL(1018) Q
I '$D(^BGOICDPR(CAT,0)) S @RET@(1)=$$ERR^BGOUTL(1019) Q
S GRP=$P(INP,U,2)
S VIEN=$P(INP,U,3)
S FREQ=$P(INP,U,4)
S:$P(^BGOICDPR(CAT,0),U,6) GRP=""
I VIEN D
.S VPX=0
.F S VPX=$O(^AUPNVPOV("AD",VIEN,VPX)) Q:'VPX D
..S I=$G(^AUPNVPOV(VPX,0))
..S:$L(I) VPX(+I,+$P(I,U,4))=VPX
S (CNT,RANK)=0
I FREQ D
.S J=""
.F S J=$O(^BGOICDPR(CAT,1,"AC",J),-1) Q:J="" D
..S IEN=0
..F S IEN=$O(^BGOICDPR(CAT,1,"AC",J,IEN)) Q:'IEN D GD1
E D
.S IEN=0
.F S IEN=$O(^BGOICDPR(CAT,1,IEN)) Q:'IEN D GD1
Q
GD1 N N0,ICDIEN,TXT,DX,FREQVAL,CODE
S N0=$G(^BGOICDPR(CAT,1,IEN,0))
S ICDIEN=+N0
Q:'ICDIEN
Q:'$D(^ICD9(ICDIEN,0))
I $$AICD^BGOUTL2 S DX=$$SD^ICDEX(80,ICDIEN,DT)
E S DX=$P(^ICD9(ICDIEN,0),U,3)
S CODE=$P(^ICD9(ICDIEN,0),U)
S TXT=$P(N0,U,2),TXT(0)=+$$FNDNARR^BGOUTL2(TXT,0)
I $$AICD^BGOUTL2 S LONG=$$LD^ICDEX(80,ICDIEN,DT)
E S LONG=$P($G(^ICD9(ICDIEN,1)),U)
S FREQVAL=$P(N0,U,3)
I FREQ D
.S RANK=RANK+1
.S RANK=$S(RANK<10:"00",RANK<100:"0",1:"")_RANK
S CNT=CNT+1
S @RET@(CNT)=ICDIEN_U_CODE_U_DX_U_TXT_U_FREQVAL_U_$G(VPX(ICDIEN,TXT(0)))_U_RANK_U_IEN_U_LONG
Q
; Return list of managers associated with a specified category
GETMGRS(RET,CAT) ;EP
D GETMGRS^BGOPFUTL(.RET,CAT,90362.35)
Q
; Set category fields
; INP = Name [1] ^ Hosp Loc [2] ^ Clinic [3] ^ Provider [4] ^ User [5] ^ Category IEN [6] ^ Delete [7] ^ Discipline [8]
SETCAT(RET,INP) ;EP
D SETCAT^BGOPFUTL(.RET,INP,90362.35)
Q
; Set field values for a ICD preference entry
; INP = Category IEN [1] ^ ICD IEN [2] ^ Display Text [3] ^ Delete [4] ^ ICD Code [5] ^ Frequency [6] ^
; Allow Dups [7] ^ Item IEN [8]
SETITEM(RET,INP) ;EP
D SETITEM^BGOPFUTL(.RET,INP,90362.35)
Q
; Add or remove a manager from a category
; INP = Category IEN [1] ^ Manager IEN [2] ^ Add [3]
SETMGR(RET,INP) ;EP
D SETMGR^BGOPFUTL(.RET,INP,90362.352)
Q
; Set display name for an item
; INP = Category IEN [1] ^ Item IEN [2] ^ Display Name [3]
SETNAME(RET,INP) ;EP
D SETNAME^BGOPFUTL(.RET,INP,90362.351)
Q
; Set frequency for an item
; INP = Category IEN [1] ^ ICD IEN [2] ^ Increment [3] ^ Frequency [4]
SETFREQ(RET,INP) ;EP
D SETFREQ^BGOPFUTL(.RET,INP,90362.351)
Q
BGOICDPR ; IHS/BAO/TMD - ICD PREFERENCES MANAGER ;14-Mar-2013 11:07;DU
+1 ;;1.1;BGO COMPONENTS;**1,3,5,8,12**;Mar 20, 2007;Build 5
+2 ; Validate an ICD9 code
VALIDATE(RET,IEN,CODE) ;EP
+1 IF 'IEN
IF $GET(CODE)'=""
Begin DoDot:1
+2 NEW X,LP
+3 SET IEN=-1
SET RET=-1
+4 FOR LP=0,1
Begin DoDot:2
+5 FOR X=0:0
SET X=$ORDER(^ICD9("AB",CODE_$SELECT(LP:" ",1:""),X))
IF 'X
QUIT
Begin DoDot:3
+6 SET IEN=X
+7 SET RET=$$CHKICD^BGOVPOV(IEN)
End DoDot:3
IF RET'<0
QUIT
End DoDot:2
IF RET'<0
QUIT
+8 IF IEN<0
SET RET=$$ERR^BGOUTL(1029,CODE)
End DoDot:1
+9 IF '$TEST
IF 'IEN
SET RET=$$ERR^BGOUTL(1030)
+10 IF '$TEST
SET RET=$$CHKICD^BGOVPOV(IEN)
+11 IF RET'<0
SET RET=""
+12 QUIT
+13 ; Return long name for an ICD9 code
GETLNAME(RET,IEN) ;EP
+1 IF 'IEN
SET RET=$$ERR^BGOUTL(1030)
+2 IF '$TEST
Begin DoDot:1
+3 IF $$AICD^BGOUTL2
SET RET=$$LD^ICDEX(80,IEN,DT)
+4 IF '$TEST
SET RET=$PIECE($GET(^ICD9(+IEN,1)),U)
End DoDot:1
+5 QUIT
+6 ; Return categories matching specified criteria
+7 ; INP = Category IEN [1] ^ Hospital Location IEN [2] ^ Provider IEN [3] ^ Manager IEN [4] ^ Show All [5]
GETCATS(RET,INP) ;EP
+1 DO GETCATS^BGOPFUTL(.RET,INP,90362.35)
+2 QUIT
+3 ; Returns list of ICD9s for specified category
+4 ; INP = Category IEN [1] ^ Group [2] ^ Visit IEN [3] ^ Display Freq Order [4]
+5 ; Returns list of records in the format
+6 ; ICD9 IEN [1] ^ ICD9 Code [2] ^ ICD9 Text [3] ^ Short Text [4] ^ Freq [5] ^
+7 ; VPOV IEN [6] ^ Rank [7] ^ Pref IEN [8] ^ Long Text [9]
GETITEMS(RET,INP) ;EP
+1 NEW PX,I,J,FREQ,VIEN,GRP,CAT,LONG,VPX,FREQ,CNT,RANK,IEN
+2 SET RET=$$TMPGBL^BGOUTL
+3 SET CAT=+INP
+4 IF 'CAT
SET @RET@(1)=$$ERR^BGOUTL(1018)
QUIT
+5 IF '$DATA(^BGOICDPR(CAT,0))
SET @RET@(1)=$$ERR^BGOUTL(1019)
QUIT
+6 SET GRP=$PIECE(INP,U,2)
+7 SET VIEN=$PIECE(INP,U,3)
+8 SET FREQ=$PIECE(INP,U,4)
+9 IF $PIECE(^BGOICDPR(CAT,0),U,6)
SET GRP=""
+10 IF VIEN
Begin DoDot:1
+11 SET VPX=0
+12 FOR
SET VPX=$ORDER(^AUPNVPOV("AD",VIEN,VPX))
IF 'VPX
QUIT
Begin DoDot:2
+13 SET I=$GET(^AUPNVPOV(VPX,0))
+14 IF $LENGTH(I)
SET VPX(+I,+$PIECE(I,U,4))=VPX
End DoDot:2
End DoDot:1
+15 SET (CNT,RANK)=0
+16 IF FREQ
Begin DoDot:1
+17 SET J=""
+18 FOR
SET J=$ORDER(^BGOICDPR(CAT,1,"AC",J),-1)
IF J=""
QUIT
Begin DoDot:2
+19 SET IEN=0
+20 FOR
SET IEN=$ORDER(^BGOICDPR(CAT,1,"AC",J,IEN))
IF 'IEN
QUIT
DO GD1
End DoDot:2
End DoDot:1
+21 IF '$TEST
Begin DoDot:1
+22 SET IEN=0
+23 FOR
SET IEN=$ORDER(^BGOICDPR(CAT,1,IEN))
IF 'IEN
QUIT
DO GD1
End DoDot:1
+24 QUIT
GD1 NEW N0,ICDIEN,TXT,DX,FREQVAL,CODE
+1 SET N0=$GET(^BGOICDPR(CAT,1,IEN,0))
+2 SET ICDIEN=+N0
+3 IF 'ICDIEN
QUIT
+4 IF '$DATA(^ICD9(ICDIEN,0))
QUIT
+5 IF $$AICD^BGOUTL2
SET DX=$$SD^ICDEX(80,ICDIEN,DT)
+6 IF '$TEST
SET DX=$PIECE(^ICD9(ICDIEN,0),U,3)
+7 SET CODE=$PIECE(^ICD9(ICDIEN,0),U)
+8 SET TXT=$PIECE(N0,U,2)
SET TXT(0)=+$$FNDNARR^BGOUTL2(TXT,0)
+9 IF $$AICD^BGOUTL2
SET LONG=$$LD^ICDEX(80,ICDIEN,DT)
+10 IF '$TEST
SET LONG=$PIECE($GET(^ICD9(ICDIEN,1)),U)
+11 SET FREQVAL=$PIECE(N0,U,3)
+12 IF FREQ
Begin DoDot:1
+13 SET RANK=RANK+1
+14 SET RANK=$SELECT(RANK<10:"00",RANK<100:"0",1:"")_RANK
End DoDot:1
+15 SET CNT=CNT+1
+16 SET @RET@(CNT)=ICDIEN_U_CODE_U_DX_U_TXT_U_FREQVAL_U_$GET(VPX(ICDIEN,TXT(0)))_U_RANK_U_IEN_U_LONG
+17 QUIT
+18 ; Return list of managers associated with a specified category
GETMGRS(RET,CAT) ;EP
+1 DO GETMGRS^BGOPFUTL(.RET,CAT,90362.35)
+2 QUIT
+3 ; Set category fields
+4 ; INP = Name [1] ^ Hosp Loc [2] ^ Clinic [3] ^ Provider [4] ^ User [5] ^ Category IEN [6] ^ Delete [7] ^ Discipline [8]
SETCAT(RET,INP) ;EP
+1 DO SETCAT^BGOPFUTL(.RET,INP,90362.35)
+2 QUIT
+3 ; Set field values for a ICD preference entry
+4 ; INP = Category IEN [1] ^ ICD IEN [2] ^ Display Text [3] ^ Delete [4] ^ ICD Code [5] ^ Frequency [6] ^
+5 ; Allow Dups [7] ^ Item IEN [8]
SETITEM(RET,INP) ;EP
+1 DO SETITEM^BGOPFUTL(.RET,INP,90362.35)
+2 QUIT
+3 ; Add or remove a manager from a category
+4 ; INP = Category IEN [1] ^ Manager IEN [2] ^ Add [3]
SETMGR(RET,INP) ;EP
+1 DO SETMGR^BGOPFUTL(.RET,INP,90362.352)
+2 QUIT
+3 ; Set display name for an item
+4 ; INP = Category IEN [1] ^ Item IEN [2] ^ Display Name [3]
SETNAME(RET,INP) ;EP
+1 DO SETNAME^BGOPFUTL(.RET,INP,90362.351)
+2 QUIT
+3 ; Set frequency for an item
+4 ; INP = Category IEN [1] ^ ICD IEN [2] ^ Increment [3] ^ Frequency [4]
SETFREQ(RET,INP) ;EP
+1 DO SETFREQ^BGOPFUTL(.RET,INP,90362.351)
+2 QUIT