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

BDGADD1.m

Go to the documentation of this file.
  1. BDGADD1 ; IHS/ANMC/LJF - A&D DETAILED PRINT CONT. ; [ 07/01/2002 10:18 AM ]
  1. ;;5.3;PIMS;**1003,1013**;MAY 28, 2004
  1. ;IHS/ITSC/LJF 6/2/2005 PATCH 1003 adjusted code under Deaths to match other sections
  1. ; added code for mulitple admits and discharges
  1. ;ihs/cmi/maw 9/14/2011 PATCH 1013 added day surgery
  1. ;
  1. PATDATA ;EP; build display lines for patient data
  1. ; called by INIT^BDGADD
  1. ;
  1. D ADMITS,DEATHS,TRANSFER
  1. D ^BDGADD2 ;day surgery listing
  1. Q
  1. ;
  1. ADMITS ; build array of admits
  1. ; first for inpatients, then observations, then newborns
  1. NEW SUB,SUB2,TITLE,TITLE2,X,NAME,DFN,IFN,LINE,DATA
  1. F SUB="ADMIT","DSCH" D
  1. . F SUB2="I","O","N","D" D
  1. .. ;
  1. .. ; display total admissions for category
  1. .. S TITLE=$S(SUB2="I":"Inpatient",SUB2="O":"Observation",SUB2="D":"Day Surgery",1:"Newborn")
  1. .. S TITLE2=$S(SUB="ADMIT":" Admissions:",1:" Discharges:")
  1. .. S X=$$COUNT(SUB,SUB2) I X>0 D SET("",.VALMCNT),SET($$PAD(TITLE_TITLE2,25)_X,.VALMCNT)
  1. .. ;
  1. .. ; loop through admits
  1. .. S NAME=0 F S NAME=$O(^TMP("BDGAD",$J,SUB,SUB2,NAME)) Q:NAME="" D
  1. ... S DFN=0 F S DFN=$O(^TMP("BDGAD",$J,SUB,SUB2,NAME,DFN)) Q:'DFN D
  1. .... ;
  1. .... ;IHS/ITSC/LJF 6/3/2005 PATCH 1003 add extra loop using IFN
  1. .... ;S DATA=^TMP("BDGAD",$J,SUB,SUB2,NAME,DFN)
  1. .... S IFN=0 F S IFN=$O(^TMP("BDGAD",$J,SUB,SUB2,NAME,DFN,IFN)) Q:'IFN D
  1. ..... S DATA=^TMP("BDGAD",$J,SUB,SUB2,NAME,DFN,IFN)
  1. ..... ;
  1. ..... ; PATCH 1003 added extra . to lines below
  1. ..... S LINE=$E($$GET1^DIQ(2,DFN,.01),1,25)
  1. ..... S LINE=$$PAD(LINE,27)_$J($$HRCN^BDGF2(DFN,DUZ(2)),6) ;chart
  1. ..... S LINE=$$PAD(LINE,35)_$P(DATA,U,4) ;age
  1. ..... S LINE=$$PAD(LINE,40)_$E($$GET1^DIQ(9000001,DFN,1118),1,15) ;community
  1. ..... S LINE=$$PAD(LINE,58)_$$GET1^DIQ(9009016.5,+$P(DATA,U,2),.02) ;ward
  1. ..... S LINE=$$PAD(LINE,65)_$$GET1^DIQ(45.7,+$P(DATA,U),99) ;service
  1. ..... S LINE=$$PAD(LINE,72)_$E($P(DATA,U,3),1,18) ;provider
  1. ..... K BDGX S BDGX="BDGX" D PCP^BSDU1(DFN,.BDGX) ;pcp
  1. ..... S LINE=$$PAD(LINE,92)_$E($P($G(BDGX(1)),"/"),1,18)
  1. ..... ;
  1. ..... D SET(LINE,.VALMCNT)
  1. ;end of PATCH 1003 changes
  1. ;
  1. Q
  1. ;
  1. TRANSFER ; loop through transfers (ward and service)
  1. NEW SUB,FILE,FIELD,TITLE,X,NAME,DFN,IFN,DATA
  1. ;
  1. F SUB="WARD","SERV" D
  1. . ;
  1. . ;ward/service abreviations file/field pairs
  1. . S FILE=$S(SUB="WARD":9009016.5,1:45.7),FIELD=$S(SUB="WARD":.02,1:99)
  1. . ;
  1. . ; display total transfers for category
  1. . S TITLE=$S(SUB="WARD":"Ward",1:"Service")
  1. . S X=$$COUNT2(SUB)
  1. . I X>0 D SET("",.VALMCNT),SET(TITLE_" Transfers: "_X,.VALMCNT)
  1. . ;
  1. . S NAME=0 F S NAME=$O(^TMP("BDGAD",$J,SUB,NAME)) Q:NAME="" D
  1. .. S DFN=0 F S DFN=$O(^TMP("BDGAD",$J,SUB,NAME,DFN)) Q:'DFN D
  1. ... S IFN=0 F S IFN=$O(^TMP("BDGAD",$J,SUB,NAME,DFN,IFN)) Q:'IFN D
  1. .... ;
  1. .... S DATA=^TMP("BDGAD",$J,SUB,NAME,DFN,IFN)
  1. .... ; old ward/srv -> new ward/srv
  1. .... S LINE=$$PAD($E(NAME,1,17),20) ;name
  1. .... S LINE=LINE_$J($$HRCN^BDGF2(DFN,DUZ(2)),6) ;chart #
  1. .... S LINE=$$PAD(LINE,30)_$$GET1^DIQ(FILE,+$P(DATA,U),FIELD)
  1. .... S LINE=$$PAD(LINE,35)_"-> "_$$GET1^DIQ(FILE,$P(DATA,U,2),FIELD)
  1. .... D SET(LINE,.VALMCNT)
  1. Q
  1. ;
  1. ;
  1. DEATHS ; Now display any deaths
  1. ; display total # of deaths first
  1. NEW X,NAME,DFN,IFN,DATA,LINE
  1. ;
  1. ;S X=$$COUNT("DEATH","") I X>0 D SET($$PAD("Deaths:",25)_X,.VALMCNT)
  1. S X=$$COUNT("DEATH","") I X>0 D SET("",.VALMCNT),SET($$PAD("Deaths:",25)_X,.VALMCNT)
  1. ;
  1. S NAME=0 F S NAME=$O(^TMP("BDGAD",$J,"DEATH",NAME)) Q:NAME="" D
  1. . S DFN=0 F S DFN=$O(^TMP("BDGAD",$J,"DEATH",NAME,DFN)) Q:'DFN D
  1. .. ;
  1. .. ;IHS/ITSC/LJF 6/2/2005 PATCH 1003 changed columns around to match other sections
  1. .. S DATA=^TMP("BDGAD",$J,"DEATH",NAME,DFN)
  1. .. S LINE=$$PAD($E($$GET1^DIQ(2,DFN,.01),1,17),25) ;name
  1. .. S LINE=$$PAD(LINE,27)_$J($$HRCN^BDGF2(DFN,DUZ(2)),6) ;chart#
  1. .. S LINE=$$PAD(LINE,35)_$P(DATA,U,4) ;age
  1. .. S LINE=$$PAD(LINE,40)_$E($$GET1^DIQ(9000001,DFN,1118),1,20) ;com
  1. .. S LINE=$$PAD(LINE,58)_$$GET1^DIQ(9009016.5,+$P(DATA,U,2),.02) ;wd
  1. .. ;S LINE=$$PAD(LINE,70)_$$GET1^DIQ(45.7,+$P(DATA,U,2),99) ;srv
  1. .. S LINE=$$PAD(LINE,65)_$$GET1^DIQ(45.7,+$P(DATA,U),99) ;srv; PATCH 1003 fixed code
  1. .. S LINE=$$PAD(LINE,72)_$E($P(DATA,U,3),1,20) ;prov
  1. .. ; PATCH 1003 - 2 new lines
  1. .. K BDGX S BDGX="BDGX" D PCP^BSDU1(DFN,.BDGX) ;pcp
  1. .. S LINE=$$PAD(LINE,92)_$E($P($G(BDGX(1)),"/"),1,18)
  1. .. ;
  1. .. D SET(LINE,.VALMCNT)
  1. Q
  1. ;
  1. COUNT(X,X1) ; returns # of events based on type sent in X and X1
  1. ; X can = "ADMIT" or "DSCH" or "DEATH"
  1. ; X1 can = "O" or "I" or "N" or "" if X="DEATH"
  1. ;
  1. NEW PIECE,SV,N,COUNT,SNM
  1. S PIECE=$S(X="ADMIT":3,X="DSCH":4,1:7) ;piece in ^BDGCTX node
  1. S SV=0 F S SV=$O(^BDGCTX(SV)) Q:'SV D
  1. . S SNM=$$GET1^DIQ(45.7,SV,.01)
  1. . I X'="DEATH",X1="I" Q:SNM="NEWBORN" Q:SNM["OBSERVATION" Q:SNM="DAY SURGERY"
  1. . I X'="DEATH",X1="O" Q:SNM'["OBSERVATION"
  1. . I X'="DEATH",X1="N" Q:SNM'="NEWBORN"
  1. . I X'="DEATH",X1="D" Q:SNM'="DAY SURGERY"
  1. . ;
  1. . S N=$G(^BDGCTX(SV,1,BDGT,0))
  1. . S COUNT=$G(COUNT)+$P(N,U,PIECE)+$P(N,U,PIECE+10)
  1. Q +$G(COUNT)
  1. ;
  1. COUNT2(X) ; returns # of events based on type sent in X and X1
  1. ; X can = "WARD" or "SERV"
  1. ;
  1. NEW GBL,SV,N,COUNT
  1. S GBL=$S(X="WARD":"^BDGCWD",1:"^BDGCTX")
  1. S SV=0 F S SV=$O(@GBL@(SV)) Q:'SV D
  1. . S N=$G(@GBL@(SV,1,BDGT,0))
  1. . S COUNT=$G(COUNT)+$P(N,U,5)+$P(N,U,15)
  1. Q +$G(COUNT)
  1. ;
  1. SET(LINE,NUM) ; put display line into array
  1. D SET^BDGADD(LINE,.NUM)
  1. Q
  1. ;
  1. PAD(D,L) ;EP -- SUBRTN to pad length of data
  1. ; -- D=data L=length
  1. Q $E(D_$$REPEAT^XLFSTR(" ",L),1,L)
  1. ;
  1. SP(N) ; -- SUBRTN to pad N number of spaces
  1. Q $$PAD(" ",N)