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

BGP1UTL2.m

Go to the documentation of this file.
  1. BGP1UTL2 ; IHS/CMI/LAB - NO DESCRIPTION PROVIDED 30 Jun 2011 9:01 AM ;
  1. ;;11.1;IHS CLINICAL REPORTING SYSTEM;;JUN 27, 2011;Build 33
  1. ;
  1. ;
  1. GETDIR() ;EP - get default directory
  1. NEW D
  1. S D=""
  1. S D=$P($G(^BGPSITE(DUZ(2),0)),U,14)
  1. I D]"" Q D
  1. S D=$P($G(^AUTTSITE(1,1)),"^",2)
  1. I D]"" Q D
  1. S D=$P($G(^XTV(8989.3,1,"DEV")),"^",1)
  1. I D]"" Q D
  1. I $P(^AUTTSITE(1,0),U,21)=1 S D="/usr/spool/uucppublic/"
  1. Q D
  1. GETDEDIR() ;EP - get default directory
  1. NEW D
  1. S D=""
  1. S D=$P($G(^AUTTSITE(1,1)),"^",2)
  1. I D]"" Q D
  1. S D=$P($G(^XTV(8989.3,1,"DEV")),"^",1)
  1. I D]"" Q D
  1. I $P(^AUTTSITE(1,0),U,21)=1 S D="/usr/spool/uucppublic/"
  1. Q D
  1. GETMEDS(P,BGPMBD,BGPMED,TAXM,TAXN,TAXC,BGPDNAME,BGPZ) ;EP
  1. S TAXM=$G(TAXM)
  1. S TAXN=$G(TAXN)
  1. S TAXC=$G(TAXC)
  1. K ^TMP($J,"MEDS"),BGPZ
  1. S BGPDNAME=$G(BGPDNAME)
  1. NEW BGPC1,BGPINED,BGPINBD,BGPMIEN,BGPD,X,Y,T,T1,D,G
  1. S BGPC1=0 K BGPZ
  1. S BGPINED=(9999999-BGPMED)-1,BGPINBD=(9999999-BGPMBD)
  1. F S BGPINED=$O(^AUPNVMED("AA",P,BGPINED)) Q:BGPINED=""!(BGPINED>BGPINBD) D
  1. .S BGPMIEN=0 F S BGPMIEN=$O(^AUPNVMED("AA",P,BGPINED,BGPMIEN)) Q:BGPMIEN'=+BGPMIEN D
  1. ..Q:'$D(^AUPNVMED(BGPMIEN,0))
  1. ..S BGPD=$P(^AUPNVMED(BGPMIEN,0),U)
  1. ..Q:BGPD=""
  1. ..Q:'$D(^PSDRUG(BGPD,0))
  1. ..S BGPC1=BGPC1+1
  1. ..S ^TMP($J,"MEDS","ORDER",(9999999-BGPINED),BGPC1)=(9999999-BGPINED)_U_$P(^PSDRUG(BGPD,0),U)_U_$P(^PSDRUG(BGPD,0),U)_U_BGPMIEN_U_$P(^AUPNVMED(BGPMIEN,0),U,3)
  1. ;reorder
  1. S BGPC1=0,X=0
  1. F S X=$O(^TMP($J,"MEDS","ORDER",X)) Q:X'=+X D
  1. .S Y=0 F S Y=$O(^TMP($J,"MEDS","ORDER",X,Y)) Q:Y'=+Y D
  1. ..S BGPC1=BGPC1+1
  1. ..S ^TMP($J,"MEDS",BGPC1)=^TMP($J,"MEDS","ORDER",X,Y)
  1. K ^TMP($J,"MEDS","ORDER")
  1. S T="" I TAXM]"" S T=$O(^ATXAX("B",TAXM,0)) I T="" W BGPBOMB
  1. S T1="" I TAXN]"" S T1=$O(^ATXAX("B",TAXN,0)) I T1="" W BGPBOMB
  1. S T2="" I TAXC]"" S T2=$O(^ATXAX("B",TAXC,0))
  1. S BGPC1=0,X=0 F S X=$O(^TMP($J,"MEDS",X)) Q:X'=+X S Y=+$P(^TMP($J,"MEDS",X),U,4) D
  1. .Q:'$D(^AUPNVMED(Y,0))
  1. .S G=0
  1. .S D=$P(^AUPNVMED(Y,0),U)
  1. .S C=$P($G(^PSDRUG(D,0)),U,2)
  1. .I C]"",T2,$D(^ATXAX(T2,21,"B",C)) S G=1
  1. .S C=$P($G(^PSDRUG(D,2)),U,4)
  1. .I C]"",T1,$D(^ATXAX(T1,21,"B",C)) S G=1
  1. .I T,$D(^ATXAX(T,21,"B",D)) S G=1
  1. .I BGPDNAME]"",$P(^PSDRUG(D,0),U)[BGPDNAME S G=1
  1. .I TAXM="",TAXN="",TAXC="" S G=1 ;WANTS ALL MEDS
  1. .I G=1 S BGPC1=BGPC1+1,BGPZ(BGPC1)=^TMP($J,"MEDS",X)
  1. .Q
  1. K ^TMP($J,"MEDS")
  1. K BGPINED,BGPINBD,BGPMBD,BGPMED,BGPD,BGPC1,BGPDNAME
  1. Q
  1. RCIS(P,BDATE,EDATE,ICDC,CPTC) ;EP
  1. I '$G(P) Q ""
  1. I $G(BDATE)="" S BDATE=$$DOB^AUPNPAT(P)
  1. I $G(EDATE)="" S EDATE=DT
  1. S ICDC=$G(ICDC)
  1. S CPTC=$G(CPTC)
  1. ;find a referral in date range BDATE to EDATE
  1. NEW ICDCAT,CPTCAT,X,Y,D,A,B,G
  1. F X=1:1 S Y=$P(ICDC,";",X) Q:Y="" S Y=$O(^BMCTDXC("B",Y,0)) I Y S ICDCAT(Y)=""
  1. F X=1:1 S Y=$P(CPTC,";",X) Q:Y="" S Y=$O(^BMCTSVC("B",Y,0)) I Y S CPTCAT(Y)=""
  1. S X=0,G="" F S X=$O(^BMCREF("D",P,X)) Q:X'=+X!(G) D
  1. .Q:'$D(^BMCREF(X,0)) ;bad xref
  1. .S D=$P(^BMCREF(X,0),U,1),D=$P(D,".")
  1. .Q:D<BDATE ;before date range
  1. .Q:D>EDATE ;after end date
  1. .S Y=$P(^BMCREF(X,0),U,12)
  1. .I $D(ICDCAT),Y="" Q ;want certain categories and this one blank
  1. .I $D(ICDCAT),'$D(ICDCAT(Y)) Q ;want certain categories and this one doesn't match
  1. .S Y=$P(^BMCREF(X,0),U,13)
  1. .I $D(CPTCAT),Y="" Q ;want certain categories and this one blank
  1. .I $D(CPTCAT),'$D(CPTCAT(Y)) Q ;want certain categories and this one doesn't match
  1. .S G=X
  1. I 'G Q ""
  1. S X="" F Y=.07,.08,.09 S A=$$VAL^XBDIQ1(90001,G,Y) I A]"" S:X]"" X=X_"; "
  1. Q 1_"^"_$P($P(^BMCREF(G,0),U),".")_"^"_$$DATE^BGP1UTL($P($P(^BMCREF(G,0),U),"."))_"^"_"RCIS referral"_"^"_X_"^"_"90001"_"^"_G
  1. ;
  1. CHKDST() ;EP - check the demo patient search template to see if it is complete
  1. ;return a 1 if template is okay
  1. ;return a 0^message if it isn't
  1. ;if it isn't the caller should ask the user if they want to continue
  1. NEW X
  1. S X=$O(^DIBT("B","RPMS DEMO PATIENT NAMES",0))
  1. I 'X Q "0^RPMS DEMO PATIENT NAMES Search Template does not exist"
  1. I '$O(^DIBT(X,1,0)) Q "0^RPMS DEMO PATIENT NAMES Search Template has no entries"
  1. Q 1
  1. DSTCONT() ;EP - called to ask user if they want to continue
  1. NEW DIR,X,Y,DIRUT
  1. W !!,"Your ",$P(BGPDPST,U,2),".",!,"If you have 'DEMO' patients whose names begin with something"
  1. W !,"other than 'DEMO,PATIENT' they will not be excluded from this report"
  1. W !,"unless you update this template.",!
  1. S DIR(0)="Y",DIR("A")="Do you wish to continue to generate this report",DIR("B")="Y" KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) Q 0
  1. I 'Y Q 0
  1. Q 1
  1. DEMOCHK() ;EP - called to check demo patient
  1. NEW BGPDPST
  1. S BGPDPST=$$CHKDST()
  1. I BGPDPST Q 1 ;no action, demo template is okay
  1. S BGPDPST=$$DSTCONT()
  1. Q BGPDPST
  1. ;