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

AGRPTPDP.m

Go to the documentation of this file.
AGRPTPDP ;IHS/SD/TPF - POTENTIAL DUPLICATE PATIENT REPORT
 ;;7.1;PATIENT REGISTRATION;**1,2,9**;AUG 25, 2005
 ;
 ;REPORT OF POTENTIAL DUPLICATE PATIENTS BASED ON 5 CRITERIA
 ;
EN ;EP
 W @IOF
 S RPTREQ=$P($G(^VA(200,DUZ,0)),U)  ;REPORT REQUESTED BY
 X ^%ZOSF("UCI")
 S UCI=$P(Y,",")
 S ROUTINE=$T(+0)
 S:$G(AGLINE("EQ"))="" $P(AGLINE("EQ"),"=",81)=""
 S:$G(AGLINE("-"))="" $P(AGLINE("-"),"-",81)=""
 W !,"This report is intended to help identify duplicate patient"
 W !,"records in the Registration system. The system can check"
 W !,"against the following fields:"
 W !!
 W !,"-Last Name and First initial of Patient"
 W !,"-Patient Date of Birth"
 W !,"-Social Security Number"
 W !,"-Current Community"
 W !,"-Mother's Maiden Name"
 W !!
 W !,"Choose at least two factors that you wish to check against for potential"
 W !,"duplicates. The system will also prompt to check over active"
 W !,"locations and inactive/deceased patients."
 W !
 K DIR
 S DIR(0)="E"
 D ^DIR
ASKCRIT ;EP - ASK FOR CRITERIA
 W @IOF
 W !!
 W !,"Please choose at least two criteria in which you want this report to run:"
 S CRITERIA=""
ASKAGAIN ;EP
 K DIR,DTOUT,DUOUT,DIROUT,DIRUT
 I CRITERIA="" S DIR("A")="Please make a selection"
 E  S DIR("A")="Please make another selection"
 I CRITERIA="" S DIR(0)="SO^1:NAME;2:DOB;3:SSN;4:COM;5:MAIDEN;A:ALL",DIR("B")="All"
 E  S DIR(0)="SO^1:NAME;2:DOB;3:SSN;4:COM;5:MAIDEN"
 S DIR("L",1)="1. Last Name and First initial of Patient"
 S DIR("L",2)="2. Date of Birth"
 S DIR("L",3)="3. Social Security Number"
 S DIR("L",4)="4. Current Community"
 S DIR("L",5)="5. Mother's Maiden Name"
 S DIR("L",6)=""
 S DIR("L")=""
 D ^DIR
 Q:$D(DTOUT)!($D(DUOUT))!($D(DIROUT))
 I Y'="" I CRITERIA'="",(CRITERIA[(Y_":"_Y(0))) W !,"CRITERIA ALREADY SELECTED" G ASKAGAIN
 I Y="" I (CRITERIA="")!($L(CRITERIA,U)<2) W !,"NOT ENOUGH CRITERIA SELECTED!" G ASKAGAIN
 I Y="",($L(CRITERIA,U)>1) D SELCRIT(CRITERIA) G ASKCRIT
 I Y(0)="ALL" S CRITERIA=$P($T(CRITTXT),";;",2) D SELCRIT(CRITERIA) G ASKCRIT
 I CRITERIA="" S CRITERIA=Y_":"_Y(0)
 E  S CRITERIA=CRITERIA_U_Y_":"_Y(0)
 G ASKAGAIN
SELCRIT(CRITERIA) ;EP
A1 D SHOWCRIT(CRITERIA)
 W !
 K DIR
 S DIR("A")="Is this correct"
 S DIR("B")="Yes"
 S DIR(0)="Y"
 D ^DIR
 Q:'Y
A2 D ASKLOC G:$D(DUOUT) A1     ;ASK IF TO INCLUDE ALL ACTIVE LOCATIONS
A3 D ASKACTDE G:$D(DUOUT) A2 ;ASK IF TO INCLUDE INACTIVE AND DECEASED PATIENTS
A4 D ASKDEV    ;ASK FOR DEVICE
 G:POP A3
 I $G(IO("Q")) D QUE Q
 U IO
 D MAIN(CRITERIA)
 ;IF PRINTING TO A SLAVE PRINTER FREEZES UP, THE CAUSE IS THE 'CLOSE EXECUTE' IN 
 ;THE 'TERMINAL TYPE' FILE IS NOT FILLED IN FOR THE 'SUBTYPE' OF THE SLAVE 
 ;DEVICE CHOSEN.
 D ^%ZISC
 Q
ASKDEV ;EP
 S %ZIS="Q"
 D ^%ZIS
 Q
ASKLOC ;EP
 S ALLLOC=0
 K DIR
 S DIR("A")="Do you wish to include across all active locations"
 S DIR("B")="Yes"
 S DIR(0)="Y"
 D ^DIR
 S ALLLOC=+Y
 Q
ASKACTDE ;EP
 S INCACTDE=0
 K DIR
 S DIR("A")="Do you wish to include inactive or deceased patients"
 S DIR("B")="No"
 S DIR(0)="Y"
 D ^DIR
 S INCACTDE=+Y
 Q
MAIN(CRITERIA) ;MAIN
 K ^XTMP(ROUTINE)
 D NOW^%DTC S Y=% X ^DD("DD")
 S RPTDATE=Y
 S (LASTINI,DOB,SSN,COM,MAIDEN)=""
 S PATIEN=0
 F  S PATIEN=$O(^AUPNPAT(PATIEN)) Q:+PATIEN=0  D
 .S DECEASE=$$CHKDEATH^AGEDERR(PATIEN)
 .I 'INCACTDE Q:DECEASE  ;INCLUDE DECEASE AND INACTIVE IS NO QUIT
 .I CRITERIA[("NAME") D
 ..S NAME=$P($G(^DPT(PATIEN,0)),U)
 ..S LASTNAME=$P(NAME,",")
 ..S FIRSTINI=$E($P(NAME,",",2))
 ..S LASTINI=LASTNAME_" "_FIRSTINI
 .I CRITERIA[("DOB") D
 ..S DOB=$P($G(^DPT(PATIEN,0)),U,3)
 .I CRITERIA[("SSN") D
 ..S SSN=$P($G(^DPT(PATIEN,0)),U,9)
 .I CRITERIA[("COM") D
 ..S COM=$P($G(^AUPNPAT(PATIEN,11)),U,18)  ;FREE TEXT - NOT A GOOD CRITERIA
 .I CRITERIA[("MAIDEN") D
 ..S MAIDEN=$P($G(^DPT(PATIEN,.24)),U,3)  ;FREE TEXT - NOT A GOOD CRITERIA
 .S FUNNYSUB=LASTINI_U_DOB_U_SSN_U_COM_U_MAIDEN
 .S ^XTMP(ROUTINE,$J,FUNNYSUB,PATIEN)=""
 .S ^XTMP(ROUTINE,$J,FUNNYSUB)=$G(^XTMP(ROUTINE,$J,FUNNYSUB))+1
 W !,"DUPLICATE CHECK COMPLETE "
 D REPORT(CRITERIA)
 Q
REPORT(CRITERIA) ;EP
 S PAGE=0
 S ESCAPE=0
 D HDR(CRITERIA)
 S FUNNYSUB=""
 F  S FUNNYSUB=$O(^XTMP(ROUTINE,$J,FUNNYSUB)) Q:FUNNYSUB=""  D  Q:ESCAPE
 .S PATIEN=""
 .F LN1=1:1 S PATIEN=$O(^XTMP(ROUTINE,$J,FUNNYSUB,PATIEN)) Q:PATIEN=""  D  Q:ESCAPE
 ..Q:$G(^XTMP(ROUTINE,$J,FUNNYSUB))<2
 ..S PATNAME=$P($G(^DPT(PATIEN,0)),U)
 ..S DECEASE=$$CHKDEATH^AGEDERR(PATIEN)
 ..S PATDOB=$P($G(^DPT(PATIEN,0)),U,3)
 ..I PATDOB'="" S Y=PATDOB X ^DD("DD") S PATDOB=Y
 ..E  S PATDOB="<none>"
 ..S MAIDEN=$P($G(^DPT(PATIEN,.24)),U,3)
 ..S CURCOM=$P($G(^AUPNPAT(PATIEN,11)),U,18)
 ..S:PATNAME="" PATNAME="<none>"
 ..S:MAIDEN="" MAIDEN="<none>"
 ..S:CURCOM="" CURCOM="<none>"
 ..S:MAIDEN="" MAIDEN="<none>"
 ..;I $Y>(IOSL-1),(IOST[("C-")) W ! K DIR S DIR(0)="E" D ^DIR S ESCAPE=$D(DUOUT) Q:ESCAPE  D HDR(CRITERIA)
 ..I $D(IO("S")),($Y>(IOSL-1)),(IOST[("C-")) W ! K DIR S DIR(0)="E" D ^DIR S ESCAPE=$D(DUOUT) Q:ESCAPE  D HDR(CRITERIA)  ;IHS/SD/IHS 2/17/2006 IM19904 FIX SUBMITTED BY MICHAEL TAYLOR
 ..I $Y>(IOSL-1),(IOST'[("C-")) D HDR(CRITERIA)
 ..;W:LN1=1 !!,"COMPARISON STRING=",FUNNYSUB PROGRAMMER ONLY
 ..W !,$E(PATNAME,1,25),$S(DECEASE:"#",1:""),?26,PATDOB,?38,$E(MAIDEN,1,15),?54,$E(CURCOM,1,15)
 ..S HRNFAC=0
 ..F LN2=1:1 S HRNFAC=$O(^AUPNPAT(PATIEN,41,HRNFAC)) Q:+HRNFAC=0  D
 ...Q:'$$ACTFAC(HRNFAC)
 ...S PSEUDO=$P($G(^AUTTLOC(HRNFAC,1)),U,2)
 ...S INACTIVE=$S((U_"I"_U)[(U_$P($G(^AUPNPAT(PATIEN,41,HRNFAC,0)),U,5)_U):"*",1:"")
 ...I 'INCACTDE Q:INACTIVE
 ...S HRN=$P($G(^AUPNPAT(PATIEN,41,HRNFAC,0)),U,2)
 ...W:LN2'=1 !
 ...W ?69,PSEUDO,?73,HRN_INACTIVE
 ;I IOST[("C-") W ! K DIR S DIR(0)="E" D ^DIR
 I $D(IO("S")),(IOST[("C-")) W ! K DIR S DIR(0)="E" D ^DIR  ;IHS/SD/IHS 2/17/2006 IM19904 FIX SUBMITTED BY MICHAEL TAYLOR
 Q
ACTFAC(FAC) ;EP - IS THE FACILITY ACTIVE?
 S INACTDT=$P($G(^AUTTLOC(FAC,0)),U,21)
 Q:INACTDT="" 1
 I INACTDT>DT Q 1
 Q 0
EXIT ;CLEANUP VARS
 K EFFDATE,EMPLECNT,COUNT,EMPLEE,EMPLEENM,EMPLEREC,EMPLRBEG,EMPLRCNT,EMPLREND
 K EMPLRNM,EMPLRREC,EMPREC
 Q
SHOWCRIT(CRITERIA) ;EP - DISPLAY CRITERIA SELECTED
 S CRITSTR=""
 W !!,"You have selected "
 F PIECE=1:1 S SEL=$P(CRITERIA,U,PIECE) Q:SEL=""  D
 .I PIECE'=1 W " and " S CRITSTR=CRITSTR_" and "
 .W "#"_$P($T(CRITTXT+SEL),";;",2)
 .S CRITSTR=CRITSTR_"#"_$P($T(CRITTXT+SEL),";;",2)
 Q
HDR(CRITERIA) ;EP - MAIN HEADER
 S PAGE=PAGE+1
 W @IOF
 W !,RPTREQ,?69,"page ",PAGE
 W !
 D CENTER^AGUTILS("INDIAN HEALTH HOSPITAL") ;AG*7.1*9 - Fixed misspelled HEALTH
 W !
 D CENTER^AGUTILS("POTENTIAL DUPLICATE PATIENT FILES REPORT")
 W !
 D WRAP^AGUTILS("CHECKING AGAINST "_CRITSTR,20,"WC50")
 W !
 D CENTER^AGUTILS("UCI: "_UCI)
 W !
 D CENTER^AGUTILS("('*' = INACTIVE), ('#' = DECEASED)")
 W !!
 D CENTER^AGUTILS("as of "_RPTDATE)
 W !!
 W "PATIENT NAME",?26,"BIRTH DATE",?38,"MOTHERS MAIDEN",?54,"CUR. COMMUNITY",?69,"LOC",?73,"HRN"
 W !,"============",?26,"==========",?38,"==============",?54,"==============",?69,"===",?73,"======"
 Q
QUE ;EP
 K IO("Q")
 S ZTRTN="MAIN^AGRPTPDP(CRITERIA)",ZTDESC="LISTING OF POTENTIAL DUPLICATE PATIENTS"
 S ZTSAVE("CRITERIA")=""
 S ZTSAVE("ALLLOC")=""
 S ZTSAVE("INCACTDE")=""
 S ZTSAVE("ROUTINE")=""
 S ZTSAVE("RPTREQ")=""
 S ZTSAVE("CRITSTR")=""
 S ZTSAVE("UCI")=""
 D ^%ZTLOAD W:$D(ZTSK) !,"REQUEST QUEUED AS TASK # "_ZTSK_" !",!
 Q
CRITTXT ;;1:NAME^2:DOB^3:SSN^4:COM^5:MAIDEN
 ;;1-Last Name and First initial of Patient
 ;;2-Patient Date of Birth
 ;;3-Social Security Number
 ;;4-Current Community
 ;;5-Mother's Maiden Name
 ;;*END*