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

BKMVA1C.m

Go to the documentation of this file.
  1. BKMVA1C ;PRX/HC/DLS - HMS PATIENT REGISTER CONT;
  1. ;;2.1;HIV MANAGEMENT SYSTEM;;Feb 07, 2011
  1. ;
  1. ; Prompts and functions related to BKMVA1
  1. Q
  1. ;
  1. REGDC(DFN) ;EP - Called by LDREC^BKMVA1B
  1. ; Determine HMS Diagnosis Category for Register/Add or PAT/REC/ED, based on HIV, AIDS, and CD4 Absolute criteria.
  1. ; Note: This logic is based on the following statement...
  1. ; 1. Patient must have at least 2 diags not on the same day of HIV Positive (DX.6);
  1. ; AND
  1. ; 2. If current CD4 Absolute (T.30) count is below 200'
  1. ; OR
  1. ; 3. Patient has at least one diagnosis of Other AIDS Defining Illness (DX.1)
  1. ; since the first HIV/AIDS diagnosis;
  1. ; Then
  1. ; Proposed Diagnosis is AIDS;
  1. ; Else
  1. ; Proposed Diagnosis is HIV.
  1. ; Currently, this statement is being interpreted to mean:
  1. ; IF (1 and (2 or 3)) --> AIDS
  1. ;
  1. ; If this logic is changed, only REGDC should be affected.
  1. ; HIV,AIDS,andCD4AB should be able to remain the same.
  1. ;
  1. N FLG,RSLT,FLAG
  1. ; Default is HIV
  1. S RSLT="",DIAGCAT="",HAIDSDT="",IAIDSDT=""
  1. ; Do HIV and set FLG("H") to result.
  1. S FLAG("H")=$$HIV(DFN)
  1. ; If not HIV, you don't need to go any further. Quit
  1. I 'FLAG("H") Q
  1. ; Do AIDS and set FLG("A") to result.
  1. S FLAG("A")=$$AIDS(DFN)
  1. ; If not AIDS, check for CD4 Absolute
  1. I 'FLAG("A") S FLAG("C")=$$CD4AB(DFN)
  1. ; If HIV and (AIDS or CD4 Absolute) set the final result to "A" (for AIDS).
  1. I FLAG("H") S RSLT="H"
  1. I FLAG("A")!$G(FLAG("C")) S RSLT="A"
  1. K ^TMP("BKMAIDS",$J),^TMP("BKMHIV",$J),^TMP("BKMCD4",$J),^TMP("BKMTST",$J),^TMP("BKMCD4AB",$J),^TMP("BKMHIVP",$J),^TMP("BKMCD4P",$J)
  1. S DIAGCAT=RSLT
  1. Q
  1. ;
  1. HIV(DFN) ; (DX.6) See if patient has 2 HIV diagnoses on differing days.
  1. ;
  1. N HIDX,HIEN,HIVDT,VISIT,CHK,FLG
  1. S HIDX="",FLG=0
  1. F S HIDX=$O(^TMP("BKMHIV",$J,HIDX)) Q:HIDX="" D
  1. . ; First check the POV's
  1. . S HIEN=""
  1. . F S HIEN=$O(^AUPNVPOV("B",HIDX,HIEN)) Q:(HIEN="")!(FLG) D
  1. .. I $P(^AUPNVPOV(HIEN,0),U,2)=DFN D
  1. ... S VISIT=$$GET1^DIQ(9000010.07,HIEN,.03,"I")
  1. ... I VISIT D
  1. .... S HIVDT=$P($$GET1^DIQ(9000010,VISIT,.01,"I"),".",1)
  1. .... I $D(^TMP("BKMHIVP",$J,DFN,HIVDT)) Q
  1. .... S ^TMP("BKMHIVP",$J,DFN,HIVDT)=""
  1. .... S ^TMP("BKMHIVP",$J,DFN)=$G(^TMP("BKMHIVP",$J,DFN))+1
  1. .... ;I $O(^TMP("BKMHIVP",$J,DFN,""))=$O(^TMP("BKMHIVP",$J,DFN,""),-1) S FLG=1
  1. . ; Now check the Problem List.
  1. . S HIEN=""
  1. . F S HIEN=$O(^AUPNPROB("B",HIDX,HIEN)) Q:(HIEN="")!(FLG) D
  1. .. I $P(^AUPNPROB(HIEN,0),U,2)=DFN D
  1. ... S HIVDT=$P($$PROB^BKMVUTL(HIEN),".")
  1. ... I $D(^TMP("BKMHIVP",$J,DFN,HIVDT)) Q
  1. ... S ^TMP("BKMHIVP",$J,DFN)=$G(^TMP("BKMHIVP",$J,DFN))+1
  1. ... ;I $O(^TMP("BKMHIVP",$J,DFN,""))=$O(^TMP("BKMHIVP",$J,DFN,""),-1) S FLG=1
  1. I $G(^TMP("BKMHIVP",$J,DFN))>1 S FLG=1
  1. Q FLG
  1. ;
  1. AIDS(DFN) ; (DX.1) See if patient has at least one AIDS Defining Illness since first HIV/AIDS diagnosis. If so, set FLG=1
  1. ;
  1. N AIDX,AIEN,VISIT,FLG
  1. ; Get Initial HIV/AIDS date from ^TMP("BKMHIVP"). If null, quit.
  1. S HAIDSDT=$O(^TMP("BKMHIVP",$J,DFN,""))
  1. S FLG=0,AIDX=""
  1. F S AIDX=$O(^TMP("BKMAIDS",$J,AIDX)) Q:(AIDX="")!(FLG) D
  1. . S AIEN=""
  1. . F S AIEN=$O(^AUPNVPOV("B",AIDX,AIEN)) Q:(AIEN="")!(FLG) D
  1. .. I $P(^AUPNVPOV(AIEN,0),U,2)=DFN D
  1. ... S VISIT=$$GET1^DIQ(9000010.07,AIEN,.03,"I") Q:VISIT=""
  1. ... S IAIDSDT=$P($$GET1^DIQ(9000010,VISIT,.01,"I"),".")
  1. ... ; If AIDS Defining Illness date is after Initial HIV/AIDS Diagnosis Date, set FLG=1.
  1. ... I IAIDSDT>HAIDSDT S FLG=1
  1. Q FLG
  1. ;
  1. CD4AB(DFN) ; (T.30) Accumulate all CD4 Absolute result and see if the most recent CD4 Absolute result is less than 200 (and not null). If so, set FLG=1.
  1. ;
  1. NEW LAB,LIEN,RESULT,RDATE,VISDTM,LSTTST,FLG
  1. S LAB="",FLG=0
  1. F S LAB=$O(^TMP("BKMCD4AB",$J,LAB)) Q:LAB="" D
  1. . S LIEN=""
  1. . F S LIEN=$O(^AUPNVLAB("B",LAB,LIEN),-1) Q:(LIEN="") D
  1. .. I $P(^AUPNVLAB(LIEN,0),U,2)=DFN D
  1. ... S RESULT=$$GET1^DIQ(9000010.09,LIEN,.04,"E")
  1. ... S RDATE=$$GET1^DIQ(9000010.09,LIEN,1212,"I")
  1. ... I 'RDATE S VISIT=$$GET1^DIQ(9000010.09,LIEN,.03,"I") Q:VISIT="" D
  1. .... S VISDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")
  1. ... I RESULT'="" D
  1. .... I RDATE S ^TMP("BKMCD4P",$J,RDATE)=RESULT
  1. .... I 'RDATE,VISDTM S ^TMP("BKMCD4P",$J,VISDTM)=RESULT
  1. S LSTTST=$O(^TMP("BKMCD4P",$J,""),-1)
  1. I LSTTST'="",^TMP("BKMCD4P",$J,LSTTST)<200 S FLG=1
  1. Q FLG
  1. ;
  1. XIT K DIAGCAT,HAIDSDT,IAIDSDT
  1. Q
  1. ;
  1. OPT() ;EP - Called by REPORTS^BKMVA1
  1. ;Select reports to print
  1. N DIR,X,Y,DTOUT,DUOUT,BKMCHK
  1. ;
  1. OPT1 ;
  1. S BKMCHK=0
  1. K DIR
  1. S DIR(0)="FO"
  1. S DIR("A")="Select Patient Report"
  1. S DIR("A",1)=" "
  1. S DIR("A",2)=" Select one of the following:"
  1. S DIR("A",3)=" "
  1. S DIR("A",4)=" DO Due/OverDue"
  1. S DIR("A",5)=" QC Quality of Care Audit Report"
  1. S DIR("A",6)=" SUPP HMS Supplement"
  1. S DIR("A",7)=" HS Health Summary"
  1. S DIR("A",8)=" BOTH Both Health Summary and Supplement"
  1. S DIR("A",9)=" SSR State Surveillance Report"
  1. S DIR("A",10)=" "
  1. S DIR("?")=" "
  1. S DIR("?",1)=" Enter DO to select the Due/OverDue Report"
  1. S DIR("?",2)=" Enter QC to select the Quality of Care Audit Report"
  1. S DIR("?",3)=" Enter SUPP to select the HMS Supplement"
  1. S DIR("?",4)=" Enter HS to select the Health Summary"
  1. S DIR("?",5)=" Enter BOTH to select both the Health Summary and the HMS Supplement"
  1. S DIR("?",6)=" Enter SSR to select the State Surveillance Report"
  1. S DIR("?",7)=" "
  1. S DIR("?",8)=" When BOTH is selected the HMS Supplement will display after the"
  1. S DIR("?",9)=" Health Summary has completed."
  1. D ^DIR K DIR
  1. I $D(DTOUT)!$D(DUOUT)!(Y="") Q ""
  1. S Y=$$UP^XLFSTR(Y)
  1. ; Special case where user enters 'H' or 'h' redisplay as ambiguous
  1. I Y="H" D I Y="" G OPT1
  1. .S DIR(0)="SO^1:HMS Supplement;2:Health Summary"
  1. .K DIR("A")
  1. .S DIR("A")="Select the report option"
  1. .K DIR("B"),DIR("?")
  1. .S DIR("?")=" "
  1. .S DIR("?",1)=" Enter 1 to select the HMS Supplement"
  1. .S DIR("?",2)=" Enter 2 to select the Health Summary"
  1. .D ^DIR K DIR
  1. .I $D(DUOUT)!$D(DTOUT)!(Y="") S Y="" Q
  1. .S Y=$S(Y=1:"SUPP",1:"HS"),BKMCHK=1
  1. .;
  1. ; Special case where user enters 'S' or 's' redisplay as ambiguous
  1. I Y="S" D I Y="" G OPT1
  1. .S DIR(0)="SO^1:HMS Supplement;2:State Surveillance Report"
  1. .K DIR("A")
  1. .S DIR("A")="Select the report option"
  1. .K DIR("B"),DIR("?")
  1. .S DIR("?")=" "
  1. .S DIR("?",1)=" Enter 1 to select the HMS Supplement"
  1. .S DIR("?",2)=" Enter 2 to select the State Surveillance Report"
  1. .D ^DIR K DIR
  1. .I $D(DUOUT)!$D(DTOUT)!(Y="") S Y="" Q
  1. .S Y=$S(Y=1:"SUPP",1:"SSR"),BKMCHK=1
  1. .;
  1. I '$F("^DO^QC^SUPP^HS^BOTH^SSR^",U_Y_U) D
  1. .I $L(Y)<4,$E("DO",1,$L(Y))=Y S Y="DO" Q
  1. .I $L(Y)<4,$E("QC",1,$L(Y))=Y S Y="QC" Q
  1. .I $L(Y)<4,$E("SUPP",1,$L(Y))=Y S Y="SUPP" Q
  1. .I $L(Y)<4,$E("HS",1,$L(Y))=Y S Y="HS" Q
  1. .I $L(Y)<4,$E("BOTH",1,$L(Y))=Y S Y="BOTH" Q
  1. .I $L(Y)<4,$E("SSR",1,$L(Y))=Y S Y="SSR" Q
  1. .I $L(Y)>0,$E("DUE/OVERDUE",1,$L(Y))=Y S Y="DO" Q
  1. .I $L(Y)>0,$E("QUALITY OF CARE AUDIT REPORT",1,$L(Y))=Y S Y="QC" Q
  1. .I $L(Y)>0,$E("HMS SUPPLEMENT",1,$L(Y))=Y S Y="SUPP" Q
  1. .I $L(Y)>0,$E("HEALTH SUMMARY",1,$L(Y))=Y S Y="HS" Q
  1. .I $L(Y)>0,$E("BOTH HEALTH SUMMARY AND SUPPLEMENT",1,$L(Y))=Y S Y="BOTH" Q
  1. .I $L(Y)>0,$E("STATE SURVEILLANCE REPORT",1,$L(Y))=Y S Y="SSR" Q
  1. I '$F("^DO^QC^SUPP^HS^BOTH^SSR^",U_Y_U) W !!?2,"Please enter a code or description from the list.",!! G OPT1
  1. I 'BKMCHK W " ",$S(Y="DO":"Due/Overdue",Y="QC":"Quality of Care Audit Report",Y="SUPP":"HMS Supplement",Y="HS":"Health Summary",Y="BOTH":"Both Health Summary and Supplement",1:"State Surveillance Report")
  1. Q Y