RORHL18 ;BPOIFO/ACS - HL7 IMMUNIZATION DATA: OBR,OBX ;11/1/09
;;1.5;CLINICAL CASE REGISTRIES;**10**;Feb 17, 2006;Build 32
;
; DBIA #5521 : ^AUPNVIMM (private)
; DBIA #2028 : ^AUPNVSIT (controlled)
; DBIA #10060: Read access to file #200 (supported)
; DBIA #2056 : $$GET1^DIQ,GETS^DIQ (supported)
Q
;
;***** SEARCH FOR IMMUNIZATION DATA
;
; RORDFN IEN of the patient in the PATIENT file (#2)
;
; .DXDTS Reference to a local variable where the
; data extraction time frames are stored.
;
; Return Values:
; 0 Ok
;
EN1(RORDFN,DXDTS) ;
N DFN,IDX,RORENDT,RORSTDT,ROR1,ROREVDT,RORSKIP
;
S DFN=RORDFN
S IDX=0
F S ROR1=0 S IDX=$O(DXDTS(17,IDX)) Q:IDX'>0 D
. S RORSTDT=$P(DXDTS(17,IDX),U),RORENDT=$P(DXDTS(17,IDX),U,2)
. ;--- Look for Immunization data
. S RORSKIP=0 F S ROR1=$O(^AUPNVIMM("C",DFN,ROR1)) Q:'ROR1 D
.. N RORIDATA,RORIERR,ROREVDT
.. ;get immunization data for the HL7 message
.. K RORIDATA,RORIERR D GETS^DIQ(9000010.11,ROR1_",",".01;.03;.06;.07;1201;1202;81101","IE","RORIDATA","RORIERR")
.. Q:$D(RORIERR("DIERR"))
.. S ROREVDT=$G(RORIDATA(9000010.11,ROR1_",",1201,"I")) ;get event date/time
.. Q:$G(ROREVDT)>(RORENDT_.999999) ;event date/time can't be in the future
.. N RORVSIT ;get VISIT IEN from immunization file
.. S RORVSIT=$G(RORIDATA(9000010.11,ROR1_",",".03","I")) ;visit IEN
.. ;get FM internal DATE LAST MODIFIED from visit file
.. N RORIDLM,RORIERR,RORDLM
.. K RORIDLM,RORIERR D GETS^DIQ(9000010,RORVSIT_",",".13","I","RORIDLM","RORIERR")
.. S RORDLM=$G(RORIDLM(9000010,RORVSIT_",",".13","I")) ;date last modified
.. S RORDLM=RORDLM\1 ;exclude 'time'
.. Q:RORDLM<RORSTDT ;quit if date last modified is before extraction start date
.. Q:RORDLM>RORENDT ;quit if date last modified is after extraction end date
.. S RORVSIT=+$G(^AUPNVSIT(RORVSIT,0)) ;get visit date/time in FM format
.. ;--- Process the data
.. D OBR(.RORIDATA,DFN,RORVSIT,ROR1)
.. D OBX(.RORIDATA,DFN,RORVSIT,ROR1)
;
Q 0
;
;***** IMMUNIZATION OBR SEGMENT BUILDER
;
; Return Values:
; <0 Error code
; 0 Ok
; >0 Non-fatal error(s)
;
OBR(RORIDATA,DFN,RORVSIT,ROR1) ;
N CS,RORSEG
D ECH^RORHL7(.CS) ;component separator = ^
;
;--- Initialize the segment
S RORSEG(0)="OBR"
;
;--- OBR-3 - Immunization IEN in V IMMUNIZATION file
;S RORSEG(3)=$G(RORIDATA(9000010.11,ROR1_",",.01,"I"))
S RORSEG(3)=$G(ROR1)
;
;--- OBR-4 - Universal Service ID
S RORSEG(4)="90749"_CS_"IMMUNIZATION"_CS_"C4"
;
;--- OBR-13 - 'COMMENTS'
S RORSEG(13)=$G(RORIDATA(9000010.11,ROR1_",",81101,"E"))
;
;--- OBR-16 - 'ORDERING PROVIDER': IEN and PROVIDER CLASS
N ROROPIEN,RORDATA,RORMSG
S ROROPIEN=$G(RORIDATA(9000010.11,ROR1_",",1202,"I"))
I ROROPIEN>0 D
. ;get provider class
. N DIERR S $P(RORDATA,CS,13)=$$GET1^DIQ(200,+ROROPIEN_",",53.5,"E",,"RORMSG")
. Q:$G(RORMSG(("DIERR")))
. S $P(RORDATA,CS,1)=ROROPIEN ;provider IEN
. S RORSEG(16)=$G(RORDATA)
;
;--- OBR-24 - Diagnostic Service ID
S RORSEG(24)="OTH"
;
;--- Store the segment
D ADDSEG^RORHL7(.RORSEG)
Q
;
;***** IMMUNIZATION OBX SEGMENT BUILDER
;
;
OBX(RORIDATA,DFN,RORVSIT,ROR1) ;
N CS,RORSEG
D ECH^RORHL7(.CS)
;
;--- Initialize the segment
S RORSEG(0)="OBX"
;
;--- OBX-2 - Value Type of OBX-5
S RORSEG(2)="FT"
;
;--- OBX-3 - Immunization 'NAME' from IMMUNIZATION file #9999999.14
S RORSEG(3)=CS_$G(RORIDATA(9000010.11,ROR1_",",.01,"E"))
;
;--- OBX-5 - 'REACTION'_CS_'CONTRAINDICATED'
N TMP1,TMP2
S TMP1=$G(RORIDATA(9000010.11,ROR1_",",.06,"I"))
S TMP2=$G(RORIDATA(9000010.11,ROR1_",",.07,"I"))
S RORSEG(5)=$G(TMP1)_CS_$G(TMP2)
;
;--- OBX-14 - 'EVENT DATE AND TIME'
N TMP1 S TMP1=$G(RORIDATA(9000010.11,ROR1_",",1201,"I"))
I $G(TMP1)>0 S RORSEG(14)=$$FM2HL^RORHL7(TMP1)
;
;--- OBX-19 - 'VISIT'
I $G(RORVSIT)>0 S RORSEG(19)=$$FM2HL^RORHL7(RORVSIT) ;convert to HL7 format
;
D ADDSEG^RORHL7(.RORSEG)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORHL18 4017 printed Dec 13, 2024@01:42:03 Page 2
RORHL18 ;BPOIFO/ACS - HL7 IMMUNIZATION DATA: OBR,OBX ;11/1/09
+1 ;;1.5;CLINICAL CASE REGISTRIES;**10**;Feb 17, 2006;Build 32
+2 ;
+3 ; DBIA #5521 : ^AUPNVIMM (private)
+4 ; DBIA #2028 : ^AUPNVSIT (controlled)
+5 ; DBIA #10060: Read access to file #200 (supported)
+6 ; DBIA #2056 : $$GET1^DIQ,GETS^DIQ (supported)
+7 QUIT
+8 ;
+9 ;***** SEARCH FOR IMMUNIZATION DATA
+10 ;
+11 ; RORDFN IEN of the patient in the PATIENT file (#2)
+12 ;
+13 ; .DXDTS Reference to a local variable where the
+14 ; data extraction time frames are stored.
+15 ;
+16 ; Return Values:
+17 ; 0 Ok
+18 ;
EN1(RORDFN,DXDTS) ;
+1 NEW DFN,IDX,RORENDT,RORSTDT,ROR1,ROREVDT,RORSKIP
+2 ;
+3 SET DFN=RORDFN
+4 SET IDX=0
+5 FOR
SET ROR1=0
SET IDX=$ORDER(DXDTS(17,IDX))
if IDX'>0
QUIT
Begin DoDot:1
+6 SET RORSTDT=$PIECE(DXDTS(17,IDX),U)
SET RORENDT=$PIECE(DXDTS(17,IDX),U,2)
+7 ;--- Look for Immunization data
+8 SET RORSKIP=0
FOR
SET ROR1=$ORDER(^AUPNVIMM("C",DFN,ROR1))
if 'ROR1
QUIT
Begin DoDot:2
+9 NEW RORIDATA,RORIERR,ROREVDT
+10 ;get immunization data for the HL7 message
+11 KILL RORIDATA,RORIERR
DO GETS^DIQ(9000010.11,ROR1_",",".01;.03;.06;.07;1201;1202;81101","IE","RORIDATA","RORIERR")
+12 if $DATA(RORIERR("DIERR"))
QUIT
+13 ;get event date/time
SET ROREVDT=$GET(RORIDATA(9000010.11,ROR1_",",1201,"I"))
+14 ;event date/time can't be in the future
if $GET(ROREVDT)>(RORENDT_.999999)
QUIT
+15 ;get VISIT IEN from immunization file
NEW RORVSIT
+16 ;visit IEN
SET RORVSIT=$GET(RORIDATA(9000010.11,ROR1_",",".03","I"))
+17 ;get FM internal DATE LAST MODIFIED from visit file
+18 NEW RORIDLM,RORIERR,RORDLM
+19 KILL RORIDLM,RORIERR
DO GETS^DIQ(9000010,RORVSIT_",",".13","I","RORIDLM","RORIERR")
+20 ;date last modified
SET RORDLM=$GET(RORIDLM(9000010,RORVSIT_",",".13","I"))
+21 ;exclude 'time'
SET RORDLM=RORDLM\1
+22 ;quit if date last modified is before extraction start date
if RORDLM<RORSTDT
QUIT
+23 ;quit if date last modified is after extraction end date
if RORDLM>RORENDT
QUIT
+24 ;get visit date/time in FM format
SET RORVSIT=+$GET(^AUPNVSIT(RORVSIT,0))
+25 ;--- Process the data
+26 DO OBR(.RORIDATA,DFN,RORVSIT,ROR1)
+27 DO OBX(.RORIDATA,DFN,RORVSIT,ROR1)
End DoDot:2
End DoDot:1
+28 ;
+29 QUIT 0
+30 ;
+31 ;***** IMMUNIZATION OBR SEGMENT BUILDER
+32 ;
+33 ; Return Values:
+34 ; <0 Error code
+35 ; 0 Ok
+36 ; >0 Non-fatal error(s)
+37 ;
OBR(RORIDATA,DFN,RORVSIT,ROR1) ;
+1 NEW CS,RORSEG
+2 ;component separator = ^
DO ECH^RORHL7(.CS)
+3 ;
+4 ;--- Initialize the segment
+5 SET RORSEG(0)="OBR"
+6 ;
+7 ;--- OBR-3 - Immunization IEN in V IMMUNIZATION file
+8 ;S RORSEG(3)=$G(RORIDATA(9000010.11,ROR1_",",.01,"I"))
+9 SET RORSEG(3)=$GET(ROR1)
+10 ;
+11 ;--- OBR-4 - Universal Service ID
+12 SET RORSEG(4)="90749"_CS_"IMMUNIZATION"_CS_"C4"
+13 ;
+14 ;--- OBR-13 - 'COMMENTS'
+15 SET RORSEG(13)=$GET(RORIDATA(9000010.11,ROR1_",",81101,"E"))
+16 ;
+17 ;--- OBR-16 - 'ORDERING PROVIDER': IEN and PROVIDER CLASS
+18 NEW ROROPIEN,RORDATA,RORMSG
+19 SET ROROPIEN=$GET(RORIDATA(9000010.11,ROR1_",",1202,"I"))
+20 IF ROROPIEN>0
Begin DoDot:1
+21 ;get provider class
+22 NEW DIERR
SET $PIECE(RORDATA,CS,13)=$$GET1^DIQ(200,+ROROPIEN_",",53.5,"E",,"RORMSG")
+23 if $GET(RORMSG(("DIERR")))
QUIT
+24 ;provider IEN
SET $PIECE(RORDATA,CS,1)=ROROPIEN
+25 SET RORSEG(16)=$GET(RORDATA)
End DoDot:1
+26 ;
+27 ;--- OBR-24 - Diagnostic Service ID
+28 SET RORSEG(24)="OTH"
+29 ;
+30 ;--- Store the segment
+31 DO ADDSEG^RORHL7(.RORSEG)
+32 QUIT
+33 ;
+34 ;***** IMMUNIZATION OBX SEGMENT BUILDER
+35 ;
+36 ;
OBX(RORIDATA,DFN,RORVSIT,ROR1) ;
+1 NEW CS,RORSEG
+2 DO ECH^RORHL7(.CS)
+3 ;
+4 ;--- Initialize the segment
+5 SET RORSEG(0)="OBX"
+6 ;
+7 ;--- OBX-2 - Value Type of OBX-5
+8 SET RORSEG(2)="FT"
+9 ;
+10 ;--- OBX-3 - Immunization 'NAME' from IMMUNIZATION file #9999999.14
+11 SET RORSEG(3)=CS_$GET(RORIDATA(9000010.11,ROR1_",",.01,"E"))
+12 ;
+13 ;--- OBX-5 - 'REACTION'_CS_'CONTRAINDICATED'
+14 NEW TMP1,TMP2
+15 SET TMP1=$GET(RORIDATA(9000010.11,ROR1_",",.06,"I"))
+16 SET TMP2=$GET(RORIDATA(9000010.11,ROR1_",",.07,"I"))
+17 SET RORSEG(5)=$GET(TMP1)_CS_$GET(TMP2)
+18 ;
+19 ;--- OBX-14 - 'EVENT DATE AND TIME'
+20 NEW TMP1
SET TMP1=$GET(RORIDATA(9000010.11,ROR1_",",1201,"I"))
+21 IF $GET(TMP1)>0
SET RORSEG(14)=$$FM2HL^RORHL7(TMP1)
+22 ;
+23 ;--- OBX-19 - 'VISIT'
+24 ;convert to HL7 format
IF $GET(RORVSIT)>0
SET RORSEG(19)=$$FM2HL^RORHL7(RORVSIT)
+25 ;
+26 DO ADDSEG^RORHL7(.RORSEG)
+27 QUIT