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

BHSBDEM.m

Go to the documentation of this file.
BHSBDEM ;IHS/MSC/MGH - Health Summary Demographics  ;14-Jan-2014 14:58;DU
 ;;1.0;HEALTH SUMMARY COMPONENTS;**4,6,9**;March 17,2006;Build 16
 ;=================================================================
 ; IHS/CMI/LAB - PART 1A OF APCHS -- SUMMARY PRODUCTION COMPONENTS IHS/MSC/MGH - Health Summary Demographics  ;29-Mar-2010 17:14;MGH
 ;;1.0;HEALTH SUMMARY COMPONENTS;**1,2,3,4**;March 17,2006;
 ;;2.0;IHS PCC SUITE;**2**;MAY 14, 2009 ;
 ;Patch 6 update for preferred language
 ;
BDEMOG ; ******************** BRIEF DEMOGRAPHICS - W/ADV DIRECTIVES ********************
 ; <SETUP>
 N BHSPAT,BHSDN,BHDNAM,BHSDOB,BHSADR,BHSZ,BHSX,BHPLNG
 S BHSPAT=DFN
 S BHSN=^DPT(BHSPAT,0)
 S BHSNAM=$P(BHSN,U,1)
 S Y=$P(BHSN,U,3)
 I 'Y S BHSDOB="<no date of birth recorded>"
 E  X ^DD("DD") S BHSDOB=Y
 S BHSADR=""
 I $D(^DPT(BHSPAT,.11)) S BHSN=^(.11) F BHSI=1:1:6 S BHSP=$P(BHSN,U,BHSI) I BHSP]"" S:BHSI=5 BHSP=$P(^DIC(5,BHSP,0),U,2) S BHSADR=BHSADR_","_BHSP
 I $D(^DPT(BHSPAT,.13)) S BHHPH=$P($G(^DPT(BHSPAT,.13)),U),BHWPH=$P($G(^DPT(BHSPAT,.13)),U,2)  ;IHS/CMI/GRL
 S BHSADR=$E(BHSADR,2,255)
BDEMDSP ; <DISPLAY>
 D CKP^GMTSUP Q:$D(GMTSQIT)
 I $$DOD^AUPNPAT(BHSPAT)]""!($$VAL^XBDIQ1(9000001,BHSPAT,1114)]"") D
 .W "*** DOD: ",$$VAL^XBDIQ1(2,BHSPAT,.351),!
 .W "*** CAUSE OF DEATH: " I $$VAL^XBDIQ1(9000001,BHSPAT,1114)]"" D  I 1
 ..W $$VAL^XBDIQ1(9000001,BHSPAT,1114)
 ..K BHSDSC
 ..;Patch 9 changed API for ICD-10
 ..I $$AICD^BHSUTL D
 ...S BHSDSC=$$ICDD^ICDEX($$VAL^XBDIQ1(9000001,BHSPAT,1114),"BHSDSC",$$DOD^AUPNPAT(BHSPAT)) I $P(BHSDSC,U)=-1 S BHSDSC(1)=$P($$ICDDX^ICDEX($P(^AUPNPAT(BHSPAT,11),U,14),$$DOD^AUPNPAT(BHSPAT)),U,4)
 ..E  S BHSDSC=$$ICDD^ICDCODE($$VAL^XBDIQ1(9000001,BHSPAT,1114),"BHSDSC",$$DOD^AUPNPAT(BHSPAT)) I $P(BHSDSC,U)=-1 S BHSDSC(1)=$P($$ICDDX^ICDCODE($P(^AUPNPAT(BHSPAT,11),U,14),$$DOD^AUPNPAT(BHSPAT)),U,4)
 ..K ^UTILITY($J,"W")
 ..S BHSX=0
 ..S DIWL=0,DIWR=45 F  S BHSX=$O(BHSDSC(BHSX)) Q:BHSX'=+BHSX!($D(GMTSQIT))  D
 ...S X=BHSDSC(BHSX)
 ...Q:X="CODE TEXT MAY BE INACCURATE"
 ...Q:X=" "
 ...D ^DIWP
 ..S BHSZ=0 F  S BHSZ=$O(^UTILITY($J,"W",DIWL,BHSZ)) Q:BHSZ'=+BHSZ  D
 ...Q:$D(GMTSQIT)
 ...W ?28,^UTILITY($J,"W",DIWL,BHSZ,0),!
 .E  W !!
 .;W !
 K ^UTILITY($J,"W"),BHSDSC,DIWL,BHSX,BHSZ,DIWL,DIW
 W !,BHSNAM,"  ",$$VAL^XBDIQ1(2,BHSPAT,.02)," DOB: ",BHSDOB," AGE: ",$$AGE^AUPNPAT(BHSPAT,DT),"  SSN: ",$$SSN^BHSDEM(BHSPAT),!
 W "TRIBE: ",$$VAL^XBDIQ1(9000001,DFN,1108),"        ",$$VAL^XBDIQ1(9000001,DFN,1112),!
 I $D(DUZ(2)),DUZ(2),$D(^AUPNPAT(BHSPAT,41,DUZ(2))) S BHSFP=DUZ(2),BHSFAC=$P(^AUPNPAT(BHSPAT,41,BHSFP,0),U,2) W $P(^DIC(4,BHSFP,0),U,1)," HEALTH RECORD NUMBER: ",BHSFAC,!
 W:BHSADR]"" BHSADR,!
 W "Home Phone: ",$S($G(BHHPH)]"":BHHPH,1:"None")_"     "_"Work Phone: ",$S($G(BHWPH)]"":BHWPH,1:"None"),! ;IHS/CMI/GRL
 S BHPLNG=$$PREFLANG^APCLAPI7(BHSPAT,DT,"E")
 I BHPLNG]"" W "Preferred Language: ",BHPLNG,!
 ;ADVANCE DIRECTIVES
 I $D(^AUPNADVD(BHSPAT,0)) D
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W "Advance Directives: "
 .S BHSI=0 F  S BHSI=$O(^AUPNADVD(BHSPAT,11,"B",BHSI)) Q:BHSI=""  S BHSN=0 F  S BHSN=$O(^AUPNADVD(BHSPAT,11,"B",BHSI,BHSN)) Q:BHSN=""  S BHSP=BHSN
 .S BHIEN=BHSP_","_BHSPAT_"," W ?20,$$GET1^DIQ(9000040.11,BHIEN,.02),"   ",$$GET1^DIQ(9000040.11,BHIEN,.03),"   Updated: ",$$GET1^DIQ(9000040.11,BHIEN,.01),!
 I '$D(^AUPNADVD(BHSPAT,0)) W "Advance Directives:  No information on file.",!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 W "Last Registration Update: ",$$VAL^XBDIQ1(9000001,BHSPAT,.03),!
 ; <CLEANUP>
BDEMOGX K BHSN,BHSFP,BHSFAC,BHSNAM,BHSDOB,BHSADR,BHSP,BHSI,BHIEN
 K BHHPH,BHWPH
 Q
 ;
HOMELOC ; ******************** LOCATION OF HOME ********************
 ; <SETUP>
 Q:'$O(^AUPNPAT(BHSPAT,12,0))
 ; <DISPLAY>
 F BHSI=0:0 S BHSI=$O(^AUPNPAT(BHSPAT,12,BHSI)) Q:'BHSI  D CKP^GMTSUP Q:$D(GMTSQIT)  W ^AUPNPAT(BHSPAT,12,BHSI,0),!
 ; <CLEANUP>
HOMELOCX K BHSI
 Q