Esempio n. 1
0
        internal void AddPatientSmokingDrinkingStatus(Patient patient, PatientSmokingDrinkingStatus patientSmokingDrinkingStatus)
        {
            if (patientSmokingDrinkingStatus.SmokingStatusId == 0)
            {
                return;
            }
            var smokingStatus = new PatientSmokingDrinkingStatus();

            smokingStatus.PatientId = patient.ID;
            patientSmokingDrinkingStatus.PatientId = patient.ID;
            smokingStatus.AlcolholUnits            = patientSmokingDrinkingStatus.AlcolholUnits;
            smokingStatus.CigarettesPerDay         = patientSmokingDrinkingStatus.CigarettesPerDay;
            smokingStatus.PacksPerYear             = patientSmokingDrinkingStatus.PacksPerYear;
            smokingStatus.PatientId              = patientSmokingDrinkingStatus.PatientId;
            smokingStatus.StartAge               = patientSmokingDrinkingStatus.StartAge;
            smokingStatus.StopAge                = patientSmokingDrinkingStatus.StopAge;
            smokingStatus.SmokingStatusId        = patientSmokingDrinkingStatus.SmokingStatusId;
            patient.PatientSmokingDrinkingStatus = smokingStatus;
            if (patientSmokingDrinkingStatus.ID == 0)
            {
                _context.PatientSmokingDrinkingStatus.Add(smokingStatus);
            }
            else
            {
                _context.Update(patientSmokingDrinkingStatus);
            }
        }
Esempio n. 2
0
 public SmokingStatusResolver(AspergillosisContext context,
                              string smokingStatus, IRow row, List <string> headers)
 {
     _context               = context;
     _smokingStatus         = smokingStatus;
     _row                   = row;
     _headers               = headers;
     _smokingDrinkingStatus = new PatientSmokingDrinkingStatus();
 }
Esempio n. 3
0
 private void AddOrSkipSmokingStatus(Patient patient, PatientSmokingDrinkingStatus patientSmokingDrinkingStatus)
 {
     if (patientSmokingDrinkingStatus.SmokingStatusId == 0)
     {
         ModelState.Remove("SmokingStatusId");
     }
     else
     {
         _patientManager.AddPatientSmokingDrinkingStatus(patient, patientSmokingDrinkingStatus);
     }
 }
Esempio n. 4
0
 private void AddSmokingStatusIfExists()
 {
     _context.Entry(_patient).Reference(p => p.PatientSmokingDrinkingStatus).Load();
     if (_patient.PatientSmokingDrinkingStatus != null)
     {
         return;
     }
     if (new Regex(@"ex-smoker", RegexOptions.IgnoreCase).IsMatch(_potentialDiagnosis))
     {
         var smokingStatus = new PatientSmokingDrinkingStatus();
         smokingStatus.SmokingStatus = _exSmoker;
         smokingStatus.PatientId     = _patient.ID;
         _context.PatientSmokingDrinkingStatus.Add(smokingStatus);
         return;
     }
     if (new Regex(@"smoker", RegexOptions.IgnoreCase).IsMatch(_potentialDiagnosis))
     {
         var smokingStatus = new PatientSmokingDrinkingStatus();
         smokingStatus.SmokingStatus = _currentSmoker;
         smokingStatus.PatientId     = _patient.ID;
         _context.PatientSmokingDrinkingStatus.Add(smokingStatus);
     }
 }
        public IActionResult Edit(int patientId)
        {
            var patient = _context.Patients
                          .Where(p => p.ID == patientId)
                          .Include(p => p.PatientSmokingDrinkingStatus)
                          .FirstOrDefault();
            PatientSmokingDrinkingStatus smokingStatus;

            smokingStatus = patient.PatientSmokingDrinkingStatus;

            if (smokingStatus == null)
            {
                smokingStatus = new PatientSmokingDrinkingStatus()
                {
                    PatientId = patient.ID
                };
                ViewBag.SmokingStatusId = _listResolver.PopulateSmokingStatusesDropdownList();
            }
            else
            {
                ViewBag.SmokingStatusId = _listResolver.PopulateSmokingStatusesDropdownList(smokingStatus.SmokingStatusId);
            }
            return(PartialView("~/Views/Patients/SmokingStatuses/_Edit.cshtml", smokingStatus));
        }
Esempio n. 6
0
        public IActionResult Create([Bind("LastName,FirstName,DOB,Gender, RM2Number, PatientStatusId, DateOfDeath, PostCode, GenericNote")]
                                    Patient patient,
                                    PatientDiagnosis[] diagnoses,
                                    PatientDrug[] drugs,
                                    PatientSTGQuestionnaire[] sTGQuestionnaires,
                                    PatientImmunoglobulin[] patientImmunoglobulin,
                                    PatientRadiologyFinding[] patientRadiologyFinding,
                                    PatientMedicalTrial[] patientMedicalTrial,
                                    PatientDrugLevel[] drugLevels,
                                    PatientSurgery[] surgeries,
                                    PatientAllergicIntoleranceItem[] allergies,
                                    PatientPulmonaryFunctionTest[] patientPulmonaryFunctionTest,
                                    PatientNACDates patientNACDates,
                                    PatientMeasurement[] patientMeasurement,
                                    PatientMRCScore[] patientMRCScore,
                                    CaseReportFormResult[] caseReportFormResult,
                                    PatientSmokingDrinkingStatus patientSmokingDrinkingStatus)
        {
            var existingPatient = _context.Patients.FirstOrDefault(x => x.RM2Number == patient.RM2Number);

            patient.CaseReportFormResults = new List <CaseReportFormResult>();
            _patientManager.Request       = Request;
            CheckIsUnique(existingPatient);
            if (caseReportFormResult != null && caseReportFormResult.Length > 0 && caseReportFormResult[0].Results != null)
            {
                var results = caseReportFormResult[0].Results.ToArray();
                _caseReportFormManager.CreateCaseReportFormForResults(patient, results);
                patient.CaseReportFormResults.Add(caseReportFormResult[0]);
                _caseReportFormManager.LockForm(caseReportFormResult[0].CaseReportFormId);
            }

            _patientManager.AddCollectionsFromFormToPatients(patient,
                                                             ref diagnoses,
                                                             ref drugs,
                                                             ref sTGQuestionnaires,
                                                             patientImmunoglobulin,
                                                             ref patientRadiologyFinding);
            _patientManager.AddMedicalTrials(patient, patientMedicalTrial);
            _patientManager.AddDrugLevels(patient, drugLevels);
            _patientManager.AddPatientSurgeries(patient, surgeries);
            _patientManager.AddPatientAllergiesIntolerances(patient, allergies);
            _patientManager.AddPatientPFTs(patient, patientPulmonaryFunctionTest);
            _patientManager.AddPatientMeasurements(patient, patientMeasurement);
            _patientManager.AddMRCScores(patient, patientMRCScore);
            _patientManager.AddPatientNACDates(patient, patientNACDates);
            AddOrSkipSmokingStatus(patient, patientSmokingDrinkingStatus);
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(patient);
                    _context.SaveChanges();
                    _externalImport.Add(ExternalPatient.BuildFromPatient(patient));
                    var externalPatient = new ExternalPatient();
                    _externalImport.SaveChanges();
                    return(Json(new { result = "ok" }));
                }
                else
                {
                    Hashtable errors = ModelStateHelper.Errors(ModelState);
                    return(Json(new { success = false, errors }));
                }
            }
            catch (DbUpdateException ex)
            {
                return(null);
            }
        }
Esempio n. 7
0
        public async Task <IActionResult> EditPatient(int?id, [Bind("ID,DiagnosisCategoryId,DiagnosisTypeId,Description")] PatientDiagnosis[] diagnoses,
                                                      [Bind("ID,DrugId,StartDate,EndDate")] PatientDrug[] drugs,
                                                      [Bind("ID, ActivityScore, SymptomScore, ImpactScore, TotalScore")] PatientSTGQuestionnaire[] sTGQuestionnaires,
                                                      [Bind("ID, DateTaken, Value, ImmunoglobulinTypeId")] PatientImmunoglobulin[] patientImmunoglobulines,
                                                      [Bind("ID, DateTaken, FindingId, RadiologyTypeId, ChestLocationId, ChestDistributionId, GradeId, TreatmentResponseId, Note")] PatientRadiologyFinding[] radiololgyFindings,
                                                      [Bind("ID, PatientId, MedicalTrialId, PatientMedicalTrialStatusId, IdentifiedDate, ConsentedDate, RecruitedDate, Consented")] PatientMedicalTrial[] patientMedicalTrial,
                                                      [Bind("ID, PatientId, DrugId, UnitOfMeasurementId, DateTaken, DateReceived, ResultValue, ComparisionCharacter")] PatientDrugLevel[] drugLevels,
                                                      [Bind("ID, SurgeryId, PatientId, SurgeryDate, Note")] PatientSurgery[] surgeries,
                                                      [Bind("ID, AllergyIntoleranceItemType, AllergyIntoleranceItemId, IntoleranceType, Severity, Note")] PatientAllergicIntoleranceItem[] allergies,
                                                      [Bind("ID, PulmonaryFunctionTestId, Value, ResultValue, PatientId")] PatientPulmonaryFunctionTest[] pulmonaryFunctionTest,
                                                      [Bind("ID, FirstSeenAtNAC, CPABand, ReferralDate, LastObservationPoint, InitialDrug, FollowUp3MonthsDrug, PatientId")] PatientNACDates patientNACDates,
                                                      [Bind("ID, DateTaken, Weight, Height")] PatientMeasurement[] patientMeasurements,
                                                      [Bind("ID, DateTaken, Score")] PatientMRCScore[] patientMRCScores,
                                                      [Bind("ID, SmokingStatusId, PatientId, StartAge, StopAge, CigarettesPerDay, PacksPerYear, AlcolholUnits")] PatientSmokingDrinkingStatus patientSmokingDrinkingStatus,
                                                      CaseReportFormResult[] caseReportFormResult)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Patient patientToUpdate = await _patientManager
                                      .FindPatientWithFirstLevelRelationsByIdAsync(id);

            _patientManager.UpdateDiagnoses(diagnoses, patientToUpdate);
            _patientManager.UpdateDrugs(drugs, patientToUpdate, Request);
            _patientManager.UpdateSGRQ(sTGQuestionnaires, patientToUpdate);
            _patientManager.UpdateImmunoglobines(patientImmunoglobulines, patientToUpdate);
            _patientManager.UpdatePatientRadiology(radiololgyFindings, patientToUpdate);
            _patientManager.UpdatePatientMedicalTrials(patientMedicalTrial, patientToUpdate);
            _patientManager.UpdatePatientDrugLevels(drugLevels, patientToUpdate);
            _patientManager.UpdatePatientSurgeries(surgeries, patientToUpdate);
            _patientManager.UpdatePatientAllergiesIntolerances(allergies, patientToUpdate, Request);
            _patientManager.UpdatePatientsPFTs(pulmonaryFunctionTest, patientToUpdate);
            _patientManager.UpdateNacDates(patientNACDates, patientToUpdate);
            _patientManager.UpdateWeightHeight(patientMeasurements, patientToUpdate);
            _patientManager.UpdateMRCScore(patientMRCScores, patientToUpdate);
            AddOrSkipSmokingStatus(patientToUpdate, patientSmokingDrinkingStatus);
            _caseReportFormManager.UpdateCaseReportFormsForPatient(caseReportFormResult, patientToUpdate);



            _context.Entry(patientToUpdate).State = EntityState.Modified;
            ModelState.Remove("FirstSeenAtNAC"); //TODO - FIX THIS HACK..
            if (await TryUpdateModelAsync <Patient>(patientToUpdate,
                                                    "",
                                                    p => p.FirstName, p => p.LastName, p => p.DOB, p => p.RM2Number, p => p.PostCode,
                                                    p => p.Gender, p => p.PatientStatusId, p => p.DateOfDeath, p => p.GenericNote))
            {
                try
                {
                    _context.SaveChanges();
                }
                catch (DbUpdateException ex)
                {
                    var message = ex.Message;
                    ModelState.AddModelError("", "Unable to save changes. " +
                                             "Try again, and if the problem persists, " +
                                             "see your system administrator.");
                }
            }
            else
            {
                Hashtable errors = ModelStateHelper.Errors(ModelState);
                return(Json(new { success = false, errors }));
            }

            return(Json(new { result = "ok" }));
        }