Package ca.uhn.hl7v2.model

Examples of ca.uhn.hl7v2.model.Segment


                        ser.serialize(doc);
                        System.out.println("Segment " + reps[j].getClass().getName() + ": \r\n" + out.toString());

                        Class[] segmentConstructTypes = { Message.class };
                        Object[] segmentConstructArgs = { null };
                        Segment s =
                            (Segment) reps[j].getClass().getConstructor(segmentConstructTypes).newInstance(
                                segmentConstructArgs);
                        xp.parse(s, root);
                        Document doc2 = docBuilder.newDocument();
                        Element root2 = doc2.createElement(s.getClass().getName());
                        doc2.appendChild(root2);
                        xp.encode(s, root2);
                        StringWriter out2 = new StringWriter();
                        ser = new XMLSerializer(out2, null); //default output format
                        ser.serialize(doc2);
View Full Code Here


     * to respond differently. 
     */
    public void fillDetails(Message ack) throws ApplicationException {
        try {
            //populate MSA and ERR with generic error ...
            Segment msa = (Segment) ack.get("MSA");
            Terser.set(msa, 1, 0, 1, 1, "AR");
            Terser.set(
                msa,
                3,
                0,
                1,
                1,
                "No appropriate destination could be found to which this message could be routed.");
            //this is max length

            //populate ERR segment if it exists (may not depending on version)
            Structure s = ack.get("ERR");
            if (s != null) {
                Segment err = (Segment) s;
                Terser.set(err, 1, 0, 4, 1, "207");
                Terser.set(err, 1, 0, 4, 2, "Application Internal Error");
                Terser.set(err, 1, 0, 4, 3, "HL70357");
            }

View Full Code Here

            throw new HL7Exception("Can't instantiate ACK of class " + ackClassName + ": " + e.getClass().getName());
        }
        Terser terser = new Terser(out);

        //populate outbound MSH using data from inbound message ...            
        Segment outHeader = (Segment) out.get("MSH");
        fillResponseHeader(inboundHeader, outHeader);

        terser.set("/MSH-9", "ACK");
        terser.set("/MSH-12", version);
        terser.set("/MSA-1", "AA");
View Full Code Here

     *             if the data fields in the message do not permit encoding
     *             (e.g. required fields are null)
     */
    protected String doEncode(Message source) throws HL7Exception {
        // get encoding characters ...
        Segment msh = (Segment) source.get("MSH");
        String fieldSepString = Terser.get(msh, 1, 0, 1, 1);

        if (fieldSepString == null)
            throw new HL7Exception("Can't encode message: MSH-1 (field separator) is missing");

View Full Code Here

        char fieldSep = mshString.charAt(3);

        // get field array
        String[] fields = split(mshString, String.valueOf(fieldSep));

        Segment msh = null;
        try {
            // parse required fields
            String encChars = fields[1];
            char compSep = encChars.charAt(0);
            String messControlID = fields[9];
View Full Code Here

                log.debug("Parsing segment " + name);

                messageIter.setDirection(name);

                if (messageIter.hasNext()) {
                    Segment next = (Segment) messageIter.next();
                    int nextIndexWithinParent = messageIter.getNextIndexWithinParent();
                    parse(next, segments[i], getEncodingChars(string), nextIndexWithinParent);
                }
            }
        }
View Full Code Here

    }


    private static Transportable makeAcceptAck(Transportable theMessage, String theAckCode, int theErrorCode, String theDescription) throws HL7Exception {
       
        Segment header = ourParser.getCriticalResponseData(theMessage.getMessage());
        Message out;
        try {
            out = DefaultApplication.makeACK(header);
        } catch (IOException e) {
            throw new HL7Exception(e);
View Full Code Here

            StructRef mshRef = null;
            synchronized (root) {
                mshRef = root.getSuccessor("MSH");
                root.reset();
            }
            Segment msh = (Segment) result.get("MSH");
            for (int i = 0; i < mshRef.getFields().length; i++) {
                int fieldNum = mshRef.getFields()[i];
                parse(mshFields[fieldNum-1], msh, fieldNum, ec);
            }           
           
View Full Code Here

       
        synchronized (root) {
            StructRef ref = root.getSuccessor("MSH");           
           
            int field = 0;
            Segment segment = null;
            int[] fields = new int[0];
           
            while (tok.hasMoreTokens()) {
                String token = tok.nextToken();
                if (token.charAt(0) == ec.getFieldSeparator()) {
View Full Code Here

     * @throws HL7Exception if the data fields in the message do not permit encoding
     *      (e.g. required fields are null)
     */
    protected String doEncode(Message source) throws HL7Exception {
        //get encoding characters ...
        Segment msh = (Segment) source.get("MSH");
        String fieldSepString = Terser.get(msh, 1, 0, 1, 1);
       
        if (fieldSepString == null)
            throw new HL7Exception("Can't encode message: MSH-1 (field separator) is missing");
       
View Full Code Here

TOP

Related Classes of ca.uhn.hl7v2.model.Segment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.