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

BGOVIF.m

Go to the documentation of this file.
BGOVIF ; IHS/BAO/TMD - Manage V INFANT FFEDING ;10-Dec-2013 14:09;DU
 ;;1.1;BGO COMPONENTS;**1,3,6,11,13**;Mar 20, 2007;Build 16
 ;---------------------------------------------
 ; Return entries from V Infant Feeding by V File Entry or by Patient or by Visit
 ;  INP = Patient IEN [1] ^ V File IEN [2] ^ Visit IEN [3]
GET(RET,INP) ;EP
 N I,X,IFDATE
 D VFGET^BGOUTL2(.RET,INP,$$FNUM,".03;.01;1201;1204")
 ;patch 6 If the 1201 field is empty, replace it with the visit date for display
 S I=0 F  S I=$O(@RET@(I)) Q:I=""  D
 .S X=$G(@RET@(I))
 .I $P(X,U,5)="" D
 ..S IFDATE=$P($P(X,U,3),"|",1)
 ..S $P(X,U,5)=IFDATE_"|"_$$CVTDATE^BGOUTL(IFDATE)
 ..S @RET@(I)=X
 ..S @RET@(I)=X
 .S IEN=$P(X,U,1)
 .S EXTRA=""
 .S EX=0 F  S EX=$O(^AUPNVIF(IEN,13,EX)) Q:'+EX  D
 ..S AIEN=EX_","_IEN
 ..S TYP=$$GET1^DIQ(9000010.4413,AIEN,.01)
 ..Q:TYP=""
 ..S TYPC=$$GET1^DIQ(9000010.4413,AIEN,.01,"I")
 ..S COMM=$$GET1^DIQ(9000010.4413,AIEN,.02)
 ..S EXTRA=$S(EXTRA="":TYP_"|"_TYPC_"|"_COMM,1:EXTRA_"~"_TYP_"|"_TYPC_"|"_COMM)
 ..S $P(X,U,7)=EXTRA
 .S @RET@(I)=X
 Q
 ; Add/Edit infant feeding data
 ;  INP = V File IEN ^ Visit IEN ^ Feeding Choice ^ EXTRA
SET(RET,INP) ;EP
 N VIEN,VFIEN,VFNEW,TYPE,FDA,FNUM,EXTRA,CNT,MUL,AIEN
 S RET="",FNUM=$$FNUM
 S VFIEN=$P(INP,U)
 I +VFIEN D DELEX(VFIEN)
 S VFNEW='VFIEN
 S VIEN=$P(INP,U,2)
 S TYPE=$P(INP,U,3)
 S EXTRA=$P(INP,U,4)
 I 'TYPE S RET=$$ERR^BGOUTL(1079) Q
 S RET=$$CHKVISIT^BGOUTL(VIEN)
 Q:RET
 I 'VFIEN D  Q:'VFIEN
 .D VFNEW^BGOUTL2(.RET,FNUM,TYPE,VIEN)
 .S:RET>0 VFIEN=RET,RET=""
 S FDA=$NA(FDA(FNUM,VFIEN_","))
 S @FDA@(.01)=TYPE
 S @FDA@(1201)="N"
 S @FDA@(1204)="`"_DUZ
 ;Patch 11 Set date entered
 I VFNEW D
 .S @FDA@(1216)="N"
 .S @FDA@(1217)="`"_DUZ
 ;Patch 11 Set last modified
 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
 S CNT=$L(EXTRA,"~")
 S FNUM=9000010.4413
 F I=1:1:CNT D
 .S MUL=$P(EXTRA,"~",I)
 .S MUL=$S(MUL="MILK":1,MUL="FRUIT JUICE":2,MUL="CARBONATED DRINK":3,MUL="SPORTS DRINK":4,MUL="GLUCOSE":5,MUL="WATER":6,1:MUL)
 .S AIEN="+"_I_","_VFIEN_","
 .S FDA(FNUM,AIEN,.01)=$P(MUL,":",1)
 .S FDA(FNUM,AIEN,.02)=$P(MUL,":",2)
 .D UPDATE^DIE(,"FDA","AIEN","ERR")
 Q
DELEX(VFIEN) ;Delete existing extras and all SNOMED and LOINC codes
 K NUM,DA,DIK
 S NUM=0 F  S NUM=$O(^AUPNVIF(VFIEN,13,NUM)) Q:NUM=""  D
 .S DA(1)=VFIEN,DA=NUM
 .S DIK="^AUPNVIF(VFIEN,13,"
 .D ^DIK
 K NUM,DA,DIK
 S NUM=0 F  S NUM=$O(^AUPNVIF(VFIEN,26,NUM)) Q:NUM=""  D
 .S DA(1)=VFIEN,DA=NUM
 .S DIK="^AUPNVIF(VFIEN,26,"
 .D ^DIK
 K NUM,DA,DIK
 S NUM=0 F  S NUM=$O(^AUPNVIF(VFIEN,27,NUM)) Q:NUM=""  D
 .S DA(1)=VFIEN,DA=NUM
 .S DIK="^AUPNVIF(VFIEN,27,"
 .D ^DIK
 Q
 ; Delete a V File entry
DEL(RET,VFIEN) ;
 D VFDEL^BGOUTL2(.RET,$$FNUM,VFIEN)
 Q
 ; Return V File #
FNUM() Q 9000010.44