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

APCHS0.m

Go to the documentation of this file.
APCHS0 ; IHS/CMI/LAB - PCC HEALTH SUMMARY - MAIN DRIVER PART 2 ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;
 ; ***** CALLED ONLY FROM APCHS: OUTSIDE CALLS USE EN^APCHS
 ; ***** REQUIRES APCHSPAT,APCHSTYP,DUZ,DUZ(2)
 ; ***** $I & IO MUST BE VALID, CALLER MUST CLOSE OUTPUT DEVICE
 ; IHS/ANMC/LJF 4/30/99 added CWAD display to header line
 ;
START ;
 U IO
 K DIC
 NEW A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,V,W,X,Y,Z
 S APCHOTYP=APCHSTYP
 I $E($G(XQY0),1,2)="SD"!($E($G(XQY0),1,3)="ASD")!($E($G(XQY0),1,3)="BSD") D
 .;is site parameters indicate to do so, switch to diabetes if DM on PL
 .Q:$P($G(^APCHSITE(DUZ(2),0)),U,2)'=1  ;don't switch per site parameters
 .Q:$P($G(^APCHSITE(DUZ(2),0)),U,3)=""  ;no dm type defined
 .Q:'$$PLTAX^APCHSMU(APCHSPAT,"SURVEILLANCE DIABETES")
 .S APCHSTYP=$P(^APCHSITE(DUZ(2),0),U,3)
 S DFN=APCHSPAT
 S APCHSCKP="Q:$D(APCHSQIT)  S APCHSNPG=0 I $Y>(IOSL-3) "
 S APCHSBRK="D BREAK^APCHS"
 I $P(IOST,"-",1)="C" S APCHSCKP=APCHSCKP_"W ""<>"" R X:DTIME S:'$T X=U S:X[U APCHSQIT="""" I '$D(APCHSQIT) "
 S APCHSCKP=APCHSCKP_"W @IOF"_$S($P(IOST,"-",1)="C":",!",1:"")_" D HEADER^APCHS,BREAK^APCHS S APCHSNPG=1"
 X:$D(IO("S")) $S($D(^DD("OS",^DD("OS"),"XY")):"S (IOX,IOY)=0 X ^(""XY"")",1:"W @IOF")
 ;W:$P(IOST,"-",1)="C" @IOF D OUTPUT W:$P(IOST,"-",1)'="C" @IOF ;IHS/CMI/LAB - commented and added line below per G. Shorr
 W:$P(IOST,"-",1)="C"&('$D(APCHSIOF)) @IOF D OUTPUT W:$P(IOST,"-",1)'="C"&('$D(APCHSIOF)) @IOF
KILLS ;
 NEW APCHSTYP,APCHSPAT,APCHSMQ,APCHSMI
 D EN^XBVK("APCH")
 Q
OUTPUT S APCHSCVD="S:Y]"""" Y=+Y,Y=$E(Y,4,5)_""/""_$S($E(Y,6,7):$E(Y,6,7)_""/"",1:"""")_$E(Y,2,3)"
 S APCHSICF=$S('$D(^APCHSCTL(APCHSTYP,2)):"L",$P(^(2),U,1)]"":$P(^(2),U,1),1:"L")
 S APCHSPG=0
 S Y=DT X ^DD("DD") S APCHSDAT=Y D NOW^%DTC S X=% X ^DD("FUNC",2,1) S APCHSTIM=X
 ;***** CONFIDENTIAL PATIENT INFORMATION --  DATE/TIME **************
 S APCHSHDR="CONFIDENTIAL PATIENT INFORMATION -- "_$$FMTE^XLFDT(DT,5)_$J(APCHSTIM,9)_"  ["_$P(^VA(200,DUZ,0),U,2)_"]" S X="",$P(X,"*",((IOM-6-$L(APCHSHDR))\2)+1)="*" S APCHSHDR=X_" "_APCHSHDR_" "_X
 K APCHSDAT,APCHSTIM
 D HEADER
 K APCHSQIT S APCHSEGN="",APCHSQ="" F  S APCHSEGN=$O(^APCHSCTL(APCHSTYP,1,"B",APCHSEGN)) Q:APCHSEGN=""  S APCHSEGT=$O(^(APCHSEGN,"")) D SEGMNT Q:$D(APCHSQIT)
 ;*** END ** CONFIDENTIAL PATIENT INFORMATION -- DATE/TIME **********
 S APCHSHDR=$E(APCHSHDR,1,3)_" END "_$E(APCHSHDR,8,255) ;IHS/CMI/LAB
 W !,APCHSHDR,!
 S APCHSCKP=$P(APCHSCKP," I '$D(APCHSQIT)",1) ; BE VERY CAREFUL HERE !!!
 I '$D(APCHSQIT) X APCHSCKP
 ;
EXIT ;
 S:$D(ZTQUEUED) ZTREQ="@"
 Q
 ;
SEGMNT ; OUTPUT A SEGMENT TYPE
 S APCHSN=^APCHSCTL(APCHSTYP,1,APCHSEGT,0)
 S APCHSEGC=$P(APCHSN,U,2),APCHSEGH=$P(APCHSN,U,5)
 S APCHSEGP=^APCHSCMP(APCHSEGC,0)
 S APCHSEGC=$P(APCHSEGP,U,2)
 I APCHSEGH="" S APCHSVAR=$P(APCHSEGP,U,4) S:APCHSVAR]"" APCHSEGH=APCHSVAR
 I APCHSEGH="" S APCHSEGH=$P(APCHSEGP,U,1)
 S APCHSVAR=$P(APCHSEGP,U,5) I APCHSVAR]"",$D(^XUSEC(APCHSVAR,DUZ))[0 Q
 S APCHSN=^APCHSCTL(APCHSTYP,1,APCHSEGT,0) S APCHSNDM=$P(APCHSN,U,3),APCHSDLM=$P(APCHSN,U,4) S:APCHSNDM="" APCHSNDM=-1 ;S:APCHSNDM>0 APCHSNDM=APCHSNDM+1
 ;LIMIT OF TIME OR VISITS
 S APCHSDLS=""
 I APCHSDLM?1N.N!(APCHSDLM?1N.N1"D") S APCHSDLS=+APCHSDLM_" day"
 S:APCHSDLM?1N.N1"M" APCHSDLS=+APCHSDLM_" month",APCHSDLM=+APCHSDLM*30
 S:APCHSDLM?1N.N1"Y" APCHSDLS=+APCHSDLM_" year",APCHSDLM=+APCHSDLM*365
 S APCHSDLM=+APCHSDLM
 S:+APCHSDLS>1 APCHSDLS=APCHSDLS_"s"
 S APCHSEGL="" I APCHSNDM>0!(APCHSDLM>0) S APCHSEGL=" (max "_$S(APCHSNDM>0:APCHSNDM_$S(APCHSNDM=1:" visit",1:" visits")_$S(APCHSDLM>0:" or ",1:""),1:"")_$S(APCHSDLM>0:APCHSDLS,1:"")_")"
 K APCHSDLS,APCHSN
 I APCHSDLM'>0 S APCHSDLM=9999999
 E  S X1=DT,X2=-APCHSDLM D C^%DTC S APCHSDLM=9999999-X K X1,X2
 D @($P(APCHSEGC,";",1)_U_$P(APCHSEGC,";",2))
 Q
 ;
 ;******* KETCHUP,LOIS  (CMED SUMMARY)  pg. 1 ********************
 ;S APCHSPG=APCHSPG+1,APCHSHD2=$P(^DPT(APCHSPAT,0),U,1)_"  ("_$P(^APCHSCTL(APCHSTYP,0),U,1)_" SUMMARY)  pg. "_APCHSPG,APCHSP="",$P(APCHSP,"*",((IOM-6-$L(APCHSHD2))\2)+1)="*",APCHSP=APCHSP_" "_APCHSHD2_" "_APCHSP
 S APCHSPG=APCHSPG+1
 ;S APCHSHD2=$P(^DPT(APCHSPAT,0),U)_" #"_$$HRN^AUPNPAT(APCHSPAT,DUZ(2))_"  ("_$P(^APCHSCTL(APCHSTYP,0),U)_" SUMMARY)  pg "_APCHSPG
 S APCHSHD2=$P(^DPT(APCHSPAT,0),U)_" #"_$$HRN^AUPNPAT(APCHSPAT,DUZ(2))_" "_$$CWAD^AUPNLKID(APCHSPAT)_"("_$P(^APCHSCTL(APCHSTYP,0),U)_" SUMMARY)  pg "_APCHSPG  ;IHS/ANMC/LJF 4/30/99
 S APCHSP="",$P(APCHSP,"*",((IOM-6-$L(APCHSHD2))\2)+1)="*",APCHSP=APCHSP_" "_APCHSHD2_" "_APCHSP
 W !,APCHSHDR,!,APCHSP,!
 Q
 ;
BREAK ;ENTRY POINT
 ;APCHSEGH IS THE COMPONENT TYPE FROM ^APCHSCMP, FROM SEGMNT ABOVE
 ;------- MEDICATIONS --------------------
 S APCHSP="",$P(APCHSP,"-",IOM-3-$L(APCHSEGH_APCHSEGL)/2)="",APCHSP=APCHSP_" "_APCHSEGH_APCHSEGL_" "_APCHSP
 I $Y'>(IOSL-5) W !,APCHSP,!! Q
 W !! X APCHSCKP
 Q