RORUTL21 ;HCIOFO/BH,SG - VACCINATION DATA SEARCH ; 12/13/05 2:16pm
;;1.5;CLINICAL CASE REGISTRIES;**29**;Feb 17, 2006;Build 18
;
; This routine uses the following IAs:
; #10104 UP^XLFSTR (supported)
; #5521 ^AUPNVIMM (private)
; #2056 GETS^DIQ
;
;******************************************************************************
;PKG/PATCH DATE DEVELOPER MODIFICATION
;----------- ---------- ----------- ----------------------------------------
;ROR*1.5*29 APR 2016 T KOPP Added routine for immunization search.
;******************************************************************************
Q
;
;***** QUERIES THE IMMUNIZATION DATA FOR SPECIFIC VACCINE NAME PATTERN MATCHES
;
; PATIEN IEN of the patient (DFN)
;
; ROR8PAT Closed root of a variable, which contains a list
; of pattern matches for names of vaccines of interest
; [in the format ROR(i)=pattern to match]
;
; [[.]ROR8DST] Closed root of an array where the data will be
; returned (^TMP("RORUTL21",$J), by default).
; The data will be stored into the destination
; array in following format:
;
; @ROR8DST = number of vaccination records found
; @ROR8DST@(i)
; ^01: Vaccine Name
; ^02: Event Date
;
; The function should return the following values:
;
; <0 Error code (the search will be aborted)
; 0 or greater = the # of matches found
;
; RORVSDT Start date (FileMan)
; [RORVEDT] End date (FileMan)
;
QUERY(PATIEN,ROR8PAT,ROR8DST,RORVSDT,RORVEDT) ;
N DFN,RC,ROR1,RESULT
;
S DFN=PATIEN
S:$G(ROR8DST)="" ROR8DST=$NA(^TMP("RORUTL21",$J))
Q:$G(ROR8PAT)="" -1 ; No vaccines to search for
;---
S:$G(RORVEDT)'>0 RORVEDT=DT
S RC=0
;
;--- Look for vaccine data (immunizations)
S (ROR1,RESULT)=0
F S ROR1=$O(^AUPNVIMM("C",DFN,ROR1)) Q:'ROR1 D
. N MATCH,RORIDATA,RORIERR,ROREVDT,RORVACNM,RORL,PATT,X,Y,Z
. ;get vaccine data field #1201 = event date/time
. K RORIDATA,RORIERR D GETS^DIQ(9000010.11,ROR1_",",".01;.03;1201","IE","RORIDATA","RORIERR")
. Q:$D(RORIERR("DIERR"))
. S ROREVDT=$G(RORIDATA(9000010.11,ROR1_",",1201,"I")) ;get event date/time
. I 'ROREVDT D
.. N Z
.. S Z=$G(RORIDATA(9000010.11,ROR1_",",.03,"I")) ; if no event date, get the visit date
.. I Z'="" S ROREVDT=$P($G(^AUPNVSIT(Z,0)),U)
. Q:ROREVDT>(RORVEDT_.999999) ;date/time past end date
. Q:ROREVDT<RORVSDT ;date/time before start date
. S RORVACNM=$$UP^XLFSTR($G(RORIDATA(9000010.11,ROR1_",",.01,"E"))) ;get name of vaccine in all uppercase
. S RORL=0,MATCH=0
. F S RORL=$O(@ROR8PAT@(RORL)) Q:'RORL S PATT=$G(^(RORL)) I PATT'="" D Q:MATCH
.. ; Check if vaccine name matches any of the pattern matches
.. I RORVACNM?@(PATT) S MATCH=1 D Q
... S RESULT=RESULT+1,@ROR8DST@(RESULT)=RORVACNM_U_ROREVDT
S @ROR8DST=RESULT,RC=RESULT
Q RC
;
; RORVLST Closed root of a variable, which contains a list
; of vaccines matching search criteria
; [in the format RORVLST(i)=vaccine name^event date
;
; PATIEN IEN of the patient (DFN)
;
; ROR8VLST Closed root of an array where the data will be
; returned.
; The data will be stored into the destination
; array in following format:
;
; @ROR8VLST = # of vaccines found
; @ROR8VLST@(Vaccine Name,Event Date) = null
;
; The function should return the following values:
;
; <0 Error
; 0 OK
;
PROCESS(RORVLST,PATIEN,ROR8VLST) ;
N CT,RC,ROR,RORNM,RORDT
S CT=0
S RC=-1,ROR=0 F S ROR=$O(@RORVLST@(ROR)) Q:'ROR D
. S RORNM=$P(@RORVLST@(ROR),U),RORDT=$P(@RORVLST@(ROR),U,2)
. I RORNM=""!(RORDT="") Q
. S @ROR8VLST@(RORNM,RORDT)="",RC=1,CT=CT+1
S @ROR8VLST=CT
Q RC
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORUTL21 4120 printed Oct 16, 2024@17:45:03 Page 2
RORUTL21 ;HCIOFO/BH,SG - VACCINATION DATA SEARCH ; 12/13/05 2:16pm
+1 ;;1.5;CLINICAL CASE REGISTRIES;**29**;Feb 17, 2006;Build 18
+2 ;
+3 ; This routine uses the following IAs:
+4 ; #10104 UP^XLFSTR (supported)
+5 ; #5521 ^AUPNVIMM (private)
+6 ; #2056 GETS^DIQ
+7 ;
+8 ;******************************************************************************
+9 ;PKG/PATCH DATE DEVELOPER MODIFICATION
+10 ;----------- ---------- ----------- ----------------------------------------
+11 ;ROR*1.5*29 APR 2016 T KOPP Added routine for immunization search.
+12 ;******************************************************************************
+13 QUIT
+14 ;
+15 ;***** QUERIES THE IMMUNIZATION DATA FOR SPECIFIC VACCINE NAME PATTERN MATCHES
+16 ;
+17 ; PATIEN IEN of the patient (DFN)
+18 ;
+19 ; ROR8PAT Closed root of a variable, which contains a list
+20 ; of pattern matches for names of vaccines of interest
+21 ; [in the format ROR(i)=pattern to match]
+22 ;
+23 ; [[.]ROR8DST] Closed root of an array where the data will be
+24 ; returned (^TMP("RORUTL21",$J), by default).
+25 ; The data will be stored into the destination
+26 ; array in following format:
+27 ;
+28 ; @ROR8DST = number of vaccination records found
+29 ; @ROR8DST@(i)
+30 ; ^01: Vaccine Name
+31 ; ^02: Event Date
+32 ;
+33 ; The function should return the following values:
+34 ;
+35 ; <0 Error code (the search will be aborted)
+36 ; 0 or greater = the # of matches found
+37 ;
+38 ; RORVSDT Start date (FileMan)
+39 ; [RORVEDT] End date (FileMan)
+40 ;
QUERY(PATIEN,ROR8PAT,ROR8DST,RORVSDT,RORVEDT) ;
+1 NEW DFN,RC,ROR1,RESULT
+2 ;
+3 SET DFN=PATIEN
+4 if $GET(ROR8DST)=""
SET ROR8DST=$NAME(^TMP("RORUTL21",$JOB))
+5 ; No vaccines to search for
if $GET(ROR8PAT)=""
QUIT -1
+6 ;---
+7 if $GET(RORVEDT)'>0
SET RORVEDT=DT
+8 SET RC=0
+9 ;
+10 ;--- Look for vaccine data (immunizations)
+11 SET (ROR1,RESULT)=0
+12 FOR
SET ROR1=$ORDER(^AUPNVIMM("C",DFN,ROR1))
if 'ROR1
QUIT
Begin DoDot:1
+13 NEW MATCH,RORIDATA,RORIERR,ROREVDT,RORVACNM,RORL,PATT,X,Y,Z
+14 ;get vaccine data field #1201 = event date/time
+15 KILL RORIDATA,RORIERR
DO GETS^DIQ(9000010.11,ROR1_",",".01;.03;1201","IE","RORIDATA","RORIERR")
+16 if $DATA(RORIERR("DIERR"))
QUIT
+17 ;get event date/time
SET ROREVDT=$GET(RORIDATA(9000010.11,ROR1_",",1201,"I"))
+18 IF 'ROREVDT
Begin DoDot:2
+19 NEW Z
+20 ; if no event date, get the visit date
SET Z=$GET(RORIDATA(9000010.11,ROR1_",",.03,"I"))
+21 IF Z'=""
SET ROREVDT=$PIECE($GET(^AUPNVSIT(Z,0)),U)
End DoDot:2
+22 ;date/time past end date
if ROREVDT>(RORVEDT_.999999)
QUIT
+23 ;date/time before start date
if ROREVDT<RORVSDT
QUIT
+24 ;get name of vaccine in all uppercase
SET RORVACNM=$$UP^XLFSTR($GET(RORIDATA(9000010.11,ROR1_",",.01,"E")))
+25 SET RORL=0
SET MATCH=0
+26 FOR
SET RORL=$ORDER(@ROR8PAT@(RORL))
if 'RORL
QUIT
SET PATT=$GET(^(RORL))
IF PATT'=""
Begin DoDot:2
+27 ; Check if vaccine name matches any of the pattern matches
+28 IF RORVACNM?@(PATT)
SET MATCH=1
Begin DoDot:3
+29 SET RESULT=RESULT+1
SET @ROR8DST@(RESULT)=RORVACNM_U_ROREVDT
End DoDot:3
QUIT
End DoDot:2
if MATCH
QUIT
End DoDot:1
+30 SET @ROR8DST=RESULT
SET RC=RESULT
+31 QUIT RC
+32 ;
+33 ; RORVLST Closed root of a variable, which contains a list
+34 ; of vaccines matching search criteria
+35 ; [in the format RORVLST(i)=vaccine name^event date
+36 ;
+37 ; PATIEN IEN of the patient (DFN)
+38 ;
+39 ; ROR8VLST Closed root of an array where the data will be
+40 ; returned.
+41 ; The data will be stored into the destination
+42 ; array in following format:
+43 ;
+44 ; @ROR8VLST = # of vaccines found
+45 ; @ROR8VLST@(Vaccine Name,Event Date) = null
+46 ;
+47 ; The function should return the following values:
+48 ;
+49 ; <0 Error
+50 ; 0 OK
+51 ;
PROCESS(RORVLST,PATIEN,ROR8VLST) ;
+1 NEW CT,RC,ROR,RORNM,RORDT
+2 SET CT=0
+3 SET RC=-1
SET ROR=0
FOR
SET ROR=$ORDER(@RORVLST@(ROR))
if 'ROR
QUIT
Begin DoDot:1
+4 SET RORNM=$PIECE(@RORVLST@(ROR),U)
SET RORDT=$PIECE(@RORVLST@(ROR),U,2)
+5 IF RORNM=""!(RORDT="")
QUIT
+6 SET @ROR8VLST@(RORNM,RORDT)=""
SET RC=1
SET CT=CT+1
End DoDot:1
+7 SET @ROR8VLST=CT
+8 QUIT RC
+9 ;