int nrSub = Terser.numSubComponents( types[t], c ); for ( int sc = 1; sc <= nrSub; sc++ ) { String string = Terser.get( segment, n, t, c, sc );
/** * @return structure of the message, e.g. '2.5.1' */ public static String messageVersion(Terser t) throws HL7Exception { return t.get("/MSH-12-1"); }
/** * @return event type of the message, e.g. 'ADT' */ public static String messageType(Terser t) throws HL7Exception { return t.get("/MSH-9-1"); }
/** * @return structure of the message, e.g. 'ADT_A01' */ public static String messageStructure(Terser t) throws HL7Exception { return t.get("/MSH-9-3"); }
/** * @return trigger event of the message, e.g. 'A01' */ public static String triggerEvent(Terser t) throws HL7Exception { return t.get("/MSH-9-2"); }
public static String mshField(String mshFieldNo, Terser t) throws HL7Exception { return t.get(mshFieldNo); }
private String[] getCurrentValues(String[] thePaths) throws HL7Exception { String[] paths = composePaths(thePaths); String[] values = new String[paths.length]; for (int i = 0; i < paths.length; i++) { values[i] = myTerser.get(paths[i]); if (values[i] == null) { values[i] = ""; } } return values; }
private String[] getCurrentValues(String[] thePaths) throws HL7Exception { String[] paths = composePaths(thePaths); String[] values = new String[paths.length]; for (int i = 0; i < paths.length; i++) { values[i] = myTerser.get(paths[i]); if (values[i] == null) { values[i] = ""; } } return values; }
/** * Returns the first Application that has been bound to messages of this type. */ private <T extends Message> ReceivingApplication<T> findApplication(T theMessage) throws HL7Exception { Terser t = new Terser(theMessage); AppRoutingData msgData = new AppRoutingDataImpl(t.get("/MSH-9-1"), t.get("/MSH-9-2"), t.get("/MSH-11-1"), t.get("/MSH-12")); ReceivingApplication<T> app = findDestination(theMessage, msgData); //have to send back an application reject if no apps available to process if (app == null) { app = (ReceivingApplication<T>)new DefaultApplication(); } return app; }
/** * Returns the first Application that has been bound to messages of this type. */ private <T extends Message> ReceivingApplication<T> findApplication(T theMessage) throws HL7Exception { Terser t = new Terser(theMessage); AppRoutingData msgData = new AppRoutingDataImpl(t.get("/MSH-9-1"), t.get("/MSH-9-2"), t.get("/MSH-11-1"), t.get("/MSH-12")); ReceivingApplication<T> app = findDestination(theMessage, msgData); //have to send back an application reject if no apps available to process if (app == null) { app = (ReceivingApplication<T>)new DefaultApplication(); } return app; }
public Object evaluate(Message msg) throws HL7Exception { return new Terser(msg).get(expression); }
public Object evaluate(Message msg) throws HL7Exception { return new Terser(msg).get(expression); }
private String[] getDeclaredProfileIDs(Message theMessage) throws HL7Exception { Terser t = new Terser(theMessage); boolean noMore = false; int c = 0; List<String> declaredProfiles = new ArrayList<String>(8); while (!noMore) { String path = "MSH-21(" + c++ + ")"; String idRep = t.get(path); //FIXME fails if empty rep precedes full rep ... should add getAll() to Terser and use that if (idRep == null || idRep.equals("")) { noMore = true; } else { declaredProfiles.add(idRep); } } return declaredProfiles.toArray(new String[declaredProfiles.size()]); }
private Map<String, Object> getMetadata(Message theMessage) throws HL7Exception { Map<String, Object> md = new HashMap<String, Object>(); Terser t = new Terser(theMessage); //snapshot so concurrent changes won't break our iteration String[] fields = getMetadataFields().toArray(new String[0]); for (int i = 0; i < fields.length; i++) { String field = fields[i].toString(); String val = t.get(field); md.put(field, val); } return md; }
private Map<String, Object> getMetadata(Message theMessage) throws HL7Exception { Map<String, Object> md = new HashMap<String, Object>(); Terser t = new Terser(theMessage); //snapshot so concurrent changes won't break our iteration String[] fields = getMetadataFields().toArray(new String[0]); for (int i = 0; i < fields.length; i++) { String field = fields[i].toString(); String val = t.get(field); md.put(field, val); } return md; }
protected void applySuperStructureName(Message theMessage) throws HL7Exception { if (theMessage instanceof AbstractSuperMessage) { if (theMessage.getName() == null) { Terser t = new Terser(theMessage); String name = null; try { name = t.get("/MSH-9-3"); } catch (HL7Exception e) { // ignore } if (StringUtil.isBlank(name)) { name = t.get("/MSH-9-1") + "_" + t.get("/MSH-9-2"); } ((AbstractSuperMessage)theMessage).setName(name); } } }
/** * @see Validator#validate */ public HL7Exception[] validate(Message message, StaticDef profile) throws ProfileException, HL7Exception { List<HL7Exception> exList = new ArrayList<HL7Exception>(); Terser t = new Terser(message); checkMessageType(t.get("/MSH-9-1"), profile, exList); checkEventType(t.get("/MSH-9-2"), profile, exList); checkMessageStructure(t.get("/MSH-9-3"), profile, exList); exList.addAll(doTestGroup(message, profile, profile.getIdentifier(), validateChildren)); return exList.toArray(new HL7Exception[exList.size()]); }
/** * @see Validator#validate */ public HL7Exception[] validate(Message message, StaticDef profile) throws ProfileException, HL7Exception { List<HL7Exception> exList = new ArrayList<HL7Exception>(); Terser t = new Terser(message); checkMessageType(t.get("/MSH-9-1"), profile, exList); checkEventType(t.get("/MSH-9-2"), profile, exList); checkMessageStructure(t.get("/MSH-9-3"), profile, exList); exList.addAll(doTestGroup(message, profile, profile.getIdentifier(), validateChildren)); return exList.toArray(new HL7Exception[exList.size()]); }
private EncodingCharacters getValidEncodingCharacters(char fieldSep, Segment msh) throws HL7Exception { String encCharString = Terser.get(msh, 2, 0, 1, 1); if (encCharString == null) { throw new HL7Exception("Can't encode message: MSH-2 (encoding characters) is missing"); } if (Version.V27.isGreaterThan(Version.versionOf(msh.getMessage().getVersion())) && encCharString.length() != 4) { throw new HL7Exception("Encoding characters (MSH-2) value '" + encCharString + "' invalid -- must be 4 characters", ErrorCode.DATA_TYPE_ERROR); } else if (encCharString.length() != 4 && encCharString.length() != 5) { throw new HL7Exception("Encoding characters (MSH-2) value '" + encCharString + "' invalid -- must be 4 or 5 characters", ErrorCode.DATA_TYPE_ERROR); } return new EncodingCharacters(fieldSep, encCharString); }
private EncodingCharacters getValidEncodingCharacters(char fieldSep, Segment msh) throws HL7Exception { String encCharString = Terser.get(msh, 2, 0, 1, 1); if (encCharString == null) { throw new HL7Exception("Can't encode message: MSH-2 (encoding characters) is missing"); } if (Version.V27.isGreaterThan(Version.versionOf(msh.getMessage().getVersion())) && encCharString.length() != 4) { throw new HL7Exception("Encoding characters (MSH-2) value '" + encCharString + "' invalid -- must be 4 characters", ErrorCode.DATA_TYPE_ERROR); } else if (encCharString.length() != 4 && encCharString.length() != 5) { throw new HL7Exception("Encoding characters (MSH-2) value '" + encCharString + "' invalid -- must be 4 or 5 characters", ErrorCode.DATA_TYPE_ERROR); } return new EncodingCharacters(fieldSep, encCharString); }