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

APCHS70.m

Go to the documentation of this file.
APCHS70 ; IHS/CMI/LAB - HEALTH SUMMARY COMPONENT FOR ALLERGY FILE (PATIENT ALLERGY) ;
 ;;2.0;IHS PCC SUITE;**2,5,6**;MAY 14, 2009;Build 11
 ;;
EN ;START HERE 
 S APCHDFN=APCHSPAT
 K APCHNKAI
 Q:'APCHDFN
 ;S X="GMTSALGB" X ^%ZOSF("TEST") I $T D ^APCHGMTS Q
 X APCHSCKP G:$D(APCHSQIT) END I 'APCHSNPG W ! X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 I '$D(^GMR(120.8,"B",APCHDFN)) D  K APCHDFN G REV
 .I $D(^GMR(120.86,APCHDFN,0)),$P(^GMR(120.86,APCHDFN,0),U,2)=0 D  Q
 ..W !,$$CJ^XLFSTR("NO KNOWN ALLERGIES/ADVERSE DRUG REACTIONS noted on "_$$FMTE^XLFDT($P($P(^GMR(120.86,APCHDFN,0),U,4),".",1)),80),! Q
 .W !,$$CJ^XLFSTR("NO ALLERGY INFORMATION RECORDED",80),! ;IHS/OKCAO/POC 4/27/2001
 I $O(^GMR(120.8,"ANKA",APCHDFN,""))="n" D
 .S APCHNKAI=$O(^GMR(120.8,"ANKA",APCHDFN,"n",""))
 .I APCHNKAI S APCHNKAD=$P(^GMR(120.8,APCHNKAI,0),U,4)
 .W !,$$CJ^XLFSTR("NO KNOWN ALLERGIES/ADVERSE DRUG REACTIONS "_$S(APCHNKAD:"noted on "_$$FMTE^XLFDT($P(APCHNKAD,".",1)),2:""),80),!
 I $G(APCHNKAI) D REV,END Q  ;IHS/OKCAO/POC 5/2/2001
 S APCHALG="" F  S APCHALG=$O(^GMR(120.8,"B",APCHDFN,APCHALG)) Q:(APCHALG="")!($D(APCHSQIT))  D
 .S APCHVER=0 ;ALWAYS START THIS WAY 5/25/2001
 .Q:$$TEST(APCHALG)
 .Q:$$INACTIVE^APCHS79(APCHALG)  ;no inactive allergies
 .S APCHPEC=$G(^GMR(120.8,APCHALG,0))
 .Q:'APCHPEC
 .Q:$P(APCHPEC,U,22)]""  ;DONT WANT IN EITHER CASE-N SHOULD ALREADY BE TAKEN CARE OF IN XREF AND NOT GET HERE AND IF Y NEED TO LOOK ELSEWHERE IHS/OKCAO/POC 5/25/2001
 .S APCHMEC=$P(APCHPEC,U,14) S:APCHMEC="" APCHMEC="A" S:APCHMEC="U" APCHMEC="A" ;IHS/OKCAO/POC 5/25/2001
 .S:$P(APCHPEC,U,16)=1 APCHVER=1 ;IHS/OKCAO/POC 5/25/2001
 .S APCHDRUG=$P(APCHPEC,U,2)
 .S:APCHDRUG']"" APCHDRUG="**NO DRUG ENTERED**" ;IHS/OKCAO/POC 5/2/2001
 .;S $P(APCHSPCE," ",24)=" " S APCHDRUG=$E(APCHDRUG_APCHSPCE,1,24) ;IHS/OKCAO/POC 5/25/2001 ;CMI 15 TO 20
 .S APCHDATE=$P($P(APCHPEC,U,4),".",1)
 .Q:APCHDATE=""
 .K APCHDATA
 .S APCHREC="0" F  S APCHREC=$O(^GMR(120.8,APCHALG,10,APCHREC)) Q:APCHREC'=+APCHREC  D
 ..S APCHRNUM=+^GMR(120.8,APCHALG,10,APCHREC,0)
 ..S APCHDATA(APCHRNUM)=$P(^GMRD(120.83,APCHRNUM,0),U,1)
 ..S:APCHDATA(APCHRNUM)="OTHER REACTION" APCHDATA(APCHRNUM)=$P(^GMR(120.8,APCHALG,10,APCHREC,0),U,2)
 .S APCHNN=0
 .S (APCHCNT,APCHDATA)="" F  S APCHCNT=$O(APCHDATA(APCHCNT)) Q:APCHCNT=""  D
 ..S APCHNN=APCHNN+1
 ..S:APCHNN>1 APCHDATA=APCHDATA_", "
 ..S APCHDATA=APCHDATA_APCHDATA(APCHCNT)
 .S APCHENT(APCHMEC,APCHDATE,APCHALG)=APCHDRUG_$S(APCHVER=0:" (un",1:" (")_"verified) - "_APCHDATA ;IHS/OKCOA/POC 5/25/2001
 ;NOW FOR THE WRITING
 S APCHPREV=""
 S APCHMEC="" F  S APCHMEC=$O(APCHENT(APCHMEC)) Q:(APCHMEC="")!($D(APCHSQIT))  D
 .S APCHDATE="" F  S APCHDATE=$O(APCHENT(APCHMEC,APCHDATE)) Q:(APCHDATE="")!($D(APCHSQIT))  D
 ..S APCHALG="" F  S APCHALG=$O(APCHENT(APCHMEC,APCHDATE,APCHALG)) Q:(APCHALG="")!($D(APCHSQIT))  D
 ...Q:$G(APCHENT(APCHMEC,APCHDATE,APCHALG))']""
 ...I APCHPREV=""!(APCHPREV'=APCHMEC) W $S(APCHMEC="A":"Allergies:",APCHMEC="P":"Adverse Reactions:",1:"Unspecified:")
 ...S APCHT=$S(APCHMEC="A":11,APCHMEC="P":19,1:13)
 ...S APCHPREV=APCHMEC
 ...W ?APCHT,APCHENT(APCHMEC,APCHDATE,APCHALG),!
 ...X APCHSCKP Q:$D(APCHSQIT)
 ...;I 'APCHSNPG W ! X APCHSCKP Q:$D(APCHSQIT)
REV ;get date last reviewed and display
 S APCHSX=$$LASTALR^APCLAPI6(APCHSPAT,,DT,"A")
 X APCHSCKP Q:$D(APCHSQIT)
 W !,"Allergy List Reviewed On: ",?36,$$FMTE^XLFDT($P(APCHSX,U,1)) W ?51,"By: ",?54,$E($S($P(APCHSX,U,3):$P($G(^VA(200,$P(APCHSX,U,3),0)),U),1:""),1,25),!
 S APCHSX=$$LASTALU^APCLAPI6(APCHSPAT,,DT,"A")
 X APCHSCKP Q:$D(APCHSQIT)
 W "Allergy List Updated On: ",?36,$$FMTE^XLFDT($P(APCHSX,U,1)) W ?51,"By: ",?54,$E($S($P(APCHSX,U,3):$P($G(^VA(200,$P(APCHSX,U,3),0)),U),1:""),1,25),!
 S APCHSX=$$LASTNAA^APCLAPI6(APCHSPAT,,DT,"A")
 X APCHSCKP Q:$D(APCHSQIT)
 ;I '$$ANYACTA^APCDAPRB(APCHSPAT) W !,"No Active Problems: ",?24,$$FMTE^XLFDT($P(APCHSX,U,1)) I $P(APCHSX,U,3) W ?39,"Documented By: ",?54,$E($P($G(^VA(200,$P(APCHSX,U,3),0)),U),1,25),!
 W "No Active Allergies Documented On: ",?36,$$FMTE^XLFDT($P(APCHSX,U,1)) W ?51,"By: ",?54,$E($S($P(APCHSX,U,3):$P($G(^VA(200,$P(APCHSX,U,3),0)),U),1:""),1,22),!
 D END
 Q
TEST(CHECKIT) ;CHECK IF VERIFED AND NOT ENTERED IN ERROR
 N CHECK
 S CHECK=0 ;CHECK=1 ENTERED IN ERROR OR NOT VERIFED
 ;S:$D(^GMR(120.8,CHECKIT,"ER")) CHECK=1
 S:$P($G(^GMR(120.8,CHECKIT,"ER")),U)=1 CHECK=1  ;CMI/GRL  *17*
 Q CHECK
 ;
END ;CLEAN UP
 K APCHWARN,APCHDATE,APCHMEC,APCHALG,APCHPREV,APCHENT
 K APCHVER,APCHSPCE
 QUIT