Example #1
0
        public override void Map(string inputLine, MapperContext context)
        {
            //Step to Identify the Practice or Prescription data set
            //Using the SDK, tried to use the MapperContext.InputFileName property: it is always empty
            //So decided to use items count of each datasets
            //Items count 8 for practice and Items count 9 for prescription

            char[] delimiterChars = { ',' };

            //split up the passed in line
            string[] individualItems = inputLine.Trim().Split(delimiterChars);

            if (individualItems.Count() == 8)
            {
                Practices practice = reader.ExtractPracticesFromCsvLineFormat(inputLine);

                if (String.IsNullOrWhiteSpace(practice.ReferenceId))
                {
                    return;
                }                                                                 //Ignore, practise name cannot be null
                if (String.IsNullOrWhiteSpace(practice.Name))
                {
                    return;
                }                                                          //Ignore, practise name cannot be null

                context.EmitKeyValue("UK", Convert.ToString(practice.ReferenceId));
            }
        }
        public void ReadPrescriptionFromCsvReturnCorrectData()
        {
            string filepath = "PracticeTest.csv";
            //201202,A81001,THE DENSHAM SURGERY ,THE HEALTH CENTRE ,LAWSON STREET,STOCKTON ,CLEVELAND,TS18 1HU



            var practice = new Practices();

            using (var sr = new StreamReader(filepath))
            {
                string line = null;
                //Read and display lines from the file until the end of the file is reached.
                while ((line = sr.ReadLine()) != null)
                {
                    practice = lineReader.ExtractPracticesFromCsvLineFormat(line);
                }
            }
            Assert.That(practice.ReferenceId, Is.EqualTo("A81001"));
            Assert.That(practice.Name, Is.EqualTo("THE DENSHAM SURGERY"));
            Assert.That(practice.PostCode, Is.EqualTo("TS18 1HU"));
        }