Exemple #1
0
        private void Add(ObservationTypeId observationTypeId)
        {
            try
            {
                using (WaitCursor wc = new WaitCursor())
                {
                    DataRow  dr       = GetPrevObservationRow(observationTypeId);
                    DateTime prevTime = dr != null ? (DateTime)dr["Time"] : patient.admissionDate;
                    DateTime dt       = App.DepartmentConfig.GetNextObservationTime(observationTypeId, patient.patientTypeId, prevTime, dr == null);

                    if (patient.dischargeDate != DateTime.MinValue && dt > patient.dischargeDate)
                    {
                        FormUtils.MessageExcl("Время наблюдения не должно быть позднее времени выписки.");
                        return;
                    }

                    Observation     observation = new Observation(observationTypeId);
                    HandbookGroupId hgId        = Observation.GetHandbookGroupId(observationTypeId);
                    if (dr != null)
                    {
                        observation.description = ObservationData.Create(dr["Description"] as string);
                    }
                    else
                    {
                        observation.description.Init(App.Config[hgId], patient.patientDescription);
                    }
                    observation.time      = dt;
                    observation.patientId = patient.Id;
                    observation.doctorId  = App.Instance.UserId;
                    ObservationForm form = new ObservationForm(observation, patientName);
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        DataRow newRow = dataTable.NewRow();
                        dataTable.Rows.Add(newRow);
                        UpdateRow(newRow, observation);
                        newRow["ObservationTypeId"]   = (int)observationTypeId;
                        newRow["ObservationTypeName"] = observationTypes[observationTypeId];
                        GridViewUtils.SetCurrentRow(gridView, newRow);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }