use of com.google.api.services.healthcare.v1.model.Message in project tdi-studio-se by Talend.
the class HL7Parse method doParse.
/**
* DOC gcui Comment method "doParse".
*
* @param filePath
* @param hl7Manager
* @param msgContentList
* @return
*/
public List<Message> doParse(String filePath, HL7Manager hl7Manager, List<String> msgContentList, String startChar, String endChar) {
List<Message> messageList = new ArrayList<Message>();
String filePathNoQuotes = TalendTextUtils.removeQuotes(filePath);
File file = Path.fromOSString(filePathNoQuotes).toFile();
if (file.exists()) {
msgContentList.clear();
ByteArray array = PropertiesFactory.eINSTANCE.createByteArray();
try {
array.setInnerContentFromFile(file);
TalendHL7Reader talendHL7Reader = new TalendHL7Reader(new java.io.FileInputStream(file), "ISO-8859-15");
String HL7InputTem = null;
if (startChar != null) {
talendHL7Reader.setStartMsgChar(stringParse2Char(startChar));
}
if (endChar != null) {
talendHL7Reader.setEndMsgChar(stringParse2Char(endChar));
}
while ((HL7InputTem = talendHL7Reader.getMessage()) != null) {
msgContentList.add(HL7InputTem);
Message message = getHL7MessageInput(HL7InputTem);
messageList.add(message);
}
if (msgContentList == null || msgContentList.size() == 0) {
String msgText = new String(array.getInnerContent());
msgContentList.add(msgText);
Message message = getHL7MessageInput(msgText);
messageList.add(message);
}
hl7Manager.getUiManager().getHl7UI().getContentProvider().getAllSegmentsForMessage().clear();
hl7Manager.getUiManager().getHl7UI().getMessageViewer().setInput(messageList.toArray());
hl7Manager.getUiManager().getHl7UI().getHeader().setMsgIsChange(true);
hl7Manager.getUiManager().getHl7UI().initSchemaCombo(null);
hl7Manager.getUiManager().getHl7UI().getMetadataEditor().removeAll();
hl7Manager.getUiManager().getHl7UI().redrawLinkers();
} catch (IOException ex) {
ExceptionHandler.process(ex);
}
}
return messageList;
}
use of com.google.api.services.healthcare.v1.model.Message in project tdi-studio-se by Talend.
the class HL7Parse method getHL7MessageInput.
/**
* DOC gcui Comment method "getHL7MessageInput".
*
* @param messageText
* @return
*/
public Message getHL7MessageInput(String messageText) {
GenericParser p = new GenericParser();
// force use novalidation
p.setValidationContext(new NoValidation());
Message message = null;
try {
if (messageText != null) {
messageText = messageText.replace('\n', '\r');
message = p.parse(messageText);
}
} catch (Exception e) {
ExceptionHandler.process(e);
MessageBox errorBox = new MessageBox(new Shell(), SWT.APPLICATION_MODAL | SWT.OK);
//$NON-NLS-1$
errorBox.setText("Parse error");
//$NON-NLS-1$
errorBox.setMessage("The content can't be parsed correctly,please check the file");
if (errorBox.open() == SWT.OK) {
errorBox.getParent().getShell().close();
}
}
return message;
}
use of com.google.api.services.healthcare.v1.model.Message in project tdi-studio-se by Talend.
the class HL7Parse method doParse.
public List<Message> doParse(String filePath, TreeViewer messageViewerStep1, List<String> msgContentList, String startChar, String endChar) {
List<Message> messageList = new ArrayList<Message>();
String filePathNoQuotes = TalendTextUtils.removeQuotes(filePath);
File file = Path.fromOSString(filePathNoQuotes).toFile();
if (file.exists()) {
msgContentList.clear();
ByteArray array = PropertiesFactory.eINSTANCE.createByteArray();
try {
array.setInnerContentFromFile(file);
//$NON-NLS-1$
TalendHL7Reader talendHL7Reader = new TalendHL7Reader(new java.io.FileInputStream(file), "ISO-8859-15");
String hl7InputTem = null;
if (startChar != null) {
talendHL7Reader.setStartMsgChar(stringParse2Char(startChar));
}
if (endChar != null) {
talendHL7Reader.setEndMsgChar(stringParse2Char(endChar));
}
while ((hl7InputTem = talendHL7Reader.getMessage()) != null) {
msgContentList.add(hl7InputTem);
Message message = getHL7MessageInput(hl7InputTem);
messageList.add(message);
}
if (msgContentList == null || msgContentList.size() == 0) {
String msgText = new String(array.getInnerContent());
msgContentList.add(msgText);
Message message = getHL7MessageInput(msgText);
messageList.add(message);
}
messageViewerStep1.setInput(messageList.toArray());
} catch (IOException ex) {
ExceptionHandler.process(ex);
}
}
return messageList;
}
use of com.google.api.services.healthcare.v1.model.Message in project tdi-studio-se by Talend.
the class HL7PublicUtil method getFirstLevelChild.
public List getFirstLevelChild(Object parentElement) {
List values = new ArrayList();
if (parentElement instanceof Message) {
Message messParent = (Message) parentElement;
String[] childNames = messParent.getNames();
if (!values.isEmpty()) {
values.clear();
}
for (int i = 0; i < childNames.length; i++) {
try {
Structure[] childReps = messParent.getAll(childNames[i]);
for (int j = 0; j < childReps.length; j++) {
if (childReps[j] instanceof Message) {
values.add(childReps[j]);
}
if (childReps[j] instanceof Group) {
values.add(childReps[j]);
allSegmentFromGroup.clear();
getAllSegmentsFromGroup((Group) childReps[j]);
}
if (childReps[j] instanceof Segment) {
SegmentModel sModel = new SegmentModel((Segment) childReps[j], messParent, i, j);
if (sModel.getTypes() != null && sModel.getTypes().length > 0) {
values.add(sModel);
if (!allSegmentsForMessage.contains(sModel)) {
allSegmentsForMessage.add(sModel);
}
}
}
}
} catch (HL7Exception e) {
e.printStackTrace();
}
}
}
return values;
}
use of com.google.api.services.healthcare.v1.model.Message in project tdi-studio-se by Talend.
the class HL7PublicUtil method getHL7TreeNodes.
public List<HL7TreeNode> getHL7TreeNodes(List<Message> messageList) {
List<HL7TreeNode> list = new ArrayList<HL7TreeNode>();
if (messageList == null) {
return list;
}
for (Message message : messageList) {
HL7TreeNode root = initTreeRoot(message);
if (root instanceof Element) {
// root = ((Element) root).getElementChildren().get(0);
root.setParent(null);
list.add(root);
}
}
return list;
}
Aggregations