private Models.PatientModel FormatStringToPatientObject(string[] patientDetails)
 {
     Models.PatientModel patient = new Models.PatientModel()
     {
         PatientId = patientDetails[0],
         Name      = patientDetails[1],
         Age       = Int32.Parse(patientDetails[2]),
         IcuId     = patientDetails[3],
         BedId     = patientDetails[4],
         Address   = patientDetails[5],
         Gender    = patientDetails[6],
         ContactNo = patientDetails[7]
     };
     return(patient);
 }
Exemple #2
0
        public bool CanPatientBeAdded(Models.PatientModel newPatient, out string msg)
        {
            if (_patientDataHandler.ReadPatients(_patientDataCsvPath).Find(patient => patient.PatientId == newPatient.PatientId) != null)
            {
                msg = "Patient Already Exists";
                return(false);
            }
            string message;

            if (IsBedAvailable(newPatient.IcuId, newPatient.BedId, out message))    // add vitals validation
            {
                msg = "Patient can be Added";
                return(true);
            }
            msg = message;
            return(false);
        }
 public IActionResult Post([FromBody] Models.PatientModel newPatient)
 {
     try
     {
         var msg = _patientRepository.AddPatient(newPatient);
         if (msg)
         {
             return(Json("Patient added to the bed"));
         }
         else
         {
             return(Json("Patient couldnot be added"));
         }
     }
     catch (Exception)
     {
         return(StatusCode(500, "unable to insert new Patient"));
     }
 }
        private string FormatPatientObjectToString(Models.PatientModel patient)
        {
            var csvFormatData = "";

            if (patient.PatientId != null)
            {
                csvFormatData = string.Join(',', new object[] {
                    patient.PatientId,
                    patient.Name,
                    patient.Age.ToString(),
                    patient.IcuId.ToString(),
                    patient.BedId.ToString(),
                    patient.Address,
                    patient.Gender,
                    patient.ContactNo
                });
            }
            return(csvFormatData);
        }
Exemple #5
0
        private string DeriveSampleNo(Models.PatientModel patient)
        {
            var tempSampleId = patient.Fullname;
            var yy           = DateTime.Today.Year.ToString("yy");
            var yyyy         = DateTime.Today.Year.ToString("yyyy");

            return(tempSampleId
                   .Replace($"US/{20}", "")
                   .Replace($"us/{20}", "")
                   .Replace($"Us/{20}", "")
                   .Replace($"uS/{20}", "")
                   .Replace(" ", "")
                   .Replace("/", "")
                   .Replace("(", "")
                   .Replace(")", "")
                   .Replace("-", "")
                   .Replace("_", "")
                   .Replace("\\", "")
                   .Trim());
        }
        public bool AddPatient(Models.PatientModel newPatient)
        {
            bool   isAdded = false;
            string message = "";

            try
            {
                if (_helpers.CanPatientBeAdded(newPatient, out message))
                {
                    isAdded = _patientDataHandler.WritePatient(newPatient, _csvFilePath);
                    _helpers.ChangeBedStatusToOccupied(newPatient.BedId);
                }
            }
            catch (Exception e)
            {
                isAdded = false;
                Console.WriteLine(message);
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
            return(isAdded);
        }
        public bool WritePatient(Models.PatientModel patient, string filepath)
        {
            string patientDetails = FormatPatientObjectToString(patient);

            return(_csvHandler.WriteToFile(patientDetails, filepath));
        }