Search in sources :

Example 71 with Message

use of bind.feature.generichierarchy.case1.model.Message in project streamsx.health by IBMStreams.

the class OruR01Ingest method run.

@Override
public void run() {
    Topology topology = new Topology("OruR01Ingest");
    ObxToSplMapper mapper = new ObxToSplMapper();
    addDependencies(topology);
    TStream<Message> messages = topology.endlessSource(new HapiMessageSupplier(getPort()));
    // transform message to Observation object
    TStream<Observation> observationStream = messages.multiTransform(message -> {
        return mapper.messageToModel(message);
    });
    StreamSchema schema = Type.Factory.getStreamSchema(Observation.OBSERVATION_SCHEMA_SPL);
    @SuppressWarnings("serial") SPLStream splObservations = SPLStreams.convertStream(observationStream, new BiFunction<Observation, OutputTuple, OutputTuple>() {

        @Override
        public OutputTuple apply(Observation observation, OutputTuple outTuple) {
            return mapper.modelToSpl(observation, outTuple);
        }
    }, schema);
    splObservations.print();
    splObservations.publish(getTopic());
    try {
        StreamsContextFactory.getStreamsContext(StreamsContext.Type.DISTRIBUTED).submit(topology);
    } catch (Exception e) {
        TRACE.error("Unable to submit topology", e);
    }
}
Also used : Message(ca.uhn.hl7v2.model.Message) Topology(com.ibm.streamsx.topology.Topology) HapiMessageSupplier(com.ibm.streamsx.health.hapi.internal.HapiMessageSupplier) StreamSchema(com.ibm.streams.operator.StreamSchema) OutputTuple(com.ibm.streams.operator.OutputTuple) SPLStream(com.ibm.streamsx.topology.spl.SPLStream) ObxToSplMapper(com.ibm.streamsx.health.hapi.mapper.ObxToSplMapper) Observation(com.ibm.streamsx.health.hapi.model.Observation)

Example 72 with Message

use of bind.feature.generichierarchy.case1.model.Message in project tdi-studio-se by Talend.

the class HL7MessageTreeContentProvider method getChildren.

public Object[] getChildren(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((Group) 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);
                            }
                        }
                    }
                }
            // values.addAll(Arrays.asList(childReps));
            } catch (HL7Exception e) {
                e.printStackTrace();
            }
        }
        return values.toArray();
    }
    if (parentElement instanceof Segment) {
        values.clear();
        Segment segment = (Segment) parentElement;
        SegmentModel sm = new SegmentModel(segment, segment, 0, 0);
        return sm.getTypes();
    }
    if (parentElement instanceof SegmentModel) {
        SegmentModel sm = (SegmentModel) parentElement;
        return sm.getTypes();
    }
    if (parentElement instanceof TypeModel) {
        TypeModel tm = (TypeModel) parentElement;
        return tm.getPrimitives();
    }
    if (parentElement instanceof Group) {
        values.clear();
        Group group = (Group) parentElement;
        String[] childNames = group.getNames();
        for (int i = 0; i < childNames.length; i++) {
            try {
                Structure[] childReps = group.getAll(childNames[i]);
                for (int j = 0; j < childReps.length; j++) {
                    if (childReps[j] instanceof Segment) {
                        SegmentModel sm = new SegmentModel((Segment) childReps[j], group, i, j);
                        if (sm.getTypes() != null && sm.getTypes().length > 0) {
                            values.add(sm);
                        }
                    } else {
                        values.add(childReps[j]);
                    }
                }
            // values.addAll(Arrays.asList(childReps));
            } catch (HL7Exception e) {
                e.printStackTrace();
            }
        }
        return values.toArray();
    }
    return new Object[0];
}
Also used : Group(ca.uhn.hl7v2.model.Group) Message(ca.uhn.hl7v2.model.Message) ArrayList(java.util.ArrayList) TypeModel(org.talend.designer.hl7.model.TypeModel) Segment(ca.uhn.hl7v2.model.Segment) HL7Exception(ca.uhn.hl7v2.HL7Exception) ArrayList(java.util.ArrayList) List(java.util.List) Structure(ca.uhn.hl7v2.model.Structure) SegmentModel(org.talend.designer.hl7.model.SegmentModel)

Example 73 with Message

use of bind.feature.generichierarchy.case1.model.Message in project tdi-studio-se by Talend.

the class HL7Parse method doParse.

/**
     * DOC gcui Comment method "doParse".
     * 
     * @param filePath
     * @return
     */
public List<Message> doParse(String filePath, String startChar, String endChar) {
    List<Message> messageList = new ArrayList<Message>();
    String filePathNoQuotes = TalendTextUtils.removeQuotes(filePath);
    File file = Path.fromOSString(filePathNoQuotes).toFile();
    if (file.exists()) {
        ByteArray array = PropertiesFactory.eINSTANCE.createByteArray();
        try {
            array.setInnerContentFromFile(file);
            TalendHL7Reader talendHL7Reader = new TalendHL7Reader(new java.io.FileInputStream(file), "ISO-8859-15");
            if (startChar != null) {
                talendHL7Reader.setStartMsgChar(stringParse2Char(startChar));
            }
            if (endChar != null) {
                talendHL7Reader.setEndMsgChar(stringParse2Char(endChar));
            }
            String HL7InputTem = null;
            String messageText = "";
            while ((HL7InputTem = talendHL7Reader.getMessage()) != null) {
                Message message = getHL7MessageInput(HL7InputTem);
                messageList.add(message);
                messageText = messageText + HL7InputTem + "\r";
            }
            if (messageText == null || "".equals(messageText)) {
                messageText = new String(array.getInnerContent());
            }
            talendHL7Reader.close();
        } catch (IOException ex) {
            ExceptionHandler.process(ex);
        }
    } else {
        MessageBox message = new MessageBox(new Shell(), SWT.APPLICATION_MODAL | SWT.OK);
        //$NON-NLS-1$
        message.setText("The file is not exist");
        //$NON-NLS-1$
        message.setMessage("Please check the file path and select the file again");
        if (message.open() == SWT.OK) {
            message.getParent().getShell().close();
        }
    }
    return messageList;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Message(ca.uhn.hl7v2.model.Message) ArrayList(java.util.ArrayList) ByteArray(org.talend.core.model.properties.ByteArray) IOException(java.io.IOException) File(java.io.File) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 74 with Message

use of bind.feature.generichierarchy.case1.model.Message in project tdi-studio-se by Talend.

the class HL7Parse method doParse.

/**
     * DOC gcui Comment method "doParse".
     * 
     * @param msgList
     * @return
     */
public List<Message> doParse(List<String> msgList) {
    List<Message> messageList = new ArrayList<Message>();
    for (int i = 0; i < msgList.size(); i++) {
        Message message = getHL7MessageInput(msgList.get(i));
        messageList.add(message);
    }
    return messageList;
}
Also used : Message(ca.uhn.hl7v2.model.Message) ArrayList(java.util.ArrayList)

Example 75 with Message

use of bind.feature.generichierarchy.case1.model.Message in project tdi-studio-se by Talend.

the class HL7UI method initMessageTree.

public void initMessageTree() {
    HL7Parse hl7Parse = new HL7Parse();
    List<Message> messageList = new ArrayList<Message>();
    if (initMsgContentList != null && initMsgContentList.size() > 0) {
        messageList = hl7Parse.doParse(initMsgContentList);
        if (messageList != null && messageList.size() > 0) {
            messageViewer.setInput(messageList.toArray());
        } else {
            messageViewer.setInput(null);
        }
    } else {
        filePath = externalNode.getElementParameter(EParameterName.FILENAME.getName()).getValue().toString();
        String filePathNoQuotes = TalendTextUtils.removeQuotes(filePath);
        File file = Path.fromOSString(filePathNoQuotes).toFile();
        if (file.exists()) {
            messageList = hl7Parse.doParse(filePath, startChar, endChar);
            if (messageList != null && messageList.size() > 0) {
                messageViewer.setInput(messageList.toArray());
            } else {
                messageViewer.setInput(null);
            }
        }
    }
}
Also used : Message(ca.uhn.hl7v2.model.Message) ArrayList(java.util.ArrayList) HL7Parse(org.talend.designer.hl7.ui.header.HL7Parse) File(java.io.File)

Aggregations

Message (ca.uhn.hl7v2.model.Message)114 Test (org.junit.Test)81 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)60 ORU_R01 (ca.uhn.hl7v2.model.v25.message.ORU_R01)30 NK1 (ca.uhn.hl7v2.model.v25.segment.NK1)21 Patient (org.openmrs.Patient)21 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)17 ORUR01Handler (org.openmrs.hl7.handler.ORUR01Handler)15 Person (org.openmrs.Person)14 ArrayList (java.util.ArrayList)13 HL7Exception (ca.uhn.hl7v2.HL7Exception)12 Concept (org.openmrs.Concept)12 Obs (org.openmrs.Obs)12 ObsService (org.openmrs.api.ObsService)11 QRD (ca.uhn.hl7v2.model.v24.segment.QRD)9 IOException (java.io.IOException)8 Encounter (org.openmrs.Encounter)8 RouteBuilder (org.apache.camel.builder.RouteBuilder)7 Structure (ca.uhn.hl7v2.model.Structure)5 CX (ca.uhn.hl7v2.model.v25.datatype.CX)5