BGOBMSR ; IHS/BAO/TMD - Manage BIRTH MEAS ;02-Jul-2018 10:19;DU
;;1.1;BGO COMPONENTS;**1,3,24**;Mar 20, 2007
;---------------------------------------------
; Return birth measurement entries for patient
; DFN = Patient IEN
; .RET = Birth Weight Lbs [1] ^ Birth Weight Oz [2] ^ Birth Weight Kg [3] ^
; Birth Weight Gms [4] ^ Apgar 1m [5] ^ Apgar 5m [6] ^ Gest Age Wks [7] ^
; Delivery Type [8] ^ Complications [9] ^ Birth Order [10] ^ Formula Started [11]
; Breast Stopped [12] ^ Solids Started [13] ^ Mother Name | IEN [14]
GET(RET,DFN) ;EP
N VAL,FLDS,FLD,IENS,FNUM,I,X,Y
S RET=""
Q:'$D(^AUPNBMSR(DFN,0))
S FLDS=".02;.03;.18;.09;.04;.05;.06;.07;.08;.11;.12;.14;.16;.21"
S IENS=DFN_",",FNUM=$$FNUM,RET=""
D GETS^DIQ(FNUM,IENS,FLDS,"IE","VAL")
F I=1:1:$L(FLDS,";") D
.S FLD=$P(FLDS,";",I)
.S X=$G(VAL(FNUM,IENS,FLD,"E")),Y=$G(VAL(FNUM,IENS,FLD,"I"))
.S:X'=Y X=X_"|"_Y
.S:$L(X) $P(RET,U,I)=X
Q
; Set birth measurements
; INP = Patient IEN [1] ^ Weight [2] ^ Order [3] ^ Formula [4] ^ Breast [5] ^
; Solids [6] ^ Mother [7] ^ Gestational Age[8]
; .RET = -1 if error; null otherwise
SET(RET,INP) ;EP
N DFN,IENS,FDA,MOTHER
S RET=""
S DFN=+INP
I '$D(^DPT(DFN,0)) S RET=$$ERR^BGOUTL(1001) Q
S MOTHER=$P(INP,U,7)
S:MOTHER MOTHER="`"_MOTHER
S IENS=$S($D(^AUPNBMSR(DFN,0)):DFN_",",1:"+1,")
S FDA=$NA(FDA($$FNUM,IENS))
S:$E(IENS)="+" @FDA@(.01)="`"_DFN
S @FDA@(.19)=$TR($P(INP,U,2),"-kg"," KG")
S @FDA@(.11)=$P(INP,U,3)
S @FDA@(.12)=$P(INP,U,4)
S @FDA@(.14)=$P(INP,U,5)
S @FDA@(.16)=$P(INP,U,6)
S @FDA@(.06)=$P(INP,U,8) ;Patch 24 added EGA
S @FDA@(.21)=MOTHER
S RET=$$UPDATE^BGOUTL(.FDA,"E@")
D:'RET EVT(DFN,$E(IENS)'="+")
Q
; Delete birth measurements
; DFN = Patient IEN
DEL(RET,DFN) ;EP
S RET=$$DELETE^BGOUTL("^AUPNBMSR(",DFN)
D:'RET EVT(DFN,2)
Q
; Broadcast an update event
EVT(DFN,OPR) ;
N DATA
S DATA=DFN_U_$G(CIA("UID"))_U_OPR_U_DFN
D:DFN BRDCAST^CIANBEVT("PCC."_DFN_".BMSR",DATA)
Q
; Return File #
FNUM() Q 9000024
BGOBMSR ; IHS/BAO/TMD - Manage BIRTH MEAS ;02-Jul-2018 10:19;DU
+1 ;;1.1;BGO COMPONENTS;**1,3,24**;Mar 20, 2007
+2 ;---------------------------------------------
+3 ; Return birth measurement entries for patient
+4 ; DFN = Patient IEN
+5 ; .RET = Birth Weight Lbs [1] ^ Birth Weight Oz [2] ^ Birth Weight Kg [3] ^
+6 ; Birth Weight Gms [4] ^ Apgar 1m [5] ^ Apgar 5m [6] ^ Gest Age Wks [7] ^
+7 ; Delivery Type [8] ^ Complications [9] ^ Birth Order [10] ^ Formula Started [11]
+8 ; Breast Stopped [12] ^ Solids Started [13] ^ Mother Name | IEN [14]
GET(RET,DFN) ;EP
+1 NEW VAL,FLDS,FLD,IENS,FNUM,I,X,Y
+2 SET RET=""
+3 IF '$DATA(^AUPNBMSR(DFN,0))
QUIT
+4 SET FLDS=".02;.03;.18;.09;.04;.05;.06;.07;.08;.11;.12;.14;.16;.21"
+5 SET IENS=DFN_","
SET FNUM=$$FNUM
SET RET=""
+6 DO GETS^DIQ(FNUM,IENS,FLDS,"IE","VAL")
+7 FOR I=1:1:$LENGTH(FLDS,";")
Begin DoDot:1
+8 SET FLD=$PIECE(FLDS,";",I)
+9 SET X=$GET(VAL(FNUM,IENS,FLD,"E"))
SET Y=$GET(VAL(FNUM,IENS,FLD,"I"))
+10 IF X'=Y
SET X=X_"|"_Y
+11 IF $LENGTH(X)
SET $PIECE(RET,U,I)=X
End DoDot:1
+12 QUIT
+13 ; Set birth measurements
+14 ; INP = Patient IEN [1] ^ Weight [2] ^ Order [3] ^ Formula [4] ^ Breast [5] ^
+15 ; Solids [6] ^ Mother [7] ^ Gestational Age[8]
+16 ; .RET = -1 if error; null otherwise
SET(RET,INP) ;EP
+1 NEW DFN,IENS,FDA,MOTHER
+2 SET RET=""
+3 SET DFN=+INP
+4 IF '$DATA(^DPT(DFN,0))
SET RET=$$ERR^BGOUTL(1001)
QUIT
+5 SET MOTHER=$PIECE(INP,U,7)
+6 IF MOTHER
SET MOTHER="`"_MOTHER
+7 SET IENS=$SELECT($DATA(^AUPNBMSR(DFN,0)):DFN_",",1:"+1,")
+8 SET FDA=$NAME(FDA($$FNUM,IENS))
+9 IF $EXTRACT(IENS)="+"
SET @FDA@(.01)="`"_DFN
+10 SET @FDA@(.19)=$TRANSLATE($PIECE(INP,U,2),"-kg"," KG")
+11 SET @FDA@(.11)=$PIECE(INP,U,3)
+12 SET @FDA@(.12)=$PIECE(INP,U,4)
+13 SET @FDA@(.14)=$PIECE(INP,U,5)
+14 SET @FDA@(.16)=$PIECE(INP,U,6)
+15 ;Patch 24 added EGA
SET @FDA@(.06)=$PIECE(INP,U,8)
+16 SET @FDA@(.21)=MOTHER
+17 SET RET=$$UPDATE^BGOUTL(.FDA,"E@")
+18 IF 'RET
DO EVT(DFN,$EXTRACT(IENS)'="+")
+19 QUIT
+20 ; Delete birth measurements
+21 ; DFN = Patient IEN
DEL(RET,DFN) ;EP
+1 SET RET=$$DELETE^BGOUTL("^AUPNBMSR(",DFN)
+2 IF 'RET
DO EVT(DFN,2)
+3 QUIT
+4 ; Broadcast an update event
EVT(DFN,OPR) ;
+1 NEW DATA
+2 SET DATA=DFN_U_$GET(CIA("UID"))_U_OPR_U_DFN
+3 IF DFN
DO BRDCAST^CIANBEVT("PCC."_DFN_".BMSR",DATA)
+4 QUIT
+5 ; Return File #
FNUM() QUIT 9000024