示例#1
0
 public CreateExamination(DoctorHome DoctorHome)
 {
     InitializeComponent();
     this.DataContext  = this;
     this.DoctorHome   = DoctorHome;
     RoomController    = new Controller.RoomController();
     patientController = new Controller.PatientController();
     LoadPatients();
 }
        public void Load()
        {
            Controller.PatientController PatientController   = new Controller.PatientController();
            Model.Examination            selectedExamination = (Model.Examination)dh.lvDataBinding.SelectedItems[0];
            Model.Patient selectedPatient = PatientController.GetOnePatient(selectedExamination.patient.User.Username);
            lbAddressPatient.Content     = selectedPatient.User.Address;
            lbuUsernamePatient.Content   = selectedPatient.User.Username;
            lbuJMBG.Content              = selectedPatient.User.Jmbg;
            lbNamePatient.Content        = selectedPatient.User.Name;
            lbGender.Content             = selectedPatient.User.Gender;
            lbDateOfBirthPatient.Content = selectedPatient.User.DateOfBirth;
            lbSurnamePatient.Content     = selectedPatient.User.Surname;
            lbNumberPatient.Content      = selectedPatient.User.PhoneNumber;


            List <Model.Anamnesis> anamneses = anamControl.GetAllAnamnesisPatient(selectedPatient.User.Username);

            lvDataBinding.Items.Clear();
            foreach (Model.Anamnesis an in anamneses)
            {
                lvDataBinding.Items.Add(an);
                Console.WriteLine(an.DescriptionAnamnesis);
            }
        }
        private DataView GetBreastQReport(string surveyGroup, string subType)
        {
            // validate type map
            if (!typesToSurveys.ContainsKey(surveyGroup))
            {
                return(new DataTable().DefaultView);
            }
            IEnumerable <string> surveyTypes = typesToSurveys[surveyGroup];

            Caisis.Controller.PatientController pc = new Controller.PatientController();
            string datasetSQL            = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]);
            CaisisBreastQEngine engine   = new CaisisBreastQEngine();
            SurveyDa            surveyDA = new SurveyDa();
            List <Dictionary <string, string> > allScores = new List <Dictionary <string, string> >();
            var aliasMap = GetAliasToSurveys();

            foreach (string surveyType in surveyTypes)
            {
                var      survey    = engine.GetSurveyDefinition(surveyType);
                var      scales    = survey.Definitions;
                string[] questions = scales.SelectMany(s => s.Questions).Distinct().ToArray();

                string[] _surveyTypes = new string[] { surveyType };
                // special case
                if (aliasMap.ContainsKey(surveyType))
                {
                    _surveyTypes = aliasMap[surveyType].ToArray();
                }
                foreach (string _surveyType in _surveyTypes)
                {
                    // optional filter by exact survey
                    if (string.IsNullOrEmpty(subType) || subType.Equals(_surveyType, StringComparison.OrdinalIgnoreCase))
                    {
                        string engineSurveyType = surveyType;
                        // TODO: refactor into generic class to read and fill scores data table
                        // read pivotted row (patient+survey+questions), and score
                        surveyDA.ConsumeBreastQSurveyData(datasetSQL, _surveyType, questions, (record) =>
                        {
                            // get responses, 1a=>2, 1b=>2, ...
                            Dictionary <string, string> responses = questions.ToDictionary(q => q, q => record[q].ToString());
                            // get scores by scale, Satisfaction With Breasts => 56, ...
                            Dictionary <string, BreastQ.BreastQScaleScore> scores = engine.GetSurveyScoreByScale(engineSurveyType, responses);
                            // create column values
                            Dictionary <string, string> values = new Dictionary <string, string>();
                            // add required columns
                            values.Add("MRN", pc.GetPatientMRN(record["PtMRN"].ToString()));
                            values.Add("Survey", _surveyType);
                            values.Add("Date", string.Format("{0:d}", record["SurveyDate"]));
                            // fill in scale scores
                            foreach (var score in scores)
                            {
                                string scaleName  = score.Key;
                                string scaleValue = "";
                                // valida score
                                if (score.Value.Error == QScoreLibrary.Estimation.eErrors.eNoError)
                                {
                                    scaleValue = score.Value.Score.ToString();
                                }
                                // error in scoring
                                else
                                {
                                    scaleValue = "FAIL: " + engine.GetQScoreErrorString(score.Value.Error);
                                }

                                //values.Add(score.Key, score.Value.Score.ToString());
                                values.Add(scaleName, scaleValue);
                            }

                            // add row
                            allScores.Add(values);

                            // continue
                            return(true);
                        });
                    }
                }
            }

            // get a list of columns across patients (i.e., PtMRN, Date, Scale 1, Scale 3, Scale 7)
            string[] columns        = allScores.SelectMany(s => s.Keys).Distinct().ToArray();
            string[] patientColumns = new string[] { "MRN", "Survey", "Date" };
            string[] scaleColumns   = columns.Except(patientColumns).ToArray();
            // normalize datasource
            DataTable dataSource = new DataTable();

            dataSource.Columns.AddRange(columns.Select(c => new DataColumn(c, typeof(String))).ToArray());
            // for each row, normalize values
            foreach (var row in allScores)
            {
                object[] values = new object[columns.Length];
                for (int i = 0; i < columns.Length; i++)
                {
                    string column = columns[i];
                    // add patient columns
                    if (patientColumns.Contains(column))
                    {
                        values[i] = row[column];
                    }
                    else if (scaleColumns.Contains(column))
                    {
                        // applicable scale
                        if (row.ContainsKey(column))
                        {
                            values[i] = row[column];
                        }
                        // non-applicable scale
                        else
                        {
                            values[i] = "N/A";
                        }
                    }
                }
                dataSource.Rows.Add(values);
            }

            return(dataSource.DefaultView);
        }