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

GMPLDISP.m

Go to the documentation of this file.
GMPLDISP ; ISL/MKB,JER,TC - Problem List detailed display ;08/26/14  11:57
 ;;2.0;Problem List;**21,26,35,36,42,45**;Aug 25, 1994;Build 53
 ;
 ; External References
 ;   DBIA  3106  ^DIC(49
 ;   ICR   5699  $$ICDDATA^ICDXCODE
 ;   ICR   5747  $$CSI/SAB/CODECS^ICDEX
 ;   DBIA 10040  ^SC(  file 44
 ;   DBIA 10060  ^VA(200
 ;   DBIA 10116  $$SETSTR^VALM1
 ;   DBIA 10117  CLEAN^VALM10
 ;   DBIA 10117  CNTRL^VALM10
 ;   DBIA 10103  $$FMTE^XLFDT
 ;   DBIA 10103  $$HTFM^XLFDT
 ;   DBIA 10104  $$REPEAT^XLFSTR
 ;
EN ; Init Variables (need GMPLSEL,GMPLNO) and List Array
 G:'$D(GMPLSEL) ERROR G:'$G(GMPLNO) ERROR
 S GMPI=+$G(GMPI)+1 I GMPI>GMPLNO D  Q
 . W !!,"There are no more problems that have been selected to view!",! S VALMBCK="" H 2
 S GMPLNUM=$P(GMPLSEL,",",GMPI) G:GMPLNUM'>0 ERROR
 S GMPIFN=$P($G(^TMP("GMPLIDX",$J,+GMPLNUM)),U,2) G:GMPIFN'>0 ERROR
 W !!,"Retrieving current data for problem #"_GMPLNUM_" ...",!
 ;
PROB ; Display problem GMPIFN
 N LINE,STR,I,J,L,TEXT,NOTE,GMPLDT,GMPL0,GMPL1,GMPL800,GMPL803,X,Y,IDT,FAC,AIFN,SP,LCNT
 N NIFN,SCTC,SCTD,SCTT,PROVNAR,ICDDESC,DESCR,ICD,PNTXT,GMPLCSYS,GMICDLBL,GMPL802,GMPLNTDT,GMPLATHR,GMPLTEXT
 K ^TMP("GMPLCMT",$J)
 G:'$G(GMPIFN) ERROR D CLEAN^VALM10
 S GMPL0=$G(^AUPNPROB(GMPIFN,0)),GMPL1=$G(^(1)),GMPL800=$G(^(800)),GMPL802=$G(^(802)),GMPL803=$G(^(803,0)),LCNT=1,SP=""
 S GMPLDT=$S(+$P(GMPL802,U,1):$P(GMPL802,U,1),+$P(GMPL1,U,9):$P(GMPL1,U,9),+$P(GMPL0,U,8):$P(GMPL0,U,8),1:DT)
 S GMPLCSYS=$S($P(GMPL802,U,2)]"":$P(GMPL802,U,2),1:$$SAB^ICDEX($$CSI^ICDEX(80,+GMPL0),GMPLDT))
 F I=11,12,13,15,16,17,18 S:+$P(GMPL1,U,I) SP=SP_$S(I=11:"AGENT ORANGE",I=12:"RADIATION",I=13:"ENV CONTAMINANTS",I=15:"HEAD/NECK CANCER",I=16:"MIL SEXUAL TRAUMA",I=17:"COMBAT VET",1:"SHAD")_U
 F  Q:$E(SP,$L(SP))'="^"  S SP=$E(SP,1,($L(SP)-1))
 S ICD=$P($$ICDDATA^ICDXCODE(GMPLCSYS,+GMPL0,GMPLDT,"I"),U,2)  ;ICD=ICD-9/10-CM Code
 S GMICDLBL=$P($$CODECS^ICDEX(ICD,80,GMPLDT),U,2)
 S PROVNAR=$$PROBTEXT^GMPLX(GMPIFN)  ;PROVNAR=Provider Narrative
 S ICDDESC=$$ICDDESC^GMPLUTL2($G(ICD),GMPLDT,GMPLCSYS)  ;ICDDESC=ICD Description
 S SCTC=$P(GMPL800,U),SCTD=$P(GMPL800,U,2)  ;SCTC=SNOMED-CT Concept Code,SCTD=SNOMED-CT Designation Code
 S:(PROVNAR["SCT") PNTXT=$P(PROVNAR," (SCT")
 D WRAP^GMPLX($G(PROVNAR),65,.TEXT)
 I TEXT=1 S GMPDT(LCNT,0)="  Problem: "_TEXT(1)
 E  I TEXT>1 D
 . S GMPDT(LCNT,0)="  Problem: "_TEXT(1)
 . F I=2:1:TEXT S LCNT=LCNT+1,GMPDT(LCNT,0)=$S($L($G(SCTC))!$L($G(SCTD)):"           ",1:"               ")_TEXT(I)
 I $L($G(SCTC)) S SCTT=$P($$SCTTEXT^GMPLUTL2(SCTC,$P(GMPL0,U,8),"SCT"),U)  ;SCTT=SNOMED-CT Preferred Text
 I $L($G(SCTC))!$L($G(SCTD)) D
 . I ($L($G(SCTT))>0)&(PNTXT'=$G(SCTT)) D
 . . D WRAP^GMPLX($G(SCTT),65,.SCTTTXT) S LCNT=LCNT+1,GMPDT(LCNT,0)="SNOMED-CT: "_SCTTTXT(1)
 . . I SCTTTXT>1 F L=2:1:SCTTTXT S LCNT=LCNT+1,GMPDT(LCNT,0)="           "_SCTTTXT(L)
 . I $L($G(ICD)) S LCNT=LCNT+1,GMPDT(LCNT,0)=$S(GMPLCSYS="ICD":" ",1:"")_$G(GMICDLBL)_": "_$G(ICD)_" ["_$G(ICDDESC)_"]"
 E  D
 . D WRAP^GMPLX($G(ICDDESC),65,.DESCR) S LCNT=LCNT+1,GMPDT(LCNT,0)=$G(GMICDLBL)_" TEXT: "_DESCR(1)
 . I DESCR>1 F J=2:1:DESCR S LCNT=LCNT+1,GMPDT(LCNT,0)="               "_DESCR(J)
 I $L($G(GMPL803))>0 D
 . N DA S DA=0 F  S DA=$O(^AUPNPROB(GMPIFN,803,DA)) Q:'+DA  D
 . . N ICDN,ICDNDX,ICDNDT,ICDNCSYS S ICDN=$P($G(^AUPNPROB(GMPIFN,803,DA,0)),U),ICDNDT=$P($G(^AUPNPROB(GMPIFN,803,DA,0)),U,3)
 . . S ICDNCSYS=$S($P($G(^AUPNPROB(GMPIFN,803,DA,0)),U,2)="ICD9":"ICD",1:$P($G(^AUPNPROB(GMPIFN,803,DA,0)),U,2))
 . . S ICDNDX=$$ICDDESC^GMPLUTL2($G(ICDN),$G(ICDNDT),$G(ICDNCSYS))
 . . S LCNT=LCNT+1,GMPDT(LCNT,0)="         : "_$G(ICDN)_$$PAD^GMPLX(ICDN,6)_" ["_$G(ICDNDX)_"]"
 S LCNT=LCNT+1,GMPDT(LCNT,0)="       "
PR1 ; Onset
 ;   SC Condition
 ;   Status
 ;   Exposure
 ;   Provider
 ;   Service/Clinic
 S LINE="    Onset: "_$S($P(GMPL0,U,13):$$EXTDT^GMPLX($P(GMPL0,U,13)),1:"date unknown"),STR=""
 S:GMPVA STR="SC Condition: "_$S(+$P(GMPL1,U,10):"YES",$P(GMPL1,U,10)=0:"NO",1:"unknown")
 S LINE=$$SETSTR^VALM1(STR,LINE,49,30),LCNT=LCNT+1,GMPDT(LCNT,0)=LINE
 S X=$P(GMPL0,U,12),LINE="   Status: "_$S(X="A":"ACTIVE",1:"INACTIVE")
 I X="A",$L($P(GMPL1,U,14)) S LINE=LINE_"/"_$S($P(GMPL1,U,14)="A":"ACUTE",1:"CHRONIC")
 I X="I",$P(GMPL1,U,7) S LINE=LINE_", Resolved "_$$EXTDT^GMPLX($P(GMPL1,U,7))
 S STR="",LCNT=LCNT+1
 S:GMPVA STR="    Exposure: "_$S('$L(SP):"none",1:$P(SP,U))
 S LINE=$$SETSTR^VALM1(STR,LINE,49,30),GMPDT(LCNT,0)=LINE
 S LINE=" Provider: "_$P($G(^VA(200,+$P(GMPL1,U,5),0)),U),LCNT=LCNT+1,STR=""
 I GMPVA,$L(SP,U)>1 S STR=$P(SP,U,2)
 S LINE=$$SETSTR^VALM1(STR,LINE,63,16),GMPDT(LCNT,0)=LINE
 I $E(GMPLVIEW("VIEW"))="S" S LINE="  Service: "_$P($G(^DIC(49,+$P(GMPL1,U,6),0)),U)
 E  S LINE="   Clinic: "_$P($G(^SC(+$P(GMPL1,U,8),0)),U)
 S LCNT=LCNT+1,STR="" I GMPVA,$L(SP,U)>2 S STR=$P(SP,U,3)
 S LINE=$$SETSTR^VALM1(STR,LINE,63,16),GMPDT(LCNT,0)=LINE
 S LCNT=LCNT+1,GMPDT(LCNT,0)="       "
PR2 ; Recorded
 ;   Entered
 S LINE=" Recorded: "_$S($P(GMPL1,U,9):$$EXTDT^GMPLX($P(GMPL1,U,9)),1:"date unknown")
 S:$P(GMPL1,U,4) LINE=LINE_", by "_$P($G(^VA(200,+$P(GMPL1,U,4),0)),U)
 S LCNT=LCNT+1,GMPDT(LCNT,0)=LINE
 S LINE="  Entered: "_$$EXTDT^GMPLX($P(GMPL0,U,8))
 S LINE=LINE_", by "_$P($G(^VA(200,+$P(GMPL1,U,3),0)),U),LCNT=LCNT+1
 S:GMPARAM("VER")&($P(GMPL1,U,2)="T") LINE=LINE_"  <unconfirmed>"
 S GMPDT(LCNT,0)=LINE
 S LCNT=LCNT+1,GMPDT(LCNT,0)="       "
PR3 ; Comments
 S LCNT=LCNT+1,GMPDT(LCNT,0)="Comments:"
 D CNTRL^VALM10(LCNT,1,8,IOUON,IOUOFF)
 ;     By Facility
 F FAC=0:0 S FAC=$O(^AUPNPROB(GMPIFN,11,FAC)) Q:+FAC'>0  D
 . I 'FAC S LCNT=LCNT+1,GMPDT(LCNT,0)="   <None>" G PR4
 . F NIFN=0:0 S NIFN=$O(^AUPNPROB(GMPIFN,11,FAC,11,NIFN)) Q:+NIFN'>0  D
 . . S NOTE=$G(^AUPNPROB(GMPIFN,11,FAC,11,NIFN,0)) Q:NOTE=""
 . . S GMPLNTDT=$P(NOTE,U,5),GMPLATHR=$P(NOTE,U,6),GMPLTEXT=$P(NOTE,U,3)
 . . I $L(NOTE) S ^TMP("GMPLCMT",$J,GMPLNTDT,NIFN)=$$EXTDT^GMPLX(GMPLNTDT)_U_$P($G(^VA(200,+GMPLATHR,0)),U)_U_GMPLTEXT
 S (GMPLNTDT,NIFN)=""
 F  S GMPLNTDT=$O(^TMP("GMPLCMT",$J,GMPLNTDT),-1) Q:GMPLNTDT=""  D
 . F  S NIFN=$O(^TMP("GMPLCMT",$J,GMPLNTDT,NIFN),-1) Q:NIFN=""  D
 . . S LINE=$J($P($G(^TMP("GMPLCMT",$J,GMPLNTDT,NIFN)),U,1),10)_": "_$P($G(^TMP("GMPLCMT",$J,GMPLNTDT,NIFN)),U,3)
 . . S LCNT=LCNT+1,GMPDT(LCNT,0)=LINE
 . . I $L($G(^TMP("GMPLCMT",$J,GMPLNTDT,NIFN))) S LINE="            "_$P($G(^TMP("GMPLCMT",$J,GMPLNTDT,NIFN)),U,2),LCNT=LCNT+1,GMPDT(LCNT,0)=LINE
 S:'($G(NOTE)) LCNT=LCNT+1,GMPDT(LCNT,0)="   <None>"
 K ^TMP("GMPLCMT",$J)
PR4 ; Audit Trail
 S LCNT=LCNT+1,GMPDT(LCNT,0)="       "
 S LCNT=LCNT+1,GMPDT(LCNT,0)="History:"
 D CNTRL^VALM10(LCNT,1,7,IOUON,IOUOFF)
 I '$D(^GMPL(125.8,"B",GMPIFN)) S LCNT=LCNT+1,GMPDT(LCNT,0)="   <No changes>" G PRQ
 F IDT=0:0 S IDT=$O(^GMPL(125.8,"AD",GMPIFN,IDT)) Q:IDT'>0  D
 . F AIFN=0:0 S AIFN=$O(^GMPL(125.8,"AD",GMPIFN,IDT,AIFN)) Q:AIFN'>0  D
 . . N FLD,GMPL0 S GMPL0=^GMPL(125.8,AIFN,0),FLD=$P(GMPL0,U,2)
 . . Q:(FLD=80201)!(FLD=80202)!(FLD=80002)
 . . D DT^GMPLHIST
PRQ ; Header Node
 S VALMCNT=LCNT,GMPDT(0)=VALMCNT,VALMSG=$$MSG^GMPLX,VALMBG=1,VALMBCK="R"
 Q
 ;
HDR ; Header Code (uses GMPDFN, GMPIFN)
 N LASTMOD,PAT S PAT=$P(GMPDFN,U,2)_"  ("_$P(GMPDFN,U,3)_")"
 S LASTMOD=$S($G(GMPIFN):$P(^AUPNPROB(GMPIFN,0),U,3),1:$E($$HTFM^XLFDT($H),1,12))
 S LASTMOD="Last Updated: "_$$FMTE^XLFDT(LASTMOD)
 S VALMHDR(1)=PAT_$$REPEAT^XLFSTR(" ",(79-$L(PAT)-$L(LASTMOD)))_LASTMOD
 Q
 ;
HELP ; Help Code
 N X W !!?4,"You may view detailed information here on this problem;"
 W !?4,"more data may be available by entering 'Next Screen'."
 W !?4,"If you have selected multiple problems to view, you may"
 W !?4,"enter 'Continue to Next Selected Problem'; to return to"
 W !?4,"the patient's problem list, enter 'Quit to Problem List'."
 W !!,"Press <return> to continue ... " R X:DTIME
 S VALMSG=$$MSG^GMPLX,VALMBCK=$S(VALMCC:"",1:"R")
 Q
 ;
DEFLT() ; Default Action, using GMPI and GMPLNO
 I GMPI<GMPLNO Q "Continue to Next Selected Problem"
 Q "Quit to Problem List"
 ;
ERROR ; Error Message - drop into EXIT
 W !!,"ERROR -- Cannot continue ... Returning to Problem List.",!
 S VALMBCK="Q" H 1
EXIT ; Exit Code
 K GMPDT Q