- MAGDHRC0 ;WOIFO/PMK - Read HL7 and generate DICOM ; 28 Mar 2011 10:30 AM
- ;;3.0;IMAGING;**46,54,49**;Mar 19, 2002;Build 2033;Apr 07, 2011
- ;; Per VHA Directive 2004-038, this routine should not be modified.
- ;; +---------------------------------------------------------------+
- ;; | Property of the US Government. |
- ;; | No permission to copy or redistribute this software is given. |
- ;; | Use of unreleased versions of this software requires the user |
- ;; | to execute a written test agreement with the VistA Imaging |
- ;; | Development Office of the Department of Veterans Affairs, |
- ;; | telephone (301) 734-0100. |
- ;; | The Food and Drug Administration classifies this software as |
- ;; | a medical device. As such, it may not be changed in any way. |
- ;; | Modifications to this software may result in an adulterated |
- ;; | medical device under 21CFR820, the use of which is considered |
- ;; | to be a violation of US Federal Statutes. |
- ;; +---------------------------------------------------------------+
- ;;
- Q
- ;
- ; Functions for accessing parsed HL7 data
- ;
- GETDATA(FLD,REP,CMP,SUB) ; get an element from HL7PARSE
- Q:'$D(FLD) $$DEQUOTE($G(@HL7PARSE@(HL7SEGNO))) ; segment
- Q:'$D(REP) $$DEQUOTE($G(@HL7PARSE@(HL7SEGNO,FLD))) ; field
- Q:'$D(CMP) $$DEQUOTE($G(@HL7PARSE@(HL7SEGNO,FLD,REP))) ; repetition
- Q:'$D(SUB) $$DEQUOTE($G(@HL7PARSE@(HL7SEGNO,FLD,REP,CMP))) ; component
- Q $$DEQUOTE($G(@HL7PARSE@(HL7SEGNO,FLD,REP,CMP,SUB))) ; subcomponent
- ;
- DEQUOTE(X) ; convert HL7 double quote data (that is, "") to empty string
- Q $S(X="""""":"",1:X)
- ;
- GETEXIST(FLD,REP,CMP,SUB) ; does the element (segment/field/rep/comp) exist
- Q:'$D(FLD) $D(@HL7PARSE@(HL7SEGNO)) ; segment
- Q:'$D(REP) $D(@HL7PARSE@(HL7SEGNO,FLD)) ; field
- Q:'$D(CMP) $D(@HL7PARSE@(HL7SEGNO,FLD,REP)) ; repetition
- Q:'$D(SUB) $D(@HL7PARSE@(HL7SEGNO,FLD,REP,CMP)) ; component
- Q $D(@HL7PARSE@(HL7SEGNO,FLD,REP,CMP,SUB)) ; subcomponent
- ;
- GETSEG(SEGMENT) ; check if the named segment exists
- Q:SEGMENT'="" $O(@HL7PARSE@("B",SEGMENT,""))
- Q 0
- ;
- GETCOUNT() ; get highest index number from HL7PARSE
- Q $O(@HL7PARSE@(" "),-1)
- ;
- GETNAME(J,K) ; get a person's name - return in DICOM format
- ; also used for provider's name - first piece is code - others shifted
- N I,LAST,NAME,X
- S NAME="",LAST=0,K=$G(K,1) F I=1:1:6 D
- . N X ; name component: last ^ first ^ mi ^ prefix ^ suffix
- . S X=$$GETDATA^MAGDHRC0(J,K,I) I $L(X) S LAST=I
- . S NAME=NAME_$S(I>1:"^",1:"")_$TR(X,"^\","") ; no ^ or \ chars in name
- . Q
- Q $P(NAME,"^",1,LAST)
- ;
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGDHRC0 2659 printed Feb 18, 2025@23:26:44 Page 2
- MAGDHRC0 ;WOIFO/PMK - Read HL7 and generate DICOM ; 28 Mar 2011 10:30 AM
- +1 ;;3.0;IMAGING;**46,54,49**;Mar 19, 2002;Build 2033;Apr 07, 2011
- +2 ;; Per VHA Directive 2004-038, this routine should not be modified.
- +3 ;; +---------------------------------------------------------------+
- +4 ;; | Property of the US Government. |
- +5 ;; | No permission to copy or redistribute this software is given. |
- +6 ;; | Use of unreleased versions of this software requires the user |
- +7 ;; | to execute a written test agreement with the VistA Imaging |
- +8 ;; | Development Office of the Department of Veterans Affairs, |
- +9 ;; | telephone (301) 734-0100. |
- +10 ;; | The Food and Drug Administration classifies this software as |
- +11 ;; | a medical device. As such, it may not be changed in any way. |
- +12 ;; | Modifications to this software may result in an adulterated |
- +13 ;; | medical device under 21CFR820, the use of which is considered |
- +14 ;; | to be a violation of US Federal Statutes. |
- +15 ;; +---------------------------------------------------------------+
- +16 ;;
- +17 QUIT
- +18 ;
- +19 ; Functions for accessing parsed HL7 data
- +20 ;
- GETDATA(FLD,REP,CMP,SUB) ; get an element from HL7PARSE
- +1 ; segment
- if '$DATA(FLD)
- QUIT $$DEQUOTE($GET(@HL7PARSE@(HL7SEGNO)))
- +2 ; field
- if '$DATA(REP)
- QUIT $$DEQUOTE($GET(@HL7PARSE@(HL7SEGNO,FLD)))
- +3 ; repetition
- if '$DATA(CMP)
- QUIT $$DEQUOTE($GET(@HL7PARSE@(HL7SEGNO,FLD,REP)))
- +4 ; component
- if '$DATA(SUB)
- QUIT $$DEQUOTE($GET(@HL7PARSE@(HL7SEGNO,FLD,REP,CMP)))
- +5 ; subcomponent
- QUIT $$DEQUOTE($GET(@HL7PARSE@(HL7SEGNO,FLD,REP,CMP,SUB)))
- +6 ;
- DEQUOTE(X) ; convert HL7 double quote data (that is, "") to empty string
- +1 QUIT $SELECT(X="""""":"",1:X)
- +2 ;
- GETEXIST(FLD,REP,CMP,SUB) ; does the element (segment/field/rep/comp) exist
- +1 ; segment
- if '$DATA(FLD)
- QUIT $DATA(@HL7PARSE@(HL7SEGNO))
- +2 ; field
- if '$DATA(REP)
- QUIT $DATA(@HL7PARSE@(HL7SEGNO,FLD))
- +3 ; repetition
- if '$DATA(CMP)
- QUIT $DATA(@HL7PARSE@(HL7SEGNO,FLD,REP))
- +4 ; component
- if '$DATA(SUB)
- QUIT $DATA(@HL7PARSE@(HL7SEGNO,FLD,REP,CMP))
- +5 ; subcomponent
- QUIT $DATA(@HL7PARSE@(HL7SEGNO,FLD,REP,CMP,SUB))
- +6 ;
- GETSEG(SEGMENT) ; check if the named segment exists
- +1 if SEGMENT'=""
- QUIT $ORDER(@HL7PARSE@("B",SEGMENT,""))
- +2 QUIT 0
- +3 ;
- GETCOUNT() ; get highest index number from HL7PARSE
- +1 QUIT $ORDER(@HL7PARSE@(" "),-1)
- +2 ;
- GETNAME(J,K) ; get a person's name - return in DICOM format
- +1 ; also used for provider's name - first piece is code - others shifted
- +2 NEW I,LAST,NAME,X
- +3 SET NAME=""
- SET LAST=0
- SET K=$GET(K,1)
- FOR I=1:1:6
- Begin DoDot:1
- +4 ; name component: last ^ first ^ mi ^ prefix ^ suffix
- NEW X
- +5 SET X=$$GETDATA^MAGDHRC0(J,K,I)
- IF $LENGTH(X)
- SET LAST=I
- +6 ; no ^ or \ chars in name
- SET NAME=NAME_$SELECT(I>1:"^",1:"")_$TRANSLATE(X,"^\","")
- +7 QUIT
- End DoDot:1
- +8 QUIT $PIECE(NAME,"^",1,LAST)
- +9 ;