Package ca.uhn.hl7v2.model

Examples of ca.uhn.hl7v2.model.Segment


     * @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

            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

        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

   * @throws HL7Exception
   */
  private Message populateResponseAsOf25(Message response, AcknowledgmentCode acknowledgmentCode,
      int repetition) throws HL7Exception {
    // TODO define what should happen if there is no MSA or ERR
    Segment msa = (Segment) response.get("MSA");
    Terser.set(msa, 1, 0, 1, 1, acknowledgmentCode.name());
    Segment err = (Segment) response.get("ERR", repetition);
    if (location != null) {
      if (location.getSegmentName() != null)
        Terser.set(err, 2, 0, 1, 1, location.getSegmentName());
      if (location.getField() > 0)
        Terser.set(err, 2, 0, 3, 1, Integer.toString(location.getField()));
View Full Code Here

   * @throws HL7Exception
   */
  private Message populateResponseBefore25(Message response, AcknowledgmentCode acknowledgmentCode,
      int repetition) throws HL7Exception {
    // TODO define what should happen if there is no MSA or ERR
    Segment msa = (Segment) response.get("MSA");
    Terser.set(msa, 1, 0, 1, 1, acknowledgmentCode.name());
    Terser.set(msa, 3, 0, 1, 1, errorCode.getMessage());
    Segment err = (Segment) response.get("ERR");
    if (location != null) {
      if (location.getSegmentName() != null)
        Terser.set(err, 1, repetition, 1, 1, location.getSegmentName());
      if (location.getField() > 0)
        Terser.set(err, 1, repetition, 3, 1, Integer.toString(location.getField()));
View Full Code Here

  private void testPrimitiveRules(Message message, ValidationExceptionHandler<R> handler)
      throws HL7Exception {
    LOG.debug("Validating message against primitive type rules");
    for (Iterator<Structure> iter = ReadOnlyMessageIterator
        .createPopulatedSegmentIterator(message); iter.hasNext();) {
      Segment s = (Segment) iter.next();
      for (int field = 1; field <= s.numFields(); field++) {
        Type[] t = s.getField(field);
        for (int rep = 0; rep < t.length; rep++) {
          Location location = new Location();
          location.setSegmentName(s.getName());
          location.setField(field);
          location.setFieldRepetition(rep);
          testType(t[rep], handler, location);
        }
      }
View Full Code Here

     */
    protected Message generateResponseMessage(Object request) throws HL7Exception {
        try {
            Message in;
            if (request instanceof String) {
                Segment s = getHapiContext().getGenericParser().getCriticalResponseData(
                        (String)request);
                in = s.getMessage();
                DeepCopy.copy(s, (Segment) in.get("MSH"));
            } else if (request instanceof Message) {
                in = (Message) request;
            } else {
                throw new HL7Exception("Validated message must be either Message or String");
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.