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

RGMTUT01.m

Go to the documentation of this file.
  1. RGMTUT01 ;BIR/CML-MPI/PD Compile and Correct Data Validation Data for Local Sites ;08/12/02
  1. ;;1.0;CLINICAL INFO RESOURCE NETWORK;**20,31,41**;30 Apr 99
  1. ;
  1. ;Reference to $$UPDATE^MPIFAPI supported by IA #2706
  1. ;Reference to VAFCTFU supported by IA #2988
  1. ;Reference to ^DPT( supported by IA #2070
  1. ;Reference to ^DGCN(391.91,"APAT" supported by IA #2911
  1. ;Reference to ^%ZTSCH("TASK" supported by IA #3520
  1. ;
  1. EN1 ;Use this entry point to get only display diagnostics for development team
  1. ;BYPASS=0 means prohibit times are enforced
  1. ;SITEOPT=0 means CMOR, TF, and diagnostics are included in report
  1. ;SITEOPT=1 means diagnostics are omitted from report (this is the report for the site)
  1. ;SITEOPT=2 means only diagnostics are in report
  1. ;
  1. S BYPASS=0,SITEOPT=2 G BEGIN
  1. ;
  1. EN2 ;Use this entry point from remote query
  1. S BYPASS=1,SITEOPT=0 G BEGIN ; **41
  1. ;
  1. EN3 ;Use this entry point for site menu option [RG NATIONAL ICN STATISTICS] to omit
  1. ;diagnostic section from report
  1. S BYPASS=0,SITEOPT=1 G BEGIN
  1. ;
  1. BY ;use this call to bypass check to prohibit primetime run
  1. S BYPASS=1,SITEOPT=2
  1. ;
  1. BEGIN ;
  1. S PRT=0,QFLG=0 K RGROU
  1. I $D(^XTMP("RGMT","UT01","@@","COMPILE STARTED"))&('$D(^XTMP("RGMT","UT01","@@","COMPILE STOPPED"))) D I QFLG G QUIT
  1. .;check running tasks to see if compile is running
  1. .S TASK=0 F S TASK=$O(^%ZTSCH("TASK",TASK)) Q:'TASK D
  1. ..S RGROU=$P(^%ZTSCH("TASK",TASK),"^",2)
  1. ..I RGROU="RGMTSTAT" D
  1. ...I TASK=$G(ZTSK) Q
  1. ...S QFLG=1
  1. ...I '$D(RGHLMQ) W !!,"The Stat Report is currently being compiled."
  1. .I 'QFLG K ^XTMP("RGMT","UT01"),^XTMP("RGMT","REINDDT")
  1. ;
  1. I $D(RGHLMQ) G STARTQ
  1. W !!,"This option provides the following statistics:"
  1. W !?3,"1. Total patients assigned to each unique COORDINATING MASTER OF"
  1. W !?3," RECORD (CMOR)."
  1. W !?3,"2. Total patients shared with each unique entry in the TREATING"
  1. W !?3," FACILITY LIST (#391.91) file."
  1. W !?3,"3. Totals for national ICNs, local ICNs, and patients with no ICN."
  1. I SITEOPT=1 G START
  1. W !?3,"4. Total CMOR assignments missing a matching Treating Facility."
  1. W !?3,"5. Total patients with NATIONAL ICN and missing local Treating Facility."
  1. W !?3,"6. Total number of patients with duplicate entries in the TREATING"
  1. W !?3," FACILITY LIST file (#391.91)."
  1. W !?3,"7. Patient File xref problems for ""AICN"", ""AICNL"", and ""SSN""."
  1. W !?3,"8. Total number of patients with a no ICN but have a CMOR assignment."
  1. W !?3,"9. Total number of patients with a no ICN but have TF assignments."
  1. W !?3,"10. Total number of patients with a local ICN but have remote TFs."
  1. ;
  1. START ;
  1. S QFLG=0
  1. I '$D(^XTMP("RGMT","UT01","@@","COMPILE STARTED")) W !!,"No data is currently available." I SITEOPT=1 G QUIT
  1. ;
  1. W !!,"===> NOTE <==="
  1. I SITEOPT=1 D
  1. .W !,"This data is compiled by a remote process initiated from the MPI in Austin"
  1. .W !,"on a regular basis for reporting purposes. It is not compiled by the local"
  1. .W !,"site, however, the local site can view the last report that was compiled.",!
  1. ;
  1. I $D(^XTMP("RGMT","UT01","@@","COMPILE STOPPED")) D G:QFLG QUIT I PRT D ^RGMTUT03 G QUIT
  1. .S PRT=0
  1. .S LAST=^XTMP("RGMT","UT01","@@","COMPILE STOPPED")
  1. .S LAST=$$FMTE^XLFDT(LAST)
  1. .W !,"This data was last compiled on ",LAST,"."
  1. .I SITEOPT=1 S PRT=1 Q
  1. .S DIR(0)="Y",DIR("B")="YES",DIR("A")="Do you just want a reprint of that data"
  1. .S DIR("?",1)="Enter:"
  1. .S DIR("?",2)=" ""YES"" or <RET> to reprint current data and NOT recompile."
  1. .S DIR("?",3)=" ""NO"" to recompile new data (this may take several hours)."
  1. .S DIR("?")=" ""^"" to HALT."
  1. .D ^DIR K DIR
  1. .I Y="^" S QFLG=1 Q
  1. .I +Y=1 S PRT=1 Q
  1. ;
  1. STARTQ ;pick up here for queued job
  1. D NOW^%DTC
  1. ;
  1. ;check to be sure stat report not being run during prime time
  1. S TODAY=$$DOW^XLFDT($$NOW^XLFDT()) I TODAY="Saturday"!(TODAY="Sunday") S BYPASS=1
  1. S QUIT=0
  1. I 'BYPASS D I QUIT G QUIT
  1. .S CHKTIME=$E($P(%,".",2),1,4)
  1. .I CHKTIME>"0700"&(CHKTIME<"1700") S QUIT=1 I '$D(RGHLMQ) D
  1. ..W !!,"<< STAT report cannot be compiled between 7:00am and 5:00pm! >>"
  1. ;
  1. I '$D(RGHLMQ) W !!,"Recompiling data..."
  1. ;
  1. S ^XTMP("RGMT",0)=$$FMADD^XLFDT(DT,30)_"^"_$$NOW^XLFDT_"^MPI/PD Maintenance Data"
  1. K ^XTMP("RGMT","UT01"),^XTMP("RGMT","REINDDT") ; **41
  1. S ^XTMP("RGMT","UT01","@@","COMPILE STARTED")=%
  1. ;
  1. D REIND^RGMTUT02
  1. D CMOR,TF,TFCHK
  1. ;
  1. I 'PRT D
  1. .D NOW^%DTC
  1. .S ^XTMP("RGMT","UT01","@@","COMPILE STOPPED")=%
  1. D ^RGMTUT03
  1. ;
  1. QUIT ;
  1. K %,BYPASS,CHKTIME,LAST,LOC,PRT,QFLG,QUIT,SITEOPT,TODAY,Y,RGROU,TASK
  1. Q
  1. ;
  1. CMOR ; Check "ACMOR" xref for:
  1. ; - existence of a TF entry for the CMOR in the TF file #391.91
  1. ; - existence of a TF for the local site (if not the CMOR)
  1. ; - CMOR totals by site
  1. ;
  1. I '$D(RGHLMQ) D
  1. .W !!,"Check #1 for:"
  1. .W !,"- Patients missing Treating Facility entries for their CMOR."
  1. .W !,"- Patients missing Treating Facility entries for their local site."
  1. .W !,"- Unique CMOR totals."
  1. ;
  1. K ^XTMP("RGMT","UT01","CMOR")
  1. K ^XTMP("RGMT","UT01","TOT CMOR MISS TF")
  1. K ^XTMP("RGMT","UT01","TOT LOC SITE MISS TF")
  1. K ^XTMP("RGMT","UT01","CMOR WITH NO ICN")
  1. S (CNT,NOICN,TOTMISSC,TOTMISSL)=0
  1. S SITESTA=$P($$SITE^VASITE(),"^",3),SITEDA=$P($$SITE^VASITE(),"^")
  1. ;
  1. S CMOR=0 F S CMOR=$O(^DPT("ACMOR",CMOR)) Q:'CMOR D
  1. .I '$D(CMOR(CMOR)) S CMOR(CMOR)=0
  1. .S DFN=0 F S DFN=$O(^DPT("ACMOR",CMOR,DFN)) Q:'DFN D
  1. ..S CNT=CNT+1 I '$D(RGHLMQ) W:'(CNT#10000) "."
  1. ..S ICN=$P($G(^DPT(DFN,"MPI")),"^")
  1. ..I $E(ICN,1,3)=SITESTA Q
  1. ..I ICN="" D Q
  1. ...S NOICN=NOICN+1
  1. ...I '$D(RGHLMQ) W !?3,"DFN #",DFN," has no ICN and a CMOR of ",$P($$NS^XUAF4(CMOR),"^")
  1. ...S ^XTMP("RGMT","UT01","CMOR WITH NO ICN",DFN)=""
  1. ...S LOC(991.03)="@" W $$UPDATE^MPIFAPI(DFN,"LOC")
  1. ..S CMOR(CMOR)=CMOR(CMOR)+1
  1. ..I '$D(^DGCN(391.91,"APAT",DFN,CMOR)) D
  1. ...S TOTMISSC=TOTMISSC+1
  1. ...S SSN=$P($G(^DPT(DFN,0)),"^",9)
  1. ...S NAME=$P($G(^DPT(DFN,0)),"^")
  1. ...S ^XTMP("RGMT","UT01","CMOR","ZZMISSC",CMOR,DFN)="DFN/"_DFN_"^NAME/"_NAME_"^SSN/"_SSN_"^ICN/"_ICN
  1. ...D FILE^VAFCTFU(DFN,CMOR,1)
  1. ..I SITEDA'=CMOR,'$D(^DGCN(391.91,"APAT",DFN,SITEDA)) D
  1. ...S TOTMISSL=TOTMISSL+1
  1. ...S SSN=$P($G(^DPT(DFN,0)),"^",9)
  1. ...S NAME=$P($G(^DPT(DFN,0)),"^")
  1. ...S ^XTMP("RGMT","UT01","CMOR","ZZMISSL",CMOR,DFN)="DFN/"_DFN_"^NAME/"_NAME_"^SSN/"_SSN_"^ICN/"_ICN
  1. ...D FILE^VAFCTFU(DFN,SITEDA,1)
  1. ;
  1. S CMOR=0 F S CMOR=$O(CMOR(CMOR)) Q:'CMOR D
  1. .S CMORNM=$P($$NS^XUAF4(CMOR),"^"),CMORSTA=$P($$NS^XUAF4(CMOR),"^",2) Q:CMORSTA=""
  1. .S ^XTMP("RGMT","UT01","CMOR",CMORNM,CMORSTA)=CMOR(CMOR)
  1. S ^XTMP("RGMT","UT01","TOT CMOR MISS TF")=TOTMISSC
  1. S ^XTMP("RGMT","UT01","TOT LOC SITE MISS TF")=TOTMISSL
  1. S ^XTMP("RGMT","UT01","CMOR WITH NO ICN")=NOICN
  1. I '$D(RGHLMQ) W !,"Check #1 - Complete"
  1. K CMOR,CMORNM,CMORSTA,CNT,DFN,ICN,NAME,NOICN,SITEDA,SITESTA,SSN,TOTMISSC,TOTMISSL
  1. Q
  1. ;
  1. TF ; Get totals for unique sites in the TF file (#391.91)
  1. I '$D(RGHLMQ) D
  1. .W !!,"Check #2 for:"
  1. .W !,"- Unique Treating Facility totals."
  1. K ^XTMP("RGMT","UT01","TF"),TFCNT S CNT=0
  1. S SITE=$P($$SITE^VASITE(),"^",3)
  1. S TF=0 F S TF=$O(^DGCN(391.91,"AINST",TF)) Q:'TF D
  1. .S CNT=CNT+1 I '$D(RGHLMQ) W:'(CNT#10000) "."
  1. .I '$D(TFCNT(TF)) S TFCNT(TF)=0
  1. .S TFIEN=0 F S TFIEN=$O(^DGCN(391.91,"AINST",TF,TFIEN)) Q:'TFIEN S TFCNT(TF)=TFCNT(TF)+1
  1. S TF=0 F S TF=$O(TFCNT(TF)) Q:'TF D
  1. .S TFNM=$P($$NS^XUAF4(TF),"^"),TFSTA=$P($$NS^XUAF4(TF),"^",2) Q:TFSTA=""
  1. .S ^XTMP("RGMT","UT01","TF",TFNM,TFSTA)=TFCNT(TF)
  1. I '$D(RGHLMQ) W !,"Check #2 - Complete"
  1. K CNT,SITE,TF,TFCNT,TFIEN,TFNM,TFSTA
  1. Q
  1. ;
  1. TFCHK ; Get totals for duplicates in TF file (#391.91)
  1. ;NOICN=# of patients found with remote TFs and no ICN
  1. ;LOCICN=# of patients found with remote TFs and a local ICN
  1. ;
  1. I '$D(RGHLMQ) D
  1. .W !!,"Check #3 for:"
  1. .W !,"- Duplicate Treating Facility assignments."
  1. .W !,"- Patients with Treating Facilities and no ICN."
  1. .W !,"- Patients remote treating Facilities and Local ICN."
  1. ;
  1. K ^XTMP("RGMT","UT01","TOT TFDUP"),^XTMP("RGMT","UT01","TOT NO ICN W/TF"),^XTMP("RGMT","UT01","TOT LOC ICN W/REMOTE TF")
  1. S (PTCNT,DUPCNT,NOICN,LOCICN)=0
  1. S SITESTA=$P($$SITE^VASITE(),"^",3),SITEDA=$P($$SITE^VASITE(),"^")
  1. S DFN=0 F S DFN=$O(^DGCN(391.91,"APAT",DFN)) Q:'DFN D
  1. .S PTCNT=PTCNT+1 I '$D(RGHLMQ) W:'(PTCNT#10000) "."
  1. .S TF=0 F S TF=$O(^DGCN(391.91,"APAT",DFN,TF)) Q:'TF D
  1. ..S MPI0=$G(^DPT(DFN,"MPI")),ICN=$P(MPI0,"^")
  1. ..;delete all TFs for patients with no ICN
  1. ..I ICN="" D Q
  1. ...S NOICN=NOICN+1
  1. ...S TFIEN=0 F S TFIEN=$O(^DGCN(391.91,"APAT",DFN,TF,TFIEN)) Q:'TFIEN D
  1. ....S ^XTMP("RGMT","UT01","NO ICN WITH REMOTE OR LOCAL TF",DFN,TFIEN)=""
  1. ....D DELETE^VAFCTFU(TFIEN)
  1. ..;delete all remote TFs for patients with local ICNs
  1. ..I $E(ICN,1,3)=SITESTA,TF'=SITEDA D Q
  1. ...S TFIEN=0 F S TFIEN=$O(^DGCN(391.91,"APAT",DFN,TF,TFIEN)) Q:'TFIEN D
  1. ....S LOCICN=LOCICN+1
  1. ....S ^XTMP("RGMT","UT01","LOCAL ICN WITH REMOTE TF",DFN,TFIEN)=""
  1. ....D DELETE^VAFCTFU(TFIEN)
  1. ..;look for TF dups
  1. ..S (TFCNT,TFIEN)=0 F S TFIEN=$O(^DGCN(391.91,"APAT",DFN,TF,TFIEN)) Q:'TFIEN D
  1. ...S TFCNT=TFCNT+1 I TFCNT>1 D
  1. ....S DUPCNT=DUPCNT+1
  1. ....S SSN=$P($G(^DPT(DFN,0)),"^",9)
  1. ....S NM=$P($G(^(0)),"^")
  1. ....S ^XTMP("RGMT","UT01","TFDUP",DFN,TFIEN)=TF_"^"_NM_"^"_SSN
  1. ....D DELETE^VAFCTFU(TFIEN)
  1. ;
  1. S ^XTMP("RGMT","UT01","TOT TFDUP")=DUPCNT
  1. S ^XTMP("RGMT","UT01","TOT NO ICN W/TF")=NOICN
  1. S ^XTMP("RGMT","UT01","TOT LOC ICN W/REMOTE TF")=LOCICN
  1. I '$D(RGHLMQ) W !,"Check #3 - Complete"
  1. K DFN,DUPCNT,ICN,LOCICN,MPI0,NM,NOICN,PTCNT,SITEDA,SITESTA,SSN,TF,TFCNT,TFIEN
  1. Q