Am building Software for a clinic using VS2010 Pro.
Among the requirements are:
- It should generate patient Number based on the date of enrollment.
-
Middle two digits for Male patient is 11.
-
Middle two digits for Female patient is 22
-
The Final two digits range from 0 to 99.
eg for Male patient enrolled today:2012-03-02.
My Question is:
What is the Maximum of patients that can be enrolled per day?here is part of my code:
public string GetCurrentDate() { DateTime currentDate = DateTime.Now; string todaydate = currentDate.ToShortDateString().ToString(); return todaydate; } public int RadomNum() { return _random.Next(00, 99); } public string GeneratePatientNumber(Gender gender) { return GetCurrentDate() + "-" + (int)gender + "-" + RadomNum(); }
Are you asking what the maximum number of patients you can register per day? If so then for each gender the only things varying are the last two digits so you have 100 possible patient codes per gender based on that pattern.
That having been said a few things should be noted.
Firstly your random number generation means that you may well hit on an already generated pateient number before you use all the available possibilities. Are random numbers needed to keep them non-sequential? If so then you should either do something like shuffle a list of the numbers 0 to 100 initially and then keep picking from that or if you are likely to use a small portion of them then you could get away with just checking for if the generated ID exists already.
Also since
RandomNum()is an int then you will probably want to make sure its padded to two digits before including it in your patient number.