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

AGGRPTDP.m

Go to the documentation of this file.
AGGRPTDP ; VNGT/HS/KDC - POTENTIAL DUPLICATE PATIENT REPORT
 ;;1.0;PATIENT REGISTRATION GUI;;Nov 15, 2010
 ;
 ; Copied from AGRPTPDP
 ; 
 ;REPORT OF POTENTIAL DUPLICATE PATIENTS BASED ON 5 CRITERIA
 ;
 Q
 ;
EN(DATA,QNAM,QDOB,QSSN,QCOM,QM,QALL,QIN) ; EP -AGG POTENTIAL DUPLICATE PATIENT REPORT
 ;Description
 ;  Generates AGG POTENTIAL DUPLICATE PATIENT REPORT
 ;
 ;Input
 ;  QNAM - A flag inticating user's selection
 ;  QDOB - A flag inticating user's selection
 ;  QSSN - A flag inticating user's selection
 ;  QCOM - A flag inticating user's selection
 ;  QM - A flag inticating user's selection
 ;  QALL - A flag inticating user's selection
 ;  QIN - A flag inticating user's selection
 ;
 ;Output
 ;  DATA - Name of global in which data is stored(^TMP("AGGRPTDP"))
 ;
 NEW UID,X,AGGI,HSTEXT,HSPATH,HSFN,Y,IOSL,IOST,IOM,I,N
 NEW CRITERIA,INCACTDE,ALLLOC,CRITSTRE,AGLINE,CURCOM,DECEASE
 NEW FUNNYSUB,MAIDEN,PAGE,PATIEN,RPTDATE,RPTREQ,UCI,CNT,CRITSTR
 ;I '$D(DT) S %DT="",X="T" D ^%DT S DT=Y
 I '$D(DT) D DT^DICRW
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGRPTDP",UID))
 K @DATA
 S AGGI=0
 D HDR
 I $$TMPFL^AGGUL1("W",UID,"AGG"_$J) G DONE
 ;I $L($G(RPTCRT),U)'=7 S BMXSEC="Invalid search criteria." G DONE
 S CRITERIA=""
 S CNT=0
 I $G(QNAM)="Y" S CRITERIA="1:NAME",CNT=CNT+1
 I $G(QDOB)="Y" S CNT=CNT+1 S:CRITERIA]"" CRITERIA=CRITERIA_U_"2:DOB" S:CRITERIA="" CRITERIA="2:DOB"
 I $G(QSSN)="Y" S CNT=CNT+1 S:CRITERIA]"" CRITERIA=CRITERIA_U_"3:SSN" S:CRITERIA="" CRITERIA="3:SSN"
 I $G(QCOM)="Y" S CNT=CNT+1 S:CRITERIA]"" CRITERIA=CRITERIA_U_"4:COM" S:CRITERIA="" CRITERIA="4:COM"
 I $G(QM)="Y" S CNT=CNT+1 S:CRITERIA]"" CRITERIA=CRITERIA_U_"5:MAIDEN" S:CRITERIA="" CRITERIA="5:MAIDEN"
 I CNT<2 D  G DONE
 . S @DATA@(AGGI)="T01024REPORT_TEXT"_$C(30)
 . S AGGI=AGGI+1
 . S @DATA@(AGGI)="NOT ENOUGH CRITERIA SELECTED!"_$C(30)
 S (ALLLOC,INCACTDE)=0
 I $G(QALL)="Y" S ALLLOC=1
 I $G(QIN)="Y" S INCACTDE=1
 U IO
 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)=""
 D SHOWCRIT(CRITERIA)
 D MAIN(CRITERIA)
 D BGL
 ;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
 K ROUTINE
 Q
MAIN(CRITERIA) ;MAIN
 NEW FIRSTINI,LASTINI,LASTNAME,SSN,NAME,DOB,COM,%
 K ^TMP("AGG",$J)
 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 ^TMP("AGG",$J,FUNNYSUB,PATIEN)=""
 .S ^TMP("AGG",$J,FUNNYSUB)=$G(^TMP("AGG",$J,FUNNYSUB))+1
 D REPORT(CRITERIA)
 Q
REPORT(CRITERIA) ;EP
 NEW ESCAPE,HRNFAC,INACTIVE,LN1,LN2,PATDOB,PATNAME,PSEUDO,HRN
 S PAGE=0
 S ESCAPE=0
 D RHDR(CRITERIA)
 S FUNNYSUB=""
 F  S FUNNYSUB=$O(^TMP("AGG",$J,FUNNYSUB)) Q:FUNNYSUB=""  D  Q:ESCAPE
 .S PATIEN=""
 .F LN1=1:1 S PATIEN=$O(^TMP("AGG",$J,FUNNYSUB,PATIEN)) Q:PATIEN=""  D  Q:ESCAPE
 ..Q:$G(^TMP("AGG",$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 RHDR(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 RHDR(CRITERIA)  ;IHS/SD/IHS 2/17/2006 IM19904 FIX SUBMITTED BY MICHAEL TAYLOR
 ..;I $Y>(IOSL-1),(IOST'[("C-")) D RHDR(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?
 NEW INACTDT
 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
 NEW PIECE,SEL
 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
RHDR(CRITERIA) ;EP - MAIN HEADER
 S PAGE=PAGE+1,IOM=80
 W @IOF
 W !,RPTREQ,?69,"page ",PAGE
 W !
 D CENTER^AGUTILS("INDIAN HEALTH HOSPITAL")
 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*
 ;;
BGL U IO W !,$C(9)
 ;
 ;
 I $$TMPFL^AGGUL1("C") G DONE
 I $$TMPFL^AGGUL1("R",UID,"AGG"_$J) G DONE
 ;
 F  U IO R HSTEXT:.1 Q:HSTEXT[$C(9)  D
 . S HSTEXT=$$STRIP^XLFSTR(HSTEXT,"^")
 . I HSTEXT="" S HSTEXT=" "
 . S AGGI=AGGI+1,@DATA@(AGGI)=HSTEXT_$C(13)_$C(10)_$C(30)
 S AGGI=AGGI+1,@DATA@(AGGI)=$C(30)
 ;
 I $$TMPFL^AGGUL1("C") G DONE
 I $$TMPFL^AGGUL1("D",UID,"AGG"_$J) G DONE
 ;
DONE ;
 ;
 S AGGI=AGGI+1,@DATA@(AGGI)=$C(31)
 Q
 ;
HDR ;
 S @DATA@(AGGI)="T01024REPORT_TEXT"_$C(30)
 Q
 ;
ERR ;
 D ^%ZTER
 NEW Y,ERRDTM
 S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
 S BMXSEC="Recording that an error occurred at "_ERRDTM
 I $D(AGGI),$D(DATA) S AGGI=AGGI+1,@DATA@(AGGI)=$C(31)
 I $$TMPFL^AGGUL1("C")
 Q