public PatientCondition AddOrUpdatePatientCondition(long id, TerminologyMedDra sourceTerm, DateTime onsetDate, DateTime?outComeDate, Outcome outcome, TreatmentOutcome treatmentOutcome, string caseNumber, string comments, string conditionSource, PatientStatus deceasedStatus) { PatientCondition patientCondition = null; if (id == 0) { patientCondition = new PatientCondition { ConditionSource = conditionSource, TerminologyMedDra = sourceTerm, OnsetDate = onsetDate, OutcomeDate = outComeDate, Outcome = outcome, TreatmentOutcome = treatmentOutcome, CaseNumber = caseNumber, Comments = comments }; PatientConditions.Add(patientCondition); } // Has person died if (outcome?.Description == "Fatal" && GetCurrentStatus()?.PatientStatus.Description != "Died") { // set patient status to deceased in patient history PatientStatusHistories.Add(new PatientStatusHistory() { EffectiveDate = outComeDate ?? DateTime.Now, //set effective date to outcome date have set it to use todays day if null but this will not happen as autosetToDeceased will only become true when an end date is supplied first Comments = $"Marked as deceased through Patient Condition ({sourceTerm.DisplayName})", PatientStatus = deceasedStatus }); } return(patientCondition); }
public PatientCondition GetConditionForEncounter(Encounter encounter) { PatientCondition tempCondition = encounter.Patient.PatientConditions.OrderByDescending(pc => pc.DateStart).Where(pc => TerminologyMedDra.Id == pc.TerminologyMedDra.Id && ((pc.OutcomeDate == null && pc.DateStart <= encounter.EncounterDate) || (pc.OutcomeDate >= encounter.EncounterDate && pc.DateStart <= encounter.EncounterDate))).FirstOrDefault(); return(tempCondition); }
public PatientCondition GetConditionForPatient(Patient patient) { PatientCondition tempCondition = patient.PatientConditions.OrderByDescending(pc => pc.DateStart).Where(pc => TerminologyMedDra.Id == pc.TerminologyMedDra.Id && pc.OutcomeDate == null).FirstOrDefault(); return(tempCondition); }