public PatientTO select(string sitecode, string localPid)
{
PatientTO result = new PatientTO();
string msg = MdwsUtils.isAuthorizedConnection(mySession, sitecode);
if (msg != "OK")
{
result.fault = new FaultTO(msg);
}
else if (String.IsNullOrEmpty(localPid))
{
result.fault = new FaultTO("Missing local PID");
}
if (result.fault != null)
{
return result;
}
if (String.IsNullOrEmpty(sitecode))
{
sitecode = mySession.ConnectionSet.BaseSiteId;
}
try
{
AbstractConnection cxn = mySession.ConnectionSet.getConnection(sitecode);
PatientApi api = new PatientApi();
Patient p = api.select(cxn, localPid);
result = new PatientTO(p);
mySession.Patient = p;
mySession.ConnectionSet.getConnection(sitecode).Pid = result.localPid;
if (p.Confidentiality.Key > 0)
{
if (p.Confidentiality.Key == 1)
{
// do nothing here - M code takes care of this per documentation
}
else if (p.Confidentiality.Key == 2)
{
api.issueConfidentialityBulletin(mySession.ConnectionSet);
}
else if (p.Confidentiality.Key > 2)
{
mySession.ConnectionSet.disconnectAll();
throw new ApplicationException(p.Confidentiality.Value);
}
}
}
catch (Exception e)
{
result.fault = new FaultTO(e.Message);
}
return result;
}