Пример #1
0
        private void CreateProblem(ProblemDto dto, long patientKey, Provenance provenance)
        {
            var clinicalCase = _clinicalCaseRepository.GetActiveClinicalCaseByPatient(patientKey);

            CodedConcept problemCode = null;

            if (dto.ProblemCodeCodedConcept != null)
            {
                problemCode = new CodedConceptBuilder().WithCodedConceptDto(dto.ProblemCodeCodedConcept);
            }
            var problem = _problemFactory.CreateProblem(clinicalCase, problemCode, provenance);

            var problemType   = _mappingHelper.MapLookupField <ProblemType> (dto.ProblemType);
            var problemStatus = _mappingHelper.MapLookupField <ProblemStatus> (dto.ProblemStatus);

            problem.ReviseProblemType(problemType);
            problem.ReviseOnsetDateRange(new DateRange(dto.OnsetStartDate, dto.OnsetEndDate));
            problem.UpdateProblemStatus(problemStatus, dto.StatusChangedDate);
            problem.ReviseCauseOfDeathIndicator(dto.CauseOfDeathIndicator);

            if (dto.ObservedByStaff != null)
            {
                var staff = Session.Load <Staff> (dto.ObservedByStaff.Key);
                problem.ReviseObservationInfo(staff, dto.ObservedDate);
            }
        }
Пример #2
0
        /// <summary>
        /// Creates the new.
        /// </summary>
        /// <param name="dto">The data trasfer object.</param>
        /// <returns>A <see cref="Rem.Domain.Clinical.VisitModule.Visit"/></returns>
        protected override Visit CreateNew(AppointmentDetailsDto dto)
        {
            var staff        = _staffRepository.GetByKey(dto.ClinicianKey.Value);
            var clinicalCase =
                _clinicalCaseRepository.GetActiveClinicalCaseByPatient(dto.PatientKey);
            var visitTemplate =
                _visitTemplateRepository.GetByKey(dto.VisitTemplateKey.Value);
            var location = _locationRepository.GetByKey(dto.Location.Key);

            var visit = _visitFactory.CreateVisit(
                staff,
                new DateTimeRange(dto.AppointmentStartDateTime.Value, dto.AppointmentEndDateTime.Value),
                clinicalCase,
                visitTemplate,
                location);

            foreach (var visitTemplateActivityType in visitTemplate.ActivityTypes)
            {
                _activitySchedulerService.ScheduleActivity(visit.Key, visitTemplateActivityType.ActivityType);

                ////// TODO: We do not currently have full support for this feature.  Eventually we
                //////       need to enable activity factories to register themselves with the base
                //////       activity service so that we can schedule activities by type.  For now
                //////       we will hard code the one supported activity type called VitalSigns.
                ////if ( visitTemplateActivityType.ActivityType.WellKnownName == WellKnownNames.VisitModule.ActivityType.VitalSign )
                ////{
                ////    var vitalSign = _vitalSignFactory.CreateVitalSign ( visit );

                ////    if ( !vitalSign.PersistenceRuleContext.CheckRules () )
                ////    {
                ////        MappingHelper.MapRuleViolationsToDataErrorInfo ( dto, vitalSign );
                ////    }
                ////}
                ////else
                ////{
                ////    throw new SystemException ( "Unknown activity type: " +
                ////                                visitTemplateActivityType.ActivityType.Name );
                ////}
            }

            return(visit);
        }
Пример #3
0
        /// <summary>
        /// Handles the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>A <see cref="Agatha.Common.Response"/></returns>
        public override Response Handle(GetDefaultClinicalCaseByPatientRequest request)
        {
            var patientKey = request.PatientKey;

            var clinicalCase = _clinicalCaseRepository.GetActiveClinicalCaseByPatient(patientKey);

            if (clinicalCase == null)
            {
                clinicalCase = _clinicalCaseRepository.GetMostRecentClosedClinicalCaseByPatient(patientKey);
            }

            CaseSummaryDto caseSummaryDto = null;

            if (clinicalCase != null)
            {
                caseSummaryDto = Mapper.Map <ClinicalCase, CaseSummaryDto> (clinicalCase);
            }

            var response = CreateTypedResponse();

            response.CaseSummaryDto = caseSummaryDto;

            return(response);
        }