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();
 }