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

BEHOENP2.m

Go to the documentation of this file.
BEHOENP2 ;MSC/IND/MGH - Summary Report for Selected Encounter ;24-Mar-2016 04:54;du
 ;;1.1;BEH COMPONENTS;**005003,005004,005005**;Mar 20, 2007
 ;=================================================================
MEAS(BEHVSIT,DFN,BEHQUIT) ;EP - Find the vital measurements for this visit
 S BEHIEN=""  F  S BEHIEN=$O(^GMR(120.5,"B",BEHVSIT,BEHIEN)) Q:BEHIEN=""  D
 .Q:$P($G(^AUPNVMSR(BEHIEN,2)),U,1)=1    ;Quit if entered in error
 .S BEHTYP=$$GET1^DIQ(9000010.01,BEHIEN,.01,"E")
 .S BEH="" S BEH=$O(^BEHOVM(90460.01,"B",BEHTYP,BEH))
 .I BEH'="" D
 ..S VDATA=$G(^BEHOVM(90460.01,BEH,0))
 ..S DEFAULT=$P(VDATA,U,2)
 ..I DEFAULT="" S DEFU=""
 ..I DEFAULT=1 D
 ...S DEFU=$P(VDATA,U,4)
 ..I DEFAULT=0 D
 ...S DEFU=$P(VDATA,U,3)
 .S BEHVAL=$$RND($$GET1^DIQ(9000010.01,BEHIEN,.04,"E"))
 .S BEHDT=$$GET1^DIQ(9000010.01,BEHIEN,.07,"E")
 .S BEHDTI=$$GET1^DIQ(9000010.01,BEHIEN,.07,"I")
 .I BEHDT="" D
 ..S BEHDT=$$GET1^DIQ(9000010.01,BEHIEN,1201,"E")
 ..S BEHDTI=$$GET1^DIQ(9000010.01,BEHIEN,1201,"I")
 .I BEHDT'=OLDBEHDT S BENCNT=0,OLDBEHDT=BEHDT
 .S QUALSTR=""
 .S MOD=0 F  S MOD=$O(^AUPNVMSR(BEHIEN,5,MOD)) Q:'+MOD  D
 ..S QUAL=$G(^AUPNVMSR(BEHIEN,5,MOD,0))
 ..S QUAL=$P($G(^GMRD(120.52,QUAL,0)),U,1)
 ..S QUALSTR=QUALSTR_QUAL_","
 .S BEHCNT=BEHCNT+1
 .S BEHVIT(BEHDTI,BEHCNT)=BEHTYP_U_BEHVAL_" "_DEFU_U_QUALSTR
 I $D(BEHVIT) D
 .S NAME="VITAL MEASUREMENTS"
 .D HDR^BEHOENPV(NAME,BEHCNT)
 .W !,"DT/TIME",?25,"TYPE",?40,"VALUE",?55,"MODIFIERS",!
 .N I,J
 .S I="" F  S I=$O(BEHVIT(I)) Q:I=""  D
 ..W !,$$FMTE^XLFDT(I)
 ..S J="" F  S J=$O(BEHVIT(I,J)) Q:J=""  D
 ...W !,?25,$P(BEHVIT(I,J),U,1),?40,$P(BEHVIT(I,J),U,2),?55,$P(BEHVIT(I,J),U,3)
 Q
 ; Write text with word wrap
WRAP(TXT,RM) ;
 N LM,WD,X,Y
 S RM=$G(RM,IOM),LM=$X,WD=RM-LM
 Q:WD<5 ""
 F  Q:'$L(TXT)  D
 .I $L(TXT)'>WD W TXT S TXT="" Q
 .S X=0,Y=WD
 .F  S X=$F(TXT," ",X) Q:'X!(X>WD)  S Y=X
 .W $E(TXT,1,Y-1)
 .S TXT=$E(TXT,Y,9999)
 .W:$L(TXT) !?LM
 Q ""
RND(X) Q $S(X=+X:+$J(X,0,2),1:X)
PROBLST(SNO,FIVE) ; Add item to problem list if not already there
 N IEN,PROB,FOUND,NCODE,NUMBER,DATA,ICD,NUM,NUMBER,NEW,SPROB,DEL,LIEN,DATA,MATCH,STAT
 S SPROB="",FOUND=0
 S NCODE=$P(VAL,U,1)
 ;If this patient already has this code on his problem list, just quit
 S PROB="" F  S PROB=$O(^AUPNPROB("APCT",DFN,SNO,PROB)) Q:PROB=""!(FOUND=1)  D
 .S DEL=$$GET1^DIQ(9000011,PROB,2.02)
 .I DEL="" S MATCH=1,SPROB=PROB
 I 'SPROB D
 .S IEN="+1",OPR=0
 .S LIEN=$$GET1^DIQ(9000010,VIEN,.06,"I")
 .S NEW=1+$E($O(^AUPNPROB("AA",DFN,LIEN,""),-1),2,99)
 .S FDA=$NA(FDA(9000011,IEN_","))
 .S @FDA@(.01)=CODE
 .S @FDA@(.02)=DFN
 .S @FDA@(.03)=$$NOW^XLFDT
 .S @FDA@(.05)=NAR
 .S @FDA@(.06)=DUZ(2)
 .S @FDA@(.07)=NEW
 .S @FDA@(.08)=$$NOW^XLFDT
 .S STAT=$$CHKSNO(SNO)
 .S @FDA@(.12)=STAT
 .S @FDA@(.14)=DUZ
 .S @FDA@(1.03)=DUZ
 .S @FDA@(1.04)=DUZ
 .;IHS/MGH/MGH SNOMED fields added
 .S @FDA@(80001)=SNO
 .S @FDA@(80002)=DESC
 .D UPDATE^DIE("","FDA","IEN","ERR")
 .I '$D(ERR("DIERR")) D
 ..S SPROB=IEN(1)
 ..S DATA=SPROB_U_$G(CIA("UID"))_U_1
 ..D:DFN BRDCAST^CIANBEVT("PCC."_DFN_".PRB",DATA)
 ..;Set any extra ICD codes
 ..D SETICD^BGOPROB1(.RES,SPROB,FIVE,";")
 ..Q:+RES
 Q:'+SPROB ""
 I $D(^AUPNPROB(SPROB,14,"B",VIEN)) Q SPROB
 N PRIEN,FDA,IEN,ERR
 S PRIEN="+1,"_SPROB_","
 S FDA(9000011.14,PRIEN,.01)=VIEN
 D UPDATE^DIE(,"FDA","IEN","ERR")
 Q SPROB
ADDICD(RET,VAL,FIVE,PROB) ;Add any additional ICD codes as POV
 N DUP2,SFIVE,X,I,DEL
 S DEL=";",PROB=$G(PROB)
 S SFIVE=$G(FIVE)
 S X=$L(FIVE,DEL)
 F I=2:1:X D
 .S $P(VAL,U,2)=$P(SFIVE,DEL,I)
 .D SETEXTRA(.RET,.VAL)
 Q
SETEXTRA(RET,VAL) ;add in extra ICD codes
 N NAR,VAL1,SNO,DESC,X,CODE,TXT,FIVE
 S DESC=$P(VAL,U,11)
 S TXT=$P(VAL,U,10)
 S CODE=$P(VAL,U,2)
 I $$AICD^BEHOENPC S CODE=$P($$CODEN^ICDEX(CODE,80),"~",1)
 E  S CODE=+$$CODEN^ICDCODE(CODE,80)
 Q:CODE'>0
 S $P(VAL,U,4)=$$NARR^BEHOENPC(TXT_"|"_DESC)
 S $P(VAL,U,2)=CODE
 S $P(VAL,U,6)="S"
 D SET^BEHOENPC(.04,4),SET^BEHOENPC(.12,6),SET^BEHOENPC(.08,7),SET^BEHOENPC(1101,9),SET^BEHOENPC(1102,11),SET^BEHOENPC(.16,12)
 D STORE^BEHOENPC(.07)
 Q
CHKSNO(SNO) ;Check for term coming from pharm ed
 N DATA,CHK,GOOD
 S GOOD="E"
 D GETLST^XPAR(.DATA,"ALL","BEHORXED POV SNOMED LIST")
 F CHK=1:1:DATA D
 .I SNO=$P($G(DATA(CHK)),U,2) S GOOD="R"
 Q GOOD