Package ca.uhn.hl7v2.model

Examples of ca.uhn.hl7v2.model.Segment


                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


     * MSH interface.
     * throws HL7Exception if there is a problem, e.g. invalid version, code not available
     *     for given version.
     */
    public static Segment makeControlMSH(String version, ModelClassFactory factory) throws HL7Exception {
        Segment msh = null;
       
        try {
            Message dummy = GenericMessage.getGenericMessageClass(version)
                .getConstructor(new Class[]{ModelClassFactory.class}).newInstance(new Object[]{factory});
           
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

     *             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

                }
               
                messageIter.setDirection(name);

                if (messageIter.hasNext()) {
                    Segment next = (Segment) messageIter.next();
                    parse(next, segments[i], getEncodingChars(string), repNum);
                }
            }
        }
    }
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 you want 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

      clazz = mcf.getMessageClass("ACK", version, false);
      Message out = clazz.newInstance();
      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-1", "ACK");
      terser.set("/MSH-9-2", Terser.get(inboundHeader, 9, 0, 2, 1));
      terser.set("/MSH-12", Terser.get(inboundHeader, 12, 0, 1, 1));
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.