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

BHSNRS.m

Go to the documentation of this file.
BHSNRS ;IHS/MSC/MGH - Health Summary for NRS and imaging ;08-Dec-2010 13:34;DU
 ;;1.0;HEALTH SUMMARY COMPONENTS;**4**;March 17, 2006;Build 13
 ;==============================================================
 ; IHS/CMI/LAB - PART 8 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;
 ;;2.0;IHS PCC SUITE;**2**;MAY 14, 2009
 ;
NRS ; ******************* NRS  - LAST 3  * 9000010.49 *******
 ; <SETUP>
 N BHSPAT,BHSCNT,BHSEX
 S BHSPAT=DFN
 Q:'$D(^AUPNVNTS("AA",BHSPAT))
 ; <DISPLAY>
 D NRDSP3
 ; <CLEANUP>
 K BHST,BHSFN
NRS3X K BHST,BHSTX,BHSTL,BHSIVD,BHSDFN,BHSRDG,BHSVDF,BHSDAT,BHSCNT,BHS,X,Y
 K BHSNFL,BHSNSH,BHSNAB,BHSVSC,BHSITE,BHRISK,BHSPR,BHSQ,BHSREF,BHSX,C,MIEN
 Q
NRDSP3 ;get NRS type
 D CKP^GMTSUP Q:$D(GMTSQIT)
 W ?1,"DATE",?12,"PROVIDER",?32,"RISK",?72,"RD ",!?72,"REFERRAL",!!
 S BHSCNT=0,BHSEX=0
 F  S BHSEX=$O(^AUPNVNTS("AA",BHSPAT,BHSEX)) Q:BHSEX'=+BHSEX!($D(GMTSQIT))!(BHSCNT>3)  D
 .S BHSIVD="" F BHSQ=0:0 S BHSIVD=$O(^AUPNVNTS("AA",BHSPAT,BHSEX,BHSIVD)) S BHSCNT=BHSCNT+1 Q:BHSIVD=""!(BHSCNT>3)!($D(GMTSQIT))  D NRDSP13
 Q
NRDSP13 ;get NRS test DFN
 S X=-BHSIVD\1+9999999 D REGDT4^GMTSU S BHSDAT=X
 S BHSDFN=0 F BHSQ=0:0 S BHSDFN=$O(^AUPNVNTS("AA",BHSPAT,BHSEX,BHSIVD,BHSDFN)) Q:'BHSDFN!(BHSCNT>3)!($D(GMTSQIT))  D NRDSP23
 Q
NRDSP23 ;compile data & display NRS test
 S X=-BHSIVD\1+9999999 D REGDT4^GMTSU S BHSDAT=X
 Q:'$D(^AUPNVNTS(BHSDFN,0))
 S BHSPR=$E($$VAL^XBDIQ1(9000010.49,BHSDFN,1204),1,18)
 S BHSREF=$S($P(^AUPNVNTS(BHSDFN,0),U,15):"Yes",1:"No")
 S BHRISK=$$VAL^XBDIQ1(9000010.49,BHSDFN,.14) I BHRISK]"" S BHRISK=BHRISK_": "
 S C=0 I $P(^AUPNVNTS(BHSDFN,0),U,4) S C=C+1 S:C>1 BHRISK=BHRISK_"; " S BHRISK=BHRISK_"Age 70+"
 I $P(^AUPNVNTS(BHSDFN,0),U,5) S C=C+1 S:C>1 BHRISK=BHRISK_"; " S BHRISK=BHRISK_"Nut Supp"
 I $P(^AUPNVNTS(BHSDFN,0),U,6) S C=C+1 S:C>1 BHRISK=BHRISK_"; " S BHRISK=BHRISK_"Weight"
 I $P(^AUPNVNTS(BHSDFN,0),U,7) S C=C+1 S:C>1 BHRISK=BHRISK_"; " S BHRISK=BHRISK_"Diagnosis"
 I $P(^AUPNVNTS(BHSDFN,0),U,8) S C=C+1 S:C>1 BHRISK=BHRISK_"; " S BHRISK=BHRISK_"Appetite"
 I $P(^AUPNVNTS(BHSDFN,0),U,9) S C=C+1 S:C>1 BHRISK=BHRISK_"; " S BHRISK=BHRISK_"Diff Chew"
 I $P(^AUPNVNTS(BHSDFN,0),U,10) S C=C+1 S:C>1 BHRISK=BHRISK_"; " S BHRISK=BHRISK_"Food Aller/Intol"
 I $P(^AUPNVNTS(BHSDFN,0),U,11) S C=C+1 S:C>1 BHRISK=BHRISK_"; " S BHRISK=BHRISK_"Vom/Diarr"
 I $P(^AUPNVNTS(BHSDFN,0),U,12) S C=C+1 S:C>1 BHRISK=BHRISK_"; " S BHRISK=BHRISK_"Other: "_$P(^AUPNVNTS(BHSDFN,0),U,13)
 D CKP^GMTSUP Q:$D(GMTSQIT)
 W ?1,BHSDAT,?12,BHSPR
 K ^UTILITY($J,"W") S X=BHRISK,DIWL=0,DIWR=40 D ^DIWP
 W ?32,^UTILITY($J,"W",0,1,0)
 W ?74,BHSREF,!
 F BHSX=2:1:$G(^UTILITY($J,"W",0)) D  Q:$D(GMTSQIT)
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W ?32,^UTILITY($J,"W",0,BHSX,0),!
 K ^UTILITY($J)
 Q
 ;
IMAGING ; EP FOR NEW COMPONENT
 S BHSPAT=DFN
 Q:'$D(^RADPT(BHSPAT))
 D CKP^GMTSUP Q:$D(GMTSQIT)
 K BHSARR
 D SVR(BHSPAT,$S(GMTSNDM=-1:9999999,1:GMTSNDM),$S(GMTSDLM=9999999:0,1:(9999999-GMTSDLM)),.BHSARR)
 D PRINT(.BHSARR)
 K BHSARR
 Q
SVR(DFN,MAX,START,LINE) ; RADIOLOGY REPORTS
 I $G(DFN),$G(MAX),$G(START)]""
 E  Q
 N X,Y,Z,T,%,IDT,IDT2,EDT,GBL,PCC,RIEN,ARR,EXDT
 N CASE,ESTAT,PRIEN,RCIEN,RDFN,RDOC,RSTAT,CNT,CPT,CPTIEN,MOD,PCE,PMIEN,PROC,TAB,TOT
 S IDT=0,T="~",CNT=0
 S IDT2=9999999-START
 S GBL=$NA(^RADPT(DFN,"DT"))
RPASS1 ;
 F  Q:CNT>MAX  S IDT=$O(@GBL@(IDT)) Q:'IDT  Q:IDT>IDT2  D
 . S EDT=+$G(@GBL@(IDT,0)) I 'EDT Q
 . S EXDT=$$FMTE^XLFDT(EDT,2),EXDT=$TR(EXDT,"@"," "),EXDT=$P(EXDT,":",1,2)
 . S RCIEN=0
 . F  S RCIEN=$O(@GBL@(IDT,"P",RCIEN)) Q:'RCIEN  D
 .. S X=$G(@GBL@(IDT,"P",RCIEN,0)) I X="" Q
 .. S RIEN=$P(X,U,17) I RIEN="" Q
 .. S RSTAT="",%=$P($G(^RARPT(RIEN,0)),U,5)
 .. I $L(%) S RSTAT=$S(%="V":"VERIFIED",%="R":"RELEASED/NOT VERIFIED",%="PD":"PROBLEM DRAFT",%="D":"DRAFT",1:"")
 .. S CNT=CNT+1 ; DONT WORRY ABOUT THE COUNT UNTIL THE NEXT DATE
 .. S CASE=$P(X,U) I CASE="" Q
 .. S ESTAT="",%=$P(X,U,3) ; NEEDS TRANSLATION
 .. I % S ESTAT=$P($G(^RA(72,%,0)),U)
 .. S RDFN=$P(X,U,15),RDOC=""
 .. I RDFN S RDOC=$P($G(^VA(200,RDFN,0)),U)
 .. S PRIEN=$P(X,U,2) I 'PRIEN Q
 .. S Y=$G(^RAMIS(71,PRIEN,0)) I Y="" Q
 .. S PROC=$P(Y,U) I PROC="" Q
 .. S CPTIEN=+$P(Y,U,9)
 .. S CPT=$P($G(^ICPT(CPTIEN,0)),U)
 .. S MIEN=0,MOD=""
 .. F  S MIEN=$O(@GBL@(IDT,"P",RCIEN,"M",MIEN)) Q:'MIEN  D
 ... S PMIEN=+$G(@GBL@(IDT,"P",RCIEN,"M",MIEN,0)) I 'PMIEN Q
 ... S %=$P($G(^RAMIS(71.2,PMIEN,0)),U) I %="" Q
 ... I MOD'="" S MOD=MOD_", "
 ... S MOD=MOD_%
 ... Q
 .. S ARR(CNT)=EXDT_T_PROC_T_MOD_T_CPT_T_RDOC_T_CASE_T_ESTAT_T_RSTAT
 .. S Z=0
 .. F  S Z=$O(@GBL@(IDT,"P",RCIEN,"H",Z)) Q:'Z  S ARR(CNT,"H",Z)=$G(@GBL@(IDT,"P",RCIEN,"H",Z,0)) ; HX
 .. S Z=0
 .. F  S Z=$O(^RARPT(RIEN,"R",Z)) Q:'Z  S ARR(CNT,"R",Z)=$G(^RARPT(RIEN,"R",Z,0)) ; REPORT
 .. S Z=0
 .. F  S Z=$O(^RARPT(RIEN,"I",Z)) Q:'Z  S ARR(CNT,"I",Z)=$G(^RARPT(RIEN,"I",Z,0)) ; IMPRESSION
 .. Q
 . Q
RPASS2 ;
 S ARR="HEADER"_T_"Procedure: "_T_"Procedure Modifier: "_T_"CPT Code: "_T_"Interpreting Staff: "_T_"Exam Case Number: "_T_"Exam Status: "_T_"Report Status: "
 S CNT=0,LINE(1)="-----  IMAGING PROFILE  -----",LINE=1,TAB="  "
 F  S CNT=$O(ARR(CNT)) Q:'CNT  D
 . S TOT=$L(ARR(CNT),T) I 'TOT Q
 . F PCE=1:1:TOT D
 .. I PCE=1 S X=$P(ARR(CNT),T,1)_"  "_$P(ARR(CNT),T,2),PCE=2
 .. E  S X=TAB_$P(ARR,T,PCE)_$P(ARR(CNT),T,PCE)
 .. S LINE=LINE+1
 .. S LINE(LINE)=X
 .. Q
 . S LINE=LINE+1,LINE(LINE)=" ",LINE=LINE+1
 . S LINE(LINE)=TAB_"History: "
 . S Z=0
 . F  S Z=$O(ARR(CNT,"H",Z)) Q:'Z  D
 .. S LINE=LINE+1
 .. S LINE(LINE)=TAB_"  "_ARR(CNT,"H",Z)
 .. Q
 . S LINE=LINE+1,LINE(LINE)=" ",LINE=LINE+1
 . S LINE(LINE)=TAB_"Report: "
 . S Z=0
 . F  S Z=$O(ARR(CNT,"R",Z)) Q:'Z  D
 .. S LINE=LINE+1
 .. S LINE(LINE)=TAB_"  "_ARR(CNT,"R",Z)
 .. Q
 . S LINE=LINE+1,LINE(LINE)=" ",LINE=LINE+1
 . S LINE(LINE)=TAB_"Impression: "
 . S Z=0
 . F  S Z=$O(ARR(CNT,"I",Z)) Q:'Z  D
 .. S LINE=LINE+1
 .. S LINE(LINE)=TAB_"  "_ARR(CNT,"I",Z)
 .. Q
 . Q
 Q
 ;
PRINT(LINE) ; EP-PRINT RESULTS
 N CNT
 S CNT=0
 F  S CNT=$O(LINE(CNT)) Q:'CNT  D  I $D(GMTSQIT) Q
 . ;W !
 . D CKP^GMTSUP Q:$D(GMTSQIT)
 . S X=$G(LINE(CNT))
 . D WP(X)
 . Q
 Q
WP(X) ;Do word wrap
 N DIWF,DIWL,DIWR
 S DIWF="",DIWL=0,DIWR=75
 D ^DIWP
 S RAX=0 F  S RAX=$O(^UTILITY($J,"W",DIWL,RAX)) Q:RAX'>0  D
 .I RAX=1 W ?5,^UTILITY($J,"W",DIWL,RAX,0),!
 .I RAX>1 W ?9,^UTILITY($J,"W",DIWL,RAX,0),!
 K ^UTILITY($J,"W")
 Q
 ;