/// <summary> Validates the given message against our accept validators, attempts to commit /// the message to safe storage, and returns an ACK message indicating acceptance /// or rejection at the accept level (see enhanced mode processing rules in HL7 /// chapter 2, v2.5). /// </summary> public static AcceptACK validate(NuGenProcessorContext theContext, NuGenTransportable theMessage) { AcceptACK ruling = null; NuGenAcceptValidator[] validators = theContext.Validators; for (int i = 0; i < validators.Length && ruling == null; i++) { Genetibase.NuGenHL7.protocol.AcceptRuling vr = validators[i].check(theMessage); if (!vr.Acceptable) { System.String description = (vr.Reasons.Length > 0)?vr.Reasons[0]:null; NuGenTransportable ack = makeAcceptAck(theMessage, vr.AckCode, vr.ErrorCode, description); ruling = new AcceptACK(false, ack); } } if (ruling == null) { try { theContext.SafeStorage.store(theMessage); NuGenTransportable ack = makeAcceptAck(theMessage, Genetibase.NuGenHL7.protocol.Processor_Fields.CA, NuGenHL7Exception.MESSAGE_ACCEPTED, ""); ruling = new AcceptACK(true, ack); } catch (NuGenHL7Exception e) { int code = NuGenHL7Exception.APPLICATION_INTERNAL_ERROR; NuGenTransportable ack = makeAcceptAck(theMessage, Genetibase.NuGenHL7.protocol.Processor_Fields.CR, code, e.Message); ruling = new AcceptACK(false, ack); } } return ruling; }
/// <summary> Validates the given message against our accept validators, attempts to commit /// the message to safe storage, and returns an ACK message indicating acceptance /// or rejection at the accept level (see enhanced mode processing rules in HL7 /// chapter 2, v2.5). /// </summary> public static AcceptACK validate(NuGenProcessorContext theContext, NuGenTransportable theMessage) { AcceptACK ruling = null; NuGenAcceptValidator[] validators = theContext.Validators; for (int i = 0; i < validators.Length && ruling == null; i++) { Genetibase.NuGenHL7.protocol.AcceptRuling vr = validators[i].check(theMessage); if (!vr.Acceptable) { System.String description = (vr.Reasons.Length > 0)?vr.Reasons[0]:null; NuGenTransportable ack = makeAcceptAck(theMessage, vr.AckCode, vr.ErrorCode, description); ruling = new AcceptACK(false, ack); } } if (ruling == null) { try { theContext.SafeStorage.store(theMessage); NuGenTransportable ack = makeAcceptAck(theMessage, Genetibase.NuGenHL7.protocol.Processor_Fields.CA, NuGenHL7Exception.MESSAGE_ACCEPTED, ""); ruling = new AcceptACK(true, ack); } catch (NuGenHL7Exception e) { int code = NuGenHL7Exception.APPLICATION_INTERNAL_ERROR; NuGenTransportable ack = makeAcceptAck(theMessage, Genetibase.NuGenHL7.protocol.Processor_Fields.CR, code, e.Message); ruling = new AcceptACK(false, ack); } } return(ruling); }