public OutcomeAt28DaysSplitter(OutcomeAt28DaysOption outcome) { _outcomeAt28Days = outcome; switch (_outcomeAt28Days) { case OutcomeAt28DaysOption.DischargedAndLikelyToHaveDied: _postDischargeOutcomeKnown = false; _diedAfterDischarge = true; break; case OutcomeAt28DaysOption.DischargedAndKnownToHaveDied: _postDischargeOutcomeKnown = true; _diedAfterDischarge = true; break; case OutcomeAt28DaysOption.DischargedAndLikelyToHaveSurvived: _postDischargeOutcomeKnown = false; _diedAfterDischarge = false; break; case OutcomeAt28DaysOption.DischargedAndKnownToHaveSurvived: _postDischargeOutcomeKnown = true; _diedAfterDischarge = false; break; } }
void SetOutcomeAt28Days() { if (_outcomeAt28Days < OutcomeAt28DaysOption.DischargedBefore28Days) { return; } else if (_diedAfterDischarge.HasValue && _postDischargeOutcomeKnown.HasValue) { if (_diedAfterDischarge.Value) { if (_postDischargeOutcomeKnown.Value) { _outcomeAt28Days = OutcomeAt28DaysOption.DischargedAndKnownToHaveDied; } else { _outcomeAt28Days = OutcomeAt28DaysOption.DischargedAndLikelyToHaveDied; } } else // Survived { if (_postDischargeOutcomeKnown.Value) { _outcomeAt28Days = OutcomeAt28DaysOption.DischargedAndKnownToHaveSurvived; } else { _outcomeAt28Days = OutcomeAt28DaysOption.DischargedAndLikelyToHaveSurvived; } } } else { _outcomeAt28Days = OutcomeAt28DaysOption.DischargedBefore28Days; } }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="causeOfDeath"></param> /// <param name="otherCauseOfDeathDetail"></param> /// <param name="bcgAdverse"></param> /// <param name="bcgAdverseDetail"></param> /// <param name="bcgPapuleAtDischarge"></param> /// <param name="lastContactWeight"></param> /// <param name="lastWeightDate"></param> /// <param name="dischargeDateTime"></param> /// <param name="deathOrLastContactDateTime"></param> /// <param name="outcomeAt28Days"></param> /// <param name="notes"></param> /// <param name="participantVaccines">if null (or ommitted) the vaccines administered will not be altered</param> public void UpdateParticipant(int id, CauseOfDeathOption causeOfDeath, string otherCauseOfDeathDetail, bool?bcgAdverse, string bcgAdverseDetail, bool?bcgPapuleAtDischarge, bool?bcgPauleAt28days, int?lastContactWeight, DateTime?lastWeightDate, DateTime?dischargeDateTime, DateTime?deathOrLastContactDateTime, OutcomeAt28DaysOption outcomeAt28Days, MaternalBCGScarStatus maternalBCGScar, FollowUpBabyBCGReactionStatus followUpBabyBCGReaction, DateTime?followUpContactMade, bool permanentlyUncontactable, string notes, IEnumerable <VaccineAdministered> participantVaccines = null, IEnumerable <UnsuccessfulFollowUp> unsuccesfulFollowUps = null) { Participant participant = _dbContext.Participants.Find(id); participant.CauseOfDeath = causeOfDeath; participant.OtherCauseOfDeathDetail = otherCauseOfDeathDetail; participant.BcgAdverse = bcgAdverse; participant.BcgAdverseDetail = bcgAdverseDetail; participant.BcgPapuleAtDischarge = bcgPapuleAtDischarge; participant.BcgPapuleAt28days = bcgPauleAt28days; participant.LastContactWeight = lastContactWeight; participant.LastWeightDate = lastWeightDate; participant.DischargeDateTime = dischargeDateTime; participant.DeathOrLastContactDateTime = deathOrLastContactDateTime; participant.OutcomeAt28Days = outcomeAt28Days; participant.RecordLastModified = DateTime.UtcNow; participant.MaternalBCGScar = maternalBCGScar; participant.FollowUpBabyBCGReaction = followUpBabyBCGReaction; participant.FollowUpContactMade = followUpContactMade; participant.PermanentlyUncontactable = permanentlyUncontactable; participant.Notes = notes; ((DbContext)_dbContext).AttachAndMarkModified(participant); if (participantVaccines != null) { AddOrUpdateVaccinesAdministered(participant.Id, participantVaccines); } if (unsuccesfulFollowUps != null) { AddOrUpdateUnsuccessfulFollowUps(participant.Id, unsuccesfulFollowUps); } _dbContext.SaveChanges(true); if (this.ParticipantUpdated != null) { if (participant.VaccinesAdministered == null) { participant.VaccinesAdministered = _dbContext.VaccinesAdministered.Where(v => v.ParticipantId == participant.Id).ToList(); } else { foreach (var v in participant.VaccinesAdministered) { if (v.VaccineGiven == null) { v.VaccineGiven = _dbContext.Vaccines.Find(v.VaccineId); } } } if (participant.UnsuccessfulFollowUps == null) { participant.UnsuccessfulFollowUps = _dbContext.UnsuccessfulFollowUps.Where(u => u.ParticipantId == participant.Id).ToList(); } this.ParticipantUpdated(this, new ParticipantEventArgs(participant)); } }