Esempio n. 1
0
        public bool postDoNotHaveValidBiometricButtonclick(string laterality)
        {
            try
            {
                errorDescription = "";

                if (laterality == "Left")
                {
                    _cannotCaptureLeftFingerprint = true;
                    _laterality = FHIRUtilities.StringToLaterality("Right");
                    return(true);
                }
                else if (laterality == "Right")
                {
                    _cannotCaptureRightFingerprint = true;
                    _laterality = FHIRUtilities.StringToLaterality("Unknown");
                }

                if (_cannotCaptureLeftFingerprint == true && _cannotCaptureRightFingerprint == true)
                {
                    showExceptionModal = "yes";
                }
                else
                {
                    errorDescription = "";
                }
            }
            catch (Exception ex)
            {
                errorDescription = ex.Message;
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        private void buttonTestAuthentication_Click(object sender, EventArgs e)
        {
            string username = textBoxUserName.Text;
            string pwd      = PasswordManager.GetPassword(textBoxUserName.Text);

            if (pwd.Length == 0)
            {
                labelStatus.Text = "Password in keystore is blank.";
                return;
            }

            Authentication auth     = new Authentication(username, pwd);
            Uri            endpoint = new Uri(StringUtilities.RemoveTrailingBackSlash(System.Configuration.ConfigurationManager.AppSettings["AddNewPatientUri"].ToString()));

            Patient newPatient = FHIRUtilities.CreateTestFHIRPatientProfile();
            WebSend ws         = new WebSend(endpoint, auth, newPatient);

            try
            {
                ws.PostHttpWebRequest();
                PasswordManager.SavePassword("Successful", username + "_Status");
                labelStatus.Text = "Status: Authentication Successful";
            }
            catch (Exception ex)
            {
                PasswordManager.SavePassword("Failed", username + "_Status");
                labelStatus.Text = "Status: Authentication Failed " + ex.Message;
            }
        }
Esempio n. 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            try
            {
                Stream       httpStream       = context.Request.InputStream;
                StreamReader httpStreamReader = new StreamReader(httpStream);
                Resource     newResource      = FHIRUtilities.StreamToFHIR(httpStreamReader);
                _patient = (Patient)newResource;

                //find all patient without fingerprints.  should be a small sample.
                //if found, return localid
                //if not found, return "no match found"
                MongoDBWrapper  dbwrapper = new MongoDBWrapper(NoIDMongoDBAddress, SparkMongoDBAddress);
                AlternateSearch altSearch = GetAlternateFromPatient(_patient);
                string          localNoID = dbwrapper.AlternateSearch(altSearch);
                if (localNoID.ToLower().Contains("noid://") == false)
                {
                    dbwrapper.AddAlternateSearch(altSearch);
                    _responseText = "no match found";
                }
                else
                {
                    _responseText = localNoID;
                }
            }
            catch (Exception ex)
            {
                _responseText = "Error in AltMatchByDemographics::ProcessRequest: " + ex.Message;
                LogUtilities.LogEvent(_responseText);
            }
            context.Response.Write(_responseText);
            context.Response.End();
        }
Esempio n. 4
0
        static Template MediaFHIRToTemplate(Resource fhirMessage)
        {
            Template converted = null;

            try
            {
                Media biometricFHIR = (Media)fhirMessage;

                Extension       organizationExtension = null;
                Extension       captureSiteExtension  = null;
                uint            n = 0;
                TemplateBuilder templateBuilder = new TemplateBuilder();
                foreach (Extension extension in biometricFHIR.Extension)
                {
                    if (n == 0)
                    {
                        organizationExtension = extension;
                    }
                    else if (n == 1)
                    {
                        captureSiteExtension = extension;
                    }
                    else
                    {
                        TemplateBuilder.Minutia minutia = new TemplateBuilder.Minutia();
                        List <Extension>        ext     = extension.Value.Extension;

                        minutia.Position.X = Int32.Parse(ext[0].Value.ToString());
                        minutia.Position.Y = Int32.Parse(ext[1].Value.ToString());
                        minutia.Direction  = Byte.Parse(ext[2].Value.ToString());
                        minutia.Type       = ConvertStringToMinutiaType(ext[3].Value.ToString());
                        templateBuilder.Minutiae.Add(minutia);
                    }
                    n += 1;
                }
                if (organizationExtension != null && captureSiteExtension != null && templateBuilder.Minutiae.Count > 0)
                {
                    templateBuilder.OriginalDpi    = Int32.Parse(captureSiteExtension.Value.Extension[5].Value.ToString());
                    templateBuilder.OriginalHeight = Int32.Parse(captureSiteExtension.Value.Extension[6].Value.ToString());
                    templateBuilder.OriginalWidth  = Int32.Parse(captureSiteExtension.Value.Extension[7].Value.ToString());
                    converted = new Template(templateBuilder);
                }
                string captureSiteCode = biometricFHIR.Extension[1].Value.Extension[1].Value.ToString();
                string lateralityCode  = biometricFHIR.Extension[1].Value.Extension[2].Value.ToString();

                converted.NoID = FHIRToNoID(fhirMessage); //Gets the NoID Identifiers
                converted.NoID.CaptureSiteSnoMedCode = FHIRUtilities.SnoMedCaptureSiteNameToCode(captureSiteCode);
                converted.NoID.LateralitySnoMedCode  = UInt32.Parse(lateralityCode);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(converted);
        }
Esempio n. 5
0
        private static Patient TestPatient()
        {
            Patient testPatient = FHIRUtilities.CreateTestFHIRPatientProfile
                                  (
                "Test NoID Org", Guid.NewGuid().ToString(), "", "English", "1961-04-22", "F", "No",
                "Donna", "Marie", "Kasick", "4712 W 3rd St.", "Apt 35", "New York", "NY", "10000-2221",
                "212-555-3000", "212-555-7400", "212-555-9555", "*****@*****.**"
                                  );

            return(testPatient);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 // C# -> Javascript function is NoIDBridge.postLateralityCaptureSite ( <params> )
 public bool postLateralityCaptureSite(string laterality, string captureSite)
 {
     try
     {
         _captureSite     = FHIRUtilities.StringToCaptureSite(captureSite);
         _laterality      = FHIRUtilities.StringToLaterality(laterality);
         errorDescription = "";
     }
     catch (Exception ex)
     {
         errorDescription = ex.Message;
         return(false);
     }
     return(true);
 }
Esempio n. 8
0
        bool SendBiometicsToSparkServer()
        {
            FhirClient client = new FhirClient(_sparkEndpoint);

            if (!(Patient == null))
            {
                try
                {
                    Resource response = client.Create(Biometics);
                    _responseText = FHIRUtilities.FHIRToString(response);
                }
                catch (Exception ex)
                {
                    _responseText = ex.Message;
                    _exception    = ex;
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 9
0
        public static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Utilities.Auth = new Authentication(_serviceName, args[0].ToString());
                Uri endpoint = new Uri(StringUtilities.RemoveTrailingBackSlash(System.Configuration.ConfigurationManager.AppSettings["AddNewPatientUri"].ToString()));

                Patient newPatient = FHIRUtilities.CreateTestFHIRPatientProfile();
                WebSend ws         = new WebSend(endpoint, Utilities.Auth, newPatient);
                try
                {
                    ws.PostHttpWebRequest();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Status: Authentication Failed " + ex.Message + " Closing NoID.");
                    return;
                }
            }

            if (Utilities.Auth != null || PasswordManager.GetPassword(_serviceName + "_Status") == "Successful")
            {
                //For Windows 7 and above, best to include relevant app.manifest entries as well
                Cef.EnableHighDPISupport();

                //Perform dependency check to make sure all relevant resources are in our output directory.
                Cef.Initialize(new CefSettings(), performDependencyCheck: true, browserProcessHandler: null);

                var browser = new BrowserForm();
                Application.Run(browser);
            }
            else
            {
                var login = new LoginForm();
                Application.Run(login);
            }
        }
Esempio n. 10
0
        public void ProcessRequest(HttpContext context)
        {
            string responseText = null;

            context.Response.ContentType = "text/plain";

            if (!(context.Request.InputStream == null))
            {
                try
                {
                    Patient newResource = (Patient)FHIRUtilities.StreamToFHIR(new StreamReader(context.Request.InputStream));

                    if (newResource.Photo.Count > 0)
                    {
                        Attachment mediaAttachment = newResource.Photo[0];
                        byte[]     byteMinutias    = mediaAttachment.Data;

                        Stream stream = new MemoryStream(byteMinutias);
                        Media  media  = (Media)FHIRUtilities.StreamToFHIR(new StreamReader(stream));
                    }
                    responseText = "Parsed List object.";
                }
                catch (Exception ex)
                {
                    //TODO: return FHIR or JSON formated error here instead of plain text.  manage errors with a class.
                    responseText = "NoID ReceiveFHIR Server Error 35000. " + ex.Message;
                }
            }
            else
            {
                //TODO: return FHIR or JSON formated error here instead of plain text.  manage errors with a class.
                responseText = "NoID ReceiveFHIR Server Error 35001.  FHIR message not found in HTTP body.";
            }
            context.Response.Write(responseText);
            context.Response.End();
        }
Esempio n. 11
0
        public string GetBiometricsCaptured()
        {
            string biometrics = "";

            if (_fingerPrintMinutiasList.Count > 0)
            {
                foreach (var finger in _fingerPrintMinutiasList)
                {
                    string fingerDesc = FixFingerDescriptions(FHIRUtilities.LateralityToString(finger.LateralitySnoMedCode) + " " + FHIRUtilities.CaptureSiteToString(finger.CaptureSiteSnoMedCode));
                    if (biometrics.Contains(fingerDesc) == false)
                    {
                        if (biometrics.Length > 0)
                        {
                            biometrics = biometrics + " and " + fingerDesc;
                        }
                        else
                        {
                            biometrics = fingerDesc;
                        }
                    }
                }
            }
            return(biometrics);
        }
Esempio n. 12
0
        /// <summary>Creates a test patient list for the ProviderBridge class
        /// <seealso cref="ProviderBridge"/>
        /// </summary>

        public static IList <PatientProfile> GetTestPatients(string organizationName)
        {
            string addressPending = StringUtilities.RemoveTrailingBackSlash(System.Configuration.ConfigurationManager.AppSettings["SparkEndpointAddress"].ToString());
            Uri    endPoint       = new Uri(addressPending);

            List <PatientProfile> newList = new List <PatientProfile>();
            Patient testPatient           = FHIRUtilities.CreateTestFHIRPatientProfile
                                            (
                organizationName, Guid.NewGuid().ToString(), "", "English", "1961-04-22", "F", "No",
                "Donna", "Marie", "Kasick", "4712 W 3rd St.", "Apt 35", "New York", "NY", "10000-2221",
                "212-555-3000", "212-555-7400", "212-555-9555", "*****@*****.**"
                                            );

            PatientProfile newProfile = new PatientProfile(organizationName, endPoint, testPatient, "New", DateTime.UtcNow.AddMinutes(-3));


            newList.Add(newProfile);

            testPatient = FHIRUtilities.CreateTestFHIRPatientProfile
                          (
                organizationName, Guid.NewGuid().ToString(), "", "English", "1992-10-30", "F", "Yes",
                "Christine", "J", "Pinkentinfuter", "2088 N 23nd St.", "Unit 51", "New York", "NY", "10012-0159",
                "", "318-777-8888", "318-222-4111", "*****@*****.**"
                          );

            newProfile = new PatientProfile(organizationName, endPoint, testPatient, "Return", DateTime.UtcNow.AddMinutes(-5));

            newList.Add(newProfile);

            testPatient = FHIRUtilities.CreateTestFHIRPatientProfile
                          (
                organizationName, Guid.NewGuid().ToString(), "", "English", "1954-02-19", "M", "No",
                "Mitchel", "James", "Hendrichs", "2442 Bleaker St.", "Apt 722", "New York", "NY", "10503-04855",
                "212-111-1234", "", "", "*****@*****.**"
                          );

            newProfile = new PatientProfile(organizationName, endPoint, testPatient, "Return", DateTime.UtcNow.AddMinutes(-15));

            newList.Add(newProfile);

            testPatient = FHIRUtilities.CreateTestFHIRPatientProfile
                          (
                organizationName, Guid.NewGuid().ToString(), "", "English", "2001-03-21", "M", "No",
                "Brian", "H", "O'Donald", "212 Cremont", "", "New Jersey", "NJ", "14235",
                "", "212-555-1234", "", "*****@*****.**"
                          );

            newProfile = new PatientProfile(organizationName, endPoint, testPatient, "New", DateTime.UtcNow.AddMinutes(-32));

            newList.Add(newProfile);

            testPatient = FHIRUtilities.CreateTestFHIRPatientProfile
                          (
                organizationName, Guid.NewGuid().ToString(), "", "English", "1999-09-02", "F", "No",
                "Jonie", "M", "Smith", "", "", "", "", "",
                "", "", "", ""
                          );

            newProfile = new PatientProfile(organizationName, endPoint, testPatient, "Return", DateTime.UtcNow.AddMinutes(-41));

            newList.Add(newProfile);

            return(newList);
        }
Esempio n. 13
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                bool   biometricsSaved = false;
                string missingReason   = "";
                string question1       = "";
                string question2       = "";
                string answer1         = "";
                string answer2         = "";

                if (uint.TryParse(MinimumAcceptedMatchScore, out _minimumAcceptedMatchScore) == false)
                {
                    _minimumAcceptedMatchScore = 30;
                }

                Stream       httpStream       = context.Request.InputStream;
                StreamReader httpStreamReader = new StreamReader(httpStream);
                Resource     newResource      = FHIRUtilities.StreamToFHIR(httpStreamReader);

                _patient = (Patient)newResource;
                //TODO: make sure this FHIR message has a new pending status.

                //TODO: make this an atomic transaction.
                //          delete the FHIR message from Spark if there is an error in the minutia.

                Patient ptSaved = (Patient)SendPatientToSparkServer();
                //LogUtilities.LogEvent("AddNewPatient.ashx Saved FHIR in spark.");

                if (ptSaved == null)
                {
                    _responseText = "Error sending Patient FHIR message to the Spark FHIR endpoint. " + ExceptionString;
                    return;
                }

                SourceAFIS.Templates.NoID noID = new SourceAFIS.Templates.NoID();
                noID.SessionID = ptSaved.Id.ToString();
                //TODO: Add Argon2d hash here:
                noID.LocalNoID = "noid://" + DomainName + "/" + StringUtilities.SHA256(DomainName + noID.SessionID + NodeSalt);
                SessionQueue seq = Utilities.PatientToSessionQueue(_patient, ptSaved.Id.ToString(), noID.LocalNoID, "new", "pending");
                seq.SubmitDate = DateTime.UtcNow;

                //TODO: send to selected match hub and get the remote hub ID.
                // Hub ID in the same format: noid://domain/LocalID

                if (_patient.Photo.Count > 0)
                {
                    dbMinutia = new FingerPrintMatchDatabase(DatabaseDirectory, BackupDatabaseDirectory, _minimumAcceptedMatchScore);
                    foreach (var minutia in _patient.Photo)
                    {
                        byte[] byteMinutias = minutia.Data;
                        Stream stream       = new MemoryStream(byteMinutias);
                        Media  media        = (Media)FHIRUtilities.StreamToFHIR(new StreamReader(stream));
                        // Save minutias for matching.
                        Template fingerprintTemplate = ConvertFHIR.FHIRToTemplate(media);
                        fingerprintTemplate.NoID = noID;
                        try
                        {
                            dbMinutia.LateralityCode = (FHIRUtilities.LateralitySnoMedCode)fingerprintTemplate.NoID.LateralitySnoMedCode;
                            dbMinutia.CaptureSite    = (FHIRUtilities.CaptureSiteSnoMedCode)fingerprintTemplate.NoID.CaptureSiteSnoMedCode;
                        }
                        catch { }
                        if (dbMinutia.AddTemplate(fingerprintTemplate) == false)
                        {
                            _responseText = "Error adding a fingerprint to the match database.";
                        }
                    }
                    dbMinutia.Dispose();
                    biometricsSaved = true;
                }
                else
                {
                    // check alternate pathway Q&A
                    foreach (var id in _patient.Identifier)
                    {
                        if (id.System.ToLower().Contains("biometric") == true)
                        {
                            Extension extExceptionQA = id.Extension[0];
                            foreach (var ext in extExceptionQA.Extension)
                            {
                                if (ext.Url.ToLower().Contains("reason") == true)
                                {
                                    missingReason = ext.Value.ToString();
                                }
                                else if (ext.Url.ToLower().Contains("question 1") == true)
                                {
                                    question1 = ext.Value.ToString();
                                }
                                else if (ext.Url.ToLower().Contains("answer 1") == true)
                                {
                                    answer1 = ext.Value.ToString();
                                }
                                else if (ext.Url.ToLower().Contains("question 2") == true)
                                {
                                    question2 = ext.Value.ToString();
                                }
                                else if (ext.Url.ToLower().Contains("answer 2") == true)
                                {
                                    answer2 = ext.Value.ToString();
                                }
                            }
                            if (
                                missingReason.Length > 0 &&
                                question1.Length > 0 && answer1.Length > 0 &&
                                question2.Length > 0 && answer2.Length > 0
                                )
                            {
                                if (missingReason != "I am permanently physically unable to provide fingerprints")
                                {
                                    if (missingReason == "I am temporarily physically unable to provide fingerprints")
                                    {
                                        seq.PatientStatus = "hold**";
                                    }
                                    else if (missingReason == "I attempted the fingerprint scan process, but I could not get a successful scan on either hand")
                                    {
                                        seq.PatientStatus = "hold";
                                    }
                                }
                                else
                                {
                                    seq.PatientStatus = "new***";
                                }
                                biometricsSaved = true;
                            }
                        }
                    }
                    // log patient in alternatesearch container
                }
                if (biometricsSaved)
                {
                    MongoDBWrapper dbwrapper = new MongoDBWrapper(NoIDMongoDBAddress, SparkMongoDBAddress);
                    dbwrapper.AddPendingPatient(seq);
                }
                else
                {
                    _responseText = "Critical Error! No biometrics or alternates provided. Can not complete enrollment.";
                    LogUtilities.LogEvent(_responseText);
                }
                //TODO: end atomic transaction.
                _responseText = "Successful.";
                //LogUtilities.LogEvent("Ending AddNewPatient.ashx");
            }
            catch (Exception ex)
            {
                _responseText = "Error in AddNewPatient::ProcessRequest: " + ex.Message;
                LogUtilities.LogEvent(_responseText);
            }
            context.Response.Write(_responseText);
            context.Response.End();
        }
Esempio n. 14
0
        public FHIRMessageRouter(HttpContext context)
        {
            try
            {
                if (uint.TryParse(MinimumAcceptedMatchScore, out _minimumAcceptedMatchScore) == false)
                {
                    _minimumAcceptedMatchScore = 30;
                }

                Resource newResource = FHIRUtilities.StreamToFHIR(new StreamReader(context.Request.InputStream));
                switch (newResource.TypeName.ToLower())
                {
                case "patient":
                    //if new patient. TODO: check meta for NoID status
                    SessionQueue seq = new SessionQueue();


                    _patient = (Patient)newResource;
                    string sessionID = "";
                    if (_patient.Identifier.Count > 0)
                    {
                        foreach (Identifier id in _patient.Identifier)
                        {
                            if (id.System.ToString().ToLower().Contains("session") == true)
                            {
                                sessionID = id.Value.ToString();
                            }
                        }
                    }

                    Patient ptSaved = (Patient)SendPatientToSparkServer();
                    if (ptSaved == null)
                    {
                        _responseText = "Error sending Patient FHIR message to the Spark FHIR endpoint. " + ExceptionString;
                        return;
                    }

                    string LocalNoID = ptSaved.Id.ToString();
                    //TODO: make this an atomic transaction.
                    //          delete the FHIR message from Spark if there is an error in the minutia.

                    //TODO check for existing patient and expire old messages for the patient.
                    if (_patient.Photo.Count > 0)
                    {
                        dbMinutia = new FingerPrintMatchDatabase(_databaseDirectory, _backupDatabaseDirectory, _minimumAcceptedMatchScore);
                        foreach (var minutia in _patient.Photo)
                        {
                            byte[] byteMinutias = minutia.Data;
                            Stream stream       = new MemoryStream(byteMinutias);
                            Media  media        = (Media)FHIRUtilities.StreamToFHIR(new StreamReader(stream));
                            // Save minutias for matching.
                            Template fingerprintTemplate = ConvertFHIR.FHIRToTemplate(media);
                            fingerprintTemplate.NoID.LocalNoID = LocalNoID;
                            try
                            {
                                dbMinutia.LateralityCode = (FHIRUtilities.LateralitySnoMedCode)fingerprintTemplate.NoID.LateralitySnoMedCode;
                                dbMinutia.CaptureSite    = (FHIRUtilities.CaptureSiteSnoMedCode)fingerprintTemplate.NoID.CaptureSiteSnoMedCode;
                            }
                            catch { }
                            if (dbMinutia.AddTemplate(fingerprintTemplate) == false)
                            {
                                _responseText = "Error adding a fingerprint to the match database.";
                            }
                        }
                        dbMinutia.Dispose();
                        _responseText = "Successful.";
                    }
                    break;

                case "media":
                    _biometics = (Media)newResource;
                    // TODO send to biometric match engine. If found, add patient reference to FHIR message.
                    // convert FHIR fingerprint message (_biometics) to AFIS template class
                    Template probe = ConvertFHIR.FHIRToTemplate(_biometics);
                    dbMinutia = new FingerPrintMatchDatabase(_databaseDirectory, _backupDatabaseDirectory, _minimumAcceptedMatchScore);
                    try
                    {
                        dbMinutia.LateralityCode = (FHIRUtilities.LateralitySnoMedCode)probe.NoID.LateralitySnoMedCode;
                        dbMinutia.CaptureSite    = (FHIRUtilities.CaptureSiteSnoMedCode)probe.NoID.CaptureSiteSnoMedCode;
                    }
                    catch { }
                    MinutiaResult minutiaResult = dbMinutia.SearchPatients(probe);
                    if (minutiaResult != null)
                    {
                        if (minutiaResult.NoID != null && minutiaResult.NoID.Length > 0)
                        {
                            // Fingerprint found in database
                            _responseText = minutiaResult.NoID;      //TODO: for now, it returns the localNoID.  should return a FHIR response.
                        }
                        else
                        {
                            _responseText = "No local database match.";
                        }
                    }
                    else
                    {
                        _responseText = "No local database match.";
                    }
                    dbMinutia.Dispose();

                    if (!(SendBiometicsToSparkServer()))
                    {
                        _responseText = "Error sending Biometric Media FHIR message to the Spark FHIR endpoint. " + ExceptionString;
                    }
                    break;

                default:
                    _responseText = newResource.TypeName.ToLower() + " not supported.";
                    break;
                }
            }
            catch (Exception ex)
            {
                _responseText = "Error in FHIRMessageRouter::FHIRMessageRouter: " + ex.Message;
            }
        }
Esempio n. 15
0
 string FixFingerDescriptions(string inputFinger)
 {
     return(FHIRUtilities.FixEnumFingerDescriptions(inputFinger));
 }
Esempio n. 16
0
        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.");
            }
        }
Esempio n. 17
0
        //  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);
        }
Esempio n. 18
0
        public Media FingerPrintFHIRMedia(FingerPrintMinutias fingerPrints, string deviceName, int originalDPI, int originalHeight, int originalWidth)
        {
            Media FingerPrintMedia = null;

            try
            {
                if ((fingerPrints != null))
                {
                    //TODO: add capture date/time to message
                    FingerPrintMedia = new Media(); //Creates the fingerprint minutia template FHIR object as media type.
                    FingerPrintMedia.AddExtension("Healthcare Node", FHIRUtilities.OrganizationExtension(OrganizationName, DomainName, ServerName));
                    FingerPrintMedia.AddExtension("Biometic Capture", FHIRUtilities.CaptureSiteExtension(fingerPrints.CaptureSiteSnoMedCode, fingerPrints.LateralitySnoMedCode, deviceName, originalDPI, originalHeight, originalWidth));

                    FingerPrintMedia.Identifier = new List <Identifier>();

                    Identifier idSession;
                    Identifier idPatientCertificate;
                    if ((SessionID != null))
                    {
                        if (SessionID.Length > 0)
                        {
                            idSession        = new Identifier();
                            idSession.System = ServerName + "/fhir/SessionID";
                            idSession.Value  = SessionID;
                            FingerPrintMedia.Identifier.Add(idSession);
                        }
                        else
                        {
                            //TODO this is a critical error.  all need a unique session id.
                        }
                    }
                    else
                    {
                        //TODO this is critical.  all need a unique session id.
                    }
                    if (LocalNoID != null)
                    {
                        if (LocalNoID.Length > 0)
                        {
                            idPatientCertificate        = new Identifier();
                            idPatientCertificate.System = ServerName + "/fhir/LocalNoID";
                            idPatientCertificate.Value  = LocalNoID;
                            FingerPrintMedia.Identifier.Add(idPatientCertificate);
                        }
                    }
                    // TODO: Add RemoteNoID.

                    foreach (var Minutia in fingerPrints.Minutiae)
                    {
                        if (FingerPrintMedia is null)
                        {
                            FingerPrintMedia = new Media();
                        }

                        Extension extFingerPrintMedia = FHIRUtilities.FingerPrintMediaExtension(
                            Minutia.PositionX.ToString(),
                            Minutia.PositionY.ToString(),
                            Minutia.Direction.ToString(),
                            Minutia.Type.ToString()
                            );

                        FingerPrintMedia.AddExtension("Biometrics", extFingerPrintMedia);
                    }
                }
            }
            catch (Exception ex)
            {
                BaseException = ex;
            }
            return(FingerPrintMedia);
        }
Esempio n. 19
0
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         if (uint.TryParse(MinimumAcceptedMatchScore, out _minimumAcceptedMatchScore) == false)
         {
             _minimumAcceptedMatchScore = 30;
         }
         Resource newResource = FHIRUtilities.StreamToFHIR(new StreamReader(context.Request.InputStream));
         _biometics = (Media)newResource;
         // TODO send to biometric match engine. If found, add patient reference to FHIR message.
         // convert FHIR fingerprint message (_biometics) to AFIS template class
         Template probe = ConvertFHIR.FHIRToTemplate(_biometics);
         dbMinutia = new FingerPrintMatchDatabase(_databaseDirectory, _backupDatabaseDirectory, _minimumAcceptedMatchScore);
         try
         {
             dbMinutia.LateralityCode = (FHIRUtilities.LateralitySnoMedCode)probe.NoID.LateralitySnoMedCode;
             dbMinutia.CaptureSite    = (FHIRUtilities.CaptureSiteSnoMedCode)probe.NoID.CaptureSiteSnoMedCode;
         }
         catch { }
         MinutiaResult minutiaResult = dbMinutia.SearchPatients(probe);
         if (minutiaResult != null)
         {
             if (minutiaResult.NoID != null && minutiaResult.NoID.Length > 0)
             {
                 // Fingerprint found in database
                 // check if patient is already pending.
                 MongoDBWrapper dbwrapper     = new MongoDBWrapper(NoIDMongoDBAddress, SparkMongoDBAddress);
                 string         currentStatus = dbwrapper.GetCurrentStatus(minutiaResult.NoID);
                 if (currentStatus.ToLower() != "pending")
                 {
                     _responseText = minutiaResult.NoID;  //TODO: for now, it returns the localNoID.  should return a FHIR response.
                 }
                 else
                 {
                     _responseText = "pending";
                 }
                 LogUtilities.LogEvent(_responseText);
             }
             else
             {
                 _responseText = "No local database match.";
                 LogUtilities.LogEvent(_responseText);
             }
         }
         else
         {
             _responseText = "No local database match.";
             LogUtilities.LogEvent(_responseText);
         }
         dbMinutia.Dispose();
         LogUtilities.LogEvent("After dbMinutia.Dispose();");
     }
     catch (Exception ex)
     {
         _exception    = ex;
         _responseText = ex.Message;
     }
     context.Response.Write(_responseText);
     context.Response.End();
 }
Esempio n. 20
0
        public Patient CreateFHIRPatientProfile()
        {
            Patient pt;

            try
            {
                /*
                 *
                 * _patientFHIRProfile.NoIDHubPassword = password;
                 * _patientFHIRProfile.NoIDHubName = patientHub;
                 * _patientFHIRProfile.GenderChangeFlag = genderChangeFlag;
                 *
                 */
                pt = new Patient();

                BiometricsCaptured = GetBiometricsCaptured();
                // Add message status New, Return or Update
                Meta meta = new Meta();

                meta.Extension.Add(FHIRUtilities.MessageTypeExtension(NoIDStatus, NoIDType, CheckinDateTime));
                meta.Extension.Add(FHIRUtilities.ClinicLocationExtension(ClinicArea, DevicePhysicalLocation));
                if (FingerPrintMinutiasList.Count > 0)
                {
                    meta.Extension.Add(FHIRUtilities.CaptureSummaryExtension(BiometricsCaptured,
                                                                             FingerPrintMinutiasList[0].DeviceName,
                                                                             FingerPrintMinutiasList[0].OriginalDpi,
                                                                             FingerPrintMinutiasList[0].OriginalHeight,
                                                                             FingerPrintMinutiasList[0].OriginalWidth)
                                       );
                }
                meta.Extension.Add(FHIRUtilities.NoIDHubInfo(NoIDHubName, NoIDHubPassword));
                if (GenderChangeFlag.ToLower().Contains("yes") == true || MultipleBirth.ToLower().Contains("no") == false)
                {
                    meta.Extension.Add(FHIRUtilities.GenderAndTwinInfo(GenderChangeFlag, MultipleBirth));
                }

                pt.Meta = meta;

                //TODO: Move fingerprint minutias to Identifier.Extension
                Identifier idSession = new Identifier();
                idSession.System = ServerName + "/fhir/SessionID";
                if (SessionID == null || SessionID.Length == 0)
                {
                    NewSession();
                }
                idSession.Value = SessionID;
                pt.Identifier.Add(idSession);


                if (BiometricExceptionMissingReason.Length > 0)
                {
                    if (SecretQuestion1.Length > 0 && SecretAnswer1.Length > 0 && SecretQuestion2.Length > 0 && SecretAnswer2.Length > 0)
                    {
                        Identifier idBiometricException = new Identifier();
                        idBiometricException.System = ServerName + "/fhir/BiometricException";
                        idBiometricException.Value  = "Biometric Exception Pathway";
                        Extension extBiometricException;
                        extBiometricException = FHIRUtilities.BiometricException(
                            BiometricExceptionMissingReason,
                            SecretQuestion1, SecretAnswer1,
                            SecretQuestion2, SecretAnswer2
                            );
                        idBiometricException.Extension.Add(extBiometricException);
                        pt.Identifier.Add(idBiometricException);
                    }
                    {
                        //throw an error back to the page.
                    }
                }

                ResourceReference managingOrganization = new ResourceReference(OrganizationName, DomainName);
                pt.ManagingOrganization = managingOrganization;

                // Add patient demographics
                pt.Language  = Language;
                pt.BirthDate = BirthDate;
                if (Gender.ToLower() == "f")
                {
                    pt.Gender = AdministrativeGender.Female;
                }
                else if (Gender.ToLower() == "m")
                {
                    pt.Gender = AdministrativeGender.Male;
                }
                else
                {
                    pt.Gender = AdministrativeGender.Unknown;
                }

                if (!(MultipleBirth == null) && MultipleBirth.Length > 0)
                {
                    if (MultipleBirth.ToLower().Substring(0, 2) == "no")
                    {
                        pt.MultipleBirth = new FhirString("No");
                    }
                    else if (MultipleBirth.ToLower() == "yes")
                    {
                        pt.MultipleBirth = new FhirString("Yes");
                    }
                }
                // Add patient name
                HumanName ptName = new HumanName();
                ptName.Given  = new string[] { FirstName, MiddleName };
                ptName.Family = LastName;
                pt.Name       = new List <HumanName> {
                    ptName
                };

                if (StreetAddress.Length > 0 || City.Length > 0 || State.Length > 0 || PostalCode.Length > 0)
                {
                    Address address = new Address(); // Add patient address
                    address.Line       = new string[] { StreetAddress, StreetAddress2 };
                    address.City       = City;
                    address.State      = State;
                    address.Country    = Country;
                    address.PostalCode = PostalCode;
                    pt.Address.Add(address);
                }

                // Add patient contact information (phone numbers and email)
                // TODO: make sure email and phone are valid.
                // Validate phone with UI.
                Patient.ContactComponent contact = new Patient.ContactComponent();
                bool addContact = false;
                if ((EmailAddress != null) && EmailAddress.Length > 0)
                {
                    ContactPoint emailAddress = new ContactPoint(ContactPoint.ContactPointSystem.Email, ContactPoint.ContactPointUse.Home, EmailAddress);
                    contact.Telecom.Add(emailAddress);
                    addContact = true;
                }
                if ((PhoneHome != null) && PhoneHome.Length > 0)
                {
                    ContactPoint phoneHome = new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Home, PhoneHome);
                    contact.Telecom.Add(phoneHome);
                    addContact = true;
                }
                if ((PhoneCell != null) && PhoneCell.Length > 0)
                {
                    ContactPoint phoneCell = new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Mobile, PhoneCell);
                    contact.Telecom.Add(phoneCell);
                    addContact = true;
                }
                if ((PhoneWork != null) && PhoneWork.Length > 0)
                {
                    ContactPoint phoneWork = new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Work, PhoneWork);
                    contact.Telecom.Add(phoneWork);
                    addContact = true;
                }
                if (addContact)
                {
                    pt.Contact.Add(contact);
                }
                //TODO: Change location of minutias in Patient FHIR profile from attached Photo.Extension to Identity.Extension
                foreach (FingerPrintMinutias minutias in FingerPrintMinutiasList)
                {
                    Attachment attach           = new Attachment();
                    Media      fingerprintMedia = FingerPrintFHIRMedia(minutias, minutias.DeviceName, minutias.OriginalDpi, minutias.OriginalHeight, minutias.OriginalWidth);
                    byte[]     mediaBytes       = FhirSerializer.SerializeToJsonBytes(fingerprintMedia, summary: SummaryType.Data);
                    attach.Data = mediaBytes;
                    pt.Photo.Add(attach);
                }
            }
            catch (Exception ex)
            {
                BaseException = new Exception("Error in PatientProfile::CreateFHIRProfile(). Failed to create a new FHIR profile: " + ex.Message);
                return(null);
            }
            return(pt);
        }
Esempio n. 21
0
 private static Resource ReadJSONFile(string filePath)
 {
     return(FHIRUtilities.FileToResource(filePath));
 }
Esempio n. 22
0
        //TODO: Abstract CaptureResult so it will work with any fingerprint scanner.
        private void OnCaptured(CaptureResult captureResult)
        {
            browser.GetMainFrame().ExecuteJavaScriptAsync("showPleaseWait();");
            //mark schroeder20170703
            if (PatientBridge.cannotCaptureLeftFingerprint == true)
            {
                Laterality = FHIRUtilities.LateralitySnoMedCode.Right;
            }

            if (currentCaptureInProcess == false)
            {
                if ((PatientBridge.hasValidLeftFingerprint == true && Laterality == FHIRUtilities.LateralitySnoMedCode.Left) || (PatientBridge.hasValidRightFingerprint == true && Laterality == FHIRUtilities.LateralitySnoMedCode.Right))
                {
                    //mark schroeder 20170701 do not capture more left fingerprints if left is set. Same for right
                    return;
                }
                else
                {
                    try
                    {
                        //mark schroeder 20170701 use this to stop more capture attempts while processing. Added to below if statememt
                        currentCaptureInProcess    = true;
                        maxFingerprintScanAttempts = Convert.ToInt16(System.Configuration.ConfigurationManager.AppSettings["maxFingerprintScanAttempts"].ToString());
                        fingerprintScanAttempts++;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        return;
                    }

                    if (_patientBridge.captureSite != FHIRUtilities.CaptureSiteSnoMedCode.Unknown && _patientBridge.laterality != FHIRUtilities.LateralitySnoMedCode.Unknown)
                    {
                        if (fingerprintScanAttempts <= maxFingerprintScanAttempts)
                        {
#if NAVIGATE
                            DisplayOutput("Captured finger image....");
#endif
                            // Check capture quality and throw an error if poor or incomplete capture.
                            if (!biometricDevice.CheckCaptureResult(captureResult))
                            {
                                return;
                            }

                            Constants.CaptureQuality quality = captureResult.Quality;
                            if ((int)quality != 0)
                            {
                                //call javascript to inform UI that the capture quality was too low to accept.
#if NAVIGATE
                                DisplayOutput("Fingerprint quality was too low to accept. Quality = " + quality.ToString());
#endif
                                return;
                            }

                            Type   captureResultType = captureResult.GetType();
                            string deviceClassName   = captureResultType.ToString();
                            string deviceName        = "";
                            if (deviceClassName == "DPUruNet.CaptureResult")
                            {
                                deviceName = "DigitalPersona U.Are.U 4500";
                            }

                            SourceAFIS.Simple.Person currentCapture = new SourceAFIS.Simple.Person();

                            Fingerprint newFingerPrint = new Fingerprint();
                            foreach (Fid.Fiv fiv in captureResult.Data.Views)
                            {
                                newFingerPrint.AsBitmap = ImageUtilities.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height);
                            }
                            currentCapture.Fingerprints.Add(newFingerPrint);
                            Afis.Extract(currentCapture);
                            Template tmpCurrent = newFingerPrint.GetTemplate();

                            if (_minutiaCaptureController.MatchFound == false)
                            {
                                if (_minutiaCaptureController.AddMinutiaTemplateProbe(tmpCurrent) == true)
                                {
                                    // Good pair found.  Query web service for a match.
                                    FingerPrintMinutias newFingerPrintMinutias = new FingerPrintMinutias
                                                                                     (SessionID, _minutiaCaptureController.BestTemplate1, Laterality, CaptureSite);
                                    PatientBridge.PatientFHIRProfile.AddFingerPrint(newFingerPrintMinutias,
                                                                                    deviceName,
                                                                                    _minutiaCaptureController.BestTemplate1.OriginalDpi,
                                                                                    _minutiaCaptureController.BestTemplate1.OriginalHeight,
                                                                                    _minutiaCaptureController.BestTemplate1.OriginalWidth);

                                    newFingerPrintMinutias = new FingerPrintMinutias
                                                                 (SessionID, _minutiaCaptureController.BestTemplate2, Laterality, CaptureSite);
                                    PatientBridge.PatientFHIRProfile.AddFingerPrint(newFingerPrintMinutias,
                                                                                    deviceName,
                                                                                    _minutiaCaptureController.BestTemplate2.OriginalDpi,
                                                                                    _minutiaCaptureController.BestTemplate2.OriginalHeight,
                                                                                    _minutiaCaptureController.BestTemplate2.OriginalWidth);

                                    Media media = PatientBridge.PatientFHIRProfile.FingerPrintFHIRMedia(newFingerPrintMinutias, deviceName, tmpCurrent.OriginalDpi, tmpCurrent.OriginalHeight, tmpCurrent.OriginalWidth);

                                    // TODO: REMOVE THIS LINE!  ONLY FOR TESTING
                                    //FHIRUtilities.SaveJSONFile(media, @"C:\JSONTest");

                                    HttpsClient    dataTransport = new HttpsClient();
                                    Authentication auth;
                                    if (Utilities.Auth == null)
                                    {
                                        auth = SecurityUtilities.GetAuthentication(NoIDServiceName);
                                    }
                                    else
                                    {
                                        auth = Utilities.Auth;
                                    }
                                    PatientBridge.fhirAddress = new Uri(SearchBiometricsUri);
                                    dataTransport.SendFHIRMediaProfile(PatientBridge.fhirAddress, auth, media);
                                    string lateralityString  = FHIRUtilities.LateralityToString(Laterality);
                                    string captureSiteString = FHIRUtilities.CaptureSiteToString(CaptureSite);
#if NAVIGATE
                                    string output = lateralityString + " " + captureSiteString + " fingerprint accepted. Score = " + _minutiaCaptureController.BestScore + ", Fingerprint sent to server: Response = " + dataTransport.ResponseText;
                                    DisplayOutput(output);
#endif
                                    if (dataTransport.ResponseText.ToLower().Contains("error") == true || dataTransport.ResponseText.ToLower().Contains("index") == true)
                                    {
                                        string message = "Critical Identity Error Occured In Fingerprint Capture method. Please contact your adminstrator: " + dataTransport.ResponseText + " Error code = 909";
                                        MessageBox.Show(message);
                                        browser.GetMainFrame().ExecuteJavaScriptAsync("pageRefresh();");
                                        return;
                                    }
                                    if (dataTransport.ResponseText.ToLower().Contains(@"noid://") == true)
                                    {
                                        // Match found, inform JavaScript that this is an returning patient for Identity.
                                        PatientBridge.PatientFHIRProfile.LocalNoID  = dataTransport.ResponseText;                                         //save the localNoID
                                        PatientBridge.PatientFHIRProfile.NoIDStatus = "Pending";
                                        browser.GetMainFrame().ExecuteJavaScriptAsync("showIdentity('" + PatientBridge.PatientFHIRProfile.LocalNoID + "');");
                                    }
                                    else if (dataTransport.ResponseText.ToLower() == "pending")
                                    {
                                        MessageBox.Show("You are already checked in.  If you believe this is an error, please contact staff");
                                        browser.GetMainFrame().ExecuteJavaScriptAsync("pageRefresh();");
                                        return;
                                    }
                                    else
                                    {
                                        if (PatientBridge.hasValidLeftFingerprint == true)
                                        {
                                            if (MatchLeftAndRight() == true)
                                            {
                                                MessageBox.Show("Both right and left capture sites are the same.  Please start over.");
                                                browser.GetMainFrame().ExecuteJavaScriptAsync("pageRefresh();");
                                                return;
                                            }
                                        }
                                        // Match not found, inform JavaScript the capture pair is complete and the patient can move to the next step.
                                        browser.GetMainFrame().ExecuteJavaScriptAsync("showComplete('" + Laterality.ToString() + "');");
                                        if (Laterality == FHIRUtilities.LateralitySnoMedCode.Left)
                                        {
                                            Laterality  = FHIRUtilities.LateralitySnoMedCode.Right;
                                            CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.IndexFinger;
                                            _firstMinutiaCaptureController        = _minutiaCaptureController;
                                            _minutiaCaptureController             = new MinutiaCaptureController(_minimumAcceptedMatchScore);
                                            PatientBridge.hasValidLeftFingerprint = true;
                                        }
                                        else if (Laterality == FHIRUtilities.LateralitySnoMedCode.Right)
                                        {
                                            Laterality  = FHIRUtilities.LateralitySnoMedCode.Unknown;
                                            CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.Unknown;
                                            PatientBridge.hasValidRightFingerprint = true;
                                        }
                                        fingerprintScanAttempts = 0;                                         //reset scan attempt count on successful scan
                                    }
                                }
                                else
                                {
                                    // Good fingerprint pairs not found yet.  inform JavaScript to promt the patient to try again.
                                    browser.GetMainFrame().ExecuteJavaScriptAsync("showFail('" + Laterality.ToString() + "');");
#if NAVIGATE
                                    DisplayOutput("Fingerprint NOT accepted. Score = " + _minutiaCaptureController.BestScore);
#endif
                                    currentCaptureInProcess = false;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            //int testy = CaptureSite.ToString().IndexOf("Thumb");
                            if (CaptureSite.ToString().IndexOf("Thumb") == -1)
                            {
                                browser.GetMainFrame().ExecuteJavaScriptAsync("alert('You have exceeded the maximum allowed scan attempts for your " + Laterality.ToString() + " " + CaptureSite + " Lets try another finger.');");
                            }
                            fingerprintScanAttempts = 0;                             //reset scan attempt count on successful scan
                            //get next laterality and capture site. Order of precedence is left, then right. Index, middle, ring, little, thumb
                            switch (Laterality.ToString() + CaptureSite.ToString())
                            {
                            case "LeftIndexFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectLeftMiddle');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.MiddleFinger;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Left;
                                break;

                            case "LeftMiddleFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectLeftRing');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.RingFinger;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Left;
                                break;

                            case "LeftRingFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectLeftLittle');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.LittleFinger;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Left;
                                break;

                            case "LeftLittleFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectLeftThumb');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.Thumb;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Left;
                                break;

                            case "LeftThumb":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("moveToRightHandScan();");
                                CaptureSite            = FHIRUtilities.CaptureSiteSnoMedCode.IndexFinger;
                                Laterality             = FHIRUtilities.LateralitySnoMedCode.Right;
                                hasLeftFingerprintScan = false;
                                break;

                            case "RightIndexFinger":
                                hasLeftFingerprintScan = _patientBridge.hasValidLeftFingerprint;
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectRightMiddle');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.MiddleFinger;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Right;
                                break;

                            case "RightMiddleFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectRightRing');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.RingFinger;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Right;
                                break;

                            case "RightRingFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectRightLittle');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.LittleFinger;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Right;
                                break;

                            case "RightLittleFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectRightThumb');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.Thumb;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Right;
                                break;

                            case "RightThumb":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                hasRightFingerprintScan   = false;
                                _minutiaCaptureController = null;
                                if (hasLeftFingerprintScan == false)
                                {
                                    _firstMinutiaCaptureController = null;
                                }
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.Unknown;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Unknown;
                                browser.GetMainFrame().ExecuteJavaScriptAsync("clickNoRightHandFingerPrint();");
                                break;

                            default:
                                break;
                            }
                            //define walk through fingers and ability to override
                        }
                    }
                    else
                    {
                        if (hasLeftFingerprintScan == true && hasRightFingerprintScan == true)
                        {
                            browser.GetMainFrame().ExecuteJavaScriptAsync("alert('You have successfully completed this step. Please proceed to the next page by clicking the NEXT button below');");
                        }
                        else
                        {
                            browser.GetMainFrame().ExecuteJavaScriptAsync("alert('Must be on the correct page to accept a fingerprint scan. Please follow the instructions on the screen.');");
                        }
#if NAVIGATE
                        DisplayOutput("Must be on the correct page to accept a fingerprint scan.");
#endif
                    }
                    currentCaptureInProcess = false;
                }
            }
            else
            {
                browser.GetMainFrame().ExecuteJavaScriptAsync("alert('Current Scan In Process. Please wait and follow the on screen instructions.');");
            }
        }
Esempio n. 23
0
        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);
        }
Esempio n. 24
0
        private CodeableConcept GetBodySite(FHIRUtilities.CaptureSiteSnoMedCode captureSite, FHIRUtilities.LateralitySnoMedCode laterality)
        {
            int             captureSiteCode = (int)captureSite;
            int             lateralityCode  = (int)laterality;
            CodeableConcept bodyCaptureSite = new CodeableConcept("SNOMED", captureSiteCode.ToString(), FHIRUtilities.CaptureSiteToString(captureSite));
            Extension       extLaterality   = new Extension(lateralityCode.ToString(), new FhirString(FHIRUtilities.LateralityToString(laterality)));

            bodyCaptureSite.AddExtension("Laterality", extLaterality);
            return(bodyCaptureSite);
        }