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

BKMQSSR.m

Go to the documentation of this file.
BKMQSSR ;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
 ; This report is generated for the supplied list of DFNs (PLIST)
 ; (the blank form option is not supported here)
EN(DATA,PLIST) ;EP - PRIMARY REPORT ENTRY POINT
 ; values for DATA and PLIST are supplied by the calling routine
 ; 
 ; Check taxonomies - added per bugzilla #1497
 ; This will be accomplished through an RPC call to BQITAXX
 N GLOB,CNT,DENPOP,BKMX,BQII,LIST,II,DFN
 N BKMLOC,BKMVLOC,BKMVLAD,BKMVLAD1,BKMVLST,BKMVLCTY,BKMVLZIP ; FAC variables
 ;
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BKMQSSR D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ; Age at diagnosis check will be performed before calling this report
 ;I $$CKAGE() G XIT
 S BQII=0
 S PLIST=$G(PLIST,"")
 I PLIST="" D
 . S LIST="",BN=""
 . F  S BN=$O(PLIST(BN)) Q:BN=""  S LIST=LIST_PLIST(BN)
 . K PLIST
 . S PLIST=LIST
 . K LIST
 I PLIST'="" D FAC
 F II=1:1 S DFN=$P(PLIST,$C(28),II) Q:DFN=""  D GDATA D UPD^BKMQUTL($C(12),,1)
 I PLIST="" D
 . N LNLEN,LINE,X
 . N APCHSPAT,APCHSTYP
 . S LNLEN=80
 . D HDR,DQUE1 ;***
 S BQII=BQII+1,@DATA@(BQII)=$C(30)
 G DONE
 ;
GDATA ; Retrieve patient information
 N BKMDDT,BKMVDOB,BKMVDOD,IEN,BKMDIAG,BKMVAGED,BKMLINE
 N BKMVSEX,BKMVSDTH,BKMVSTAT,BKMVHRN,BKMVRCE,BKMVETH
 N BKMVPHN,BKMVPOB,BKMVADD1,BKMVADD2,BKMVADD3,BKMVCITY,BKMVPST
 N BKMVPZP,BKMVCNTY,BKMVADDL
 N BKMPROV,BKMVPPH
 N BKMHDR,BKMPAD,BKMHDR1,PAGE,BKMX,BKM1,BKMLINE1,BKMSEC
 N BKM0,BKMDT,BKM2,BKMCC,BKMNDT,BKM,BN
 N BKMVETO,BKMCKDT,BKMVNDT,BKMVLN,BKMIEN,BKMSIG,BKMQTY,BKMDAY
 N BKMVLABS,BKMICD,BKMSICD,BKMHAART,BKMPCP
 D AGE
 ;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'="" S BKMDIAG=$$GET1^DIQ(90451.01,"1,"_IEN,2.3,"E")
 I 'BQII D HDR
 S BKMX=0
 D QUE(DFN)
 Q
 ;
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
DQUE ;ENTRY FROM QUEUE
 N LNLEN,LINE,X
 N APCHSPAT,APCHSTYP
 ;
 S LNLEN=80 ; 80 Character display - currently hardcoded - could be a parameter
 ;D FAC,PATDEMO,PRACDIAG
 D PATDEMO,PRACDIAG
 D EN^BKMQSSR1 ;G:BKMX XIT
 D EN^BKMQSSR2 ;G:BKMX XIT
DQUE1 ;
 D EN^BKMQSSR3 ;G:BKMX XIT
 D EN^BKMQSSR4 ;G:BKMX XIT
 D EN^BKMQSSR5 ;G:BKMX XIT
 D EN^BKMQSSR6 ;G:BKMX XIT
 Q
XIT ;KILL LOCALS AND EXIT
 ;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
 ;
CKAGE() ;Call AGE subroutine and confirm eligibility for report
 D AGE
 ; *** The following will have to be handled differently since look-up will take place before accessing this
 I $G(BKMVAGED)<13 D  Q 1
 . S BMXSEC="Patient age at diagnosis less than 13.  Not a reportable case."
 Q ""
 ;
HDR ;
 S @DATA@(BQII)="T00120REPORT_TEXT"_$C(30)
 Q
DONE ;
 S BQII=BQII+1,@DATA@(BQII)=$C(31)
 Q
 ;
ERR ;
 D ^%ZTER
 N Y,ERRDTM
 S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
 S BMXSEC="Recording that an error occurred at "_ERRDTM
 Q