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

BDMFUTIL.m

Go to the documentation of this file.
BDMFUTIL ; IHS/CMI/LAB - DMS UTILITY PROGRAM ;
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**3,8**;JUN 14, 2007;Build 53
 ;UTILITY PROGRAM
 ;LOCATION FOR VARIOUS UTILITY FUNCTIONS
TAX ;EP;TAXONOMY MANAGEMENT
 F  D TAX1 Q:$D(BDMQUIT)!$D(BDMOUT)
TAXEXIT K BDMQUIT,BDMOUT
 Q
TAX1 D TAXHEAD
 S DIR(0)="SO^1:Diagnostic/Treatment Taxonomies;2:Lab Taxonomies"
 S DIR("A")="Which one"
 D DIR^BDMFDIC
 I Y<1 S BDMQUIT="" Q
 I Y=1 D TAXRX Q
 I Y=2 D TAXLAB Q
 Q
TAXRX ;PROCESS DX/TX TAXONOMIES
 S DIR(0)="SO^1:Diagnosis;2:ADA Code;3:Medication;4:Procedure (Medical);5:Patient Education Topic;6:Health Factors;7:Problem List Diagnosis"
 S DIR("A")="Which one"
 D DIR^BDMFDIC
 I Y<1 K BDMQUIT Q
 I Y=1 S BDMX="DIAGNOSIS"
 I Y=2 S BDMX="ADA CODE"
 I Y=3 S BDMX="RX"
 I Y=4 S BDMX="PROCEDURE (MEDICAL)"
 I Y=5 S BDMX="PATIENT ED TOPIC"
 I Y=6 S BDMX="HEALTH FACTORS"
 I Y=7 S BDMX="PROBLEM LIST DIAGNOSIS"
 S X=$O(^AMQQ(5,"B",BDMX,""))
 I 'X D  Q
 .W !!,"A taxonomy can not be created for this attribute.  Ask your"
 .W !,"system manager to add ",BDMX," as an attribute then try again."
 S AMQQATNM=Y(0)
 S AMQQATN=X
 S AMQQLINK=$P(^AMQQ(5,X,0),U,5)
 Q
TAXLAB ;PROCESS LAB TAXONOMIES
 Q
TAXHEAD ;PRINT HEADER FOR TAXONOMY MANAGEMENT
 W @IOF
 N X
 F X="DIABETES MANAGEMENT SYSTEM","TAXONOMY MANAGEMENT" D
 .W !?(80-$L(X))\2,X
 Q
SORT ;EP;FOR AUTO ADD OF NEW CMS SORT CRITERIA
 S X="PRIMARY PROVIDER"
 Q:$O(^ACM(48.5,"B",X,0))
 S DIC="^ACM(48.5,"
 S DIC(0)="L"
 S DIC("DR")="1////P;4////ACM(41,;7////VA(200,"
 D FILE^BDMFDIC
 Q:+Y<1
 S BDMDA=+Y
 S ^ACM(48.5,BDMDA,1)="S ACMVAL=$P($G(^ACM(41,ACMRGDFN,""DT"")),U,15) Q:'ACMVAL  S ACMVAL=$P($G(^VA(200,ACMVAL,0)),U)"
 S ^ACM(48.5,BDMDA,3)="PRIMARY PROVIDER"
 S $P(^ACM(48.5,BDMDA,2,0),U,2)="9002248.51P"
 F BDMX="RECALL DATES","MASTER LIST","CASE REVIEW DATE","REGISTER DATA","MULTIPLE SUMMARIES","PCC HS MULTIPLE","RECALL LETTERS" D
 .S X="ACM "_BDMX
 .S DIC("DR")="1////"_X
 .S X=$O(^DIPT("B",X,0))
 .Q:'X
 .S (DA,DA(1))=BDMDA
 .S DIC="^ACM(48.5,"_DA_",2,"
 .S DIC(0)="L"
 .D FILE^BDMFDIC
 Q
IDDM ;EP;TO SYNCHRONIZE DIABETES DIAGNOSES
 N BDM,DR
 S BDMX=""
 F  S BDMX=$O(^ACM(44.1,BDMX)) Q:BDMX=""  D:BDMX["IDDM"
 .S BDM=0
 .F  S BDM=$O(^ACM(44.1,"G",BDMX,BDM)) Q:'BDM  D
 ..K DR
 ..I $P($G(^ACM(44.1,BDM)),U)="IDDM" S DR=".01///TYPE 1"
 ..I $P($G(^ACM(44.1,BDM)),U)="NIDDM" S DR=".01///TYPE 2"
 ..Q:$G(DR)=""
 ..S DA=BDM
 ..S DIE="^ACM(44.1,"
 ..D DIE^BDMFDIC
 Q:'BDMRDA
 F BDMX="TYPE 1","TYPE 2","IMPAIRED GLUCOSE TOLERANCE","GESTATIONAL DM" D
 .S BDMDA=0
 .F  S BDMDA=$O(^ACM(44.1,"B",BDMX,BDMDA)) Q:'BDMDA  D
 ..Q:$D(^ACM(44.1,BDMDA,"RG","B",BDMRDA))
 ..S X=BDMRDA
 ..S (DA,DA(1))=BDMDA
 ..S DIC="^ACM(44.1,"_BDMDA_",""RG"","
 ..S DIC(0)="L"
 ..S $P(^ACM(44.1,BDMDA,"RG",0),U,2)="9002244.11P"
 ..D FILE^BDMFDIC
 Q
SWITCH ;EP;TO SWITCH REGISTERS
 K BDMRDA,BDM("REGISTER")
 D REG
 I $D(BDMONE) D
 .W !!,"If there are other DIABETES registers you need access to,"
 .W !,"contact your DIABETES system manager for assistance.",!!
 .H 5
 .K BDMONE
 Q
REG ;EP;TO SET REGISTER DATA     
 K BDMQUIT
 I $G(BDMRDA)&($G(BDMREGNM)["") Q
 D REGLIST
 Q:$D(BDMQUIT)
 I $D(BDMNOREG) D NEWREG K BDMNOREG G REG
 Q:$D(BDMQUIT)
 D DECEASED^ACMGTP(BDMRDA)
 D REGVARS
 D MM^BDMFMENU
 Q
REGVARS ;SET REGISTER VARIABLES
 S BDMREGNM=$P(^ACM(41.1,BDMRDA,0),U)
 D NEWHS
 D IDDM
 D NEWDIAG
 D NEWCOMP
 Q
NEWREG ;CREATE IHS DIABETES REGISTER
 S X="IHS DIABETES REGISTER"
 I $D(^ACM(41.1,"B",X)) S BDMRDA=$O(^(X,0)) Q:BDMRDA
 S DIC="^ACM(41.1,"
 S DIC(0)="L"
 D FILE^BDMFDIC
 S BDMRDA=+Y
 Q
NEWDIAG ;ESTABLISH IHS DIABETES REGISTER DIAGNOSES
 F BDMX="TYPE 1","TYPE 2","GESTATIONAL DM","IMPAIRED GLUCOSE TOLERANCE" D
 .S BDMY=$O(^ACM(44.1,"B",BDMX,0))
 .I BDMY,$D(^ACM(44.1,BDMY,"RG","B",BDMRDA)) Q
 .S X=BDMX
 .S DIC="^ACM(44.1,"
 .S DIC(0)="L"
 .D FILE^BDMFDIC
 .S X=BDMRDA
 .S DA=+Y
 .S DA(1)=+Y
 .S $P(^ACM(44.1,BDMY,"RG",0),U,2)="9002244.11P"
 .S DIC="^ACM(44.1,"_DA_",""RG"","
 .S DIC(0)="L"
 .D FILE^BDMFDIC
 Q
NEWCOMP ;ESTABLISH IHS DIABETES REGISTER COMPLICATIONS
 S:'$G(BDMRDA) BDMRDA=$O(^ACM(41.1,"B",BDMREGNM,0))
 Q:'BDMRDA
 F BDMX="CVA (STROKE)","END STAGE RENAL DISEASE","FIXED PROTEINURIA","HIGH RISK FOOT","HYPERTENSION","LASER TX FOR RETINOPATHY","MAJOR AMPUTATION(S)","MINOR AMPUTATION(S)","RETINOPATHY" D
 .S BDMY=$O(^ACM(42.1,"B",BDMX,0))
 .I BDMY,$D(^ACM(42.1,BDMY,"RG","B",BDMRDA)) Q
 .I 'BDMY D
 ..S X=BDMX
 ..S DIC="^ACM(42.1,"
 ..S DIC(0)="L"
 ..D FILE^BDMFDIC
 ..S BDMY=+Y
 .S X=BDMRDA
 .S DA(1)=BDMY
 .S $P(^ACM(42.1,BDMY,"RG",0),U,2)="9002242.11P"
 .S DIC="^ACM(42.1,"_BDMY_",""RG"","
 .S DIC(0)="L"
 .D FILE^BDMFDIC
 Q
NEWHS ;ESTABLISH NEW HEALTH SUMMARIES FOR DMS
 N BDMX,BDMDA
 F BDMX="DMS LAB REPORT","DMS DIABETES LAB REPORT","DMS DIABETIC FLOWSHEET" D
 .S BDMDA=""
 .I $D(^APCHSCTL("B",BDMX)) S BDMDA=$O(^APCHSCTL("B",BDMX,0))
 .I '$G(BDMDA) D
 ..S X=BDMX
 ..S DIC="^APCHSCTL("
 ..S DIC(0)="LZ"
 ..D FILE^BDMFDIC
 ..S BDMDA=+Y
 .Q:BDMDA<1
 .I BDMX["LAB REPORT" D LAB
 .I BDMX["FLOWSHEET" D FS
 Q
LAB S X=$O(^APCHSCMP("B","LABORATORY DATA",0))
 Q:'X
 K BDMQUIT
 S Y=0
 F  S Y=$O(^APCHSCTL(BDMDA,1,Y)) Q:'Y  D
 .I $P($G(^APCHSCTL(BDMDA,1,Y,0)),U,2)=X S BDMQUIT=""
 I $D(BDMQUIT) K BDMQUIT Q
 S $P(^APCHSCTL(BDMDA,1,0),U,2)="9001015.01IA"
 S (DA,DA(1))=BDMDA
 S DIC="^APCHSCTL("_DA_",1,"
 S DIC(0)="L"
 S DIC("DR")="1////"_X_";2////30;3////1Y"
 S X=5
 D FILE^BDMFDIC
 Q:Y<1
 D DMLAB:BDMX["DIABETES LAB"
 Q
FS S X=$O(^APCHSCMP("B","FLOWSHEETS",0))
 Q:'X
 K BDMQUIT
 S Y=0
 F  S Y=$O(^APCHSCTL(BDMDA,1,Y)) Q:'Y  D
 .I $P($G(^APCHSCTL(BDMDA,1,Y,0)),U,2)=X S BDMQUIT=""
 I $D(BDMQUIT) K BDMQUIT Q
 S $P(^APCHSCTL(BDMDA,1,0),U,2)="9001015.01IA"
 S (DA,DA(1))=BDMDA
 S DIC="^APCHSCTL("_DA_",1,"
 S DIC(0)="L"
 S DIC("DR")="1////"_X_";2////10;3////1Y"
 S X=5
 D FILE^BDMFDIC
 Q:Y<1
 S X=$O(^APCHSFLC("B","DIABETIC FLOWSHEET",0))
 Q:'X
 K BDMQUIT
 S Y=0
 F  S Y=$O(^APCHSCTL(BDMDA,6,Y)) Q:'Y  D
 .I $P($G(^APCHSCTL(BDMDA,6,Y,0)),U,2)=X S BDMQUIT=""
 I $D(BDMQUIT) K BDMQUIT Q
 S (DA,DA(1))=BDMDA
 S $P(^APCHSCTL(DA,6,0),U,2)="9001015.07IA"
 S DIC="^APCHSCTL("_DA_",6,"
 S DIC(0)="L"
 S DIC("DR")="1////"_X
 S X=5
 D FILE^BDMFDIC
 Q
DMLAB ;EP;SET DM LABS
 S BDMJ=0
 F BDMX="FASTING GTT","1/2Hr.GTT","1Hr.GTT","2Hr.GTT","3Hr.GTT","4Hr.GTT","5Hr.GTT","6Hr.GTT","FASTING GTT (URINE)","1/2Hr.GTT (URINE)","1Hr.GTT (URINE)","2Hr.GTT (URINE)","3Hr.GTT (URINE)","4Hr.GTT (URINE)","5Hr.GTT (URINE)" D D1
 F BDMX="6Hr.GTT (URINE)","GLUCOSE","GLUCOSE TOLERANCE TEST","GLUCOSE, OTHER","GLUCOSE TOLERANCE (URINE)","HEMOGLOBIN A1C","SGOT","SGPT","TRIGLYCERIDE","LDL","HDL","CHOLESTEROL","LDL CHOLESTEROL" D D1
 Q
D1 S X=$O(^LAB(60,"B",BDMX,0))
 Q:'X
 Q:$D(^APCHSCTL(BDMDA,4,"C",X))
 S BDMJ=BDMJ+1
 S BDMLAB=X
 S X=$S($O(^APCHSCTL(BDMDA,4,99999),-1):$O(^APCHSCTL(BDMDA,4,99999),-1),1:1)
 S $P(^APCHSCTL(BDMDA,4,0),U,2)="9001015.05IA"
 S (DA,DA(1))=BDMDA
 S DIC="^APCHSCTL("_DA_",4,"
 S DIC(0)="L"
 S DIC("DR")="1////"_BDMLAB
 D FILE^BDMFDIC
 Q
REGLIST ;EP;LIST DIABETES REGISTERS
 K BDMQUIT
 N J,X,Y,Z,BDM
 S BDMNOREG=""
 S J=0
 S X=""
 F  S X=$O(^ACM(41.1,"B",X)) Q:X=""  D
 .X ^%ZOSF("UPPERCASE")
 .Q:Y'["DIABET"
 .K BDMNOREG
 .S Y=0
 .F  S Y=$O(^ACM(41.1,"B",X,Y)) Q:'Y  D
 ..S BDMNOACC=1
 ..Q:'$D(^ACM(41.1,+Y,"AU","B",DUZ))
 ..K BDMNOACC
 ..S J=J+1
 ..S BDM(J)=Y_U_X
 I '$O(BDM(0)) D  Q
 .I $G(BDMNOACC) D  Q
 ..W !!,"You do not have access to the DIABETES register."
 ..W !,"Ask your Diabetes Management System coordinator for assistance."
 ..S BDMQUIT="" H 5
 .K BDMNOACC
 K BDMQUIT
 I '$O(BDM(1)) D  Q
 .S BDMRDA=+BDM(1)
 .W !!,"You have access to the ",$P(^ACM(41.1,BDMRDA,0),U)," register,"
 .S BDMONE=""
 W @IOF
 W !!?5,"Select DIABETES Register"
 W !!?5,"---",?10,"------------------------------"
 S J=0
 F  S J=$O(BDM(J)) Q:'J  D
 .W !?5,J,?10,$P(BDM(J),U,2)
 .S BDMJ=J
 S DIR(0)="NO^1:"_BDMJ
 S DIR("A")="Which REGISTER"
 W !
 D DIR^BDMFDIC
 I Y<1 S BDMQUIT="" Q
 S BDMRDA=+BDM(Y)
 Q
CHARTS ;EP;TO EXPORT CHART NUMBERS
 K ^TMP("BDMCHART",$J)
 W @IOF
 S %FN="/usr/spool/uucppublic/dmschart.dat"
 S BDMOP="W"
 D HOST^BDMFZIS
 I $D(BDMQUIT) D  Q
 .W !!,"The file ",%FN," could not be created."
 .W !,"Consult your site manager for assistance."
 .D PAUSE^BDMFMENU
 S ASUFAC=$S($L($P($G(^AUTTLOC($S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0)),U,10))=6:$P(^(0),U,10),1:"ASUFAC")
 S BDMX="ANMC DIABETES REGISTRY"
 S BDMRDA=0
 F  S BDMRDA=$O(^ACM(41.1,"B",BDMX,BDMRDA)) Q:'BDMRDA  D
 .S X=0
 .F  S X=$O(^ACM(41,"B",BDMRDA,X)) Q:'X  D
 ..Q:$E($G(^ACM(41,X,"DT")))'="A"
 ..S DFN=$P($G(^ACM(41,X,0)),U,2)
 ..S FAC=1665
 ..Q:'$D(^AUPNPAT(+DFN,41,FAC,0))  S CHART=$P(^(0),U,2)
 ..S CHART=$E("000000",1,6-$L(CHART))_CHART
 ..S ^TMP("BDMCHART",$J,ASUFAC,BDMX,CHART)=""
 ..S ^TMP("BDMCHART",$J,CHART)=""
 D C1
 D ^%ZISC
 W !!,"The file 'dmschart.dat' has been filed in the /usr/spool/uucppublic/ directory."
 D PAUSE^BDMFMENU
 K ^TMP("BDMCHART",$J)
 Q
C1 ;
 S XX="ASUFAC"
 S $E(XX,10)="REGISTER"
 S $E(XX,50)="CHART"
 S XX="CHART NO."
 S Y=DT
 X ^DD("DD")
 S $E(XX,15)="File created on: "_Y
 U IO W XX,!
 S X=""
 F  S X=$O(^TMP("BDMCHART",$J,X)) Q:X=""  D:X=""
 .S Y=""
 .F  S Y=$O(^TMP("BDMCHART",$J,X,Y)) Q:Y=""  D
 ..S Z=""
 ..F  S Z=$O(^TMP("BDMCHART",$J,X,Y,Z)) Q:Z=""  D
 ...S XX=X
 ...S $E(XX,10)=$E(Y,1,30)
 ...S $E(XX,50)=Z
 ...S XX=Z
 ...U IO W XX,!
 ...U 0 W "."
 S Z=""
 F  S Z=$O(^TMP("BDMCHART",$J,Z)) Q:Z=""  D
 .U IO W Z,!
 .U 0 W "."
 Q