/// <summary> /// If the visit does not have a SocialHistory, then it returns a newly created SocialHistory, /// else, it returns an existing one from the visit. /// </summary> /// <param name="visit">The visit.</param> /// <returns>A SocialHistory.</returns> public SocialHistory CreateSocialHistory(Visit visit) { Check.IsNotNull(visit, "visit is required."); //NOTE : There can be only one 'Social History' per visit. SocialHistory socialHistory; var existingSocialHistory = _socialHistoryRepository.GetSocialHistoryInVisit(visit.Key); if (existingSocialHistory != null) { socialHistory = existingSocialHistory; } else { var type = _lookupValueRepository.GetLookupByWellKnownName <ActivityType> (WellKnownNames.VisitModule.ActivityType.SocialHistory); socialHistory = new SocialHistory(visit, type); _socialHistoryRepository.MakePersistent(socialHistory); } return(socialHistory); }
/// <summary> /// Destroys the social history. /// </summary> /// <param name="socialHistory">The social history.</param> public void DestroySocialHistory( SocialHistory socialHistory ) { _socialHistoryRepository.MakeTransient ( socialHistory ); }
/// <summary> /// If the visit does not have a SocialHistory, then it returns a newly created SocialHistory, /// else, it returns an existing one from the visit. /// </summary> /// <param name="visit">The visit.</param> /// <returns>A SocialHistory.</returns> public SocialHistory CreateSocialHistory( Visit visit ) { Check.IsNotNull ( visit, "visit is required." ); //NOTE : There can be only one 'Social History' per visit. SocialHistory socialHistory; var existingSocialHistory = _socialHistoryRepository.GetSocialHistoryInVisit(visit.Key); if (existingSocialHistory != null) { socialHistory = existingSocialHistory; } else { var type = _lookupValueRepository.GetLookupByWellKnownName<ActivityType> ( WellKnownNames.VisitModule.ActivityType.SocialHistory ); socialHistory = new SocialHistory ( visit, type ); _socialHistoryRepository.MakePersistent ( socialHistory ); } return socialHistory; }
/// <summary> /// Destroys the social history. /// </summary> /// <param name="socialHistory">The social history.</param> public void DestroySocialHistory(SocialHistory socialHistory) { _socialHistoryRepository.MakeTransient(socialHistory); }
private static void AddSocialHistory( C32Dto dto, Visit visit, SocialHistory socialHistory, OriginalTextCodedConceptDto socialHistoryTypeDto ) { var socialHistoryEntryDto = new SocialHistoryEntryDto (); socialHistoryEntryDto.SocialHistoryId = new IIDataTransferObject { Root = socialHistory.Key.ToString () }; socialHistoryEntryDto.SocialHistoryTime = new OperatorDateTimeDto { Date = visit.AppointmentDateTimeRange.StartDateTime.ToString ( "yyyyMMdd" ) }; socialHistoryEntryDto.SocialHistoryType = socialHistoryTypeDto; if ( dto.Body.SocialHistory == null ) { dto.Body.SocialHistory = new C32Gen.DataTransferObject.SocialHistoryDto (); } if ( dto.Body.SocialHistory.SocialHistoryEntries == null ) { dto.Body.SocialHistory.SocialHistoryEntries = new List<SocialHistoryEntryDto> (); } dto.Body.SocialHistory.SocialHistoryEntries.Add ( socialHistoryEntryDto ); }