예제 #1
0
        /// <summary>
        /// Récupère les données d'une répétition d'un champ.
        /// Les champs et répétitions sont stocké(e)s à partir de l'indice 0 mais une base 1 est utilisée pour les accès.
        /// </summary>
        /// <param name="numField">Numéro du champ.</param>
        /// <param name="numRepetition">Numéro de la répétition.</param>
        /// <returns></returns>
        public IType GetField(int numField, int numRepetition)
        {
            if (numField <= 0)
            {
                throw new SegmentException("L'accès à un champ doit être réalisé à partir de l'index 1.");
            }

            if (numField > this._fields.Count)
            {
                throw new SegmentException($"Le champ {InteropUtil.ConstructFieldNumber(this.SegmentName, numField)} n'existe pas.");
            }

            if (numRepetition <= 0)
            {
                throw new SegmentException($"L'accès à une répétition du champ {InteropUtil.ConstructFieldNumber(this.SegmentName, numField)} doit être réalisé à partir de l'index 1.");
            }

            int currentRep = this._fields[numField - 1].Repetitions.Count;

            // Création d'une répétition si nécessaire et si limite maximale non atteinte
            if (numRepetition > currentRep)
            {
                if (numRepetition > this._fields[numField - 1].MaxRepetitions)
                {
                    throw new SegmentException($"Impossible d'ajouter la répétition {InteropUtil.ConstructFieldNumber(this.SegmentName, numField, numRepetition)} : le nombre maximal autorisé de répétitions est de {this._fields[numField - 1].MaxRepetitions}.");
                }
                else
                {
                    this._fields[numField - 1].Repetitions.Add(this.CreateNewSegmentItem(numField));
                }
            }

            return(this._fields[numField - 1][numRepetition]);
        }
예제 #2
0
 /// <summary>
 /// Récupère les donnés d'un champ.
 /// Les champs sont stockés à partir de l'indice 0 mais une base 1 est utilisée pour les accès.
 /// </summary>
 /// <param name="numField">Numéro du champ.</param>
 /// <returns>Tableau de longueur 1 pour les champs non répétables, et > 1 pour les champs répétables.</returns>
 public IType[] GetField(int numField)
 {
     try
     {
         if (numField > 0)
         {
             return(this._fields[numField - 1].ConvertRepetitionsToITypeArray);
         }
         else
         {
             throw new SegmentException("L'accès à un champ doit être réalisé à partir de l'index 1.");
         }
     }
     catch (ArgumentOutOfRangeException)
     {
         throw new SegmentException($"Le champ {InteropUtil.ConstructFieldNumber(this.SegmentName, numField)} n'existe pas.");
     }
 }
예제 #3
0
        /// <summary>
        /// Constructeur.
        /// </summary>
        /// <param name="countryCode">Code pays exporté sur les champs <see cref="MSH.VersionId"/> (MSH-12) et <see cref="MSH.CountryCode/> (MSH-17).</param>
        /// <param name="version">Version de la norme exportée sur le champ <see cref="MSH.VersionId"/> (MSH-12).</param>
        /// <param name="exportPaths">Chemins d'export des fichiers.</param>
        /// <param name="encChars">Caractères d'encodage à utiliser.</param>
        /// <param name="fileExtension">Extension des fichiers générés.</param>
        /// <param name="validationFileExtension">Extension des fichiers de validation.</param>
        /// <param name="msgControlIdInMilliseconds">Indique si le champ <see cref="MSH.MessageControlId"/> (MSH-10) est généré en millisecondes.</param>
        /// <param name="createValidationFile">Indique si un fichier de validation doit être créé pour chaque fichier généré.</param>
        public EncodingOptions(string countryCode,
                               string version,
                               List <string> exportPaths,
                               EncodingCharacters encChars     = null,
                               string fileExtension            = null,
                               string validationFileExtension  = null,
                               bool msgControlIdInMilliseconds = true,
                               bool createValidationFile       = true)
        {
            if (string.IsNullOrWhiteSpace(countryCode))
            {
                throw new EncodingException($"Le code pays à exporter sur les champs {InteropUtil.ConstructFieldNumber("MSH", 12)} et {InteropUtil.ConstructFieldNumber("MSH", 17)} n'a pas été renseignée.");
            }

            if (!Structure.Table.CountryCode.Description.ContainsKey(countryCode))
            {
                throw new EncodingException($"Le code pays à exporter sur les champs {InteropUtil.ConstructFieldNumber("MSH", 12)} et {InteropUtil.ConstructFieldNumber("MSH", 17)} n'est pas valide.");
            }

            if (string.IsNullOrWhiteSpace(version))
            {
                throw new EncodingException($"La version de la norme à exporter sur le champ {InteropUtil.ConstructFieldNumber("MSH", 12)} n'a pas été renseignée.");
            }

            if (!VersionID.Description.ContainsKey(version))
            {
                throw new EncodingException($"La version de la norme à exporter sur le champ {InteropUtil.ConstructFieldNumber("MSH", 12)} n'est pas valide.");
            }

            if (exportPaths == null || !exportPaths.Any())
            {
                throw new EncodingException("Aucun chemin d'export n'a été renseigné.");
            }

            if (encChars == null)
            {
                this._encChars = new EncodingCharacters();
            }
            else
            {
                this._encChars = encChars;
            }

            if (string.IsNullOrWhiteSpace(fileExtension))
            {
                this._fileExtension = EncoderContainer.CSTS_DEFAULT_EXTENSION_HL7;
            }
            else
            {
                this._fileExtension = fileExtension;
            }

            if (string.IsNullOrWhiteSpace(validationFileExtension))
            {
                this._validationFileExtension = EncoderContainer.CSTS_DEFAULT_EXTENSION_VALIDATION;
            }
            else
            {
                this._validationFileExtension = validationFileExtension;
            }

            this._msgControlIdInMilliseconds = msgControlIdInMilliseconds;
            this._version              = version;
            this._countryCode          = countryCode;
            this._exportPaths          = exportPaths;
            this._createValidationFile = createValidationFile;
        }