Esempio n. 1
0
        //public PatientLabTestResults()
        //{
        //    this.InitializeComponent();
        //}

        public PatientLabTestResults(PatientLabTests labTest)
        {
            this.InitializeComponent();

            //this.code_TextBlock.Text = labTest.Code;
            //this.name_TextBlock.Text = labTest.Name;
            //this.result_TextBox.Text = labTest.Result;
        }
Esempio n. 2
0
        public void ArchiveLabTest(int patientLabTestId, string reason, User user)
        {
            var patientLabTest = PatientLabTests.SingleOrDefault(t => t.Id == patientLabTestId);

            if (patientLabTest == null)
            {
                throw new KeyNotFoundException($"Unable to locate lab test {patientLabTestId} for patient {Id}");
            }

            patientLabTest.Archive(user, reason);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the patient lab tests.
        /// </summary>
        /// <param name="ssn">The SSN.</param>
        /// <returns></returns>
        public async Task <List <PatientLabTests> > GetPatientLabTests(string ssn)
        {
            //TODO MAKE ME ASYNC
            var labtests = new List <PatientLabTests>();

            using (MySqlConnection conn = DbConnection.GetConnection())
            {
                //Open the connection
                await conn.OpenAsync();

                string query = "select o.`id`, `order_date`, `due_date`, `code`, `name`, `result` from `ordered_test` as o, `ordered_test_components` as oc, `patient` as p where p.`ssn`=@ssn and `patientID`=p.`id` and oc.`orderID`=o.`id`";
                using (MySqlCommand comm = new MySqlCommand(query, conn))
                {
                    comm.Parameters.Add("@ssn", (DbType)MySqlDbType.String).Value = ssn;

                    using (var reader = await comm.ExecuteReaderAsync())
                    {
                        int idOrdinal        = reader.GetOrdinal("id");
                        int orderDateOrdinal = reader.GetOrdinal("order_date");
                        int dueDateOrdinal   = reader.GetOrdinal("due_date");
                        int codeOrdinal      = reader.GetOrdinal("code");
                        int nameOrdinal      = reader.GetOrdinal("name");
                        int resultOrdinal    = reader.GetOrdinal("result");

                        while (await reader.ReadAsync())
                        {
                            var id        = !reader.IsDBNull(idOrdinal) ? reader.GetInt32(idOrdinal) : 1;
                            var orderDate = !reader.IsDBNull(orderDateOrdinal) ? reader.GetDateTime(orderDateOrdinal) : new DateTime();
                            var dueDate   = !reader.IsDBNull(dueDateOrdinal) ? reader.GetDateTime(dueDateOrdinal) : new DateTime();
                            var code      = !reader.IsDBNull(codeOrdinal) ? reader.GetString(codeOrdinal) : string.Empty;
                            var name      = !reader.IsDBNull(nameOrdinal) ? reader.GetString(nameOrdinal) : string.Empty;
                            var result    = !reader.IsDBNull(resultOrdinal) ? reader.GetString(resultOrdinal) : string.Empty;

                            var labTest = new PatientLabTests
                            {
                                OrderId    = id,
                                Order_Date = orderDate,
                                Due_Date   = dueDate,
                                Code       = code,
                                Name       = name,
                                Result     = result
                            };

                            labtests.Add(labTest);
                        }
                    }
                }
                conn.Close();
            }
            return(labtests);
        }
Esempio n. 4
0
        public PatientLabTest AddLabTest(DateTime testDate, string testResult, LabTest labTest, LabTestUnit testUnit, string labValue, string referenceLower, string referenceUpper)
        {
            if (DateOfBirth.HasValue)
            {
                if (testDate.Date < DateOfBirth.Value.Date)
                {
                    throw new DomainException("Test Date should be after patient Date Of Birth");
                }
            }

            var newPatientLabTest = new PatientLabTest(testDate, testResult, labTest, testUnit, labValue, referenceLower, referenceUpper, labTest.Description);

            PatientLabTests.Add(newPatientLabTest);
            return(newPatientLabTest);
        }
Esempio n. 5
0
        public void ChangeLabTestDetails(int patientLabTestId, DateTime testDate, string testResult, LabTestUnit testUnit, string labValue, string referenceLower, string referenceUpper)
        {
            var patientLabTest = PatientLabTests.SingleOrDefault(t => t.Id == patientLabTestId);

            if (patientLabTest == null)
            {
                throw new KeyNotFoundException($"Unable to locate lab test {patientLabTestId} on patient {Id}");
            }

            if (DateOfBirth.HasValue)
            {
                if (testDate.Date < DateOfBirth.Value.Date)
                {
                    throw new DomainException("Test Date should be after patient Date Of Birth");
                }
            }

            patientLabTest.ChangeDetails(testDate, testResult, testUnit, labValue, referenceLower, referenceUpper);
        }
Esempio n. 6
0
        public bool HasClinicalData()
        {
            var hasData = false;

            if (PatientClinicalEvents.Count() > 0 || PatientConditions.Count() > 0 || PatientLabTests.Count() > 0 || PatientMedications.Count() > 0 || Encounters.Count() > 0)
            {
                hasData = true;
            }
            ;

            return(hasData);
        }