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

SCMSVUT4.m

Go to the documentation of this file.
  1. SCMSVUT4 ;BPFO/JRP - IEMM Utilities (cont);6/18/2002
  1. ;;5.3;Scheduling;**245,1015**;Aug 13, 1993;Build 21
  1. ;
  1. Q
  1. ;
  1. CNVRTHLQ(STRING,HLQ) ;Convert HL7 null designation to null
  1. ;Input : STRING - String to perform conversion on
  1. ; HLQ - HL7 null designation (defaults to "")
  1. ;Output : STRING with HLQ converted to null
  1. ;
  1. ;Declare variables
  1. N X,L
  1. S STRING=$G(STRING)
  1. I (STRING="") Q ""
  1. S:('$D(HLQ)) HLQ=$C(34,34)
  1. S:HLQ="" HLQ=$C(34,34)
  1. S L=$L(HLQ)
  1. ;Convert by removing all instances of HLQ
  1. F S X=$F(STRING,HLQ) Q:'X D
  1. .S STRING=$E(STRING,1,(X-L-1))_$E(STRING,X,$L(STRING))
  1. Q STRING
  1. ;
  1. PARFLD(FLD,OUTARR,HL,SUBS) ;Parse HL7 field by component
  1. ;Input : FLD - Field to parse
  1. ; OUTARR - Array to put parsed field into (pass by value)
  1. ; HL - Array containing HL7 variables (pass by reference)
  1. ; Using HL("FS"), HL("ECH"), HL("Q")
  1. ; This is output by $$INIT^HLFNC2()
  1. ; SUBS - Flag indicating if sub-components should also
  1. ; be broken out
  1. ; 0 = No (default)
  1. ; 1 = Yes
  1. ;Output : None
  1. ; OUTARR = Value (if field not broken into components)
  1. ; OUTARR(Cmp#) = Value
  1. ; OUTARR(Cmp#,Sub#) = Value (if sub-component requested)
  1. ;Notes : Existance and validity of input is assumed
  1. ; : OUTARR initialized (KILLed) on entry
  1. ; : FLD can not be a repeating field
  1. ;Declare variables
  1. N CS,COMP,SS,VALUE,SUB
  1. S FLD=$G(FLD)
  1. Q:FLD=""
  1. Q:'$D(HL)
  1. S CNVRT=+$G(CNVRT)
  1. K @OUTARR
  1. ;Get component & sub-component separators
  1. S CS=$E(HL("ECH"),1)
  1. S SS=$E(HL("ECH"),4)
  1. ;No components - set field at main level
  1. I FLD'[CS S @OUTARR=FLD Q
  1. ;Parse out components
  1. F COMP=1:1:$L(FLD,CS) D
  1. .S VALUE=$P(FLD,CS,COMP)
  1. .I 'SUBS S @OUTARR@(COMP)=VALUE Q
  1. .;Parse out sub-components
  1. .I VALUE'[SS S @OUTARR@(COMP)=VALUE Q
  1. .F SUB=1:1:$L(VALUE,SS) D
  1. ..S @OUTARR@(COMP,SUB)=$P(VALUE,SS,SUB)
  1. Q
  1. ;
  1. PARSEG(SEGARR,OUTARR,HL,PARCOMP,CNVRT) ;Parse HL7 segment by field
  1. ;Input : SEGARR - Array containing segment (pass by value)
  1. ; SEGARR = First 245 characters of segment
  1. ; SEGARR(1..n) = Continuation nodes
  1. ; OR
  1. ; SEGARR(0) = First 245 characters of segment
  1. ; SEGARR(1..n) = Continuation nodes
  1. ; OUTARR - Array to put parsed segment into (pass by value)
  1. ; HL - Array containing HL7 variables (pass by reference)
  1. ; Using HL("FS"), HL("ECH"), HL("Q")
  1. ; This is output by $$INIT^HLFNC2()
  1. ; PARCOMP - Flag indicating if fields should be parsed into
  1. ; their components
  1. ; 0 = No (default)
  1. ; 10 = Yes - components only
  1. ; 11 = Yes - component and sub-components
  1. ; CNVRT - Flag indicating if HL7 null designation should be
  1. ; converted to MUMPS null (optional)
  1. ; 0 = No (default)
  1. ; 1 = Yes
  1. ;Output : None
  1. ; OUTARR will be in the following format:
  1. ; OUTARR(0) = Segment name
  1. ; OUTARR(Seq#,Rpt#) = Value
  1. ; OUTARR(Seq#,Rpt#,Cmp#) = Value
  1. ; OUTARR(Seq#,Rpt#,Cmp#,Sub#) = Value
  1. ;
  1. ;Notes : Existance and validity of input is assumed
  1. ; : OUTARR initialized (KILLed) on entry
  1. ; : Assumes no field in segment greater than 245 characters
  1. ; : Data stored with the least number of subscripts in OUTARR.
  1. ; If field not broken into components then the component
  1. ; subscript will not be used. Same is true of the
  1. ; sub-component subscript.
  1. ;
  1. ;Declare variables
  1. N SEQ,CURNODE,CURDATA,NXTNODE,NXTDATA,VALUE,RS,REP,STOP,SEG
  1. Q:'$D(SEGARR)
  1. Q:'$D(@SEGARR)
  1. Q:'$D(OUTARR)
  1. Q:'$D(HL)
  1. S PARCOMP=+$G(PARCOMP)
  1. S CNVRT=+$G(CNVRT)
  1. K @OUTARR
  1. ;Get repetition separator
  1. S RS=$E(HL("ECH"),2)
  1. ;Get initial and next nodes
  1. S CURNODE=$S($D(@SEGARR)#2:"",1:$O(@SEGARR@("")))
  1. S CURDATA=$S(CURNODE="":@SEGARR,1:@SEGARR@(CURNODE))
  1. S NXTNODE=$O(@SEGARR@(CURNODE))
  1. S NXTDATA=$S(NXTNODE="":"",1:$G(@SEGARR@(NXTNODE)))
  1. ;Get/strip segment name
  1. S SEG=$P(CURDATA,HL("FS"),1)
  1. Q:($L(SEG)'=3)
  1. S CURDATA=$P(CURDATA,HL("FS"),2,99999)
  1. S @OUTARR@(0)=SEG
  1. ;Parse out fields
  1. S STOP=0
  1. S SEQ=1
  1. F D Q:STOP
  1. .S VALUE=$P(CURDATA,HL("FS"),1)
  1. .;Account for continuation of data on next node
  1. .I CURDATA'[HL("FS") D
  1. ..S VALUE=VALUE_$P(NXTDATA,HL("FS"),1)
  1. ..S NXTDATA=$P(NXTDATA,HL("FS"),2,99999)
  1. .;Convert HL7 null to MUMPS null
  1. .I CNVRT S VALUE=$$CNVRTHLQ(VALUE,HL("Q"))
  1. .;Parse out repetitions
  1. .F REP=1:1:$L(VALUE,RS) D
  1. ..;Parse out components
  1. ..I PARCOMP D Q
  1. ...D PARFLD($P(VALUE,RS,REP),$NA(@OUTARR@(SEQ,REP)),.HL,(PARCOMP#2))
  1. ..;Don't parse out components
  1. ..S @OUTARR@(SEQ,REP)=$P(VALUE,RS,REP)
  1. .;Increment sequence number
  1. .S SEQ=SEQ+1
  1. .;No more fields on current node - move to next node
  1. .I CURDATA'[HL("FS") D Q
  1. ..;No more fields - stop parsing
  1. ..I NXTDATA="" S STOP=1 Q
  1. ..;Update current node and get next node
  1. ..S CURDATA=NXTDATA
  1. ..S CURNODE=NXTNODE
  1. ..S NXTNODE=$O(@SEGARR@(CURNODE))
  1. ..S NXTDATA=$S(NXTNODE="":"",1:$G(@SEGARR@(NXTNODE)))
  1. .;Remove current field from node
  1. .S CURDATA=$P(CURDATA,HL("FS"),2,99999)
  1. Q
  1. ;
  1. PARMSG(MSGARR,OUTARR,HL,PARCOMP,CNVRT) ;Parse HL7 message by segment
  1. ; and field
  1. ;Input : MSGARR - Array containing message (pass by value)
  1. ; MSGARR(x) = First 245 characters of Xth segment
  1. ; MSGARR(x,1..n) = Continuation nodes for Xth segment
  1. ; OUTARR - Array to put parsed message into (pass by value)
  1. ; HL - Array containing HL7 variables (pass by reference)
  1. ; Using HL("FS"), HL("ECH"), HL("Q")
  1. ; This is output by $$INIT^HLFNC2()
  1. ; PARCOMP - Flag indicating if fields should be parsed into
  1. ; their components
  1. ; 0 = No (default)
  1. ; 1 = Yes
  1. ; CNVRT - Flag indicating if HL7 null designation should be
  1. ; converted to MUMPS null (optional)
  1. ; 0 = No (default)
  1. ; 10 = Yes - components only
  1. ; 11 = Yes - component and sub-components
  1. ;Output : None
  1. ; OUTARR will be in the following format:
  1. ; OUTARR(0) = Segment name
  1. ; OUTARR(SegName,Rpt#)=Seg#
  1. ; OUTARR(Seg#,Seq#,Rpt#) = Value
  1. ; OUTARR(Seg#,Seq#,Rpt#,Cmp#) = Value
  1. ; OUTARR(Seg#,Seq#,Rpt#,Cmp#,Sub#) = Value
  1. ;
  1. ;Notes : Existance and validity of input is assumed
  1. ; : OUTARR initialized (KILLed) on entry
  1. ; : Assumes no field in segment greater than 245 characters
  1. ; : Data stored with the least number of subscripts in OUTARR.
  1. ; If field not broken into components then the component
  1. ; subscript will not be used. Same is true of the
  1. ; sub-component subscript.
  1. ;
  1. ;Declare variables
  1. N SEG,SEGNAME,REP
  1. Q:'$D(MSGARR)
  1. Q:'$D(@MSGARR)
  1. Q:'$D(OUTARR)
  1. Q:'$D(HL)
  1. S PARCOMP=+$G(PARCOMP)
  1. S CNVRT=+$G(CNVRT)
  1. K @OUTARR
  1. ;Parse message by segment
  1. S SEG=""
  1. F S SEG=$O(@MSGARR@(SEG)) Q:SEG="" D
  1. .;Parse segment
  1. .D PARSEG($NA(@MSGARR@(SEG)),$NA(@OUTARR@(SEG)),.HL,PARCOMP,CNVRT)
  1. .;Set up segment index
  1. .S SEGNAME=$G(@OUTARR@(SEG,0))
  1. .Q:SEGNAME=""
  1. .S REP=$O(@OUTARR@(SEGNAME,""),-1)+1
  1. .S @OUTARR@(SEGNAME,REP)=SEG
  1. Q