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

VENPCCS3.m

Go to the documentation of this file.
VENPCCS3 ; IHS/OIT/GIS - RESULT GRAPHING ;
 ;;2.6;PCC+;;NOV 12, 2007
 ;
 ; GRAPH RESULTS IN 2.5
 ; 
GRAPH(DFN,DEFEF) ; EP-GIVEN PT DFN AND ENCOUNTER FORM IEN, RETURN ALL DATA TO MAKE ALL OF THAT FORMS GRAPHS
 I '$D(^VEN(7.41,+$G(DEFEF),6)) Q  ; NO GRAPHS ASSOCIATED WITH THIS FORM
 I '$D(^DPT(+$G(DFN),0)) Q  ; INVALID PATIENT DFN
 N RIEN,GIEN,NAME,GNAME,XAX,YAX,UNITS,MVS,MVSTG,OTRANS
 N VAL3,VAL,MAXM,MAXDP,RTYPE,LIEN,MIEN,OBFLD,DATA,TOT,STG,X,Y,%
 S GIEN=0,TOT=0,STG=""
 F  S GIEN=$O(^VEN(7.41,DEFEF,6,GIEN)) Q:'GIEN  S RIEN=+$G(^VEN(7.41,DEFEF,6,GIEN,0)) I RIEN D
 . S X=$G(^VEN(7.63,RIEN,0)) I '$L(X) Q
 . S NAME=$P(X,U),RTYPE=$P(X,U,2),MAXM=$P(X,U,3),MAXDP=$P(X,U,4),GNAME=$P(X,U,5),XAX=$P(X,U,6)
 . S YAX=$P(X,U,7),UNITS=$P(X,U,8),MIEN=$P(X,U,11),LIEN=$P(X,U,12),OBFLD=$P(X,U,13),MVS=$G(^VEN(7.63,RIEN,1)),OTRANS=$G(^VEN(7.63,RIEN,2))
 . I 'RTYPE Q
 . I GNAME="" S GNAME=NAME ; GRAPH NAME
 . I MAXM="" S MAXM=24 ; MAX MONTHS
 . I MAXDP="" S MAXDP=25 ; MAX DATA POINTS
 . S MVSTG=$$MVS(MVS) ; MULTIVALUED RESULTS
 . S DATA=$$DATA(RTYPE) I DATA="" S DATA="NO DATA AVAILABLE"
 . S TOT=TOT+1
 . S $P(STG,"`",TOT)=GNAME_"\"_XAX_"\"_YAX_"\"_UNITS_"\"_$P(MVSTG,"~",2,99)_"\"_DATA
 S SPECHOLD("u90")=STG ; ALL GRAPH RESULTS STORED IN MAIL MERGE FIELD "u90"
 Q
 ;
MVS(MVS) ; EP-GET MULTIVALUED DATA ELEMENT NAMES AND DELIMITER
 N STG,PCE,DELIM
 I MVS["-" S DELIM="-" G MVS1
 I MVS["/" S DELIM="/" G MVS1
 I MVS[":" S DELIM=":" G MVS1
 I MVS[";" S DELIM=";" G MVS1
 Q ""
MVS1 I $L(MVS)<3 Q ""
 S STG=DELIM
 F PCE=1:1:$L(MVS,DELIM) S STG=STG_"~"_$P(MVS,DELIM,PCE)
 Q STG
 ; 
DATA(RTYPE) ; EP-RETURN THE DATA STRING
 N RES,DATE,VAL1,VAL2
 I RTYPE=1 Q $$MEAS(DFN,MAXM,MAXDP,MIEN,MVSTG,OTRANS)
 I RTYPE=2 Q $$LAB(DFN,MAXM,MAXDP,LIEN,MVSTG,OTRANS)
 I RTYPE=3 Q $$OB(DFN,MAXM,MAXDP,OBFLD,MVSTG,OTRANS)
 Q ""
 ;
LAB(DFN,MAXM,MAXDP,LIEN,MVSTG,OTRANS) ; EP-RETURN LAB RESULTS
 N VLIEN,IDATE,X,Y,DATE,STG,RES,DELIM,TOT,STOP,VIEN,PCE
 S IDATE=0,STG="",TOT=0
 F  Q:$G(STOP)  S IDATE=$O(^AUPNVLAB("AA",DFN,LIEN,IDATE)) Q:'IDATE  S VLIEN=0 F  Q:$G(STOP)  S VLIEN=$O(^AUPNVLAB("AA",DFN,LIEN,IDATE,VLIEN)) Q:'VLIEN  D
 . S X=$G(^AUPNVLAB(VLIEN,0)) I '$L(X) Q
 . S VIEN=+$P(X,U,3) I 'VIEN Q
 . S Y=+$G(^AUPNVSIT(VIEN,0)) I 'Y Q
 . S Y=Y\1
 . I $$CHKDT(Y,MAXM) S DATE=$$DT(Y)
 . E  S STOP=1 Q
 . S RES=$P($G(^AUPNVLAB(VLIEN,0)),U,4)
 . I '$L(RES) Q
 . I $L(MVSTG) S DELIM=$P(MVSTG,"~"),RES=$TR(RES,DELIM,"~")
 . I $L(OTRANS) F PCE=1:1:$L(RES,"~") S X=$P(RES,"~",PCE) X OTRANS S $P(RES,"~",PCE)=X
 . I STG'="" S STG=STG_"|"
 . S STG=STG_DATE_"~"_RES
 . S TOT=TOT+1
 . I TOT=MAXDP S STOP=1
 . Q
 Q STG
 ;
MEAS(DFN,MAXM,MAXDP,MIEN,MVSTG,OTRANS) ; EP-RETURN MEASUREMENT RESULTS
 N VMIEN,IDATE,X,Y,DATE,STG,RES,DELIM,TOT,STOP,VIEN,PCE,FLD,SS,PCE,FLDN
 S IDATE=0,STG="",TOT=0
 F  Q:$G(STOP)  S IDATE=$O(^AUPNVMSR("AA",DFN,MIEN,IDATE)) Q:'IDATE  S VMIEN=0 F  Q:$G(STOP)  S VMIEN=$O(^AUPNVMSR("AA",DFN,MIEN,IDATE,VMIEN)) Q:'VMIEN  D
 . S X=$G(^AUPNVMSR(VMIEN,0)) I '$L(X) Q
 . S VIEN=+$P(X,U,3) I 'VIEN Q
 . S Y=+$G(^AUPNVSIT(VIEN,0)) I 'Y Q
 . S Y=Y\1
 . I $$CHKDT(Y,MAXM) S DATE=$$DT(Y)
 . E  S STOP=1 Q
 . S RES=$P($G(^AUPNVMSR(VMIEN,0)),U,4)
 . I '$L(RES) Q
 . F  Q:RES'["/20"  S RES=$P(RES,"/20",1)_$P(RES,"/20",2,99)
 . I $L(MVSTG) S DELIM=$P(MVSTG,"~"),RES=$TR(RES,DELIM,"~")
 . I $L(OTRANS) F PCE=1:1:$L(RES,"~") S X=$P(RES,"~",PCE) X OTRANS S $P(RES,"~",PCE)=X
 . I STG'="" S STG=STG_"|"
 . S STG=STG_DATE_"~"_RES
 . S TOT=TOT+1
 . I TOT=MAXDP S STOP=1
 . Q
 Q STG
 ;
OB(DFN,MAXM,MAXDP,OBFLD,MVSTG,OTRANS) ; EP-RETURN PRENATAL RESULTS
 N VOBIEN,IDATE,X,Y,DATE,STG,RES,DELIM,TOT,STOP,VIEN,PCE,SS,PCE,FLDN,%
 S IDATE=0,STG="",TOT=0
 I '$L($G(OBFLD)) Q
 S FLDN=$O(^DD(9000010.43,"B",OBFLD,0)) I 'FLDN Q
 S %=$P($G(^DD(9000010.43,FLDN,0)),U,4),SS=$P(%,";"),PCE=$P(%,";",2) ; GET DATA LOCATION PARAMETERS
 I $L(SS),PCE
 E  Q
 F  Q:$G(STOP)  S IDATE=$O(^AUPNVOB("AA",DFN,IDATE)) Q:'IDATE  S VOBIEN=0 F  Q:$G(STOP)  S VOBIEN=$O(^AUPNVOB("AA",DFN,IDATE,VOBIEN)) Q:'VOBIEN  D
 . S X=$G(^AUPNVOB(VOBIEN,0)) I '$L(X) Q
 . S VIEN=+$P(X,U,3) I 'VIEN Q
 . S Y=+$G(^AUPNVSIT(VIEN,0)) I 'Y Q
 . S Y=Y\1
 . I $$CHKDT(Y,MAXM) S DATE=$$DT(Y)
 . E  S STOP=1 Q
 . S RES=$P($G(^AUPNVOB(VOBIEN,SS)),U,PCE)
 . I '$L(RES) Q
 . I $L(MVSTG) S DELIM=$P(MVSTG,"~"),RES=$TR(RES,DELIM,"~")
 . I $L(OTRANS) F PCE=1:1:$L(RES,"~") S X=$P(RES,"~",PCE) X OTRANS S $P(RES,"~",PCE)=X
 . I STG'="" S STG=STG_"|"
 . S STG=STG_DATE_"~"_RES
 . S TOT=TOT+1
 . I TOT=MAXDP S STOP=1
 . Q
 Q STG
 ; 
DT(X) ; CONVERT A DATE
 N D,M,Y
 S D=$E(X,6,7)
 S M=$E(X,4,5)
 S Y=$E(X,1,3)+1700
 Q M_"/"_D_"/"_Y
 ; 
CHKDT(DATE,MAXM) ; CHECK DATE
 N M,D,Y,X,Z,R
 S Y=$E(DT,1,3),M=$E(DT,4,5),D=$E(DT,6,7)
 I MAXM>11 D  G C1
 . S X=MAXM\12,Y=Y-X
 . S R=MAXM#12
 . I M>R S M=M-R Q
 . S Y=Y-1,M=12-(R-M)
 . Q
 I M>MAXM S M=M-MAXM
 E  S Y=Y-1,M=12-(MAXM-M)
C1 S M=+M
 I M=2,D>28 S D=28
 I D=31,M=11 S D=30
 I D=31,"469"[M S D=30
 I $L(M)=1 S M="0"_M
 S Z=(Y_M_D)
 I DATE<Z Q 0
 Q 1
 ; 
BMI(DFN,WT,IDATE) ; EP- GIVEN PT DFN, WT AND INVERSE DATE, RETURN THE BMI FOR THAT DATE
 N X
 I $D(^DPT(+$G(DFN),0)),$G(WT),$G(IDATE)
 E  Q ""
 S X=$$BMI^APCHS2A3(DFN,WT,IDATE)
 S X=+$$STRIP^VENPCCU(X)
 I 'X Q ""
 Q X
 ;
FUND(VOBIEN,PCE) ; EP-GIVEN V OB IEN AND RESULT PIECE RETURN THE COMPOUND VALUE FUNDAL HT / EGW
 N X,EWG,FH
 I '$D(^AUPNVOB(+$G(VOBIEN),1)) Q ""
 I $G(PCE)'=1 Q ""
 S X=^AUPNVOB(VOBIEN,1),FH=$P(X,U,3),EWG=$P(X,U,13)
 I FH,EWG
 E  Q ""
 Q FH_"~"_EWG
 ;