private IList <PatientProfile> GetPendingPatients() { List <PatientProfile> listPending = new List <PatientProfile>(); try { MongoDBWrapper dbwrapper = new MongoDBWrapper(NoIDMongoDBAddress, SparkMongoDBAddress); List <SessionQueue> pendingSessionList = dbwrapper.GetPendingPatients(); FhirClient client = new FhirClient(sparkEndpointAddress); foreach (var pending in pendingSessionList) { string sparkAddress = sparkEndpointAddress.ToString() + "/Patient/" + pending.SparkReference; Patient pendingPatient = (Patient)client.Get(sparkAddress); PatientProfile patientProfile = new PatientProfile(pendingPatient, true); patientProfile.SessionID = pending._id; patientProfile.LocalNoID = pending.LocalReference; patientProfile.NoIDStatus = pending.ApprovalStatus; patientProfile.NoIDType = pending.PatientStatus; patientProfile.CheckinDateTime = FHIRUtilities.DateTimeToFHIRString(pending.SubmitDate); listPending.Add(patientProfile); } /* * string gtDateFormat = "gt" + FHIRUtilities.DateToFHIRString(DateTime.UtcNow.AddDays(-2)); * client.PreferredFormat = ResourceFormat.Json; * Uri uriTwoDays = new Uri(sparkEndpointAddress.ToString() + "/Patient?_lastUpdated=" + gtDateFormat); * Bundle patientBundle = (Bundle)client.Get(uriTwoDays); * foreach (Bundle.EntryComponent entry in patientBundle.Entry) * { * string ptURL = entry.FullUrl.ToString().Replace("http://localhost:49911/fhir", sparkEndpointAddress.ToString()); * Patient pt = (Patient)client.Get(ptURL); * if (pt.Meta.Extension.Count > 0) * { * Extension ext = pt.Meta.Extension[0]; * if (ext.Value.ToString().ToLower().Contains("pending") == true) * { * PatientProfile patientProfile = new PatientProfile(pt, false); * listPending.Add(patientProfile); * } * } * } */ } catch (Exception ex) { throw ex; } return(listPending); }
public bool postDemoForNoBioMatch ( string language, string firstName, string middleName, string lastName, string gender, string birthYear, string birthMonth, string birthDay, string streetAddress, string streetAddress2, string city, string state, string postalCode, string emailAddress, string phoneCell, string selectedExceptionReason, string secretExAnswer1, string secretExAnswer2, string selectedsecretQuestion1, string selectedsecretQuestion2 ) { try { if (selectedExceptionReason == "") { return(true); } errorDescription = ""; _patientFHIRProfile.Language = language; _patientFHIRProfile.LastName = lastName; _patientFHIRProfile.FirstName = firstName; _patientFHIRProfile.MiddleName = middleName; if (gender.ToLower() == "f") { _patientFHIRProfile.Gender = "F"; } else if (gender.ToLower() == "m") { _patientFHIRProfile.Gender = "M"; } _patientFHIRProfile.BirthDate = formatDateOfBirth(birthYear, birthMonth, birthDay); _patientFHIRProfile.StreetAddress = streetAddress; _patientFHIRProfile.StreetAddress2 = streetAddress2; _patientFHIRProfile.City = city; _patientFHIRProfile.State = state; _patientFHIRProfile.PostalCode = postalCode; _patientFHIRProfile.EmailAddress = emailAddress; _patientFHIRProfile.PhoneCell = phoneCell; _patientFHIRProfile.ClinicArea = ClinicArea; _patientFHIRProfile.DevicePhysicalLocation = DevicePhysicalLocation; _patientFHIRProfile.NoIDType = "Identity"; _patientFHIRProfile.NoIDStatus = "Pending"; _patientFHIRProfile.CheckinDateTime = FHIRUtilities.DateTimeToFHIRString(DateTime.UtcNow); _patientFHIRProfile.BiometricExceptionMissingReason = exceptionMissingReason; _patientFHIRProfile.SecretQuestion1 = selectedsecretQuestion1; _patientFHIRProfile.SecretAnswer1 = secretAnswer1; _patientFHIRProfile.SecretQuestion2 = selectedsecretQuestion2; _patientFHIRProfile.SecretAnswer2 = secretAnswer2; // Send FHIR message Authentication auth; if (Utilities.Auth == null) { auth = SecurityUtilities.GetAuthentication(serviceName); } else { auth = Utilities.Auth; } HttpsClient client = new HttpsClient(); Patient pt = _patientFHIRProfile.CreateFHIRPatientProfile(); // TODO: REMOVE THIS LINE! ONLY FOR TESTING //FHIRUtilities.SaveJSONFile(pt, @"C:\JSONTest"); fhirAddress = new Uri(AltMatchByDemographicsUri); if (client.SendDemographicFHIRSearch(fhirAddress, auth, pt) == false) { // Error occured set error description errorDescription = HandleNullString(client.ResponseText); return(false); } else { if (client.ResponseText.ToLower().Contains("noid://") == true) { string localNoID = client.ResponseText; ExecuteJavaScriptAsync("showNoBioIdentity('" + localNoID + "');"); return(true); } else if (client.ResponseText.ToLower().Contains("no match") == true) { return(true); } else if (client.ResponseText.ToLower().Contains("error") == true) { errorDescription = "Error in PatientBridge::postDemoForNoBioMatch: " + client.ResponseText; return(false); } } } catch (Exception ex) { errorDescription = ex.Message; return(false); } return(true); }
// C# -> Javascript function is NoIDBridge.postDemographics( <params> ) // Maybe rename to postEnrollment // TODO: pass multi birth flag, password, hub selected, gender Q&A to this funtion. public bool postDemographics ( string language, string firstName, string middleName, string lastName, string gender, string birthYear, string birthMonth, string birthDay, string streetAddress, string streetAddress2, string city, string state, string postalCode, string emailAddress, string phoneCell, string multipleBirthFlag, string genderChangeFlag, string password, string patientHub, string doesLeftBiometricExist, string doesRightBiometricExist, string missingBiometricReason, string secretExAnswer1, string secretExAnswer2, string selectedsecretQuestion1, string selectedsecretQuestion2 ) { try { _patientFHIRProfile.Language = language; _patientFHIRProfile.LastName = lastName; _patientFHIRProfile.FirstName = firstName; _patientFHIRProfile.MiddleName = middleName; if (gender.ToLower() == "f") { _patientFHIRProfile.Gender = "F"; } else if (gender.ToLower() == "m") { _patientFHIRProfile.Gender = "M"; } _patientFHIRProfile.BirthDate = formatDateOfBirth(birthYear, birthMonth, birthDay); _patientFHIRProfile.StreetAddress = streetAddress; _patientFHIRProfile.StreetAddress2 = streetAddress2; _patientFHIRProfile.City = city; _patientFHIRProfile.State = state; _patientFHIRProfile.PostalCode = postalCode; _patientFHIRProfile.EmailAddress = emailAddress; _patientFHIRProfile.PhoneCell = phoneCell; _patientFHIRProfile.ClinicArea = ClinicArea; _patientFHIRProfile.DevicePhysicalLocation = DevicePhysicalLocation; _patientFHIRProfile.NoIDType = "New"; _patientFHIRProfile.NoIDStatus = "Pending"; _patientFHIRProfile.CheckinDateTime = FHIRUtilities.DateTimeToFHIRString(DateTime.UtcNow); _patientFHIRProfile.NoIDHubPassword = password; _patientFHIRProfile.NoIDHubName = patientHub; _patientFHIRProfile.MultipleBirth = multipleBirthFlag; _patientFHIRProfile.GenderChangeFlag = genderChangeFlag; _patientFHIRProfile.BiometricExceptionMissingReason = exceptionMissingReason; _patientFHIRProfile.SecretQuestion1 = SecretQuestion1; //TODO: Implement non-fixed questions and get value from HTML _patientFHIRProfile.SecretAnswer1 = secretAnswer1; _patientFHIRProfile.SecretQuestion2 = SecretQuestion2; //TODO: Implement non-fixed questions and get value from HTML _patientFHIRProfile.SecretAnswer2 = secretAnswer2; // Send FHIR message Authentication auth; if (Utilities.Auth == null) { auth = SecurityUtilities.GetAuthentication(serviceName); } else { auth = Utilities.Auth; } HttpsClient client = new HttpsClient(); Patient pt = _patientFHIRProfile.CreateFHIRPatientProfile(); // TODO: REMOVE THIS LINE! ONLY FOR TESTING //FHIRUtilities.SaveJSONFile(pt, @"C:\JSONTest"); fhirAddress = new Uri(AddNewPatientUri); if (client.SendFHIRPatientProfile(fhirAddress, auth, pt) == false) { // Error occured set error description errorDescription = HandleNullString(client.ResponseText); return(false); } else { // No error, return message. _reponseString = HandleNullString(client.ResponseText); } } catch (Exception ex) { errorDescription = ex.Message; return(false); } return(true); }
public PatientProfile(string organizationName, Uri fhirAddress, Patient loadPatient, string noidStatus, DateTime checkinDateTime) { _organizationName = organizationName; _fhirAddress = fhirAddress; _noidStatus = noidStatus; _checkinDateTime = FHIRUtilities.DateTimeToFHIRString(checkinDateTime); NewSession(); if (loadPatient != null) { _noID = new SourceAFIS.Templates.NoID(); SetMetaData(loadPatient); //Sets all the data from the meta area of FHIR message SetIdentifierData(loadPatient); //Sets all the data from the identifier area of FHIR message // Gets the demographics from the patient FHIR resource class _lastName = loadPatient.Name[0].Family.ToString(); List <string> givenNames = loadPatient.Name[0].Given.ToList(); _firstName = givenNames[0].ToString(); if (givenNames.Count > 1) { _middleName = givenNames[1].ToString(); } _gender = loadPatient.Gender.ToString().Substring(0, 1).ToUpper(); _birthDate = loadPatient.BirthDate.ToString(); // Gets the address information from the patient FHIR resource class if (loadPatient.Address.Count > 0) { List <string> addressLines = loadPatient.Address[0].Line.ToList(); _streetAddress = addressLines[0].ToString(); if (addressLines.Count > 1) { _streetAddress2 = addressLines[1].ToString(); } _city = loadPatient.Address[0].City.ToString(); _state = loadPatient.Address[0].State.ToString(); _postalCode = loadPatient.Address[0].PostalCode.ToString(); _country = loadPatient.Address[0].Country.ToString(); } // Gets the contact information from the patient FHIR resource class if (loadPatient.Contact.Count > 0) { foreach (var contact in loadPatient.Contact) { foreach (var telecom in contact.Telecom) { if (telecom.Use.ToString().ToLower() == "home") { if (telecom.System.ToString().ToLower() == "email") { EmailAddress = telecom.Value.ToString(); } else if (telecom.System.ToString().ToLower() == "phone") { PhoneHome = telecom.Value.ToString(); } } else if (telecom.Use.ToString().ToLower() == "work") { PhoneWork = telecom.Value.ToString(); } else if (telecom.Use.ToString().ToLower() == "mobile") { PhoneCell = telecom.Value.ToString(); } } } } if (loadPatient.Photo.Count > 0) { foreach (var minutia in loadPatient.Photo) { Attachment mediaAttachment = loadPatient.Photo[0]; byte[] byteMinutias = mediaAttachment.Data; Stream stream = new MemoryStream(byteMinutias); Media media = (Media)FHIRUtilities.StreamToFHIR(new StreamReader(stream)); // Get captureSite and laterality from media string captureSiteDescription = media.Extension[1].Value.Extension[1].Value.ToString(); string lateralityCode = media.Extension[1].Value.Extension[2].Value.ToString(); string DeviceName = media.Extension[2].Value.Extension[1].Value.ToString(); string OriginalDpi = media.Extension[2].Value.Extension[2].Value.ToString(); string OriginalHeight = media.Extension[2].Value.Extension[3].Value.ToString(); string OriginalWidth = media.Extension[2].Value.Extension[4].Value.ToString(); Template addMinutia = ConvertFHIR.FHIRToTemplate(media); FingerPrintMinutias newFingerPrintMinutias = new FingerPrintMinutias( SessionID, addMinutia, FHIRUtilities.SnoMedCodeToLaterality(lateralityCode), FHIRUtilities.StringToCaptureSite(captureSiteDescription)); AddFingerPrint(newFingerPrintMinutias, DeviceName, Int32.Parse(OriginalDpi), Int32.Parse(OriginalHeight), Int32.Parse(OriginalWidth)); } _biometricsCaptured = GetBiometricsCaptured(); } } else { throw new Exception("Error in PatientProfile constructor. loadPatient is null."); } }