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

VENPCC1K.m

Go to the documentation of this file.
VENPCC1K ; IHS/OIT/GIS - SPECIAL DISPLAY OF PROBLEMS AND POVS ; 
 ;;2.6;PCC+;;NOV 12, 2007
 ;
 ; SPECIAL PROBLEM DISPLAY FOR VER 2.5
 ; 
PROB(DFN,DEPTIEN) ; EP - SPECIAL PROBLEM DISPLAY
 N TMP
 S TMP="^TMP(""VEN PRNT"",$J)"
 D APL(DFN) ; ACTIVE PROBLEMS
 I $G(DEFEF),$P($G(^VEN(7.41,DEFEF,5)),U,17)>1,$L($T(PCCPLUS^APCHSPRN)) D PCCPLUS^APCHSPRN(DFN,DEFEF) ;  PROBLEM NARRATIVE LOOKUP FOR ANMC
 D POV(DFN) ; ALL RECENT POVS
 N CSIEN
 S CSIEN=$P($G(^VEN(7.95,DEPTIEN,0)),U,4) I 'CSIEN Q
 D CSPOV(DFN,CSIEN) ; CLINIC SPECIFIC POVS
 Q
 ; 
APL(DFN) ; EP-GET UP TO 25 ACTIVE PROBLEMS STORED IN pb1-pb25 AND CODES IN pb1c-pb25c
 NEW TOT,PIEN,X,NIEN,IIEN,STAT,TYPE,NARR,VAR,VAR1,ICD,MAXNARR
 S TOT=0,PIEN=0,MAXNARR=$$MAXNARR^VENPCCU(+$G(DEFEF))
 F  S PIEN=$O(^AUPNPROB("AC",DFN,PIEN)) Q:'PIEN  D  I TOT>24 Q
 . S X=$G(^AUPNPROB(PIEN,0)),NIEN=$P(X,U,5),IIEN=+X,STAT=$P(X,U,12),TYPE=$P(X,4,U)
 . I NIEN,IIEN,STAT="A",TYPE=""
 . E  Q
 . S NARR=$G(^AUTNPOV(NIEN,0)),ICD=$P($G(^ICD9(IIEN,0)),U),ICD9(IIEN)=""
 . S TOT=TOT+1
 . S VAR="pb"_TOT,VAR1=VAR_"c"
 . S @TMP@(1,VAR)=$E(NARR,1,MAXNARR),@TMP@(1,VAR1)=ICD
 . Q
 Q
 ; 
POV(DFN) ; EP-GET UP TO 30 MOST RECENT POVS
 ; DATA STORED IN MAIL MERGE FIELD PAIRS pv1 - pv30
 N PIEN,X,NIEN,IIEN,TOT,NARR,VAR,VAR1,ICD,DATE,Y,VISIT,MAXNARR,VCN
 S TOT=0,PIEN=999999999,MAXNARR=$$MAXNARR^VENPCCU(+$G(DEFEF))
 F  S PIEN=$O(^AUPNVPOV("AC",DFN,PIEN),-1) Q:'PIEN  D  I TOT>29 Q
 . S VISIT=$P($G(^AUPNVPOV(PIEN,0)),U,3) I 'VISIT Q
 . S Y=+$G(^AUPNVSIT(VISIT,0))
 . S DATE=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_$E(Y,2,3)  I '$L(DATE) Q
 . S X=$G(^AUPNVPOV(PIEN,0)),NIEN=$P(X,U,4),IIEN=+X
 . S NARR=$G(^AUTNPOV(+$G(NIEN),0)),ICD=$$FVICD^VENPCCU(PIEN)
 . I '$L(NARR) S NARR=$P($G(^ICD9(IIEN,0)),U,3) I '$L(NARR) S NARR="<missing narrative>"
 . S TOT=TOT+1
 . S VAR1="pv"_TOT
 . S VCN="" ; VCN MAY BE APPENDED TO OUTPUT IF EF FLD 5.21 = 2
 . I $P($G(^VEN(7.41,+$G(DEFEF),5)),U,21) S %=$P($G(^AUPNVSIT(VISIT,11)),U,3) I $L(%) S VCN=" "_%
 . S @TMP@(1,VAR1)=DATE_" "_$E(NARR,1,MAXNARR)_" ["_ICD_"]"_VCN
 . Q
 Q
 ; 
CSPOV(DFN,CSIEN) ; EP-GET UP TO 30 MOST RECENT POVS FOR THIS CLINIC
 ; DATA STORED IN MAIL MERGE FIELD  pv1C THRU pv30C
 N PIEN,X,NIEN,IIEN,TOT,NARR,VAR,ICD,VISIT,VCS,DATE,Y,MAXNARR,VCN
 S TOT=0,PIEN=999999999,MAXNARR=$$MAXNARR^VENPCCU(+$G(DEFEF))
 F  S PIEN=$O(^AUPNVPOV("AC",DFN,PIEN),-1) Q:'PIEN  D  I TOT>29 Q
 . S VISIT=$P($G(^AUPNVPOV(PIEN,0)),U,3) I 'VISIT Q
 . S VCS=$P($G(^AUPNVSIT(VISIT,0)),U,8) I VCS'=CSIEN Q  ; CLINIC STOP FILTER
 . S Y=+$G(^AUPNVSIT(VISIT,0)) I '$L(Y) Q
 . S DATE=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_$E(Y,2,3)
 . S X=$G(^AUPNVPOV(PIEN,0)),NIEN=$P(X,U,4),IIEN=+X
 . S NARR=$G(^AUTNPOV(+$G(NIEN),0)),ICD=$$FVICD^VENPCCU(PIEN)
 . I '$L(NARR) S NARR=$P($G(^ICD9(IIEN,0)),U,3) I '$L(NARR) S NARR="<missing narrative>"
 . S TOT=TOT+1
 . S VAR="pv"_TOT_"c"
 . S VCN="" ; VCN MAY BE APPENDED TO OUTPUT IF EF FLD 5.21 = 2
 . I $P($G(^VEN(7.41,+$G(DEFEF),5)),U,21) S %=$P($G(^AUPNVSIT(VISIT,11)),U,3) I $L(%) S VCN=" "_%
 . S @TMP@(1,VAR)=DATE_" "_$E(NARR,1,MAXNARR)_" ["_ICD_"]"_VCN
 . Q
 Q
 ; 
MH(DFN) ; EP-GET 15 MOST RECENT MENTAL HEALTH VISITS
 ; DATA IS STORED IN mh1-mh15
 N PIEN,X,NIEN,IIEN,TOT,NARR,VAR,ICD,VISIT,VCS,DATE,Y,MAXNARR
 S TOT=0,PIEN=999999999,MAXNARR=$$MAXNARR^VENPCCU(+$G(DEFEF))
 F  S PIEN=$O(^AUPNVPOV("AC",DFN,PIEN),-1) Q:'PIEN  D  I TOT>14 Q
 . S VISIT=$P($G(^AUPNVPOV(PIEN,0)),U,3) I 'VISIT Q
 . S Y=+$G(^AUPNVSIT(VISIT,0))
 . S DATE=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_$E(Y,2,3) I '$L(DATE) Q
 . S X=$G(^AUPNVPOV(PIEN,0)),NIEN=$P(X,U,4),IIEN=+X I 'IIEN Q
 . S ICD=$$FVICD^VENPCCU(PIEN) I '$L(ICD) Q
 . I +ICD<290!(+ICD>319.999999) Q  ; FILTER OUT NON MENTAL HEALTH DXS
 . S NARR=$G(^AUTNPOV(+$G(NIEN),0))
 . I '$L(NARR) S NARR=$P($G(^ICD9(IIEN,0)),U,3) I '$L(NARR) S NARR="<missing narrative>"
 . S NARR=NARR
 . S TOT=TOT+1
 . S VAR="mh"_TOT
 . S @TMP@(1,VAR)=DATE_" "_$E(NARR,1,MAXNARR)_" ["_ICD_"]"
 . Q
 Q
 ; 
ORLOG(DFN) ; EP-SURGERY HX BASED ON ANMC OR LOG
 ; FOR ANMC ONLY
 I '$D(^AZAORM(1,+$G(DFN),1)) Q "" ; MUST HAVE A VALID DFN
 N DN,SN,PN,DATE,TOT,SURGEON,PNARR,ICD,DATE,X,Y,%,GBL,OUT,SIEN,STG
 S GBL="^AZAORM(1,"_DFN_",1)",TOT=0,DN=999999999,OUT=""
 F  S DN=$O(@GBL@(DN),-1) Q:'DN  D
 . S Y=$P($G(@GBL@(DN,0)),U)\1 I 'Y Q
 . X ^DD("DD") S DATE=Y
 . S SN=0
 . F  S SN=$O(@GBL@(DN,1,SN)) Q:'SN  D
 .. S SIEN=+$G(@GBL@(DN,1,SN,0)) I 'SIEN Q
 .. S %=U_"DIC("_16_")",SURGEON=$P($G(@%@(SIEN,0)),U) I '$L(SURGEON) Q
 .. S PN=0
 .. F  S PN=$O(@GBL@(DN,1,SN,4,PN)) Q:'PN  D
 ... S STG=$G(@GBL@(DN,1,SN,4,PN,0)) I '$L(STG) Q
 ... S PNARR=$P(STG,U) I '$L(PNARR) Q
 ... S %=$P(STG,U,2)
 ... S ICD=$P($G(^ICD0(+%,0)),U)
 ... S TOT=TOT+1
 ... S $P(OUT,U,TOT)=(DATE_";"_PNARR_";"_ICD_";"_SURGEON)
 ... Q
 .. Q
 . Q
 Q OUT
 ;
SURG(DFN,DEFEF) ; EP - PRINT THE SURGICAL HX FROM THE OR LOG ON THE PCC+ FORM IN MERGE FIELDS u1-u15
 ; FOR ANMC ONLY
 I '$D(^AZAORM(1,+$G(DFN))) Q  ; MUST HAVE A VILD ER LOG DFN
 N VAR,STG,X,Y,%,TOT,CASE,I,MAX
 S STG=$$ORLOG(DFN) I '$L(STG) Q
 S MAX=$L(STG,U) I MAX>15 S MAX=15
 F TOT=1:1:MAX S CASE=$P(STG,U,TOT) I $L(CASE) D
 . S X=$P(CASE,";")_" "_$P(CASE,";",2) ; PRINT DATE AND PROCEDURE NARRATIVE
 . I $P($G(^VEN(7.41,DEFEF,5)),U,19) S X=X_" "_$P(CASE,";",3) ; PRINT THE ICD PROCEDURE CODE
 . I $P($G(^VEN(7.41,DEFEF,5)),U,20) S Y=$P(CASE,";"),X=X_" DR. "_$E($P(Y,",",2))_". "_$P(Y,",") ; PRINT THE SURGEON
 . S VAR="u"_TOT
 . S @TMP@(1,VAR)=X
 . Q
 Q
 ;