From: <Fre...@cl...> - 2005-11-21 09:00:51
|
Hi, For the first time, I have to parse messages with repetitive OBX-5=20 fields. Unfortunately, the method Varies.fixOBX5 sets the data type of=20 only the first repetition of this field. Is there any reason for that? I've quickly added these few lines of codes (not the best solution, but=20 I would avoid changing the code structure) and it seems to work: public static void fixOBX5(Segment segment) throws HL7Exception { try { //get unqualified class name Primitive obx2 =3D (Primitive) segment.getField(2, 0); Varies v =3D (Varies) segment.getField(5, 0); if (obx2.getValue() =3D=3D null) { ... } else { //set class Class c =3D ... v.setData((Type) c.newInstance()); // What about repetitions? * Type[] obx5s =3D segment.getField(5); for (int i =3D 1; i < obx5s.length; i++) { v =3D (Varies) obx5s[i]; v.setData((Type) c.newInstance()); } * } } ... By the way, wouldn't it be a good idea to make this method more generic?=20 For example, I also had to use a workaroud to build MFN M02 messages:=20 since version 2.3.1, the MFE-4 field is a variant, from which the=20 datatype is specified in MFE-5. I don't know if there are other similar=20 cases in the HL7 spec. Why not a generic fixFieldDataType method, with 3=20 parameters: the segment, the field to be set and the field specifying=20 the datatype? Regards, --=20 Fr=E9d=E9ric Dubru Cliniques universitaires Saint-Luc 10, avenue Hippocrate B-1200 Bruxelles +32 2 764 36 43 http://www.saintluc.be |