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

VENPCCS1.m

Go to the documentation of this file.
VENPCCS1 ; IHS/OIT/GIS - POPULATE OCX OBJECTS FOR WELL BABY FORMS ; 
 ;;2.6;PCC+;**1,2,3**;APR 03, 2012;Build 24
 ;
 ; 
 ;
GGD(OUT,IN) ; EP - RPC: VEN WCM GET GROWTH DATA ; IN = DFN    OUT = DELEMITED GROWTH DATA STRING
 I $D(^DPT(+$G(IN),0))
 E  Q
 N GUIRPC
 S GUIRPC=1
 S OUT=$$VISIT^VENPCCS1(IN)
 Q
 ;
GGDI(OUT,IN) ; EP - RPC: VEN WCM INIT GROWTH DATA
 I $D(^DPT(+$G(IN),0))
 E  Q
 N MOS,SEX
 S SEX=$P(^DPT(IN,0),U,2)
 S MOS=$$AGEM(IN)
 S OUT=SEX_"|"_MOS
 Q
 ; 
FORMAT(DFN,AMOS,DOB,SEX,VTYPE) ; EP-RETURN THE OUTPUT STRING
 I $G(DFN),$G(AMOS),$G(DOB),$L($G(TYPE)),$L($G(SEX))
 E  Q ""
 N STG,S,VIEN
 S STG="",VIEN=999999999999
 F  S VIEN=$O(@TMP@(VIEN),-1) Q:'VIEN  S STG=STG_@TMP@(VIEN)_"|"
 Q STG
 ; 
AIM(DOB,DATE) ; EP-GIVEN THE FM DOB RETURN THE AGE IN MONTHS
 S DOB=DOB\1 I DOB'?7N Q ""
 I '$G(DATE) S DATE=$G(DT)
 I 'DATE Q ""
 I DOB>DATE Q ""
 N Y,M,D,YR,MB,DAY,MOS,F
 S MOS=0
 S Y=$E(DATE,1,3),D=$E(DATE,6,7),M=$E(DATE,4,5)
 S YR=$E(DOB,1,3),DAY=$E(DOB,6,7),MB=$E(DOB,4,5)
 I Y>YR S MOS=12*(Y-YR)
 I M'<MB S MOS=MOS+(M-MB)
 E  S MOS=MOS-(MB-M)
 I D<DAY S MOS=MOS-1
 I D=DAY Q MOS
 I DAY>D S F=(30.5-(DAY-D))/30.5
 E  S F=(D-DAY)/30.5
 S F=$J(F,1,1) I F S MOS=MOS+F
 Q MOS
 ; 
PCT(VMIEN,AGEM,SEX,TYPE) ; EP-RETURN THE VALUE AND PERCENTILE
 N VAL,PCT
 I $G(AGEM)="" Q ""
 I '$L(SEX) Q ""
 I '$L(TYPE) Q ""
 S AGEM=$J(AGEM,1,0)
 S VAL=$P($G(^AUPNVMSR(+$G(VMIEN),0)),U,4) I VAL="" Q ""
 I '$G(GUIRPC) D  ; ONLY JUSTIFY FOR TRADITIONAL PAPER BASED PCC+
 . S VAL=$J(VAL,1,1) ; PATCHED BY GIS 5/7/07
 . I VAL[".0" S VAL=VAL\1
 . Q
 I AGEM>216!(TYPE="HC") Q VAL_U ; gis/1/28/10
 S PCT=$$AUHTWT^APCHS2A2(TYPE,SEX,AGEM,VAL)
 Q VAL_U_PCT
 ; 
BMI(W,H) ; EP-RETURN THE BMI
 N BMI
 I $G(W),$G(H)
 E  Q ""
 I '$G(GUIRPC) S BMI=W/((H*H)/10000)
 E  S BMI=W/(H*H)*703
 S BMI=$J(BMI,0,1)
 Q BMI
 ; 
KG(WT) ; EP-CONVERT LBS TO KGS
 I '$G(WT) Q ""
 N %
 S %=+$$WEIGHT^XLFMSMT(WT,"lb","kg")
 I % Q $J(%,1,2)
 Q ""
 ; 
CM(HT) ; EP-COVERT INS TO CMS
 I '$G(HT) Q ""
 N %
 S %=+$$LENGTH^XLFMSMT(HT,"in","cm")
 I % Q $J(%,1,2)
 Q ""
 ; 
EXDT(DATE) ; EP-CONVERT FM DATE TO AN EXTERNAL DATE
 I '$G(DATE) Q ""
 S DATE=DATE\1 I DATE'?7N Q ""
 N Y,M,D
 S Y=$E(DATE,1,3) S Y=1700+Y
 S M=$E(DATE,4,5)
 S D=$E(DATE,6,7)
 Q (M_"/"_D_"/"_Y)
 ; 
NAME(DFN) ; EP-GIVEN A DFN REURN FNAME LNAME
 N NAME,X
 S X=$P($G(^DPT(+$G(DFN),0)),U) I X="" Q ""
 S NAME=$P(X,",",2)_" "_$P(X,",",1)
 Q NAME
 ; 
DOB(DFN) ; EP-RETURN DOB IN MM/DD/YYYY
 N DOB,X
 S DOB=$P($G(^DPT(+$G(DFN),0)),U,3) I 'DOB Q ""
 S X=$E(DOB,4,5)_"/"_$E(DOB,6,7)_"/"_(1700+$E(DOB,1,3))
 Q X
 ; 
GENDER(DFN) ; EP-RETURN FORMATTED GENDER
 N SEX,X
 S SEX=$P($G(^DPT(+$G(DFN),0)),U,2) I SEX="" Q ""
 S X=$S(SEX="M":"Male",SEX="F":"Female",1:"")
 Q X
 ; 
BF(DFN) ; EP-RETIRN BMI OR FOC
 N AGEM,X
 S AGEM=$$AGEM(DFN) I 'AGEM Q ""
 S X=$S(AGEM<24:"FOC",1:"BMI")
 Q X
 ; 
AGEM(DFN) ; EP-RETURN THE AGE IN MONTHS
 N AGEM,DOB
 S DOB=$P($G(^DPT(+$G(DFN),0)),U,3) I 'DOB Q ""
 S AGEM=$$AIM(DOB)
 Q AGEM
 ; 
VISIT(DFN) ; EP-GET LAST 100 VISITS FOR A PT AND RETURN REQUESTED DATA IN A FORMATTED STRING
 ; RETURN MEASUREMENTS AND PERCENTILES
 ; PATCHED BY GIS/OIT 1/10/11 ; INCLUDES FIXES FOR VEN 2.6, PATCH 2
 N VIEN,TOT,WTT,HTT,HCT,DIC,X,Y,%,DOB,VDATE,OK,VMIEN,TYPE,TMP,SEX,STOP,STG,AMOS,BMI,AGEM,HT,WT,HC,VTYPE,XDATE
 S DOB=$P($G(^DPT(+$G(DFN),0)),U,3) I 'DOB Q ""
 S SEX=$P($G(^DPT(+$G(DFN),0)),U,2) I SEX="" Q ""
 S DIC="^AUTTMSR(",DIC(0)="",X="WT" D ^DIC Q:Y=-1 "" S WTT=+Y
 S X="HT" D ^DIC Q:Y=-1 "" S HTT=+Y
 S X="HC" D ^DIC Q:Y=-1 "" S HCT=+Y
 S TOT=0,VIEN=999999999999,TMP="^TMP(""VEN WBC"","""_$J_""")" K @TMP
 S AMOS=$$AIM(DOB) I 'AMOS Q "" ; CURRENT AGE IN MONTHS
 S VTYPE=$S(AMOS<24:"FOC",1:"BMI") ; IF <24 MOS SHOW HC CHART - OTHERWISE SHOW BMI
 F  S VIEN=$O(^AUPNVSIT("AC",DFN,VIEN),-1) Q:'VIEN  D  I TOT>99 Q
 . K ARR
 . S VDATE=$P($G(^AUPNVSIT(VIEN,0)),U) I 'VDATE Q
 . S VMIEN=999999999,STOP=0,HT="",WT="",HC="",BMI=""
 . F  S VMIEN=$O(^AUPNVMSR("AD",VIEN,VMIEN),-1) Q:'VMIEN  D  ; FOR EACH TYPE, GET ONLY THE MOST RECENT RESULT (NOT ENTERED IN ERROR) FOR THAT VISIT
 .. I $P($G(^AUPNVMSR(VMIEN,2)),U) Q  ; FILTER OUT ANY RESULTS ENTERED IN ERROR
 .. S XDATE=$P($G(^AUPNVMSR(VMIEN,12)),U)
 .. I 'XDATE S XDATE=VDATE
 .. S XDATE=XDATE\1
 .. I $G(ARR(XDATE,"WT")),$G(ARR(XDATE,"HT")),$G(ARR(XDATE,"HC")) Q  ; GOT ALL 3 MEASUREMENTS - NO NEED TO LOOK AT THIS VISIT DATE ANY MORE
 .. S TYPE=$P($G(^AUPNVMSR(VMIEN,0)),U)
 .. I TYPE'=WTT,TYPE'=HTT,TYPE'=HCT Q  ; NOT A REQUIRED MEASUREMENT
 .. S AGEM=$$AIM(DOB,XDATE) I AGEM="" Q  ; AGE IN MONTHS WHEN MEASUREMENT WAS TAKEN
 .. I TYPE=WTT,'$D(ARR(XDATE,"WT")) S WT=$$PCT(VMIEN,AGEM,SEX,"WT"),ARR(XDATE,"WT")=WT_U_AGEM Q
 .. I TYPE=HTT,'$D(ARR(XDATE,"HT")) S HT=$$PCT(VMIEN,AGEM,SEX,"HT"),ARR(XDATE,"HT")=HT_U_AGEM Q
 .. I TYPE=HCT,'$D(ARR(XDATE,"HC")) S HC=$$PCT(VMIEN,AGEM,SEX,"HC"),ARR(XDATE,"HC")=HC_U_AGEM Q
 .. Q
 . I '$O(ARR(0)) Q  ; NO MEASUREMENTS RECORDED ON THIS VISIT
 . D XRES(.ARR,SEX,DFN,VTYPE) ; FORMAT INDIVIDUAL EVENT RESULTS
 . K ARR
 . S TOT=TOT+1
 . Q
 S STG=$$FORMAT(DFN,AMOS,DOB,SEX,VTYPE) ; EP-CREATE THE OUTPUT STRING
 K @TMP
 ; F %=1:1:5 S X=$P(STG,"|",%) Q:'$L(X)  S $P(X,"~",6,7)="~",$P(STG,"|",%)=X
 Q STG
 ;
XRES(ARR,SEX,DFN,VTYPE) ; EP-FORMAT INDIVIDUAL VISIT RESULTS AND STORE IN TMP ARRAY
 N TYPE,W,H,FOC,DATE,WP,HP,T,XDATE,AGEM,BMI
 I $O(ARR(0)),$L(SEX),$D(^DPT(+$G(DFN),0)),$L($G(VTYPE))
 E  Q
 S XDATE=9999999,T="~"
 F  S XDATE=$O(ARR(XDATE),-1) Q:'XDATE  D
 . S TYPE=""
 . K W,H,WP,HP,FOC,BMI
 . F  S TYPE=$O(ARR(XDATE,TYPE)) Q:TYPE=""  D
 .. S DATE=$$EXDT(XDATE) I '$L(DATE) Q
 .. S %=$G(ARR(XDATE,TYPE)) I %="" Q
 .. S AGEM=$P(%,U,3) I AGEM="" Q
 .. I TYPE="WT" D  Q
 ... S W=$P(%,U),WP=$P(%,U,2)
 ... I W,'$G(GUIRPC) S W=$$KG(W)
 ... Q
 .. I TYPE="HT" D  Q
 ... S H=$P(%,U),HP=$P(%,U,2)
 ... I H,'$G(GUIRPC) S H=$$CM(H)
 ... Q
 .. I TYPE="HC" D  Q
 ... S FOC=""
 ... I VTYPE="FOC" S FOC=$P(%,U) ; GIS/OIT/2/22/11
 ... I FOC,'$G(GUIRPC) S FOC=$$CM(FOC)
 ... Q
 .. Q
 . I VTYPE="BMI" D
 .. S BMI=""
 .. I AGEM>23,$G(W),$G(H) S BMI=$$BMI(W,H)
 .. Q
 . I $D(@TMP@(XDATE)) D  Q  ; MANAGE CASES WITH MULTIPLE VISITS ON THE SAME DAY ; ALWAYS USE ONLY THE MOST RECENT VALUE ; PATCHED BY GIS/OIT/3/23/11
 .. I $G(W),$P(@TMP@(XDATE),T,3)="" S $P(@TMP@(XDATE),T,3,4)=$G(W)_T_$G(WP)
 .. I $G(H),$P(@TMP@(XDATE),T,5)="" S $P(@TMP@(XDATE),T,5,6)=$G(H)_T_$G(HP)
 .. I $G(@VTYPE),$P(@TMP@(XDATE),T,7)="" S $P(@TMP@(XDATE),T,7)=@VTYPE
 .. Q
 . S @TMP@(XDATE)=DATE_T_AGEM_T_$G(W)_T_$G(WP)_T_$G(H)_T_$G(HP)_T_$G(@VTYPE)_T
 . Q
 Q
 ;