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

BTIUPLAN.m

Go to the documentation of this file.
BTIUPLAN ; IHS/MSC/MGH - Problem/Visit Objects ;06-Jan-2015 12:50;du
 ;;1.0;TEXT INTEGRATION UTILITIES;**1012,1013**;MAR 20, 2013;Build 33
 ;Obects for entries from Care Plan file
 Q
 ;
CPDT(DFN,TARGET,TYPE) ;Active Care Plans by Date
 N ARRAY,INVDT,IEN,VCNT,CNT,EDATE,EDTE,SIGN,SIGNDT,STAT,NARR,X,PCNT
 K @TARGET
 S CNT=0,PCNT=0,EDATE=0
 D GETPROB(.ARRAY,DFN,TYPE)
 S X=""
 F  S X=$O(ARRAY(X)) Q:X=""  D
 .;S EDATE=9999999-X
 .;S EDATE=$$FMTE^XLFDT(EDATE,5)
 .;S CNT=CNT+1
 .;S @TARGET@(CNT,0)="Date: "_EDATE
 .S Y="" F  S Y=$O(ARRAY(X,Y)) Q:Y=""  D
 ..S PRIEN=$P(ARRAY(X,Y),U,2)
 ..S EDTE=$P(ARRAY(X,Y),U,7)
 ..I EDATE'=$P(EDTE,".",1) D
 ...S CNT=CNT+1
 ...S @TARGET@(CNT,0)="Date: "_$$FMTE^XLFDT($P(EDTE,".",1),5)
 ...S EDATE=$P(EDTE,".",1)
 ..S STAT=$$GET1^DIQ(9000011,PRIEN,.12)
 ..S PNAR=$$GET1^DIQ(9000011,PRIEN,.05)
 ..S CONCT=$$GET1^DIQ(9000011,PRIEN,80001)
 ..S SIGN=$P(ARRAY(X,Y),U,4)
 ..S SIGNDT=$P(ARRAY(X,Y),U,6)
 ..S CNT=CNT+1,PCNT=PCNT+1
 ..S @TARGET@(CNT,0)=$J(PCNT,2)_")"_PNAR
 ..S CNT=CNT+1
 ..S @TARGET@(CNT,0)=" - Problem Status: "_STAT
 ..;S CNT=CNT+1
 ..;S @TARGET@(CNT,0)=" ("_$P(ARRAY(X,Y),U,6)_" by "_$P(ARRAY(X,Y),U,4)_")"
 ..S CNT=CNT+1
 ..S @TARGET@(CNT,0)=" - TEXT"
 ..S CPIEN=$P(ARRAY(X,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)
 ;
GETPROB(ARRAY,DFN,TYPE) ;EP
 ;Start by finding the patient's problems
 N PRIEN,REC,REC8,CONCT,PNAR,STAT,VCNT
 S VCNT=0,PRIEN=""
 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 GETP(.ARRAY,PRIEN,TYPE)
 Q
GETP(ARRAY,PRIEN,TYPE) ;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)
 .S STATUS=$P($G(^AUPNCPL(CPIEN,11,SIEN,0)),U,1)
 .Q:STATUS'="A"
 .S INVDT=9999999-$P($G(^AUPNCPL(CPIEN,0)),U,5)
 .S DATA=$$DATA(CPIEN,SIEN)
 .Q:DATA=""
 .S VCNT=VCNT+1
 .S ARRAY($P(INVDT,".",1),VCNT)=INVDT_U_PRIEN_U_DATA
 Q
 ;
DATA(CPIEN,SIEN) ;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:STAT'="A"
 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
 ;
TEXT(CPIEN) ;do the text
 N TXTIEN
 S TXTIEN=0 F  S TXTIEN=$O(^AUPNCPL(CPIEN,12,TXTIEN)) Q:'+TXTIEN  D
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)="   "_$G(^AUPNCPL(CPIEN,12,TXTIEN,0))
 S CNT=CNT+1
 S @TARGET@(CNT,0)=""
 Q
CPPR(DFN,TARGET,TYPE) ;Active Care plans by problem
 N ARRAY,INVDT,VCNT,CNT,STAT,NARR,X,Y,SIGN,SIGNDT
 K @TARGET
 S CNT=0,ARRAY=""
 D GETPROB2(.ARRAY,DFN,TYPE)
 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 CNT=CNT+1
 .;S @TARGET@(CNT,0)=""
 .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 CNT=CNT+1
 ...S @TARGET@(CNT,0)=" - Date: "_EDATE
 ...;S CNT=CNT+1
 ...;S @TARGET@(CNT,0)=" - Signed: "_$P(ARRAY(X,Y),U,4)_" on "_$P(ARRAY(X,Y),U,6)
 ...S CNT=CNT+1
 ...S @TARGET@(CNT,0)=" - TEXT"
 ...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) ;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)
 Q
GETPL(ARRAY,PRIEN,TYPE) ;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)
 .S STATUS=$P($G(^AUPNCPL(CPIEN,11,SIEN,0)),U,1)
 .Q:STATUS'="A"
 .S INVDT=9999999-$P($G(^AUPNCPL(CPIEN,0)),U,5)
 .S DATA=$$DATA(CPIEN,SIEN)
 .Q:DATA=""
 .S VCNT=VCNT+1
 .S ARRAY(PRIEN,INVDT,VCNT)=PRIEN_U_INVDT_U_DATA
 Q