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

APCHS81.m

Go to the documentation of this file.
APCHS81 ; IHS/CMI/LAB - PART 2 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;
 ;;2.0;IHS PCC SUITE;**10**;MAY 14, 2009;Build 88
NT ; ******************** NARRATIVE TEXT 9000010.34 ******
 K APCHSTXA
 ; <SETUP>
 Q:'$D(^AUPNVNT("AA",APCHSPAT))
 X APCHSBRK
 ; <DISPLAY>
 X APCHSCKP Q:$D(APCHSQIT)  W !
 S APCHSTT="" F APCHSQ=0:0 S APCHSTT=$O(^AUPNVNT("AA",APCHSPAT,APCHSTT)) Q:APCHSTT=""  S APCHSND2=APCHSNDM D NTDTYP Q:$D(APCHSQIT)
 D WRITE
 ; <CLEANUP>
NTX K APCHSTT,APCHSTT2,APCHSTT3,APCHSDFN,APCHSND2,APCHSDAT,APCHSIVD,APCHSTXA,APCHWP,APCHX,APCHSNDM
 Q
NTDTYP S APCHSTT2=$S($D(^AUTTNTYP(APCHSTT,0)):$P(^(0),U,1),1:APCHSTT) S APCHSTT3=APCHSTT2
 S (APCHSIVD,APCHSDFN)="" F  S APCHSIVD=$O(^AUPNVNT("AA",APCHSPAT,APCHSTT,APCHSIVD)) Q:APCHSIVD=""!(APCHSIVD>APCHSDLM)  S APCHSND2=APCHSND2-1 Q:APCHSND2=-1  D NTDSP
 Q
NTDSP ;
 S APCHSDFN=0 F  S APCHSDFN=$O(^AUPNVNT("AA",APCHSPAT,APCHSTT,APCHSIVD,APCHSDFN)) Q:APCHSDFN'=+APCHSDFN!($D(APCHSQIT))  S Y=-APCHSIVD\1+9999999 D
 .S APCHSTXA(APCHSIVD,APCHSTT,APCHSDFN)=""
 Q
 ;
WRITE ;write out Narrative text
 S APCHSIVD=0 F  S APCHSIVD=$O(APCHSTXA(APCHSIVD)) Q:APCHSIVD=""!($D(APCHSQIT))  D
 .S APCHSTT=0 F  S APCHSTT=$O(APCHSTXA(APCHSIVD,APCHSTT)) Q:APCHSTT=""!($D(APCHSQIT))  D
 ..S APCHSDFN=0 F  S APCHSDFN=$O(APCHSTXA(APCHSIVD,APCHSTT,APCHSDFN)) Q:APCHSDFN'=+APCHSDFN!($D(APCHSQIT))  D
 ...X APCHSCKP Q:$D(APCHSQIT)
 ...W !,$$FMTE^XLFDT(9999999-APCHSIVD),?23,$P(^AUTTNTYP(APCHSTT,0),U)
 ... K APCHWP D WP
 ...S APCHX=0 F  S APCHX=$O(APCHWP(APCHX)) Q:APCHX'=+APCHX!($D(APCHSQIT))  D
 ....X APCHSCKP Q:$D(APCHSQIT)
 ....W !?3,APCHWP(APCHX)
 ....Q
 ...Q
 ..Q
 .Q
 Q
WP ;EP - Entry point to print wp fields pass node in APCHWP
 NEW APCHG,APCHX,CNT
 K ^UTILITY($J,"W")
 S APCHX=0
 S DIWL=1,DIWR=70 F  S APCHX=$O(^AUPNVNT(APCHSDFN,11,APCHX)) Q:APCHX'=+APCHX  D
 .S X=^AUPNVNT(APCHSDFN,11,APCHX,0) D ^DIWP
 .Q
 S (Z,CNT)=0 F  S Z=$O(^UTILITY($J,"W",DIWL,Z)) Q:Z'=+Z  S CNT=CNT+1,APCHWP(CNT)=^UTILITY($J,"W",DIWL,Z,0)
 K DIWL,DIWR,DIWF,Z
 K ^UTILITY($J,"W"),APCHG,CNT,APCHX
 Q
VID ;EP
 S APCHORD=1  ;order by date
 G VII
VIP ;EP
 S APCHORD=2  ;order by problem
 G VII
VII ;
 K APCHSTXA
 ; <SETUP>
 Q:'$D(^AUPNVVI("AA",APCHSPAT))
 X APCHSBRK
 ; <DISPLAY>
 X APCHSCKP Q:$D(APCHSQIT)
 S APCHPROB=""
 F  S APCHPROB=$O(^AUPNVVI("AA",APCHSPAT,APCHPROB)) Q:APCHPROB=""  D
 .S APCHSIVD=0 F  S APCHSIVD=$O(^AUPNVVI("AA",APCHSPAT,APCHPROB,APCHSIVD)) Q:APCHSIVD=""!(APCHSIVD>APCHSDLM)  D
 ..;table them by date,problem or problem,date depending on the component
 ..S X=0 F  S X=$O(^AUPNVVI("AA",APCHSPAT,APCHPROB,APCHSIVD,X)) Q:X'=+X  D
 ...S D=$$VALI^XBDIQ1(9000010.58,X,1201),D=$P(D,".",1) I D]"" S D=9999999-D
 ...I D="" S D=APCHSIVD
 ...I APCHORD=1 S APCHSTXA("DATE",D,APCHPROB,X)=""
 ...I APCHORD=2 S APCHSTXA("PROB",APCHPROB,D,X)=""
 D WRITEVI
 ; <CLEANUP>
VIIX K APCHPROB,APCHSTXA,APCHORD,APCHSICL,APCHSTXT,APCHSNRQ
 Q
WRITEVI ;
 I APCHORD=1 D  Q
 .S APCHSIVD=0 F  S APCHSIVD=$O(APCHSTXA("DATE",APCHSIVD)) Q:APCHSIVD=""!($D(APCHSQIT))  D
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..W $$DATE^APCHSMU(9999999-$P(APCHSIVD,"."))
 ..S APCHPROB=0 F  S APCHPROB=$O(APCHSTXA("DATE",APCHSIVD,APCHPROB)) Q:APCHPROB=""!($D(APCHSQIT))  D
 ...S APCHSICL=12 D GETPROB
 ...S APCHX=0 F  S APCHX=$O(APCHSTXA("DATE",APCHSIVD,APCHPROB,APCHX)) Q:APCHX=""!($D(APCHSQIT))  D
 ....X APCHSCKP Q:$D(APCHSQIT)
 ....W ?12,"Visit Instructions Signed By: "_$$GET1^DIQ(9000010.58,APCHX,.04),!
 ...X APCHSCKP Q:$D(APCHSQIT)
 ...W !
 I APCHORD=2 D  Q
 .S APCHPROB=0 F  S APCHPROB=$O(APCHSTXA("PROB",APCHPROB)) Q:APCHPROB=""!($D(APCHSQIT))  D
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..S APCHSICL=1 D GETPROB
 ..S APCHSIVD=0 F  S APCHSIVD=$O(APCHSTXA("PROB",APCHPROB,APCHSIVD)) Q:APCHSIVD=""!($D(APCHSQIT))  D
 ...S APCHX=0 F  S APCHX=$O(APCHSTXA("PROB",APCHPROB,APCHSIVD,APCHX)) Q:APCHX=""!($D(APCHSQIT))  D
 ....X APCHSCKP Q:$D(APCHSQIT)
 ....W ?5,$$DATE^APCHSMU(9999999-$P(APCHSIVD,"."))
 ....X APCHSCKP Q:$D(APCHSQIT)
 ....W ?16,"Visit Instructions Signed By: "_$$GET1^DIQ(9000010.58,APCHX,.04),!
 ...X APCHSCKP Q:$D(APCHSQIT)
 ..W !
 Q
GETPROB ;
 S X=$$GET1^DIQ(9000011,APCHPROB,.05)
 I $P(^APCHSCTL(APCHSTYP,0),U,3) S S=$$GET1^DIQ(9000011,APCHPROB,80001) I S]"" S X=X_" [SNOMED: "_S_"]"
 S D=$$GET1^DIQ(9000011,APCHPROB,.01) I $P($G(^APCHSCTL(APCHSTYP,2)),U,1)="C" S X=X_" [DX: "_D_"]"
 S X="Problem: "_X
 S APCHSNRQ="",APCHSTXT=X D PRTTXT^APCHSUTL
 Q
WPVI ;
 K ^UTILITY($J,"W")
 S DIWL=12,DIWR=79,DIWF="|"
 D ^DIWP
 S Z=0 F  S Z=$O(^UTILITY($J,"W",DIWL,Z)) Q:Z'=+Z!($D(APCHSQIT))  D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W ?12,^UTILITY($J,"W",DIWL,Z,0),!
 K DIWL,DIWR,DIWF,Z
 K ^UTILITY($J,"W"),APCHG,CNT,APCHX
 Q
REFD ;EP
 S APCHORD=1  ;order by date
 G REFI
REFP ;EP
 S APCHORD=2  ;order by problem
 G REFI
REFI ;
 K APCHSTXA
 ; <SETUP>
 Q:'$D(^AUPNVREF("AA",APCHSPAT))
 X APCHSBRK
 ; <DISPLAY>
 X APCHSCKP Q:$D(APCHSQIT)
 S APCHPROB=""
 F  S APCHPROB=$O(^AUPNVREF("APRB",APCHSPAT,APCHPROB)) Q:APCHPROB=""  D
 .S APCHSIVD=0 F  S APCHSIVD=$O(^AUPNVREF("APRB",APCHSPAT,APCHPROB,APCHSIVD)) Q:APCHSIVD=""!(APCHSIVD>APCHSDLM)  D
 ..;table them by date,problem or problem,date depending on the component
 ..S X=0 F  S X=$O(^AUPNVREF("APRB",APCHSPAT,APCHPROB,APCHSIVD,X)) Q:X'=+X  D
 ...S D=$$VALI^XBDIQ1(9000010.59,X,1201),D=$P(D,".",1) I D]"" S D=9999999-D
 ...I D="" S D=$P(APCHSIVD,".")
 ...I APCHORD=1 S APCHSTXA("DATE",D,APCHPROB,X)=""
 ...I APCHORD=2 S APCHSTXA("PROB",APCHPROB,D,X)=""
 D WRITEREF
 ; <CLEANUP>
REFX K APCHPROB,APCHSTXA,APCHORD,APCHSICL,APCHSTXT,APCHSNRQ
 Q
WRITEREF ;
 I APCHORD=1 D  Q
 .S APCHSIVD=0 F  S APCHSIVD=$O(APCHSTXA("DATE",APCHSIVD)) Q:APCHSIVD=""!($D(APCHSQIT))  D
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..W $$DATE^APCHSMU(9999999-$P(APCHSIVD,"."))
 ..S APCHPROB=0 F  S APCHPROB=$O(APCHSTXA("DATE",APCHSIVD,APCHPROB)) Q:APCHPROB=""!($D(APCHSQIT))  D
 ...S APCHSICL=12 D GETPROB
 ...S APCHX=0 F  S APCHX=$O(APCHSTXA("DATE",APCHSIVD,APCHPROB,APCHX)) Q:APCHX=""!($D(APCHSQIT))  D
 ....X APCHSCKP Q:$D(APCHSQIT)
 ....W ?12,"Referral: ",$$CONCPT^AUPNVUTL($$GET1^DIQ(9000010.59,APCHX,.01))," ["_$$GET1^DIQ(9000010.59,APCHX,.01)_"]",!
 ....W ?12,"Ordered by: ",$$GET1^DIQ(9000010.59,APCHX,1202)
 ....S X=$$GET1^DIQ(9000010.59,APCHX,.05) I X W "   ====> Discontinued"
 ....W !
 ...X APCHSCKP Q:$D(APCHSQIT)
 ...W !
 I APCHORD=2 D  Q
 .S APCHPROB=0 F  S APCHPROB=$O(APCHSTXA("PROB",APCHPROB)) Q:APCHPROB=""!($D(APCHSQIT))  D
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..S APCHSICL=1 D GETPROB
 ..S APCHSIVD=0 F  S APCHSIVD=$O(APCHSTXA("PROB",APCHPROB,APCHSIVD)) Q:APCHSIVD=""!($D(APCHSQIT))  D
 ...S APCHX=0 F  S APCHX=$O(APCHSTXA("PROB",APCHPROB,APCHSIVD,APCHX)) Q:APCHX=""!($D(APCHSQIT))  D
 ....S X=$$DATE^APCHSMU(9999999-$P(APCHSIVD,"."))_" Referral: "_$$CONCPT^AUPNVUTL($$GET1^DIQ(9000010.59,APCHX,.01))_" ["_$$GET1^DIQ(9000010.59,APCHX,.01)_"]"
 ....S APCHSNRQ="",APCHSTXT=X,APCHSICL=5 D PRTTXT^APCHSUTL
 ....X APCHSCKP Q:$D(APCHSQIT)
 ....W ?5,"Ordered by: ",$$GET1^DIQ(9000010.59,APCHX,1202)
 ....S X=$$GET1^DIQ(9000010.59,APCHX,.05) I X W "   ====> Discontinued"
 ....W !
 ...X APCHSCKP Q:$D(APCHSQIT)
 ...W !
 Q
TXRD ;EP
 S APCHORD=1  ;order by date
 G TXRI
TXRP ;EP
 S APCHORD=2  ;order by problem
 G TXRI
TXRI ;
 K APCHSTXA
 ; <SETUP>
 Q:'$D(^AUPNVTXR("AA",APCHSPAT))
 X APCHSBRK
 ; <DISPLAY>
 X APCHSCKP Q:$D(APCHSQIT)
 S APCHPROB=""
 F  S APCHPROB=$O(^AUPNVTXR("APRB",APCHSPAT,APCHPROB)) Q:APCHPROB=""  D
 .S APCHSIVD=0 F  S APCHSIVD=$O(^AUPNVTXR("APRB",APCHSPAT,APCHPROB,APCHSIVD)) Q:APCHSIVD=""!(APCHSIVD>APCHSDLM)  D
 ..;table them by date,problem or problem,date depending on the component
 ..S X=0 F  S X=$O(^AUPNVTXR("APRB",APCHSPAT,APCHPROB,APCHSIVD,X)) Q:X'=+X  D
 ...S D=$$VALI^XBDIQ1(9000010.61,X,1201),D=$P(D,".",1) I D]"" S D=9999999-D
 ...I D="" S D=$P(APCHSIVD,".")
 ...I APCHORD=1 S APCHSTXA("DATE",D,APCHPROB,X)=""
 ...I APCHORD=2 S APCHSTXA("PROB",APCHPROB,D,X)=""
 D WRITETXR
 ; <CLEANUP>
TXRX K APCHPROB,APCHSTXA,APCHORD,APCHSICL,APCHSTXT,APCHSNRQ
 Q
WRITETXR ;
 I APCHORD=1 D  Q
 .S APCHSIVD=0 F  S APCHSIVD=$O(APCHSTXA("DATE",APCHSIVD)) Q:APCHSIVD=""!($D(APCHSQIT))  D
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..W $$DATE^APCHSMU(9999999-$P(APCHSIVD,"."))
 ..S APCHPROB=0 F  S APCHPROB=$O(APCHSTXA("DATE",APCHSIVD,APCHPROB)) Q:APCHPROB=""!($D(APCHSQIT))  D
 ...S APCHSICL=12 D GETPROB
 ...S APCHX=0 F  S APCHX=$O(APCHSTXA("DATE",APCHSIVD,APCHPROB,APCHX)) Q:APCHX=""!($D(APCHSQIT))  D
 ....X APCHSCKP Q:$D(APCHSQIT)
 ....W ?12,"Treatment/Regimen: ",$$CONCPT^AUPNVUTL($$GET1^DIQ(9000010.61,APCHX,.01))," ["_$$GET1^DIQ(9000010.61,APCHX,.01)_"]",!
 ....W ?12,"Ordered by: ",$$GET1^DIQ(9000010.61,APCHX,1202)
 ....S X=$$GET1^DIQ(9000010.61,APCHX,.05) I X W "   ====> Discontinued"
 ....W !
 ...X APCHSCKP Q:$D(APCHSQIT)
 ...W !
 I APCHORD=2 D  Q
 .S APCHPROB=0 F  S APCHPROB=$O(APCHSTXA("PROB",APCHPROB)) Q:APCHPROB=""!($D(APCHSQIT))  D
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..S APCHSICL=1 D GETPROB
 ..S APCHSIVD=0 F  S APCHSIVD=$O(APCHSTXA("PROB",APCHPROB,APCHSIVD)) Q:APCHSIVD=""!($D(APCHSQIT))  D
 ...S APCHX=0 F  S APCHX=$O(APCHSTXA("PROB",APCHPROB,APCHSIVD,APCHX)) Q:APCHX=""!($D(APCHSQIT))  D
 ....S X=$$DATE^APCHSMU(9999999-$P(APCHSIVD,"."))_" Treatment/Regimen: "_$$CONCPT^AUPNVUTL($$GET1^DIQ(9000010.61,APCHX,.01))_" ["_$$GET1^DIQ(9000010.61,APCHX,.01)_"]"
 ....S APCHSNRQ="",APCHSTXT=X,APCHSICL=5 D PRTTXT^APCHSUTL
 ....X APCHSCKP Q:$D(APCHSQIT)
 ....W ?5,"Ordered by: ",$$GET1^DIQ(9000010.61,APCHX,1202)
 ....S X=$$GET1^DIQ(9000010.61,APCHX,.05) I X W "   ====> Discontinued"
 ....W !
 ...X APCHSCKP Q:$D(APCHSQIT)
 ...W !
 Q