Ejemplo n.º 1
0
        static async Task ComposeTextReportDoctorBlock(TextWriter writer, Func<int> lineNumberGetter, Action<int> lineNumberSetter, ExecutingDoctor executingDoctor)
        {
            var lineNumber = lineNumberGetter();

            //(lijn 1:)RIZIV-nummer uitvoerend arts of paramedicus (positie 1-14)
            //formaat: C/CCCCC/CC/CCC
            lineNumber++;
            await writer.WriteLineAsync(Regex.Replace(executingDoctor.RizivNr ?? string.Empty, @"(\w{1})(\w{5})(\w{2})(\w{3})", @"$1/$2/$3/$4"));

            //(lijn 2:)Naam (positie 1-24) + Voornaam (positie 25-40)
            //uitvoerend arts of paramedicus
            lineNumber++;
            await writer.WriteLineAsync(string.Concat(executingDoctor.LastName?.TrimToMaxSize(24).PadRight(24) ?? string.Empty, executingDoctor.FirstName).TrimToMaxSize(40));

            //(lijn 3:)Straat (positie 1-35) + nr (positie 36-45)
            //uitvoerend arts of paramedicus
            lineNumber++;
            await writer.WriteLineAsync(string.Concat(executingDoctor.Address?.Street?.TrimToMaxSize(35).PadRight(35) ?? string.Empty, executingDoctor.Address?.HouseNr).TrimToMaxSize(45));

            //(lijn 4:)Postcode (positie 1-10) + Gemeente (positie 11-45)
            //uitvoerend arts of paramedicus
            lineNumber++;
            await writer.WriteLineAsync(string.Concat(executingDoctor.Address?.PostalCode?.TrimToMaxSize(10).PadRight(10) ?? string.Empty, executingDoctor.Address?.HouseNr).TrimToMaxSize(45));

            //(lijn 5:)Telefoon- en faxnummer (vrije tekst) (positie 1-50)
            //uitvoerend arts of paramedicus
            lineNumber++;
            await writer.WriteLineAsync(executingDoctor.Phone?.TrimToMaxSize(50));

            //(lijn 6:)Boodschap (vrije tekst) (positie 1-50)
            lineNumber++;
            await writer.WriteLineAsync(executingDoctor.Message?.TrimToMaxSize(50));

            //(lijn 7:)Datum(+eventueel tijdstip) aanmaak diskette (positie 1-10)
            //formaat: JJJJMMDD(+evtHHMM)
            lineNumber++;
            await writer.WriteLineAsync(executingDoctor.Date?.IsMidnight() ?? false ?
                executingDoctor.Date?.ToString("yyyyMMdd") :
                executingDoctor.Date?.ToString("yyyyMMddHHmm"));

            //(lijn 8:)RIZIV-nummer aanvragende arts (positie 1-14)
            //formaat: C/CCCCC/CC/CCC
            lineNumber++;
            await writer.WriteLineAsync(Regex.Replace(executingDoctor.RequestingDoctor?.RizivNr ?? string.Empty, @"(\w{1})(\w{5})(\w{2})(\w{3})", @"$1/$2/$3/$4"));

            //(lijn 9:)Naam (positie 1-24) + Voornaam (positie 25-40)
            //aanvragende arts
            lineNumber++;
            await writer.WriteLineAsync(string.Concat(executingDoctor.RequestingDoctor?.LastName?.TrimToMaxSize(24).PadRight(24) ?? string.Empty, executingDoctor.RequestingDoctor?.FirstName).TrimToMaxSize(40));

            foreach (var patient in executingDoctor.Patients)
                await ComposePatientBlock(writer, () => lineNumber, (ln) => lineNumber = ln, patient, true);

            lineNumber++;
            await writer.WriteLineAsync($"#/{lineNumber}");

            lineNumberSetter(lineNumber);
        }
Ejemplo n.º 2
0
        static async Task<ExecutingDoctor> ParseTextReportDoctorBlock(TextReader reader, Func<int> lineNumberGetter, Action<int> lineNumberSetter, string line)
        {
            var executingDoctor = new ExecutingDoctor();
            var lineNumber = lineNumberGetter();

            //(lijn 1:)RIZIV-nummer uitvoerend arts of paramedicus (positie 1-14)
            //formaat: C/CCCCC/CC/CCC
            if (line == null || !Regex.Match(line?.Trim(), @"\d/\d{5}/\d{2}/\d{3}", RegexOptions.IgnoreCase).Success)
                executingDoctor.ParserErrors.AddItem(lineNumber, $"Not a valid rizivnumber: '{line}' of format C/CCCCC/CC/CCC");
            executingDoctor.RizivNr = line?.Replace("/", string.Empty).Trim();

            //(lijn 2:)Naam (positie 1-24) + Voornaam (positie 25-40)
            //uitvoerend arts of paramedicus
            lineNumber++;
            var name = (await reader.ReadLineAsync())?.CheckMaxSize(40, executingDoctor.ParserErrors, lineNumber);
            executingDoctor.LastName = name?.Substring(0, name.Length > 24 ? 24 : name.Length).Trim();
            if (name?.Length > 24)
                executingDoctor.FirstName = name?.Substring(24).Trim();

            //(lijn 3:)Straat (positie 1-35) + nr (positie 36-45)
            //uitvoerend arts of paramedicus
            lineNumber++;
            var address = (await reader.ReadLineAsync())?.CheckMaxSize(45, executingDoctor.ParserErrors, lineNumber);
            executingDoctor.Address.Street = address?.Substring(0, address.Length > 35 ? 35 : address.Length).Trim();
            if (address?.Length > 35)
                executingDoctor.Address.HouseNr = address?.Substring(35).Trim();

            //(lijn 4:)Postcode (positie 1-10) + Gemeente (positie 11-45)
            //uitvoerend arts of paramedicus
            lineNumber++;
            address = (await reader.ReadLineAsync())?.CheckMaxSize(45, executingDoctor.ParserErrors, lineNumber);
            executingDoctor.Address.PostalCode = address?.Substring(0, address.Length > 10 ? 10 : address.Length).Trim();
            if (address?.Length > 10)
                executingDoctor.Address.Town = address?.Substring(10).Trim();

            //(lijn 5:)Telefoon- en faxnummer (vrije tekst) (positie 1-50)
            //uitvoerend arts of paramedicus
            lineNumber++;
            executingDoctor.Phone = (await reader.ReadLineAsync())?.CheckMaxSize(50, executingDoctor.ParserErrors, lineNumber).Trim();

            //(lijn 6:)Boodschap (vrije tekst) (positie 1-50)
            lineNumber++;
            executingDoctor.Message = (await reader.ReadLineAsync())?.CheckMaxSize(50, executingDoctor.ParserErrors, lineNumber).Trim();

            //(lijn 7:)Datum(+eventueel tijdstip) aanmaak diskette (positie 1-10)
            //formaat: JJJJMMDD(+evtHHMM)
            executingDoctor.Date = (await reader.ReadLineAsync())?.ToNullableDatetime("yyyyMMddHHmm", "yyyyMMdd", "yyMMdd");


            executingDoctor.RequestingDoctor = new Doctor();
            //(lijn 8:)RIZIV-nummer aanvragende arts (positie 1-14)
            //formaat: C/CCCCC/CC/CCC
            lineNumber++;
            executingDoctor.RequestingDoctor.RizivNr = (await reader.ReadLineAsync())?.Replace("/", string.Empty).Trim();

            //(lijn 9:)Naam (positie 1-24) + Voornaam (positie 25-40)
            //aanvragende arts
            lineNumber++;
            name = (await reader.ReadLineAsync())?.CheckMaxSize(40, executingDoctor.ParserErrors, lineNumber);
            executingDoctor.RequestingDoctor.LastName = name?.Substring(0, name.Length > 24 ? 24 : name.Length).Trim();
            if (name?.Length > 24)
                executingDoctor.RequestingDoctor.FirstName = name?.Substring(24).Trim();

            lineNumber++;
            line = await reader.ReadLineAsync();
            do
            {
                if (line == null || !line.StartsWith("#A"))
                    executingDoctor.ParserErrors.AddItem(lineNumber, $"Not valid start of patient block expected '#A' but got '{line}'");

                if (line != null)
                    executingDoctor.Patients.Add(await ParsePatientBlock(reader, () => lineNumber, (ln) => lineNumber = ln, executingDoctor.ParserErrors, line, false));
                lineNumber++;
            }
            while ((line = (await reader.ReadLineAsync())) != null && !line.StartsWith(@"#/"));

            //line = sr.ReadLine();
            if (line == null || !line.StartsWith(@"#/"))
                executingDoctor.ParserErrors.AddItem(lineNumber, $"Expected end of doctor blok '#/' but got '{line}'");

            lineNumberSetter(lineNumber);
            return executingDoctor;
        }