The code below produces the error:
10/08/2011 9:04:39 AM au.gov.qld.health.sit.bsqr.BsqrCreateHapiMessage main
SEVERE: null
ca.uhn.hl7v2.model.DataTypeException: The GMT offset minute value of the TM
datatype must be >=0 and <=59
at ca.uhn.hl7v2.model.primitive.CommonTM.setOffset(CommonTM.java:457)
at ca.uhn.hl7v2.model.primitive.CommonTS.setOffset(CommonTS.java:362)
at ca.uhn.hl7v2.model.primitive.CommonTS.setValue(CommonTS.java:397)
at
ca.uhn.hl7v2.model.primitive.TSComponentOne.setValue(TSComponentOne.java:222)
at
au.gov.qld.health.sit.bsqr.BsqrCreateHapiMessage.main(BsqrCreateHapiMessage.java:44)
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package au.gov.qld.health.sit.bsqr;
import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.v231.datatype.TM;
import ca.uhn.hl7v2.model.v231.datatype.XPN;
import ca.uhn.hl7v2.model.v231.message.ORM_O01;
import
ca.uhn.hl7v2.model.v231.group.ORM_O01_ORCOBRRQDRQ1ODSODTRXONTEDG1RXRRXCNTEOBXNTECTIBLG;
import ca.uhn.hl7v2.model.v231.group.ORM_O01_PIDPD1NTEPV1PV2IN1IN2IN3GT1AL1;
import ca.uhn.hl7v2.model.v231.message.ORU_R01;
import ca.uhn.hl7v2.model.v231.segment.OBR;
import ca.uhn.hl7v2.model.v231.segment.ORC;
import ca.uhn.hl7v2.model.v231.segment.PID;
import ca.uhn.hl7v2.parser.PipeParser;
import ca.uhn.hl7v2.util.Terser;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author VowlesI
*/
public class BsqrCreateHapiMessage {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try {
ORM_O01 hl7Out = new ORM_O01();
hl7Out.getMSH().getEncodingCharacters().setValue("^~\\&");
hl7Out.getMSH().getFieldSeparator().setValue("|");
hl7Out.getMSH().getVersionID().getVersionID().setValue("2.3.1");
hl7Out.getMSH().getDateTimeOfMessage().getTimeOfAnEvent().setValue(Calendar.getInstance(TimeZone.getTimeZone("GMT+10:00")));
hl7Out.getMSH().getDateTimeOfMessage().getTimeOfAnEvent().setOffset(1000);
int tm =
hl7Out.getMSH().getDateTimeOfMessage().getTimeOfAnEvent().getGMTOffset();
System.out.println("GMTOffset = " + tm);
hl7Out.getMSH().getProcessingID().getProcessingID().setValue("P");
hl7Out.getMSH().getCountryCode().setValue("AUS");
hl7Out.getMSH().getCharacterSet(0).setValue("ASCII");
hl7Out.getMSH().getPrincipalLanguageOfMessage().getIdentifier().setValue("ENG");
Terser terser = new Terser(hl7Out);
String pidTerse = "/PIDPD1NTEPV1PV2IN1IN2IN3GT1AL1";
String orcTerse =
"/ORCOBRRQDRQ1ODSODTRXONTEDG1RXRRXCNTEOBXNTECTIBLG";
String obrTerse = orcTerse +
"/OBRRQDRQ1ODSODTRXONTEDG1RXRRXCNTEOBXNTE";
// Populate the MSH
terser.set("/MSH-9-1", "ORM") ;
terser.set("/MSH-9-2", "O01") ;
// Populate the PID
terser.set(pidTerse + "/PID-5-1", "MOUSE");
terser.set(pidTerse + "/PID-5-2", "MINNIE");
terser.set(pidTerse + "/PID-5-3", null);
terser.set(pidTerse + "/PID-5-5", "MS");
terser.set(pidTerse + "/PID-7", "19510621");
terser.set(pidTerse + "/PID-8", "F");
// Populate the ORC
terser.set(orcTerse + "/ORC-1", "NW");
terser.set(orcTerse + "/ORC-4", null);
terser.set(orcTerse + "/ORC-5", null);
terser.set(orcTerse + "/ORC-6", "N");
// Populate the OBR
terser.set(obrTerse + "/OBR-1", "1");
terser.set(obrTerse + "/OBR-3-1", "1234");
terser.set(obrTerse + "/OBR-3-2", "LAB");
terser.set(obrTerse + "/OBR-4-1", "SCREENING MAMMO");
terser.set(obrTerse + "/OBR-4-2", "SCREENING");
terser.set(obrTerse + "/OBR-18", "2000000");
terser.set(obrTerse + "/OBR-25", "SCHEDULED");
terser.set(obrTerse + "/OBR-27-4", "201108030800");
// Output
System.out.println(hl7Out.printStructure());
String[] segments = (new PipeParser().encode(hl7Out)).split("\r");
for (int i=0; i < segments.length; i++) {
System.out.println(segments[i]);
}
} catch (DataTypeException ex) {
Logger.getLogger(BsqrCreateHapiMessage.class.getName()).log(Level.SEVERE, null,
ex);
} catch (HL7Exception ex) {
Logger.getLogger(BsqrCreateHapiMessage.class.getName()).log(Level.SEVERE, null,
ex);
}
}
}
When the line
hl7Out.getMSH().getDateTimeOfMessage().getTimeOfAnEvent().setValue(Calendar.getInstance(TimeZone.getTimeZone("GMT+10:00")));
is changed to read
hl7Out.getMSH().getDateTimeOfMessage().getTimeOfAnEvent().setValue(Calendar.getInstance(TimeZone.getTimeZone("total
nonsense")));
It works, producing output
GMTOffset = 1000
ORM_O01 (start)
MSH -
MSH|^~\&|||||20110809231301.578+1000||ORM^O01||P|2.3.1|||||AUS|ASCII|ENG
[ { NTE } ] - Not populated
PIDPD1NTEPV1PV2IN1IN2IN3GT1AL1 (start)
[
PID - PID|||||MOUSE^MINNIE^^^MS||19510621|F
[ PD1 ] - Not populated
[ { NTE } ] - Not populated
PV1PV2 (start)
[
PV1 - Not populated
[ PV2 ] - Not populated
]
PV1PV2 (end)
IN1IN2IN3 (start)
[{
IN1 - Not populated
[ IN2 ] - Not populated
[ { IN3 } ] - Not populated
}]
IN1IN2IN3 (end)
[ GT1 ] - Not populated
[ { AL1 } ] - Not populated
]
PIDPD1NTEPV1PV2IN1IN2IN3GT1AL1 (end)
ORCOBRRQDRQ1ODSODTRXONTEDG1RXRRXCNTEOBXNTECTIBLG (start)
{
ORC - ORC|NW|||||N
OBRRQDRQ1ODSODTRXONTEDG1RXRRXCNTEOBXNTE (start)
[
OBR - OBR|1||1234^LAB|SCREENING
MAMMO^SCREENING||||||||||||||2000000|||||||SCHEDULED||^^^201108030800
RQD - Not populated
RQ1 - Not populated
ODS - Not populated
ODT - Not populated
RXO - Not populated
[ { NTE } ] - Not populated
[ { DG1 } ] - Not populated
{ RXR } - Not populated
RXCNTE (start)
[
RXC - Not populated
NTE - Not populated
]
RXCNTE (end)
OBXNTE (start)
[{
OBX - Not populated
[ { NTE } ] - Not populated
}]
OBXNTE (end)
]
OBRRQDRQ1ODSODTRXONTEDG1RXRRXCNTEOBXNTE (end)
[ { CTI } ] - Not populated
[ BLG ] - Not populated
}
ORCOBRRQDRQ1ODSODTRXONTEDG1RXRRXCNTEOBXNTECTIBLG (end)
ORM_O01 (end)
MSH|^~\&|||||20110809231301.578+1000||ORM^O01||P|2.3.1|||||AUS|ASCII|ENG
PID|||||MOUSE^MINNIE^^^MS||19510621|F
ORC|NW|||||N
OBR|1||1234^LAB|SCREENING
MAMMO^SCREENING||||||||||||||2000000|||||||SCHEDULED||^^^201108030800
Anyone got any thoughts why setting the time zone correctly produces an error,
whereas getting it wrong makes it work?
Tests produce the same outcome on HAPI v 1.1 and 1.2
Thanks
Ian
********************************************************************************
This email, including any attachments sent with it, is confidential and for the
sole use of the intended recipient(s). This confidentiality is not waived or
lost, if you receive it and you are not the intended recipient(s), or if it is
transmitted/received in error.
Any unauthorised use, alteration, disclosure, distribution or review of this
email is strictly prohibited. The information contained in this email,
including any attachment sent with it, may be subject to a statutory duty of
confidentiality if it relates to health service matters.
If you are not the intended recipient(s), or if you have received this email in
error, you are asked to immediately notify the sender by telephone collect on
Australia +61 1800 198 175 or by return email. You should also delete this
email, and any copies, from your computer system network and destroy any hard
copies produced.
If not an intended recipient of this email, you must not copy, distribute or
take any action(s) that relies on it; any form of disclosure, modification,
distribution and/or publication of this email is also prohibited.
Although Queensland Health takes all reasonable steps to ensure this email does
not contain malicious software, Queensland Health does not accept
responsibility for the consequences if any person's computer inadvertently
suffers any disruption to services, loss of information, harm or is infected
with a virus, other malicious computer programme or code that may occur as a
consequence of receiving this email.
Unless stated otherwise, this email represents only the views of the sender and
not the views of the Queensland Government.
**********************************************************************************
------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model
configuration take the hassle out of deploying and managing Subversion and
the tools developers use with it. Learn more about uberSVN and get a free
download at: http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Hl7api-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel