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

BHSPLST2.m

Go to the documentation of this file.
BHSPLST2 ;IHS/MSC/MGH  - Health Summary for Problem list;04-Jan-2016 10:17;DU
 ;;1.0;HEALTH SUMMARY COMPONENTS;**13**;Mar 17,2006;Build 6
 ; IHS/CMI/LAB - PART 4 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;31-Mar-2014 16:53;DU
 ;
ICPR(DFN,TARGET,TYPE,ACTIVE) ;Care plans by problem
 N ARRAY,INVDT,VCNT,CNT,STAT,NARR,X,Y,Z,SIGN,SIGNDT,CDTE,EDATE
 K @TARGET
 S CNT=0,ARRAY="",ACTIVE=$G(ACTIVE)
 D GETPROB2(.ARRAY,DFN,TYPE,ACTIVE)
 S X=""  F  S X=$O(ARRAY(X)) Q:X=""  D
 .S PRIEN=X
 .S STAT=$$GET1^DIQ(9000011,PRIEN,.12)
 .S PNAR=$$GET1^DIQ(9000011,PRIEN,.05)
 .S CONCT=$$GET1^DIQ(9000011,PRIEN,80001)
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)="Problem: "_PNAR
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)=" - Problem Status: "_STAT
 .S Z="" F  S Z=$O(ARRAY(X,Z)) Q:Z=""  D
 ..S Y="" F  S Y=$O(ARRAY(X,Z,Y)) Q:Y=""  D
 ...S EDATE=9999999-$P(ARRAY(X,Z,Y),U,2)
 ...S EDATE=$$FMTE^XLFDT(EDATE,5)
 ...S SIGN=$P(ARRAY(X,Z,Y),U,4)
 ...S SIGNDT=$P(ARRAY(X,Z,Y),U,6)
 ...S CDTE=$P(ARRAY(X,Z,Y),U,8)
 ...S CNT=CNT+1
 ...S @TARGET@(CNT,0)=" - Date: "_EDATE
 ...S CNT=CNT+1
 ...S @TARGET@(CNT,0)=" - TEXT  Status: "_CDTE
 ...S CPIEN=$P(ARRAY(X,Z,Y),U,3)
 ...D TEXT^BTIUPV1(TYPE,CPIEN)
 I CNT=0 S @TARGET@(1,0)="No Care Plans found of type "_$S(TYPE="G":"Goal",1:"Care Plan")
 Q "~@"_$NA(@TARGET)
 ;
GETPROB2(ARRAY,DFN,TYPE,ACTIVE) ;EP
 ;Start by finding the patient's problems
 N PRIEN,REC,CONCT,PNAR,STAT,VCNT
 S PRIEN="",VCNT=0
 F  S PRIEN=$O(^AUPNPROB("AC",DFN,PRIEN)) Q:'PRIEN  D
 .S REC=$G(^AUPNPROB(PRIEN,0))
 .S STAT=$P(REC,U,12)
 .Q:STAT="D"!(STAT="I")  ;Only doing active problems
 .D GETPL(.ARRAY,PRIEN,TYPE,ACTIVE)
 Q
GETPL(ARRAY,PRIEN,TYPE,ACTIVE) ;Return data
 N INVDT,STATUS,CPIEN,SIEN,DATA
 S CPIEN="",DATA=""
 F  S CPIEN=$O(^AUPNCPL("APT",PRIEN,TYPE,CPIEN)) Q:CPIEN=""  D
 .S SIEN=$C(0) S SIEN=$O(^AUPNCPL(CPIEN,11,SIEN),-1)  Q:'+SIEN  D
 ..S STATUS=$P($G(^AUPNCPL(CPIEN,11,SIEN,0)),U,1)
 ..Q:ACTIVE="I"&(STATUS="A")
 ..Q:STATUS="E"
 ..S INVDT=9999999-$P($G(^AUPNCPL(CPIEN,0)),U,5)
 ..S DATA=$$DATA(CPIEN,SIEN,ACTIVE)
 ..Q:DATA=""
 ..S VCNT=VCNT+1
 ..S ARRAY(PRIEN,INVDT,VCNT)=PRIEN_U_INVDT_U_DATA
 Q
DATA(CPIEN,SIEN,ACTIVE) ;Get data for this item
 N BY,WHEN,LIEN,TXT,TXTIEN,PTYPE,SIGNED,PROB,SIG,FNUM,NODE,EVDT
 S FNUM=9000092.11
 S SIGNED=0
 S SIGNED=$P($G(^AUPNCPL(CPIEN,0)),U,7)
 S EVDT=$P($G(^AUPNCPL(CPIEN,0)),U,5)
 Q:(SIGNED="")&(DUZ'=$$GET1^DIQ(9000092,CPIEN,.03,"I")) ""
 S NODE=$G(^AUPNCPL(CPIEN,11,SIEN,0))
 S LIEN=SIEN_","_CPIEN
 S WHEN=$$GET1^DIQ(FNUM,LIEN,.03,"I")
 S WHEN=$$FMTDATE^BGOUTL(WHEN)
 S BY=$$GET1^DIQ(9000092,CPIEN,.07,"E")
 S STAT=$$GET1^DIQ(FNUM,LIEN,.01,"I")
 Q:ACTIVE="I"&(STAT="A") ""
 Q:STAT="E" ""
 S SIG=$$GET1^DIQ(9000092,CPIEN,.08,"I")
 I SIG'="" S SIG=$$FMTDATE^BGOUTL(SIG)
 Q CPIEN_U_BY_U_WHEN_U_SIG_U_EVDT_U_STAT