- RORX025 ;ALB/TK,MAF - HEP B VACCINE OR IMMUNITY REPORT ;4/21/16 9:40am
- ;;1.5;CLINICAL CASE REGISTRIES;**29,31,33,34**;Feb 17, 2006;Build 45
- ;
- ;******************************************************************************
- ;******************************************************************************
- ; --- ROUTINE MODIFICATION LOG ---
- ;
- ;PKG/PATCH DATE DEVELOPER MODIFICATION
- ;----------- ---------- ----------- ----------------------------------------
- ;ROR*1.5*29 APR 2016 T KOPP Added 'Hep B vaccine or immunity report'
- ;ROR*1.5*31 MAY 2017 M FERRARESE Adding PACT, PCP, and AGE/DOB as additional
- ; identifiers.
- ;ROR*1.5*33 MAR 2018 M FERRARESE Adding FUTURE APPOINTMENT as additional identifiers.
- ;ROR*1.5*34 SEP 2018 M FERRARESE Adding Future Appointment clinic name ; Fix LOINC code table for HEP A/B
- ;******************************************************************************
- ;******************************************************************************
- ;
- ;***** COMPILES THE "HEP B VACCINE OR IMMUNITY" REPORT
- ; REPORT CODE: 025
- ;
- ; .RORTSK Task number and task parameters
- ;
- ; The ^TMP("RORX025",$J) global node is used by this function.
- ;
- ; ^TMP("RORX025",$J,
- ; "PAT",
- ; DFN, Patient descriptor
- ; ^01: Last 4 digits of SSN
- ; ^02: Patient name
- ; ^03: Date of Death
- ; ^04: ICN
- ; ^05: Patient Care Team
- ; ^06: Priamary Care Provider
- ; ^07: Age/DOB
- ; ^08: Future Appt date
- ; ^09: Future Appt Clinic
- ; "IMM") Result if positive test found or "" if no positive test found
- ; ^01: Local lab test name
- ; ^02: Collected date (FM)
- ; ^03: Lab test result
- ; "VAC", Number of results
- ; ^01: #
- ; VaccineName,
- ; VaccineDate) Always null if node exists
- ; ^01: Null
- ;
- ; Return Values:
- ; <0 Error code
- ; 0 Ok
- ;
- HEPBRPT(RORTSK) ;
- N RORIMM ; Immunity wanted mode (-1|0|1) no|not selected|yes (verified by lab test)
- N RORVAC ; Vaccination (-1|0|1) not received|not selected|received (verified by immunization record)
- N RORREG ; Registry IEN
- N RORVEDT ; Vaccination end date
- N RORVSDT ; Vaccination start date
- N RORLEDT ; Lab test/LOINC end date
- N RORLSDT ; Lab test/LOINC start date
- N RORRTN ; Routine to invoke for hep B processing
- N RORDAYS ; Future Days patch 33
- N RORFUT ; Future Appointment patch 33 & 34
- N RORCLIN ; Future Appointment clinic patch 34
- ;
- N NSPT,RC,REPORT,SFLAGS,TMP
- S RC=0,RORRTN="RORX025"
- K ^TMP(RORRTN,$J)
- ;--- Root node of the report
- S REPORT=$$ADDVAL^RORTSK11(RORTSK,"REPORT")
- Q:REPORT<0 REPORT
- ;
- D
- . ;--- Get and prepare the report parameters
- . S RORREG=$$PARAM^RORTSK01("REGIEN") ; Registry IEN
- . S RORVAC=$$RPTMODE^RORX024("HEPBVAC") ; Vaccination option chosen
- . S RORIMM=$$RPTMODE^RORX024("HEPBIMM") ; Immunity option chosen
- . S RC=$$PARAMS(REPORT,.RORVSDT,.RORVEDT,.SFLAGS) Q:RC<0
- . ;--- Report header
- . S RC=$$HEADER(REPORT) Q:RC<0
- . ;--- Query the registry
- . D TPPSETUP^RORTSK01(80)
- . S RC=$$QUERY^RORX024A(SFLAGS,.NSPT,RORRTN)
- . I RC Q:RC<0
- . ;--- Store the results
- . D TPPSETUP^RORTSK01(20)
- . S RC=$$STORE^RORX024A(REPORT,NSPT,RORRTN)
- . I RC Q:RC<0
- ;
- ;--- Cleanup
- K ^TMP(RORRTN,$J)
- Q $S(RC<0:RC,1:0)
- ;
- ;
- ;
- ;***** OUTPUTS THE REPORT HEADER
- ;
- ; PARTAG Reference (IEN) to the parent tag
- ;
- ; Return Values:
- ; <0 Error code
- ; >0 IEN of the HEADER element
- ;
- ;;PATIENTS(#,NAME,LAST4,DOD,VAC_NAME,VAC_DATE,LTNAME,DATE,RESULT,ICN,PACT,PCP,FUT_APPT,FUT_CLIN)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
- ;;PATIENTS(#,NAME,LAST4,AGE,DOD,VAC_NAME,VAC_DATE,LTNAME,DATE,RESULT,ICN,PACT,PCP,FUT_APPT,FUT_CLIN)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
- ;;PATIENTS(#,NAME,LAST4,DOB,DOD,VAC_NAME,VAC_DATE,LTNAME,DATE,RESULT,ICN,PACT,PCP,FUT_APPT,FUT_CLIN)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
- ;
- N HEADER,LN,RC,CTAG,LTAG
- S HEADER=$$HEADER^RORXU002(.RORTSK,PARTAG)
- Q:HEADER<0 HEADER
- ;automatically build the table defintion(s) listed under the header tag above PATCH 33
- ;--- LOINC codes output
- I $G(RORIMM) D
- . S LTAG=$$ADDVAL^RORTSK11(RORTSK,"LOINC_CODES",,PARTAG)
- . S LN=0 F S LN=$O(^TMP("RORX025",$J,"IMM","TYPE",LN)) Q:'LN D
- . . S CTAG=$$ADDVAL^RORTSK11(RORTSK,"CODE",,LTAG)
- . . D ADDATTR^RORTSK11(RORTSK,CTAG,"CODE",^TMP("RORX025",$J,"IMM","TYPE",LN))
- S RC=$$TBLDEF^RORXU002("HEADER^RORX025",HEADER)
- Q $S(RC<0:RC,1:HEADER)
- ;
- ;***** OUTPUTS THE PARAMETERS TO THE REPORT
- ;
- ; PARTAG Reference (IEN) to the parent tag
- ;
- ; [.STDT] Start and end dates of the report
- ; [.ENDT] are returned via these parameters
- ;
- ; [.FLAGS] Flags for the $$SKIP^RORXU005 are
- ; returned via this parameter
- ;
- ; Return Values:
- ; <0 Error code
- ; >0 IEN of the PARAMETERS element
- ;
- PARAMS(PARTAG,STDT,ENDT,FLAGS) ;
- N PARAMS,TMP
- S PARAMS=$$PARAMS^RORXU002(.RORTSK,PARTAG,,,.FLAGS)
- Q:PARAMS<0 PARAMS
- ;--- Process the list of Lab tests/LOINC codes
- I $G(RORIMM) D
- . D GETIMM^RORX024("RORX025") ;extract the immunity criteria for HEP B
- ;--- Process the list of vaccinations
- I $G(RORVAC) D
- . D GETVAC^RORX024("RORX025") ;extract the vaccine criteria for HEP B
- ;---
- Q PARAMS
- ;
- ; -- LOINC codes to check for HEP B immunity
- IMMUNITY ; LOINC codes indicating HEP B immunity results by type Line +1 = Surface AB (priority), Line +2 = Core AB
- ;;Surface AB^22322-2^10900-9^16935-9^5193-8^5194-6^22323-0^32019-2
- ;;Core AB^32685-0^22318-0^13919-6^16933-4^13952-7^22316-4^5187-0^5188-8^22317-2^21005-4
- ;;
- Q
- ;
- ; -- List of Hep B vaccines to include
- VACCINE ; Hepatitis B vaccine names (% = wild card)
- ;;%ENGERIX-B%^%HEP B%^%HEPATITIS B%^HEPATITIS-B%^HEPB%^HEP A&B^HEPA/HEPB%^%HEP A/B%^HEPAB%^HEPATITIS A & B%^HEPATITIS A&B%
- ;;HEPATITIS A/B^HEPATITIS AB^TWINRIX%
- ;;
- Q
- ;
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORX025 6497 printed Mar 13, 2025@20:49:43 Page 2
- RORX025 ;ALB/TK,MAF - HEP B VACCINE OR IMMUNITY REPORT ;4/21/16 9:40am
- +1 ;;1.5;CLINICAL CASE REGISTRIES;**29,31,33,34**;Feb 17, 2006;Build 45
- +2 ;
- +3 ;******************************************************************************
- +4 ;******************************************************************************
- +5 ; --- ROUTINE MODIFICATION LOG ---
- +6 ;
- +7 ;PKG/PATCH DATE DEVELOPER MODIFICATION
- +8 ;----------- ---------- ----------- ----------------------------------------
- +9 ;ROR*1.5*29 APR 2016 T KOPP Added 'Hep B vaccine or immunity report'
- +10 ;ROR*1.5*31 MAY 2017 M FERRARESE Adding PACT, PCP, and AGE/DOB as additional
- +11 ; identifiers.
- +12 ;ROR*1.5*33 MAR 2018 M FERRARESE Adding FUTURE APPOINTMENT as additional identifiers.
- +13 ;ROR*1.5*34 SEP 2018 M FERRARESE Adding Future Appointment clinic name ; Fix LOINC code table for HEP A/B
- +14 ;******************************************************************************
- +15 ;******************************************************************************
- +16 ;
- +17 ;***** COMPILES THE "HEP B VACCINE OR IMMUNITY" REPORT
- +18 ; REPORT CODE: 025
- +19 ;
- +20 ; .RORTSK Task number and task parameters
- +21 ;
- +22 ; The ^TMP("RORX025",$J) global node is used by this function.
- +23 ;
- +24 ; ^TMP("RORX025",$J,
- +25 ; "PAT",
- +26 ; DFN, Patient descriptor
- +27 ; ^01: Last 4 digits of SSN
- +28 ; ^02: Patient name
- +29 ; ^03: Date of Death
- +30 ; ^04: ICN
- +31 ; ^05: Patient Care Team
- +32 ; ^06: Priamary Care Provider
- +33 ; ^07: Age/DOB
- +34 ; ^08: Future Appt date
- +35 ; ^09: Future Appt Clinic
- +36 ; "IMM") Result if positive test found or "" if no positive test found
- +37 ; ^01: Local lab test name
- +38 ; ^02: Collected date (FM)
- +39 ; ^03: Lab test result
- +40 ; "VAC", Number of results
- +41 ; ^01: #
- +42 ; VaccineName,
- +43 ; VaccineDate) Always null if node exists
- +44 ; ^01: Null
- +45 ;
- +46 ; Return Values:
- +47 ; <0 Error code
- +48 ; 0 Ok
- +49 ;
- HEPBRPT(RORTSK) ;
- +1 ; Immunity wanted mode (-1|0|1) no|not selected|yes (verified by lab test)
- NEW RORIMM
- +2 ; Vaccination (-1|0|1) not received|not selected|received (verified by immunization record)
- NEW RORVAC
- +3 ; Registry IEN
- NEW RORREG
- +4 ; Vaccination end date
- NEW RORVEDT
- +5 ; Vaccination start date
- NEW RORVSDT
- +6 ; Lab test/LOINC end date
- NEW RORLEDT
- +7 ; Lab test/LOINC start date
- NEW RORLSDT
- +8 ; Routine to invoke for hep B processing
- NEW RORRTN
- +9 ; Future Days patch 33
- NEW RORDAYS
- +10 ; Future Appointment patch 33 & 34
- NEW RORFUT
- +11 ; Future Appointment clinic patch 34
- NEW RORCLIN
- +12 ;
- +13 NEW NSPT,RC,REPORT,SFLAGS,TMP
- +14 SET RC=0
- SET RORRTN="RORX025"
- +15 KILL ^TMP(RORRTN,$JOB)
- +16 ;--- Root node of the report
- +17 SET REPORT=$$ADDVAL^RORTSK11(RORTSK,"REPORT")
- +18 if REPORT<0
- QUIT REPORT
- +19 ;
- +20 Begin DoDot:1
- +21 ;--- Get and prepare the report parameters
- +22 ; Registry IEN
- SET RORREG=$$PARAM^RORTSK01("REGIEN")
- +23 ; Vaccination option chosen
- SET RORVAC=$$RPTMODE^RORX024("HEPBVAC")
- +24 ; Immunity option chosen
- SET RORIMM=$$RPTMODE^RORX024("HEPBIMM")
- +25 SET RC=$$PARAMS(REPORT,.RORVSDT,.RORVEDT,.SFLAGS)
- if RC<0
- QUIT
- +26 ;--- Report header
- +27 SET RC=$$HEADER(REPORT)
- if RC<0
- QUIT
- +28 ;--- Query the registry
- +29 DO TPPSETUP^RORTSK01(80)
- +30 SET RC=$$QUERY^RORX024A(SFLAGS,.NSPT,RORRTN)
- +31 IF RC
- if RC<0
- QUIT
- +32 ;--- Store the results
- +33 DO TPPSETUP^RORTSK01(20)
- +34 SET RC=$$STORE^RORX024A(REPORT,NSPT,RORRTN)
- +35 IF RC
- if RC<0
- QUIT
- End DoDot:1
- +36 ;
- +37 ;--- Cleanup
- +38 KILL ^TMP(RORRTN,$JOB)
- +39 QUIT $SELECT(RC<0:RC,1:0)
- +40 ;
- +41 ;
- +42 ;
- +43 ;***** OUTPUTS THE REPORT HEADER
- +44 ;
- +45 ; PARTAG Reference (IEN) to the parent tag
- +46 ;
- +47 ; Return Values:
- +48 ; <0 Error code
- +49 ; >0 IEN of the HEADER element
- +50 ;
- +1 ;;PATIENTS(#,NAME,LAST4,DOD,VAC_NAME,VAC_DATE,LTNAME,DATE,RESULT,ICN,PACT,PCP,FUT_APPT,FUT_CLIN)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
- +2 ;;PATIENTS(#,NAME,LAST4,AGE,DOD,VAC_NAME,VAC_DATE,LTNAME,DATE,RESULT,ICN,PACT,PCP,FUT_APPT,FUT_CLIN)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
- +3 ;;PATIENTS(#,NAME,LAST4,DOB,DOD,VAC_NAME,VAC_DATE,LTNAME,DATE,RESULT,ICN,PACT,PCP,FUT_APPT,FUT_CLIN)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
- +4 ;
- +5 NEW HEADER,LN,RC,CTAG,LTAG
- +6 SET HEADER=$$HEADER^RORXU002(.RORTSK,PARTAG)
- +7 if HEADER<0
- QUIT HEADER
- +8 ;automatically build the table defintion(s) listed under the header tag above PATCH 33
- +9 ;--- LOINC codes output
- +10 IF $GET(RORIMM)
- Begin DoDot:1
- +11 SET LTAG=$$ADDVAL^RORTSK11(RORTSK,"LOINC_CODES",,PARTAG)
- +12 SET LN=0
- FOR
- SET LN=$ORDER(^TMP("RORX025",$JOB,"IMM","TYPE",LN))
- if 'LN
- QUIT
- Begin DoDot:2
- +13 SET CTAG=$$ADDVAL^RORTSK11(RORTSK,"CODE",,LTAG)
- +14 DO ADDATTR^RORTSK11(RORTSK,CTAG,"CODE",^TMP("RORX025",$JOB,"IMM","TYPE",LN))
- End DoDot:2
- End DoDot:1
- +15 SET RC=$$TBLDEF^RORXU002("HEADER^RORX025",HEADER)
- +16 QUIT $SELECT(RC<0:RC,1:HEADER)
- +17 ;
- +18 ;***** OUTPUTS THE PARAMETERS TO THE REPORT
- +19 ;
- +20 ; PARTAG Reference (IEN) to the parent tag
- +21 ;
- +22 ; [.STDT] Start and end dates of the report
- +23 ; [.ENDT] are returned via these parameters
- +24 ;
- +25 ; [.FLAGS] Flags for the $$SKIP^RORXU005 are
- +26 ; returned via this parameter
- +27 ;
- +28 ; Return Values:
- +29 ; <0 Error code
- +30 ; >0 IEN of the PARAMETERS element
- +31 ;
- PARAMS(PARTAG,STDT,ENDT,FLAGS) ;
- +1 NEW PARAMS,TMP
- +2 SET PARAMS=$$PARAMS^RORXU002(.RORTSK,PARTAG,,,.FLAGS)
- +3 if PARAMS<0
- QUIT PARAMS
- +4 ;--- Process the list of Lab tests/LOINC codes
- +5 IF $GET(RORIMM)
- Begin DoDot:1
- +6 ;extract the immunity criteria for HEP B
- DO GETIMM^RORX024("RORX025")
- End DoDot:1
- +7 ;--- Process the list of vaccinations
- +8 IF $GET(RORVAC)
- Begin DoDot:1
- +9 ;extract the vaccine criteria for HEP B
- DO GETVAC^RORX024("RORX025")
- End DoDot:1
- +10 ;---
- +11 QUIT PARAMS
- +12 ;
- +13 ; -- LOINC codes to check for HEP B immunity
- IMMUNITY ; LOINC codes indicating HEP B immunity results by type Line +1 = Surface AB (priority), Line +2 = Core AB
- +1 ;;Surface AB^22322-2^10900-9^16935-9^5193-8^5194-6^22323-0^32019-2
- +2 ;;Core AB^32685-0^22318-0^13919-6^16933-4^13952-7^22316-4^5187-0^5188-8^22317-2^21005-4
- +3 ;;
- +4 QUIT
- +5 ;
- +6 ; -- List of Hep B vaccines to include
- VACCINE ; Hepatitis B vaccine names (% = wild card)
- +1 ;;%ENGERIX-B%^%HEP B%^%HEPATITIS B%^HEPATITIS-B%^HEPB%^HEP A&B^HEPA/HEPB%^%HEP A/B%^HEPAB%^HEPATITIS A & B%^HEPATITIS A&B%
- +2 ;;HEPATITIS A/B^HEPATITIS AB^TWINRIX%
- +3 ;;
- +4 QUIT
- +5 ;