/// <summary> /// </summary> /// <remarks> /// This method assumes there has been no login and therefore no credentials or user /// so it makes a new ConnectionSet, new credentials, etc. /// </remarks> /// <param name="pwd">Client app's BSE security phrase</param> /// <param name="sourceId">Station number</param> /// <param name="userId">DUZ</param> /// <param name="patientId">DFN</param> /// <returns>PersonsTO: a UserTO and a PatientTO</returns> public PersonsTO cprsLaunch(string pwd, string sourceId, string userId, string patientId) { PersonsTO result = new PersonsTO(); if (String.IsNullOrEmpty(sourceId)) { result.fault = new FaultTO("No sitecode!"); } else if (String.IsNullOrEmpty(userId)) { result.fault = new FaultTO("No DUZ!"); } else if (String.IsNullOrEmpty(patientId)) { result.fault = new FaultTO("No DFN!"); } else if (mySession.ConnectionSet != null && mySession.ConnectionSet.Count > 0) { result.fault = new FaultTO("This session has pre-existing connections and this method should be the base connection.", "Do a disconnect?"); } if (result.fault != null) { return result; } // Get the site // Note the visit site and user site are the same! Site site = mySession.SiteTable.getSite(sourceId); if (site == null) { result.fault = new FaultTO("No site " + sourceId + " in sites table"); return result; } // Now select the patient try { User trueUser = getVisitorData(sourceId, userId, pwd); // Now visit as the real user // Note context has to be CPRS! result.user = visitAndAuthorize( pwd, sourceId, sourceId, trueUser.Name.getLastNameFirst(), userId, trueUser.SSN.toString(), mySession.DefaultPermissionString); if (result.user.fault != null) { result.fault = result.user.fault; return result; } PatientApi patientApi = new PatientApi(); mySession.Patient = patientApi.select(mySession.ConnectionSet.getConnection(sourceId), patientId); result.patient = new PatientTO(mySession.Patient); } catch (Exception e) { //mySession.cxnMgr.disconnect(); if (e.Message.StartsWith("Patient unknown to CPRS")) { result.patient.fault = new FaultTO(e.Message); } else { result.fault = new FaultTO(e.Message); } } return result; }
/// <summary> /// patientVisit /// This method is used by MHV and will probably be used by other PHR apps. /// </summary> /// <param name="pwd">Client app's BSE security phrase</param> /// <param name="homeSitecode">Station number</param> /// <param name="mpiPid">ICN</param> /// <param name="multiSite">Set to false for now</param> /// <returns>SiteArray: Nothing really in it though, except error messages</returns> public SiteArray patientVisit(string pwd, string homeSitecode, string mpiPid, bool multiSite) { SiteArray result = new SiteArray(); //Make sure we have all the args we need if (mySession == null || mySession.SiteTable == null) { result.fault = new FaultTO("No session has been started"); } else if (String.IsNullOrEmpty(homeSitecode)) { result.fault = new FaultTO("No homeSitecode"); } else if (mySession.SiteTable.getSite(homeSitecode) == null) { result.fault = new FaultTO("No site " + homeSitecode + " in the site table"); } else if (mySession.ConnectionSet != null && mySession.ConnectionSet.Count > 0 && mySession.ConnectionSet.HasConnection(homeSitecode)) { result.fault = new FaultTO("Site " + homeSitecode + " already connected"); } else if (mySession.ConnectionSet != null && mySession.ConnectionSet.Count > 0) { result.fault = new FaultTO("This session has pre-existing connections and this method should be the base connection.", "Do a disconnect?"); } else if (mpiPid == "") { result.fault = new FaultTO("No MPI PID"); } if (result.fault != null) { return result; } Site homeSite = mySession.SiteTable.getSite(homeSitecode); mySession.Credentials = getAdministrativeCredentials(homeSite); mySession.Credentials.SecurityPhrase = pwd; string context = MdwsConstants.MDWS_CONTEXT; if (mySession.DefaultVisitMethod == MdwsConstants.NON_BSE_CREDENTIALS) { context = MdwsConstants.CPRS_CONTEXT; } mySession.PrimaryPermission = new MenuOption(context); try { mySession.User = doTheVisit(homeSitecode, mySession.Credentials, mySession.PrimaryPermission); PatientApi patientApi = new PatientApi(); string localPid = patientApi.getLocalPid(myCxn, mpiPid); if (localPid == "") { myCxn.disconnect(); result.fault = new FaultTO("No such patient at this site"); return result; } mySession.Patient = patientApi.select(myCxn, localPid); addMyCxn2CxnSet(); } catch (Exception e) { myCxn.disconnect(); result.fault = new FaultTO(e.Message); return result; } return result; }
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; }