*/
public Segment getCriticalResponseData(String message) throws HL7Exception {
//try to get MSH segment
int locStartMSH = message.indexOf("MSH");
if (locStartMSH < 0)
throw new HL7Exception(
"Couldn't find MSH segment in message: " + message,
HL7Exception.SEGMENT_SEQUENCE_ERROR);
int locEndMSH = message.indexOf('\r', locStartMSH + 1);
if (locEndMSH < 0)
locEndMSH = message.length();
String mshString = message.substring(locStartMSH, locEndMSH);
//find out what the field separator is
char fieldSep = mshString.charAt(3);
//get field array
String[] fields = split(mshString, String.valueOf(fieldSep));
Segment msh = null;
try {
//parse required fields
String encChars = fields[1];
char compSep = encChars.charAt(0);
String messControlID = fields[9];
String[] procIDComps = split(fields[10], String.valueOf(compSep));
//fill MSH segment
String version = "2.4"; //default
try {
version = this.getVersion(message);
}
catch (Exception e) { /* use the default */
}
msh = Parser.makeControlMSH(version, getFactory());
Terser.set(msh, 1, 0, 1, 1, String.valueOf(fieldSep));
Terser.set(msh, 2, 0, 1, 1, encChars);
Terser.set(msh, 10, 0, 1, 1, messControlID);
Terser.set(msh, 11, 0, 1, 1, procIDComps[0]);
Terser.set(msh, 12, 0, 1, 1, version);
}
catch (Exception e) {
throw new HL7Exception(
"Can't parse critical fields from MSH segment ("
+ e.getClass().getName()
+ ": "
+ e.getMessage()
+ "): "