/// <summary> Tests whether the given type falls within a maximum length. </summary> /// <returns> null of OK, an HL7Exception otherwise /// </returns> public virtual NuGenHL7Exception testLength(Genetibase.NuGenHL7.model.Type type, int maxLength) { NuGenHL7Exception e = null; System.String encoded = NuGenPipeParser.encode(type, this.enc); if (encoded.Length > maxLength) { e = new NuGenProfileNotFollowedException("Length of " + encoded.Length + " exceeds maximum of " + maxLength); } return(e); }
/// <summary> Checks cardinality and creates an appropriate exception if out /// of bounds. The usage code is needed because if min cardinality /// is > 0, the min # of reps is only required if the usage code /// is 'R' (see HL7 v2.5 section 2.12.6.4). /// </summary> /// <param name="reps">the number of reps /// </param> /// <param name="min">the minimum number of reps /// </param> /// <param name="max">the maximum number of reps (-1 means *) /// </param> /// <param name="usage">the usage code /// </param> /// <param name="name">the name of the repeating structure (used in exception msg) /// </param> /// <returns> null if cardinality OK, exception otherwise /// </returns> protected internal virtual NuGenHL7Exception testCardinality(int reps, int min, int max, System.String usage, System.String name) { NuGenHL7Exception e = null; if (reps < min && usage.ToUpper().Equals("R".ToUpper())) { e = new NuGenProfileNotFollowedException(name + " must have at least " + min + " repetitions (has " + reps + ")"); } else if (max > 0 && reps > max) { e = new NuGenProfileNotFollowedException(name + " must have no more than " + max + " repetitions (has " + reps + ")"); } return(e); }
private NuGenHL7Exception testValueAgainstTable(System.String profileID, System.String codeSystem, System.String value_Renamed) { NuGenHL7Exception ret = null; CodeStore store = ProfileStoreFactory.getCodeStore(profileID, codeSystem); if (store == null) { } else { if (!store.isValidCode(codeSystem, value_Renamed)) { ret = new NuGenProfileNotFollowedException("Code " + value_Renamed + " not found in table " + codeSystem + ", profile " + profileID); } } return(ret); }
/// <summary> Tests an element against the corresponding usage code. The element /// is required in its encoded form. /// </summary> /// <param name="encoded">the pipe-encoded message element /// </param> /// <param name="usage">the usage code (e.g. "CE") /// </param> /// <param name="name">the name of the element (for use in exception messages) /// </param> /// <returns>s null if there is no problem, an HL7Exception otherwise /// </returns> private NuGenHL7Exception testUsage(System.String encoded, System.String usage, System.String name) { NuGenHL7Exception e = null; if (usage.ToUpper().Equals("R".ToUpper())) { if (encoded.Length == 0) { e = new NuGenProfileNotFollowedException("Required element " + name + " is missing"); } } else if (usage.ToUpper().Equals("RE".ToUpper())) { //can't test anything } else if (usage.ToUpper().Equals("O".ToUpper())) { //can't test anything } else if (usage.ToUpper().Equals("C".ToUpper())) { //can't test anything yet -- wait for condition syntax in v2.6 } else if (usage.ToUpper().Equals("CE".ToUpper())) { //can't test anything } else if (usage.ToUpper().Equals("X".ToUpper())) { if (encoded.Length > 0) { e = new NuGenXElementPresentException("Element " + name + " is present but specified as not used (X)"); } } else if (usage.ToUpper().Equals("B".ToUpper())) { //can't test anything } return(e); }
/// <seealso cref="Validator.validate"> /// </seealso> public virtual NuGenHL7Exception[] validate(Message message, StaticDef profile) { System.Collections.ArrayList exList = new System.Collections.ArrayList(20); Terser t = new Terser(message); //check msg type, event type, msg struct ID System.String msgType = t.get_Renamed("/MSH-9-1"); if (!msgType.Equals(profile.MsgType)) { NuGenHL7Exception e = new NuGenProfileNotFollowedException("Message type " + msgType + " doesn't match profile type of " + profile.MsgType); exList.Add(e); } System.String evType = t.get_Renamed("/MSH-9-2"); if (!evType.Equals(profile.EventType) && !profile.EventType.ToUpper().Equals("ALL".ToUpper())) { NuGenHL7Exception e = new NuGenProfileNotFollowedException("Event type " + evType + " doesn't match profile type of " + profile.EventType); exList.Add(e); } System.String msgStruct = t.get_Renamed("/MSH-9-3"); if (msgStruct == null || !msgStruct.Equals(profile.MsgStructID)) { NuGenHL7Exception e = new NuGenProfileNotFollowedException("Message structure " + msgStruct + " doesn't match profile type of " + profile.MsgStructID); exList.Add(e); } System.Exception[] childExceptions; childExceptions = testGroup(message, profile, profile.Identifier); for (int i = 0; i < childExceptions.Length; i++) { exList.Add(childExceptions[i]); } return(toArray(exList)); }
/// <seealso cref="Validator.validate"> /// </seealso> public virtual NuGenHL7Exception[] validate(Message message, StaticDef profile) { System.Collections.ArrayList exList = new System.Collections.ArrayList(20); Terser t = new Terser(message); //check msg type, event type, msg struct ID System.String msgType = t.get_Renamed("/MSH-9-1"); if (!msgType.Equals(profile.MsgType)) { NuGenHL7Exception e = new NuGenProfileNotFollowedException("Message type " + msgType + " doesn't match profile type of " + profile.MsgType); exList.Add(e); } System.String evType = t.get_Renamed("/MSH-9-2"); if (!evType.Equals(profile.EventType) && !profile.EventType.ToUpper().Equals("ALL".ToUpper())) { NuGenHL7Exception e = new NuGenProfileNotFollowedException("Event type " + evType + " doesn't match profile type of " + profile.EventType); exList.Add(e); } System.String msgStruct = t.get_Renamed("/MSH-9-3"); if (msgStruct == null || !msgStruct.Equals(profile.MsgStructID)) { NuGenHL7Exception e = new NuGenProfileNotFollowedException("Message structure " + msgStruct + " doesn't match profile type of " + profile.MsgStructID); exList.Add(e); } System.Exception[] childExceptions; childExceptions = testGroup(message, profile, profile.Identifier); for (int i = 0; i < childExceptions.Length; i++) { exList.Add(childExceptions[i]); } return toArray(exList); }
private NuGenHL7Exception testValueAgainstTable(System.String profileID, System.String codeSystem, System.String value_Renamed) { NuGenHL7Exception ret = null; CodeStore store = ProfileStoreFactory.getCodeStore(profileID, codeSystem); if (store == null) { } else { if (!store.isValidCode(codeSystem, value_Renamed)) ret = new NuGenProfileNotFollowedException("Code " + value_Renamed + " not found in table " + codeSystem + ", profile " + profileID); } return ret; }
/// <summary> Tests an element against the corresponding usage code. The element /// is required in its encoded form. /// </summary> /// <param name="encoded">the pipe-encoded message element /// </param> /// <param name="usage">the usage code (e.g. "CE") /// </param> /// <param name="name">the name of the element (for use in exception messages) /// </param> /// <returns>s null if there is no problem, an HL7Exception otherwise /// </returns> private NuGenHL7Exception testUsage(System.String encoded, System.String usage, System.String name) { NuGenHL7Exception e = null; if (usage.ToUpper().Equals("R".ToUpper())) { if (encoded.Length == 0) e = new NuGenProfileNotFollowedException("Required element " + name + " is missing"); } else if (usage.ToUpper().Equals("RE".ToUpper())) { //can't test anything } else if (usage.ToUpper().Equals("O".ToUpper())) { //can't test anything } else if (usage.ToUpper().Equals("C".ToUpper())) { //can't test anything yet -- wait for condition syntax in v2.6 } else if (usage.ToUpper().Equals("CE".ToUpper())) { //can't test anything } else if (usage.ToUpper().Equals("X".ToUpper())) { if (encoded.Length > 0) e = new NuGenXElementPresentException("Element " + name + " is present but specified as not used (X)"); } else if (usage.ToUpper().Equals("B".ToUpper())) { //can't test anything } return e; }
/// <summary> Tests whether the given type falls within a maximum length. </summary> /// <returns> null of OK, an HL7Exception otherwise /// </returns> public virtual NuGenHL7Exception testLength(Genetibase.NuGenHL7.model.Type type, int maxLength) { NuGenHL7Exception e = null; System.String encoded = NuGenPipeParser.encode(type, this.enc); if (encoded.Length > maxLength) { e = new NuGenProfileNotFollowedException("Length of " + encoded.Length + " exceeds maximum of " + maxLength); } return e; }
/// <summary> Checks cardinality and creates an appropriate exception if out /// of bounds. The usage code is needed because if min cardinality /// is > 0, the min # of reps is only required if the usage code /// is 'R' (see HL7 v2.5 section 2.12.6.4). /// </summary> /// <param name="reps">the number of reps /// </param> /// <param name="min">the minimum number of reps /// </param> /// <param name="max">the maximum number of reps (-1 means *) /// </param> /// <param name="usage">the usage code /// </param> /// <param name="name">the name of the repeating structure (used in exception msg) /// </param> /// <returns> null if cardinality OK, exception otherwise /// </returns> protected internal virtual NuGenHL7Exception testCardinality(int reps, int min, int max, System.String usage, System.String name) { NuGenHL7Exception e = null; if (reps < min && usage.ToUpper().Equals("R".ToUpper())) { e = new NuGenProfileNotFollowedException(name + " must have at least " + min + " repetitions (has " + reps + ")"); } else if (max > 0 && reps > max) { e = new NuGenProfileNotFollowedException(name + " must have no more than " + max + " repetitions (has " + reps + ")"); } return e; }