|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.uhn.hl7v2.model.AbstractStructure
ca.uhn.hl7v2.model.AbstractGroup
ca.uhn.hl7v2.model.AbstractMessage
public abstract class AbstractMessage
A default implementation of Message.
| Field Summary |
|---|
| Fields inherited from class ca.uhn.hl7v2.model.AbstractStructure |
|---|
log |
| Constructor Summary | |
|---|---|
AbstractMessage(ModelClassFactory theFactory)
|
|
| Method Summary | |
|---|---|
String |
encode()
Encodes this message using the parser returned by Message.getParser() |
Message |
generateACK()
Generates and returns an ACK message which would be used to acknowledge this message successfully, with an MSA-1 code of "AA". |
Message |
generateACK(String theAcknowledgementCode,
HL7Exception theException)
Generates and returns an ACK message which would be used to acknowledge this message successfully. |
String |
getEncodingCharactersValue()
Convenience method which retrieves the encoding characters value from the second field of the first segment. |
Character |
getFieldSeparatorValue()
Convenience method which retrieves the field separator value from the first field of the first segment. |
Message |
getMessage()
Returns this Message object. |
Group |
getParent()
Returns the parent group within which this structure exists (may be root message group). |
Parser |
getParser()
Returns the parser to be used when parse/encode methods are called on this Message, as well as its children. |
ValidationContext |
getValidationContext()
|
String |
getVersion()
Returns the version number. |
void |
initQuickstart(String messageCode,
String messageTriggerEvent,
String processingId)
Quickly initializes this message with common values in the first (MSH) segment. |
void |
parse(String string)
Parses the string into this message using the parser returned by Message.getParser() |
String |
printStructure()
Prints a summary of the contents and structure of this message. |
void |
setParser(Parser parser)
Sets the parser to be used when parse/encode methods are called on this Message, as well as its children. |
void |
setValidationContext(ValidationContext theContext)
|
String |
toString()
Provides an overview of the type and structure of this message |
| Methods inherited from class ca.uhn.hl7v2.model.AbstractGroup |
|---|
add, add, addNonstandardSegment, addNonstandardSegment, clear, currentReps, get, get, getAll, getAllAsList, getClass, getFieldNumForName, getModelClassFactory, getName, getNames, getNonStandardNames, getReps, getTyped, getTyped, insert, insertRepetition, insertRepetition, isGroup, isRepeating, isRequired, removeRepetition, tryToInstantiateStructure |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface ca.uhn.hl7v2.model.Group |
|---|
addNonstandardSegment, addNonstandardSegment, get, get, getAll, getClass, getNames, isGroup, isRepeating, isRequired |
| Methods inherited from interface ca.uhn.hl7v2.model.Structure |
|---|
getName |
| Constructor Detail |
|---|
public AbstractMessage(ModelClassFactory theFactory)
theFactory - factory for model classes (e.g. group, segment) for this message| Method Detail |
|---|
public Message getMessage()
getMessage in interface StructuregetMessage in class AbstractStructurepublic Group getParent()
Structure
getParent in interface StructuregetParent in class AbstractStructurepublic String getVersion()
getVersion in interface MessageMessage.getVersion()public ValidationContext getValidationContext()
getValidationContext in interface Messagepublic void setValidationContext(ValidationContext theContext)
setValidationContext in interface MessagetheContext - the set of validation rules that are to apply to this message
public Character getFieldSeparatorValue()
throws HL7Exception
getFieldSeparatorValue in interface MessageHL7Exception - If an error occurs
public String getEncodingCharactersValue()
throws HL7Exception
getEncodingCharactersValue in interface MessageHL7Exception - If an error occurspublic void setParser(Parser parser)
Sets the parser to be used when parse/encode methods are called on this Message, as well as its children. It is recommended that if these methods are going to be called, a parser be supplied with the validation context wanted. Where possible, the parser should be reused for best performance, unless thread safety is an issue.
Note that not all parsers can be used. As of version 1.0, only PipeParser
supports this functionality
Serialization note: The message parser is marked as transient, so it will not survive serialization.
setParser in interface Messagepublic Parser getParser()
Returns the parser to be used when parse/encode methods are called on this
Message, as well as its children. The default value is a new PipeParser.
Serialization note: The message parser is marked as transient, so it will not survive serialization.
getParser in interface Message
public void parse(String string)
throws HL7Exception
Message.getParser()
parse in interface MessageHL7Exception
public String encode()
throws HL7Exception
Message.getParser()
encode in interface MessageHL7Exception
public Message generateACK()
throws HL7Exception,
IOException
Generates and returns an ACK message which would be used to acknowledge this message successfully, with an MSA-1 code of "AA". The ACK generated will be of the same version as the value of MSH-12 in this message (as opposed to the version of the message class instance, if they are different)
Note that this method will fail if it is not possible to generate an ACK for any reason, such as
generateACK in interface MessageHL7Exception - If the message can not be constructed
IOException - If a failure occurs in generating a control ID for the message
public Message generateACK(String theAcknowledgementCode,
HL7Exception theException)
throws HL7Exception,
IOException
Generates and returns an ACK message which would be used to acknowledge this message successfully. The ACK generated will be of the same version as the value of MSH-12 in this message (as opposed to the version of the message class instance, if they are different)
Note that this method will fail if it is not possible to generate an ACK for any reason, such as
generateACK in interface MessagetheAcknowledgementCode - The acknowledement code (MSA-1) to supply. If null, defaults to "AA". To generate a typical NAK, use "AE"theException - The exceptions used to populate the ERR segment (if any)
HL7Exception - If the message can not be constructed
IOException - If a failure occurs in generating a control ID for the messagepublic String toString()
toString in class Object
public String printStructure()
throws HL7Exception
Prints a summary of the contents and structure of this message. This is useful for debugging purposes, if you want to figure out where in the structure of a message a given segment has been placed.
For instance, the following message (containing a few quirks for demonstration purposes):
...produces the following output:
MSH|^~\\&|^QueryServices||||20021011161756.297-0500||ADT^A01|1|D|2.4\r
EVN|R01
EVN|R02
PID|1
IN1|1
IN1|2
PID|2
ADT_A01 (start)
MSH - MSH|^~\&|^QueryServices||||20021011161756.297-0500||ADT^A01|1|D|2.4
EVN - EVN|R01
[ { EVN2 } ] (non-standard) - EVN|R02
PID - PID|1
[ PD1 ] - Not populated
[ { ROL } ] - Not populated
[ { NK1 } ] - Not populated
PV1 - Not populated
[ PV2 ] - Not populated
[ { ROL2 } ] - Not populated
[ { DB1 } ] - Not populated
[ { OBX } ] - Not populated
[ { AL1 } ] - Not populated
[ { DG1 } ] - Not populated
[ DRG ] - Not populated
PROCEDURE (start)
[{
PR1 - Not populated
[ { ROL } ] - Not populated
}]
PROCEDURE (end)
[ { GT1 } ] - Not populated
INSURANCE (start)
[{
IN1 - IN1|1
[ IN2 ] - Not populated
[ { IN3 } ] - Not populated
[ { ROL } ] - Not populated
}]
[{
IN1 - IN1|2
[ { PID } ] (non-standard) - PID|2
[ IN2 ] - Not populated
[ { IN3 } ] - Not populated
[ { ROL } ] - Not populated
}]
INSURANCE (end)
[ ACC ] - Not populated
[ UB1 ] - Not populated
[ UB2 ] - Not populated
[ PDA ] - Not populated
ADT_A01 (end)
printStructure in interface MessageHL7Exception - If any problems occur encoding the structure
public void initQuickstart(String messageCode,
String messageTriggerEvent,
String processingId)
throws HL7Exception,
IOException
Settings include:
MessageIDGenerator
messageCode - The message code (aka message type) to insert into MSH-9-1. Example: "ADT"messageTriggerEvent - The message trigger event to insert into MSG-9-2. Example: "A01"processingId - The message processing ID to insert into MSH-11. Examples: "T" (for TEST) or "P" for (PRODUCTION)
IOException - If the message ID generation fails for some reason
HL7Exception - If the message rejects any of the values which are generated to setting
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||