Monday 14 October 2013

Professional Achievements - we all like our victories noticed and recorded

I was recovering data off a semi failed disk and found some crap treasure that I had forgotten about. In a previous job I created a 'Professional Achievements' application, which is basically a rip-off of steam achievements but for work.

This is the front page. Observant people may notice that the default MVC template has been hardly changed.



Here's some of the achievements that were earned by me after a lot of dedicated effort:





The app would let you create your own achievements and assign them (or other previously created achievements) to anyone.


You could pick different pre-loaded icons or upload your own.  Most people used the team fortress 2 ones. I suspect this is because they were lazy. I also suspect this is a stunning copyright breach. I think I included any achievement icons that were easily found from a Google search! Please don't sue me Valve!

Here's some other random achievements that could be given out:





Spelling 'achievements' correctly in this post has really been a challenge. The More You Know.
Also, I've made the pictures full size even though it will blow out the layout cause I'm the boss round these parts.

NHI number validation or whatever


Yeah NHI number validation!  There is an exciting document here that the Ministry of Health have supplied which specifies what makes an NHI number valid or not.

Here's a method y'all.

public bool ValidateNhi(string nhi)
{
    bool valid = false;
    const string validNhiChars = "ABCDEFGHJKLMNPQRSTUVWXYZ";
                
    nhi = nhi.ToUpper();
    // must be seven chars long
    if (nhi.Length == 7)
    {
        // must not contain I or O
        if (!nhi.Contains("I") && !nhi.Contains("O"))
        {
            // last four must be integer
            int parsed;
            if (int.TryParse(nhi.Substring(3), out parsed))
            {
                // multiply each character by 8 minus its index and then sum em all together
                // e.g. first char * 7 + second char * 6 + third char * 5 etc
                int result = 0;
                int counter = 7;
                foreach (var character in nhi.Substring(0, 6)) // exclude last character
                {
                    int parsedCharacter = counter > 4 ? validNhiChars.IndexOf(character) + 1 : (int)Char.GetNumericValue(character);
                    result = result + (counter * parsedCharacter);
                    counter--;
                }
                // create a checksum by mod 11
                int checksum = result % 11;
                int checkDidgit = 11 - checksum;
                if (checkDidgit == 10)
                    checkDidgit = 0;

                // last value in nhi number must equal check digit
                valid = (int)Char.GetNumericValue(nhi.Last()) == checkDidgit;
            }
        }
    }

    return valid;
}

I can't deal with the excitement!

Tuesday 1 October 2013

Extracting Data from the Patient Administration System (it's the PAS yo)


You want patient data out of the system?  Sure, sure, let me connect in and write some quick SQL for you.  Let's see what tables we have here.



Ok. This might take a little while. Lets have a look at the field names.



Hmmm.  Well, we'll try the data dictionary.



Ummm, hey look it's home time, let's do this tomorrow.