public Patient UploadAndDetectFaces(byte[] array) { try { Stream str = new MemoryStream(array); IEnumerable <FaceAttributeType> faceAttributes = new FaceAttributeType[] { FaceAttributeType.Gender, FaceAttributeType.Age, FaceAttributeType.Smile, FaceAttributeType.Glasses, FaceAttributeType.FacialHair }; Face[] faces = faceServiceClient.DetectAsync(str, false, false, faceAttributes).Result; var face = faces.FirstOrDefault(); var patient = new Patient() { Age = (int)face.FaceAttributes.Age, Gender = face.FaceAttributes.Gender.ToLowerInvariant() == "male" ? Gender.Male : Gender.Female }; return(patient); } catch { return(PatientGenerator.Create().FirstOrDefault()); } }
public static void SeedPatients(HospitalContext context, int count) { for (int i = 0; i < count; i++) { context.Patients.Add(PatientGenerator.NewPatient(context)); } context.SaveChanges(); }
private static void SeedPatients(HospitalContext context, int patientSeeds) { var patients = context.Patients.ToList(); for (int ps = 1; ps <= patientSeeds; ps++) { Patient patient = PatientGenerator.GeneratePatient(context); if (!patients.Any(p => p.CompareTo(patient) == 0)) { patients.Add(patient); } } context.Patients.AddRange(patients); context.SaveChanges(); }
public Patient Post(string data) { try { //string realBase = base64.Substring(base64.IndexOf(',') + 1); //realBase = realBase.Trim('\0'); //byte[] bytes = System.Convert.FromBase64String(base64); var base64Data = Regex.Match(data, @"data:image/(?<type>.+?),(?<data>.+)").Groups["data"].Value; var binData = Convert.FromBase64String(base64Data); var service = new FaceServiceHelper(); var info = service.UploadAndDetectFaces(binData); return(info); } catch (Exception e) { return(PatientGenerator.Create().FirstOrDefault()); } }
public GameObject SpawnPatient(Vector3 NewPatientLocation) { if (MyPatientGenerator == null) { MyPatientGenerator = GetComponent<PatientGenerator> (); } //Debug.Log ("Spawning patient at: " + Time.time); if (PatientPrefab != null) { Debug.LogError ("spawnin le patient!"); GameObject NewPatient = (GameObject) Instantiate(PatientPrefab, NewPatientLocation, Quaternion.identity); MyPatients.Add (NewPatient.GetComponent<Patient>()); if (MyPatientGenerator){ //MyPatientGenerator.UpdatePatientName(NewPatient); MyPatientGenerator.UpdatePatientWithStats(NewPatient); //MyPatientGenerator.UpdatePatientWithDescription(NewPatient); } return NewPatient; } Debug.LogError ("NO patient prefab... check patient manager!"); return null; }
public static void Main(string[] args) { s_logger.Info("PatientGenerator starting"); // If a number of patient to generate in a period of time are not specified, exit program. if (args.Length != 2) { // Display the proper way to call the program. Console.WriteLine("Usage: numberOfPatientsToGenerate periodOfTimeMilliSec"); return; } // Two events list, one used by the main thread and the other by the DB thread // Échange de données synchronisé par un n-tuple tampon (dans ce cas 2-tuplet) _hospitalEventDictionary.Add(ListType.FirstList, new List<HospitalEvent>()); _hospitalEventDictionary.Add(ListType.SecondList, new List<HospitalEvent>()); _elapsedTimeDictionary.Add(ListType.FirstList, 0); _elapsedTimeDictionary.Add(ListType.SecondList, 0); // Data base access thread var thread = new Thread(InsertEventsInDataBaseHandle); thread.Start(); long eventId = 0; try { var numberOfPatientsToGenerate = int.Parse(args[0]); var periodOfTimeMilliSec = long.Parse(args[1]); var generator = new PatientGenerator(); var stopWatch = new Stopwatch(); Console.WriteLine("Try to generate " + numberOfPatientsToGenerate + " patients in " + periodOfTimeMilliSec + " ms"); Console.WriteLine("Press ESC to stop"); while (!(Console.KeyAvailable && (Console.ReadKey(true).Key == ConsoleKey.Escape))) { _listToPopulateWithEvents = (_listToInsertInDataBase == ListType.FirstList) ? ListType.SecondList : ListType.FirstList; var hospitalEventList = _hospitalEventDictionary[_listToPopulateWithEvents]; var generatedPatientNb = 1; stopWatch.Restart(); // Generated arrival patients while ((stopWatch.ElapsedMilliseconds < periodOfTimeMilliSec) && (generatedPatientNb <= numberOfPatientsToGenerate)) { var patient = generator.GeneratePatientArrival(); hospitalEventList.Add(new HospitalEvent { EventId = eventId++, PatiendId = patient.PatientId, HospitalId = patient.HospitalId, EventType = HospitalEventType.PatientArrival, EventTime = patient.ArrivalTime, DiseaseType = patient.Disease.Id }); ++generatedPatientNb; } while ((stopWatch.ElapsedMilliseconds < periodOfTimeMilliSec) && ((generator.WaitingPatientCount > 0) || (generator.TakenInChargePatientCount > 0))) { // Generated taken in charge patients IPatientTakenInChargeByDoctor patientTakenInCharge; while ((stopWatch.ElapsedMilliseconds < periodOfTimeMilliSec) && ((patientTakenInCharge = generator.GeneratePatientTakenInChargeByDoctor(periodOfTimeMilliSec - stopWatch.ElapsedMilliseconds)) != null)) { hospitalEventList.Add(new HospitalEvent { EventId = eventId++, PatiendId = patientTakenInCharge.PatientId, HospitalId = patientTakenInCharge.HospitalId, EventType = HospitalEventType.PatientTakenInChargeByDoctor, EventTime = patientTakenInCharge.TakenInChargeByDoctorTime, DiseaseType = patientTakenInCharge.Disease.Id, DoctorId = patientTakenInCharge.DoctorId }); } // Generated leaving patients IPatientLeaving patientLeaving; while ((stopWatch.ElapsedMilliseconds < periodOfTimeMilliSec) && ((patientLeaving = generator.GeneratePatientLeaving(periodOfTimeMilliSec - stopWatch.ElapsedMilliseconds)) != null)) { hospitalEventList.Add(new HospitalEvent { EventId = eventId++, PatiendId = patientLeaving.PatientId, HospitalId = patientLeaving.HospitalId, EventType = HospitalEventType.PatientLeaving, EventTime = patientLeaving.LeavingTime }); } } // Raised the insert event allowing the data base thread to proceed _syncEvent.WaitOne(); _listToInsertInDataBase = (_listToPopulateWithEvents == ListType.FirstList) ? ListType.FirstList : ListType.SecondList; _elapsedTimeDictionary[_listToInsertInDataBase] = stopWatch.ElapsedMilliseconds; _insertEvent.Set(); // Sleep the remaining time Thread.Sleep((stopWatch.ElapsedMilliseconds < periodOfTimeMilliSec) ? (int) (periodOfTimeMilliSec - stopWatch.ElapsedMilliseconds) : 0); stopWatch.Stop(); } } catch (Exception ex) { s_logger.Error("ERROR: {0}", ex); } thread.Abort(); thread.Join(); }
// Use this for initialization void Start() { TimeSinceSpawned = Time.time; MyPatientGenerator = GetComponent<PatientGenerator> (); }
public IActionResult Index() { return(View(PatientGenerator.Create())); }