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

BKMVSSR.m

Go to the documentation of this file.
BKMVSSR ;PRXM/HC/CJS - STATE SURV. REPORT ; 14 Jun 2005  3:06 PM
 ;;2.1;HIV MANAGEMENT SYSTEM;;Feb 07, 2011
 ;
 ;
 ;This report will use the skeleton structure as provided by
 ;file 90456
EN ;PRIMARY REPORT ENTRY POINT
 ; Check taxonomies - added per bugzilla #1497
 NEW DFLAG
 S DFLAG=1 D EN^BKMVC1
 N DFN
 S BKMX=0
 S TYPE=$$TYPE()
 I $D(DTOUT)!$D(DUOUT) G XIT
 I TYPE="B" D QUE("") G XIT
 D RLK^BKMPLKP("") G:$G(DFN)="" XIT
 I $$CKAGE() G XIT
 D QUE(DFN)
 G XIT
 ;
AGE ;GET PATIENT DOB AND DIAGNOSIS INFO AND CALCULATE AGE AT DIAGNOSIS
 S BKMDDT=""
 S BKMVDOB=$$GET1^DIQ(2,DFN,.03,"I")
 S BKMVDOD=$$GET1^DIQ(2,DFN,.351,"I")
 S IEN=$$FIND1^DIC(90451,,"Q",DFN,"B")
 I IEN]"" D
 . S BKMDIAG=$$GET1^DIQ(90451.01,"1,"_IEN,2.3,"E")
 . S:BKMDIAG'="HIV"&(BKMDIAG'="AIDS") BKMDIAG=""
 . S:BKMDIAG="HIV" BKMDDT=$$GET1^DIQ(90451.01,"1,"_IEN,5,"I")
 . S:BKMDIAG="AIDS" BKMDDT=$$GET1^DIQ(90451.01,"1,"_IEN,5.5,"I")
 ; Calculate age at date of diagnosis, if available.
 ; Otherwise, calculate age at date of death, if available.
 ; Otherwise, calculate age at date of report.
 D
 . I BKMVDOB>0&(BKMDDT>0) S BKMVAGED=$$FMDIFF^XLFDT(BKMDDT,BKMVDOB)\365.25 Q
 . I BKMVDOB>0&(BKMVDOD>0) S BKMVAGED=$$FMDIFF^XLFDT(BKMVDOD,BKMVDOB)\365.25 Q
 . I BKMVDOB>0 S BKMVAGED=$$FMDIFF^XLFDT(DT,BKMVDOB)\365.25 Q
 . S BKMVAGED="UNK"
 Q
FAC ;GATHER FACILITY DATA
 S BKMLOC=$$GET1^DIQ(9999999.39,1,.01,"I")
 S BKMVLOC=$$GET1^DIQ(4,BKMLOC,.01,"E")
 S BKMVLAD=$$GET1^DIQ(4,BKMLOC,1.01,"E")
 S BKMVLAD1=$$GET1^DIQ(4,BKMLOC,1.02,"E")
 S BKMVLST=$$GET1^DIQ(4,BKMLOC,.02,"E")
 S BKMVLCTY=$$GET1^DIQ(4,BKMLOC,1.03,"E")
 S BKMVLZIP=$$GET1^DIQ(4,BKMLOC,1.04,"E")
 Q
PATDEMO ;GET PATIENT DEMOGRAPHICS
 S BKMVSEX=$$GET1^DIQ(2,DFN,.02,"E")
 S BKMVSDTH=$$GET1^DIQ(9000001,DFN,1115,"E")
 S BKMVSTAT="Alive" I BKMVDOD]"" S BKMVSTAT="Dead"
 ; An inactive record should be reported as 'Unknown' instead of 'Alive'.
 I $G(IEN)]"",$$GET1^DIQ(90451.01,"1,"_IEN,.5,"I")="I",BKMVSTAT="Alive" S BKMVSTAT="Unknown"
 S BKMVHRN=$$GET1^DIQ(9000001.41,BKMLOC_","_DFN,.02,"E")
 S BKMVRCE=$$GET1^DIQ(9000001,DFN,1111,"E") D
 .I BKMVRCE="INDIAN/ALASKA NATIVE" S BKMVRCE="AMERICAN INDIAN OR ALASKA NATIVE" Q
 .S BKMVRCE=$$GET1^DIQ(2,DFN,.06,"E")
 S BKMVETH="",BKM=0
 F  S BKM=$O(^DPT(DFN,.06,BKM)) Q:'BKM  S BKMVETH=$P(^DPT(DFN,.06,BKM,0),U,1)
 S:BKMVETH'="" BKMVETH=$$GET1^DIQ(10.2,BKMVETH,.01,"E")
 S BKMVPHN=$$GET1^DIQ(2,DFN,.131,"E")
 S BKMVPOB=$$GET1^DIQ(2,DFN,.093,"I")
 S BKMVADD1=$$GET1^DIQ(2,DFN,.111,"E")
 S BKMVADD2=$$GET1^DIQ(2,DFN,.112,"E")
 S BKMVADD3=$$GET1^DIQ(2,DFN,.113,"E")
 S BKMVCITY=$$GET1^DIQ(2,DFN,.114,"E")
 S BKMVPST=$$GET1^DIQ(2,DFN,.115,"E")
 S BKMVPZP=$$GET1^DIQ(2,DFN,.116,"E")
 S BKMVCNTY=$$GET1^DIQ(2,DFN,.117,"E")
 S BKMVADDL=BKMVADD1_"," D
 .I BKMVADD2'="" S BKMVADDL=BKMVADDL_BKMVADD2_","
 .I BKMVADD3'="" S BKMVADDL=BKMVADDL_BKMVADD3_","
 .I BKMVCITY'="" S BKMVADDL=BKMVADDL_BKMVCITY_","
 .I BKMVPST'="" S BKMVADDL=BKMVADDL_BKMVPST_"  "
 .I BKMVPZP'="" S BKMVADDL=BKMVADDL_"  "_BKMVPZP
 Q
PRACDIAG ;GATHER PROVIDER DATA
 S BKMPROV=$$GET1^DIQ(90451.01,"1,"_IEN,6,"I")
 I $G(IEN)]"",BKMPROV="" S BKMPROV=$$GET1^DIQ(90451.01,"1,"_IEN,6.5,"I")
 S BKMVPPH=$S(BKMPROV]"":$$GET1^DIQ(200,BKMPROV,.132,"E"),1:"")
 I BKMPROV]"" S BKMPROV=$$GET1^DIQ(200,BKMPROV,.01,"E")
 Q
QUE(DFN) ;QUEUE REPORT FOR PRINT/DISPLAY
 ;DFN is set to "" if a blank form is desired
 K %ZIS,IOP,IOC,ZTIO S %ZIS="MQ" D ^%ZIS G:POP XIT
 I $D(IO("Q")) D  G XIT
 .S ZTRTN="DQUE^BKMVSSR",ZTDESC="HMS STATE SURVEILLANCE REPORT"
 .S ZTSAVE("BKM*")="",ZTSAVE("DFN")="",ZTSAVE("IEN")=""
 .K IO("Q") D ^%ZTLOAD W:$D(ZTSK) !,"REQUEST QUEUED" H 2
DQUE ;ENTRY FROM QUEUE
 U IO
 I $G(DFN)="" G DQUE1 ; Skip DFN lookups if generating blank form.
 D FAC,PATDEMO,PRACDIAG
 D EN^BKMVSSR1 G:BKMX XIT
 D EN^BKMVSSR2 G:BKMX XIT
DQUE1 ;
 D EN^BKMVSSR3 G:BKMX XIT
 D EN^BKMVSSR4 G:BKMX XIT
 D EN^BKMVSSR5 G:BKMX XIT
 D EN^BKMVSSR6 G:BKMX XIT
 I IOST["C-" D
 .I $Y>(IOSL-4) D HDR^BKMVSSR3 Q:BKMX  D HDR1^BKMVSSR3
 .W !!?1,"**End of report**"
 .S BKMX=$$PAUSE^BKMIXX3
 Q
XIT ;KILL LOCALS AND EXIT
 D ^%ZISC
 K BKMVADD1,BKMVADD2,BKMVADD3,BKMVCITY,BKMVPST,BKMVPZP,BKMVETH
 K BKMPROV,BKMVPPH,BKMDIAG,BKMDT,BKMVDOB,BKMDDT
 K BKM,BKM0,BKM1,BKM2,BKMIEN,BKMHAART,BKMHDR,BKMHDR1,BKMX,BKMCC
 K BKMICD,BKMLINE,BKMLINE1,BKMLOC,BKMNDT,BKMPAD,BKMPCP,BKMCKDT
 K BKMSEC,BKMSICD,BKMVADDL,BKMVAGED,BKMVDOD,BKMVPOB
 K BKMVETO,BKMVHRN,BKMVLABS,BKMVNDT,BKMVPHN,BKMVCNTY
 K BKMVLAD,BKMVLAD1,BKMVLCTY,BKMVLN,BKMVLOC,BKMVLST,BKMVLZIP
 K BKMSIG,BKMQTY,BKMDAY,BKMVRCE,BKMVSDTH,BKMVSEX,BKMVSTAT,PAGE
 K POP,X,Y,DIR,DIWF,DIWL,DIWR,DTOUT,DUOUT,GLOBAL,IEN,%DT,%H,TYPE
 Q
 ;
EN1 ;EP - Secondary entry point from within REP action of Review/Edit Patient HMS Record Data option
 S BKMX=0
 S TYPE=$$TYPE()
 I $D(DTOUT)!$D(DUOUT) G XIT
 I TYPE="B" D QUE("") G XIT
 I $$CKAGE() G XIT
 D QUE(DFN)
 G XIT
TYPE() ;Type of report requested
 K DIR
 S DIR(0)="S^B:BLANK;P:PATIENT"
 S DIR("A")="     Type of form"
 S DIR("?",1)="  'B' to print a form with fields empty (fill-in-the-blank)"
 S DIR("?",2)="  'P' to print a form with fields filled in for a selected patient"
 S DIR("?")=" "
 D ^DIR
 Q $G(Y)
CKAGE() ;Call AGE subroutine and confirm eligibility for report
 D AGE
 I $G(BKMVAGED)<13 D  I BKMX Q 1
 . W !!,"Patient age at diagnosis less than 13.  Not a reportable case."
 . K DIR
 . S DIR(0)="YA"
 . S DIR("A")="Would you like to print a copy anyway (Y/N)? ",DIR("B")="N"
 . D ^DIR
 . I $D(DTOUT)!$D(DUOUT)!(Y=0) S BKMX=1
 Q ""