source: FOIAVistA/trunk/r/CLINICAL_PROCEDURES-MD/MDPFTP1.m@ 794

Last change on this file since 794 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 6.5 KB
Line 
1MDPFTP1 ;HOIFO/NCA - PFT REPORT-DEMO INFO ;3/15/04 11:55
2 ;;1.0;CLINICAL PROCEDURES;**2**;Apr 01, 2004
3 ; Reference IA #10061 for VADPT call.
4 ; #10040 for HOSPITAL LOCATION FILE #44.
5 ; #10060 for NEW PERSON file #200.
6 ; #3175 for measurement API XLFMSMT
7 ; ------------------------
8 ; SSN = Enternal Format of the patients SSN with the first letter
9 ; of the last name tacked on the end
10 ; ------------------------
11GET(MDGRS,MDF,MDR,MDPNAM,MDLNE,MDH) ; Return the PFT report in MDGRS
12 Q:'$G(MDR) N DFN
13 S MCPFT0=$G(^MCAR(700,+MDR,0)),DFN=$P(MCPFT0,U,2) Q:MCPFT0=""
14 D DEM^VADPT S MCARGNM=VADM(1),SSN=VA("PID")
15 S X1=$E($P(MCPFT0,U),1,7),X2=$P(VADM(3),U)
16 ; ---------------------
17 ; AGE = the patients age at the date of the procedure
18 ; ---------------------
19 S AGE=$E(X1,1,3)-$E(X2,1,3)-($E(X1,4,7)<$E(X2,4,7))
20 S RACE=$P(VADM(8),U,2),CLIN="" S:$P(MCPFT0,U,10) CLIN=$P(MCPFT0,U,10) I CLIN,$D(^SC(CLIN,0)) S CLIN=$P(^(0),U)
21 N MCHOLD S MCHOLD=RACE,RACE=$$ETHN(MCHOLD,.VADM)
22 S DATE=$P(MCPFT0,U),DATE=+$E(DATE,4,5)_"/"_+$E(DATE,6,7)_"/"_$E(DATE,2,3)_$S($P(DATE,".",2):"@"_+$E(DATE,9,10)_":"_$S($L($E(DATE,11,12))=2:$E(DATE,11,12),$L($E(DATE,11,12))=1:$E(DATE,11)_"0",1:"00"),1:"")
23 N HTCM,HTIN,WTKG,WTLB
24 S (HTIN,HT1)=$P(MCPFT0,U,4),(HTCM,HT)=$P($$LENGTH^XLFMSMT(HTIN,"IN","CM")," ")
25 S (WTLB,WT1)=$P(MCPFT0,U,5),(WTKG,WT)=$P($$WEIGHT^XLFMSMT(WTLB,"LB","KG")," ")
26 I HT'>0 S (HTCM,HT)=$P(MCPFT0,U,3),(HTIN,HT1)=$P($$LENGTH^XLFMSMT(HTCM,"CM","IN")," ")
27 I WT'>0 S (WTKG,WT)=$P(MCPFT0,U,6),(WTLB,WT1)=$P($$WEIGHT^XLFMSMT(WTKG,"KG","LB")," ")
28 S $P(MCDOT,".",81)=""
29 S (MC17,MCEFF,MCSEX)="" S:$D(^MCAR(700,+MDR,17)) MC17=^(17),MCEFF=$P(MC17,U,6),MCEFF=$S(MCEFF="G":"GOOD",MCEFF="E":"EXCELLENT",MCEFF="P":"POOR",1:"")
30 S MCSEX=$P(VADM(5),U),X=$P(VADM(3),"^",2) S MCARDOB=$S(X'="":X,1:""),X=$P(MCPFT0,U) D DTIME^MCARP S (MCARGDT,MCARGDT2)=X
31 D INP^VADPT S MCARWARD=$S(VAIN(4)'="":$P(VAIN(4),U,2),1:"NOT INPATIENT"),MCARRB=VAIN(5) D NOW^%DTC S X=% D DTIME^MCARP S MCARDTM=X
32 D HEAD^MDPS2
33 S SS="SEX: "_MCSEX_" AGE: "_AGE_$J(" ",10)_+$J(HT1,0,2)_" in/"_+$J(WT1,0,1)_" lb"
34 S SS=SS_$J(" ",60-$L(SS))_"AMBIENT: "_$P(MCPFT0,U,12)_"C/"_$P(MCPFT0,U,7)_"T" K HT1,WT1 D SETNODE(MDGRS,SS) S SS=""
35 S SS="RACE: "_RACE S TECH=$P(MCPFT0,U,13) I TECH,$$GET1^DIQ(200,TECH_",",.01)'="" S TECH=$$GET1^DIQ(200,TECH_",",.01)
36 I $L(RACE)>60 D SETNODE(MDGRS,SS) S SS=""
37 S SS=SS_$J(" ",60-$L(SS))_"TECH: "_$E(TECH,1,14) D SETNODE(MDGRS,SS) S SS=""
38 S SS=$S($P(MCPFT0,U,8)="Y":"SMOKER",$P(MCPFT0,U,8)="N":"NON-SMOKER",1:"")
39 S SS=SS_$J(" ",30-$L(SS))_$S($P(MCPFT0,U,9)="Y":"CURRENT BRONCHODILATOR USE",1:"")
40 S SS=SS_$J(" ",60-$L(SS))_"EFFORT: "_MCEFF D SETNODE(MDGRS,SS)
41 K ^UTILITY("DIQ1",$J) D SETNODE^MDPFTP1(MDGRS," "),SETNODE^MDPFTP1(MDGRS,"CONSULT DX: ") S DR(700.01)=.01,DIQ(0)="E",DIC="^MCAR(700,"
42 F K=0:0 S K=$O(^MCAR(700,MDR,1,K)) Q:K'?1N.N S DA=MDR,DA(700.01)=K,DR=11,DIQ(0)="E" D EN^DIQ1 I $D(^UTILITY("DIQ1",$J,700.01,K,.01,"E"))#2 D SETNODE(MDGRS,$J(" ",15)_$G(^("E")))
43 K ^UTILITY("DIQ1",$J),DIQ D SETNODE(MDGRS,MCDOT) D PRED
44 S RDATE=9999999.9999-$P(MCPFT0,U)
45 D:$D(MCRCN) SETNODE(MDGRS,MCRCN)
46 D ^MDPFTP2,FOOTER^MDPS2
47EXIT ; End of PFT Report process
48 K ^UTILITY($J),MCOUT,ACT,AGE,CK,CLIN,D0,D1,DA,DATE,CI95
49 K HB,PH,PACO2,PAO2,O2HB,COHB,FIO2,MHB,PAAO2,QSQT,CAO2,CVO2
50 K DIC,DIW,DIWL,DIWR,DIWT,DLCOSB,DN,MCDOT,DR,FEV1,FRC,FVC,MC17
51 K HT,I,J,K,MCARGNM,MCFF,MCK,MCN,MCPI,MCREC,MCREC1,MCVCN
52 K MCREC2,MCTLCN,MCVN,MCX,MEAS,FEF2575,ND,ND1,P1,P2,PC,PD1,PD11,MCEFF
53 K PD2,PD21,PF,MCPFT0,PG,PRED,MCPV,RACE,RDATE,RDATE1,RDATE2,RV,MCSEX
54 K SSN,TAB,TECH,TLC,TYPE,UNIT,UNITS,VC,WT,X,Z,VA,MCRCN
55 K MCMVVN,MVV,PMVV,MCSP,MCP1S0,MCP1S1,MCP1S2,MCP2S0,MCP2S1,MCP2S2
56 K CDLCOSB,MCIAO1,MCIAO2,MCIDA,MCIDL,MCIDP,MCIFA,MCIFE
57 K MCIFL,MCIFV,MCIPTL,MCIRV,MCITL,MCMAIN,MCP1,MCP2,MCRC,MCRCR
58 K MCTYPEP,MCY,MCRC1,MCRC2,MCRC3,MCRC4,MCSTAT,MCFOOTER,MCOUNT
59 K MCARRB,MCARDOB,MCARWARD,MCARDTM,MCARHDR,MCARZ,MCARGDT,MCARGDT2,MCDL,MCLNG
60 D KVAR^VADPT
61 Q
62PRED S (DLCOSB,FEV1,FRC,FVC,FEF2575,PF,RV,TLC,VC,MVV,CTLC,CVC,CFRC,CRV,CFVC,CFEV1,CPF,CFEF2575,CMVV,CDLCOSB,ACT,COHB)=""
63 S MCPV=$$MCPV(+MDR)
64 I ('HT)!('WT)!('AGE)!(MCPV=0) Q
65 D PREDS,MCRACE Q
66MCRACE S MCRCR="",MCRC=$G(^MCAR(700.1,MCPV,"RC")) Q:MCRC=""
67 S MCRCR=$G(^MCAR(700,+MDR,17)) Q:MCRCR="" Q:$P(MCRCR,U,5)'="Y"
68 N MCRAC,MCMRAC S MCMRAC=0
69 S:RACE["ASIAN" MCMRAC=MCMRAC+1
70 S:RACE["BLACK" MCMRAC=MCMRAC+1
71 I MCMRAC>1 S MCRAC=$P(MCRCR,U,7),MCRAC=$S(MCRAC="A":"O",1:MCRAC)
72 S MCRCR=$S(RACE["BLACK":"B",RACE["ASIAN":"O",1:"") Q:MCRCR=""
73 I MCMRAC>1 S MCRCR=MCRAC Q:MCRCR=""
74 F I=1:1:6 I $P(MCRC,U,I) S J=$P(MCRC,U,I) D:J
75 .Q:'$D(^MCAR(700.2,J,0)) S J=$P(^(0),U,1)
76 .S @("MCRC"_I)="S PRED="_J
77 K J G ORIENTAL:MCRCR="O" K MCRC2,MCRC6
78 I '$D(MCRC1),'$D(MCRC3),'$D(MCRC4),'$D(MCRC5) Q
79 S:$D(MCRC1) MCRCN="TLC,VC,FVC,FEV1" S:$D(MCRC3) MCRCN=MCRCN_",FRC,RV" S:$D(MCRC4) MCRCN=MCRCN_",FEF25-75" S:$D(MCRC5) MCRCN=MCRCN_",MVV" S:$E(MCRCN,1)="," MCRCN=$E(MCRCN,2,35)
80 G NOTE
81SETNODE(NODE,VALUE) ;Set the node with the string
82 S MDLNE=MDLNE+1,@NODE@(MDLNE,0)=VALUE
83 Q
84ORIENTAL I '$D(MCRC2),'$D(MCRC6) K MCRC1,MCRC3,MCRC4,MCRC5 Q
85 S:$D(MCRC2) MCRC1=MCRC2 S:$D(MCRC6) MCRC5=MCRC6 K MCRC3,MCRC4,MCRC6 S MCRCN="TLC,VC,FVC,FEV1,MVV"
86NOTE S MCRCN="NOTE: Race Correction on predicted values: "_MCRCN
87 I $G(MCMRAC)>1 S MCRCN=MCRCN_$S(MCRCR="O":" - ASIAN",1:" - BLACK")
88 Q
89CONFID(MCPV,VALUE) ;
90 Q $P(^MCAR(700.2,^MCAR(700.1,MCPV,VALUE),0),U,5)
91PREDV(MCPV,VALUE) ;
92 N EXPRESS,FORMULA,IEN,RESULT
93 S IEN=+$P($G(^MCAR(700.1,MCPV,VALUE)),U)
94 S FORMULA=$P($G(^MCAR(700.2,IEN,0)),U)
95 S RESULT=""
96 I FORMULA]"" S EXPRESS="S RESULT="_FORMULA X EXPRESS
97 Q $S(RESULT]"":RESULT,1:"")
98MCPV(MCDA) ; Get the Predicted Value entry
99 Q $S($D(^MCAR(700,MCDA,"PV")):^("PV"),1:0)
100PREDS S BSA=+$$BSA(HT,WT),I="DLCOSB",DLCOSB=$$PREDV(MCPV,"DLCOSB"),CDLCOSB=$$CONFID(MCPV,"DLCOSB")
101 S FEV1=$$PREDV(MCPV,"FEV1"),CFEV1=$$CONFID(MCPV,"FEV1")
102 S FRC=$$PREDV(MCPV,"FRC"),CFRC=$$CONFID(MCPV,"FRC")
103 S FVC=$$PREDV(MCPV,"FVC"),CFVC=$$CONFID(MCPV,"FVC")
104 S FEF2575=$$PREDV(MCPV,"FEF2575"),CFEF2575=$$CONFID(MCPV,"FEF2575")
105 S PF=$$PREDV(MCPV,"PF"),CPF=$$CONFID(MCPV,"PF")
106 S RV=$$PREDV(MCPV,"RV"),CRV=$$CONFID(MCPV,"RV")
107 S TLC=$$PREDV(MCPV,"TLC"),CTLC=$$CONFID(MCPV,"TLC")
108 S VC=$$PREDV(MCPV,"VC"),CVC=$$CONFID(MCPV,"VC")
109 S MVV=$$PREDV(MCPV,"MVV"),CMVV=$$CONFID(MCPV,"MVV")
110 Q
111BSA(HT,WT) ; Compute BSA
112 D COMPUTE^MCARBSA
113 Q X
114ETHN(MCRSTR,MCETH) ; Get the Race and Ethnicity arrays and concat with Race
115 N MCCTR,MCSTR,MCLP,MCX,Y
116 S MCCTR=+$G(MCETH(12)),MCSTR=""
117 I MCCTR F MCLP=1:1:MCCTR S MDX=$G(MCETH(12,MCLP)) S:$P(MDX,"^",2)'="" MCSTR=MCSTR_$S(MCSTR="":"",1:", ")_$P(MDX,"^",2)
118 S Y=$S(MCSTR'="":MCSTR,1:MCRSTR)
119 Q Y
Note: See TracBrowser for help on using the repository browser.