public PatientArray mpiLookup(
string SSN,
string lastName,
string firstName,
string middleName,
string nameSuffix,
string DOB,
string gender)
{
PatientArray result = new PatientArray();
if (String.IsNullOrEmpty(SSN))
{
result.fault = new FaultTO("Missing SSN");
}
else if (!SocSecNum.isValid(SSN))
{
result.fault = new FaultTO("Invalid SSN");
}
// hard coded the cxn string since our MPI database should really be a service for everyone
//else if (mySession == null || mySession.MdwsConfiguration == null || mySession.MdwsConfiguration.SqlConfiguration == null ||
// String.IsNullOrEmpty(mySession.MdwsConfiguration.SqlConfiguration.ConnectionString))
//{
// result.fault = new FaultTO("Your MDWS configuration does not contain a valid SQL connection string");
//}
if (result.fault != null)
{
return result;
}
Patient patient = new Patient();
patient.SSN = new SocSecNum(SSN);
if (!String.IsNullOrEmpty(lastName) && !String.IsNullOrEmpty(firstName))
{
patient.Name = new PersonName();
patient.Name.Lastname = lastName;
patient.Name.Firstname = firstName;
if(!String.IsNullOrEmpty(middleName))
{
patient.Name.Firstname = firstName + " " + middleName;
}
patient.Name.Suffix = nameSuffix;
}
if(!String.IsNullOrEmpty(DOB))
{
patient.DOB = DOB;
}
// SQL query doesn't care about gender so just ignore it for now
//patient.Gender = gender;
try
{
PatientApi api = new PatientApi();
Patient[] matches = null;
Site site = mySession.SiteTable.getSite("500");
matches = api.mpiMatch(site.Sources[0], SSN);
//if (patient.Name != null && !String.IsNullOrEmpty(patient.Name.LastNameFirst)) // match all patient info if present
//{
// matches = api.mpiLookup(patient);
//}
//else // otherwise just match on SSN
//{
// matches = api.mpiLookup(SSN);
//}
result = new PatientArray(matches);
}
catch (Exception e)
{
result.fault = new FaultTO(e.Message);
}
return result;
}