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

BHSPHN.m

Go to the documentation of this file.
BHSPHN ;IHS/CIA/MGH - Health Summary for PUBLIC HEALTH NURSING file ;24-Aug-2012 14:24;DU
 ;;1.0;HEALTH SUMMARY COMPONENTS;**7**;March 17, 2006;Build 12
 ;===================================================================
 ;Taken from APCHS2G
 ;IHS/TUCSON/LAB - PART 2B OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;
 ;;2.0;IHS RPMS/PCC Health Summary;**3**;JUN 24, 1997
 ;Routines to document public health nursing encounters from the visit file
 ;in the VA health summary component
OUTPT ; ********** OUTPATIENT ENCOUNTERS * 9000010/9000010.07 **********
 ; <SETUP>
 N BHSPAT,BHSN,BHSNTE,BHSQ,BHSTXT,X
 S BHSPAT=DFN
 Q:'$D(^AUPNVSIT("AA",BHSPAT))
 D CKP^GMTSUP Q:$D(GMTSQIT)
 ; <DISPLAY>
 S BHSPVD=0
 S BHSPFN=""
 F BHSIVD=0:0 S BHSIVD=$O(^AUPNVSIT("AA",BHSPAT,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM)  D  Q:GMTSNDM=0!($D(GMTSQIT))
 . D ONEDATE
 . Q:$D(GMTSQIT)
 . S:(BHSDAT'=BHSPVD)&BHSDTU GMTSNDM=GMTSNDM-BHSDTU,BHSPVD=BHSDAT
 . Q
 ;
OUTPTX ; <CLEANUP>
 K BHSIVD,BHSDTU,BHSDAT,BHSVDF,BHSFAC,BHSPFN,BHSSCL,BHSMTX,BHSMOD,BHSPVD,BHSOVT,BHSNDT,BHSCLI,BHSPDN,BHSICD,BHSICL,BHSNRQ,BHSPHN
 K BHSNFL,BHSNSH,BHSCCL,BHSNAB,BHSVSC,BHSITE,BHSQIT,BHSDCL,Y
 Q
 ;
ONEDATE ;
 S BHSCCL=""
 S X=-BHSIVD\1+9999999 D REGDT4^GMTSU S BHSDAT=X
 S BHSDTU=0,BHSNDT=(BHSDAT'=BHSPVD)
 S BHSVDF="" F BHSQ=0:0 S BHSVDF=$O(^AUPNVSIT("AA",BHSPAT,BHSIVD,BHSVDF)) Q:BHSVDF=""  D  Q:$D(GMTSQIT)
 . S BHSSCL=""
 . S BHSN=^AUPNVSIT(BHSVDF,0)
 . Q:'$P(BHSN,U,9)
 . Q:$P(BHSN,U,11)
 . Q:'$$PHN(BHSVDF)  ;do not use is phn is not a provider on this visit
 . D GETCLN
 . D GETSITEV^BHSUTL,DSPVIS
 . Q:$D(GMTSQIT)
 . Q
 Q
 ;
GETCLN ;
 ;BHSDCL=set to 34 if Display Clinic is Yes, 23 if No
 I $D(^GMT(142.1,GMTSE,0)),$P(^(0),U,10)="Y" D
 .S BHSDCL=34
 .S BHSCLI=$P(BHSN,U,8) I BHSCLI="" S BHSCCL="<none>" Q
 .S BHSCLI=$P(BHSN,U,8) Q:BHSCLI=""
 .Q:'$D(^DIC(40.7,BHSCLI))
 .I $D(^DIC(40.7,BHSCLI,9999999)),$P(^(9999999),U,1)]"" S BHSCLI=$P(^DIC(40.7,BHSCLI,9999999),U,1),BHSCCL=BHSCLI Q
 .S BHSCLI=$E($P(^DIC(40.7,BHSCLI,0),U,1),1,10)
 .S BHSCCL=BHSCLI
 E  S BHSCLI=" ",BHSDCL=23 Q
 Q
PHN(V) ;if one provider is phn quit on 1 otherwise quit on ""
 I 'V Q ""
 I '$D(^AUPNVSIT(V)) Q ""
 I '$D(^AUPNVPRV("AD",V)) Q ""
 I $$PRIMPROV^APCLV(V,"D")=13!($$PRIMPROV^APCLV(V,"D")=32) Q 1
 Q ""
 ;if include secondary remove lines above about primary
 NEW %,%1,Y,P S Y=0,%1="" F  S Y=$O(^AUPNVPRV("AD",V,Y)) Q:Y'=+Y  S P=$P(^AUPNVPRV(Y,0),U) D
 .I $P(^DD(9000010.06,.01,0),U,2)[200,'$D(^VA(200,P)) Q
 .I $P(^DD(9000010.06,.01,0),U,2)[6,'$D(^DIC(6,P)) Q
 .S %=$$VALI^XBDIQ1($S($P(^DD(9000010.06,.01,0),U,2)[200:200,1:6),P,$S($P(^DD(9000010.06,.01,0),U,2)[200:53.5,1:2)) I % S %=$P($G(^DIC(7,%,9999999)),U)
 .I %=13!(%=32) S %1=1
 Q %1
DSPVIS ;
 S BHSDTU=1
 I $O(^AUPNVPOV("AD",BHSVDF,""))="" D NOPOV Q
 S BHSPDN="" F BHSQ=0:0 S BHSPDN=$O(^AUPNVPOV("AD",BHSVDF,BHSPDN)) Q:'BHSPDN  S BHSN=^AUPNVPOV(BHSPDN,0) D HASPOV
 Q
 ;
NOPOV ;
 S (BHSICD,BHSNRQ)="<purpose of visit not yet entered>",BHSMOD=""
 G COMMON
 ;
HASPOV ;
 S BHSICD=$P(BHSN,U,1) D GETICDDX^BHSUTL
 S BHSNRQ=$P(BHSN,U,4) D GETNARR^BHSUTL I $P(BHSN,U,5)]"" S BHSNRQ=BHSNRQ_"  (Stage: "_$P(BHSN,U,5)_")" ;IHS/CMI/LAB
 S BHSMOD=$P(BHSN,U,6)
COMMON ;
 D CKP^GMTSUP Q:$D(GMTSQIT)  S:GMTSNPG BHSNDT=1
 I BHSNDT W !,BHSDAT S (BHSPFN,BHSSCL)="",BHSNDT=0
 I BHSNSH=BHSPFN S BHSFAC=""
 E  S (BHSFAC,BHSPFN)=BHSNSH,BHSSCL=""
 I BHSCCL=BHSSCL S BHSCLI=""
 E  S (BHSCLI,BHSSCL)=BHSCCL
 I BHSICD["<purpose of visit not"&(BHSSCL="<none>") S BHSCLI=""
 I BHSMOD]"" S BHSMTX=$P(^DD(9000010.07,.06,0),U,3),BHSMTX=$P($P(BHSMTX,BHSMOD_":",2),";",1),BHSMTX=$P(BHSMTX,",",1),BHSICD=BHSMTX_" "_BHSICD
 S:$D(^AUPNVCHS("AD",BHSVDF)) BHSNTE="*** CHS ***"
 W ?12,BHSFAC W:BHSCLI]"" ?23,BHSCLI
 S BHSICL=$S(BHSDCL=34:34,1:24)
 S:0 BHSICD=BHSVSC_":"_BHSICD D PRTICD^BHSUTL
 Q
GOALS(BHSVDF) ;display phn fields
 Q:'$D(^AUPNVPHN("AD",BHSVDF))
 S BHSPHN=$O(^AUPNVPHN("AD",BHSVDF,0))
 Q:'BHSPHN
 I $P(^AUPNVPHN(BHSPHN,0),U,5)]"" D CKP^GMTSUP Q:$D(GMTSQIT)  S:GMTSNPG BHSNDT=1 W ?BHSICL,"Intervention: ",$$VAL^XBDIQ1(9000010.32,BHSPHN,.05)
 I $P(^AUPNVPHN(BHSPHN,0),U,6)]"" D CKP^GMTSUP Q:$D(GMTSQIT)  S:GMTSNPG BHSNDT=1 W !?BHSICL,"Complexity: ",$$VAL^XBDIQ1(9000010.32,BHSPHN,.06)
 I $P(^AUPNVPHN(BHSPHN,0),U,5)]""!($P(^AUPNVPHN(BHSPHN,0),U,6)]"") W !
 I $D(^AUPNVPHN(BHSPHN,21)) S BHSTXT="Psycho/Soc/Env: "_^AUPNVPHN(BHSPHN,21),BHSICL=$S(BHSDCL=34:34,1:24)+1 D PRTTXT
 I $D(^AUPNVPHN(BHSPHN,22)) S BHSTXT="NSG Dx: "_^AUPNVPHN(BHSPHN,22),BHSICL=$S(BHSDCL=34:34,1:24)+1 D PRTTXT
 I $D(^AUPNVPHN(BHSPHN,23)) S BHSTXT="Short Term Goals: "_^AUPNVPHN(BHSPHN,23),BHSICL=$S(BHSDCL=34:34,1:24)+1 D PRTTXT
 I $D(^AUPNVPHN(BHSPHN,24)) S BHSTXT="Long Term Goals: "_^AUPNVPHN(BHSPHN,24),BHSICL=$S(BHSDCL=34:34,1:24)+1 D PRTTXT
 Q
 ;
DETAIL ; ********** PHN OUTPATIENT ENCOUNTERS * 9000010/9000010.07 **********
 ; <SETUP>
 N BHSPAT,BHSN,BHSNTE,BHSQ,BHSTXT,X
 S BHSPAT=DFN
 Q:'$D(^AUPNVSIT("AA",BHSPAT))
 D CKP^GMTSUP Q:$D(GMTSQIT)
 ; <DISPLAY>
 S BHS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