Package ca.uhn.hl7v2.model

Examples of ca.uhn.hl7v2.model.Segment


      if (version == null) {
        Version availableVersion = Version.highestAvailableVersionOrDefault();
        version = availableVersion.getVersion();
      }

      Segment msh = Parser.makeControlMSH(version, getFactory());
      Terser.set(msh, 1, 0, 1, 1, String.valueOf(fieldSep));
      Terser.set(msh, 2, 0, 1, 1, encChars);
      Terser.set(msh, 10, 0, 1, 1, messControlID);
      Terser.set(msh, 11, 0, 1, 1, procIDComps[0]);
      Terser.set(msh, 12, 0, 1, 1, version);
View Full Code Here


        messageIter.setDirection(name);

        try {
          if (messageIter.hasNext()) {
            Segment next = (Segment) messageIter.next();
            parse(next, segments[i], getEncodingChars(string), repNum);
          }
        } catch (Error e) {
          if (e.getCause() instanceof HL7Exception) {
            throw (HL7Exception)e.getCause();
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

        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

     * 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

     *             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

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.