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

DGYMF31A.m

Go to the documentation of this file.
  1. DGYMF31A ;ALB/CMM FIND DANGLING PT IN ^DPT TO ^DIC(31 ;12/30/94
  1. ;;5.3;Registration;**53,1015**;Aug 13, 1993;Build 21
  1. ;
  1. ;This is a one shot routine that will loop through the patient
  1. ;file entries looking at the disabilities to see if the pointer
  1. ;values are valid to file 31 (disability conditions file).
  1. ;
  1. DRIVE ;
  1. U IO S PAGE=1
  1. D LOOP
  1. S ^TMP($J,"DG31",0)=NXT,INDEX="B"
  1. D HEAD1 I $O(^TMP($J,"DG31",0))="" W !!,"No bad pointers." Q
  1. D REPORT I END="Y" Q
  1. I $D(^TMP($J,"DG31","D")) S INDEX="D" D HEAD I END'="Y" D REPORT
  1. I END'="Y" W !!,"TOTAL PATIENTS WITH DANGLING POINTER(S) = ",NXT
  1. I $D(ZTSK) D EXIT^DGYMF31
  1. Q
  1. LOOP ;looping through patient file
  1. S (DFN,NXT,CPT)=0 K ^TMP($J,"DG31")
  1. F S DFN=$O(^DPT(DFN)) Q:'DFN D
  1. .S (ANY,CNT)=0,CPT=CPT+1
  1. .I $E(IOST,1,2)="C-" W:'(CPT#100) "."
  1. .F S CNT=$O(^DPT(DFN,.372,CNT)) Q:CNT="" D
  1. ..S PTR=+^DPT(DFN,.372,CNT,0)
  1. ..I '$D(^DIC(31,PTR,0)) D:BADDEL="Y" KILL S ANY=ANY+1 I ANY D FOUND
  1. .I ANY&(INVALID="Y") D DIS
  1. Q
  1. FOUND ;
  1. S LAST=$$LTD(DFN)
  1. S DEAD=+$G(^DPT(DFN,.35))
  1. I '$D(^TMP($J,"DG31",$S('DEAD:"B",1:"D"),$P(^DPT(DFN,0),"^"))) D
  1. .S NXT=NXT+1,^TMP($J,"DG31",NXT)=$P(^DPT(DFN,0),"^")_"^"_$P(^DPT(DFN,0),"^",9)_"^"_$P(^DPT(DFN,0),"^",3)_"^"_LAST_"^"_DEAD
  1. .S ^TMP($J,"DG31",$S('DEAD:"B",1:"D"),$P(^DPT(DFN,0),"^"),NXT)=""
  1. Q
  1. DIS ;include 'good' disabilities in report
  1. N PTR,TLP,TCT S (TLP,TCT)=0
  1. F S TLP=$O(^DPT(DFN,.372,TLP)) Q:TLP="" D
  1. .S PTR=+^DPT(DFN,.372,TLP,0)
  1. .I $D(^DIC(31,PTR,0)) S TCT=TCT+1,^TMP($J,"DG31",NXT,TCT)=$P(^DIC(31,PTR,0),"^")
  1. Q
  1. S END="N"
  1. I ($E(IOST,1,2)="C-") S DIR(0)="E" D ^DIR I 'Y S END="Y" K X,Y,DUOUT,DTOUT,DIRUT Q
  1. HEAD1 ;
  1. W @IOF
  1. W !!,"Patients with bad pointers in the Rated Disability field ",?100,"PAGE ",PAGE,!
  1. W !,?5,"Patient Name",?35,"SSN",?50,"Date of Birth",?70,"Last Date of Contact"
  1. I INDEX="D" W ?100,"Date of Death"
  1. I INVALID="Y" W !,?10,"Valid Disabilities on file"
  1. W !
  1. S PAGE=PAGE+1
  1. Q
  1. REPORT ;Display information gathered.
  1. N NM S LP=0,END="N",NM=""
  1. F S NM=$O(^TMP($J,"DG31",INDEX,NM)) Q:(NM="")!(END="Y") D
  1. .F S LP=$O(^TMP($J,"DG31",INDEX,NM,LP)) Q:(LP="")!(END="Y") D
  1. ..I $Y+3>IOSL D HEAD I END="Y" Q
  1. ..D DATA
  1. ..I INVALID="Y" D DATA2
  1. Q
  1. DATA ;
  1. N NODE S NODE=^TMP($J,"DG31",LP)
  1. S SSN=$P(NODE,"^",2),SSN=$E(SSN,1,3)_"-"_$E(SSN,4,5)_"-"_$E(SSN,6,10)
  1. S DEAD=$$FMTE^XLFDT($P(NODE,"^",5)) I DEAD=0 S DEAD=""
  1. S LAST=$$FMTE^XLFDT($P(NODE,"^",4)) I LAST=0 S LAST=""
  1. W !,$P(NODE,"^"),?31,SSN,?50,$$FMTE^XLFDT($P(NODE,"^",3)),?70,LAST,?100,DEAD
  1. ;NAME,SSN,DOB,LAST DATE OF CONTACT,DATE OF DEATH
  1. Q
  1. ;
  1. DATA2 ;
  1. N TCT S TCT=0
  1. F S TCT=$O(^TMP($J,"DG31",LP,TCT)) Q:TCT=""!(END="Y") D
  1. .I $Y+2>IOSL D HEAD I END'="Y" S NX="Y"
  1. .I END="Y" Q
  1. .I $D(NX) K NX D DATA
  1. .W !,?10,^TMP($J,"DG31",LP,TCT)
  1. Q
  1. LTD(DFN) ; Find Last Treatment Date
  1. ; Input: DFN - pointer to the patient in file #2
  1. ; Output: LTD - Last Treatment Date (really last date seen at facility)
  1. ;
  1. N LTD,X
  1. ; - if current inpatient, set LTD = today and quit
  1. I $G(^DPT(DFN,.105)) S LTD=DT G LTDQ
  1. ; - get the last discharge date
  1. S LTD=+$O(^DGPM("ATID3",DFN,"")) S:LTD LTD=9999999.9999999-LTD\1 S:LTD>DT LTD=DT
  1. ; - get the last registration date and compare to LTD
  1. S X=+$O(^DPT(DFN,"DIS",0)) I X S X=9999999-X\1 S:X>LTD LTD=X
  1. ; - get the last appointment and compare to LTD
  1. S X=LTD F S X=$O(^DPT(DFN,"S",X)) Q:'X!(X>DT) I $D(^(X,0)),$P(^(0),"^",2)="" S LTD=X\1
  1. ; - get the last stop and compare to LTD
  1. S X=LTD F S X=$O(^SDV("ADT",DFN,X)) Q:'X S LTD=X
  1. LTDQ Q LTD
  1. ;
  1. KILL ;Delete pointer from Patient file
  1. S DA(1)=DFN,DA=CNT,DIK="^DPT("_DA(1)_",.372," D ^DIK K DIK,DA
  1. Q