Package ca.uhn.hl7v2.model

Examples of ca.uhn.hl7v2.model.Segment


        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

     * message.  This method parses only that required information, hopefully
     * avoiding the condition that caused the original error.</p>
     */
    public Segment getCriticalResponseData(String message) throws HL7Exception {
        String version = getVersion(message);
        Segment criticalData = Parser.makeControlMSH(version, getFactory());

        Terser.set(criticalData, 1, 0, 1, 1, parseLeaf(message, "MSH.1", 0));
        Terser.set(criticalData, 2, 0, 1, 1, parseLeaf(message, "MSH.2", 0));
        Terser.set(criticalData, 10, 0, 1, 1, parseLeaf(message, "MSH.10", 0));
        String procID = parseLeaf(message, "MSH.11", 0);
View Full Code Here

                        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

     *             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

   * information, hopefully avoiding the condition that caused the original error.
   * </p>
   */
  public Segment getCriticalResponseData(String message) throws HL7Exception {
    String version = getVersion(message);
    Segment criticalData = Parser.makeControlMSH(version, getFactory());

    Terser.set(criticalData, 1, 0, 1, 1, parseLeaf(message, "MSH.1", 0));
    Terser.set(criticalData, 2, 0, 1, 1, parseLeaf(message, "MSH.2", 0));
    Terser.set(criticalData, 10, 0, 1, 1, parseLeaf(message, "MSH.10", 0));
    String procID = parseLeaf(message, "MSH.11", 0);
View Full Code Here

        // HAPI will still parse this message fine
        ADT_A01 message = (ADT_A01) new PipeParser().parse(messageText);
       
        // If we want to access the data in the ZPI segment, it's pretty easy
        Segment zpiGenericSegment = (Segment) message.get("ZPI");

        String firstPetName  = zpiGenericSegment.getField(1, 0).encode();
        String secondPetName = zpiGenericSegment.getField(1, 1).encode();
        System.out.println(firstPetName); // Fido
        System.out.println(secondPetName); // Fred

        String shoeSize = zpiGenericSegment.getField(2, 0).encode();
        System.out.println(shoeSize); // 13


        // Now, suppose our message is actually called ZDT^A01, and we plan on
        // using it frequently, so we want to explicitly define a class to
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

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.