public async Task <object> ImportAsync(string insuranceNumber, DateTime birthday)
        {
            var user = await userRepository.GetByInsuranceNumberAndBirthdayAsync(insuranceNumber, birthday);

            if (user == null)
            {
                return(null);
            }

            var docs          = (await documentRepository.GetByUserIdAsync(user.Id)).ToList();
            var diseases      = (await diseaseRepository.GetByUserIdAsync(user.Id)).ToList();
            var acuteDiseases = (await acuteDiseaseRepository.GetByUserIdAsync(user.Id)).ToList();

            return(new
            {
                user.Id,
                user.Email,
                user.Mobile,
                user.Firstname,
                user.Lastname,
                user.Street,
                user.Zip,
                user.City,
                user.Country,
                user.Birthday,
                user.InsuranceNumber,
                user.Weight,
                user.Height,
                AvailableData = new
                {
                    user.HasHplus,
                    user.HasCoach,
                    user.HasMedicalEvents,
                    user.HasPrescriptionDrugs,
                },
                AvailableDocuments = new
                {
                    General = docs.Any(d => d.DocumentType == DocumentType.General),
                    Diagnosis = docs.Any(d => d.DocumentType == DocumentType.Diagnosis),
                    XRays = docs.Any(d => d.DocumentType == DocumentType.XRays),
                    CtScans = docs.Any(d => d.DocumentType == DocumentType.CtScans),
                    MedicalReports = docs.Any(d => d.DocumentType == DocumentType.MedicalReports),
                    LabResults = docs.Any(d => d.DocumentType == DocumentType.LabResults),
                    Prescription = docs.Any(d => d.DocumentType == DocumentType.Prescription),
                    VaccinationDetails = docs.Any(d => d.DocumentType == DocumentType.VaccinationDetails),
                    Bills = docs.Any(d => d.DocumentType == DocumentType.Bill)
                },
                Diseases = diseases.Select(d => d.DiseaseType),
                AcuteDiseases = acuteDiseases.Select(d => d.AcuteDiseaseType)
            });
        }
        public async Task<AllSharedData> RetrieveAsync(string shareKey)
        {
            var share = await shareRepository.GetByShareKeyAsync(shareKey);
            if (share == null || share.ValidFromTime > DateTime.Now || share.ValidUntilTime < DateTime.Now)
            {
                return null;
            }

            return new AllSharedData
            {
                Share = share,
                User = await userRepository.GetByIdAsync(share.SharingUserId),
                Activities = share.AllowActivities ? await activityRepository.GetByUserIdAsync(share.SharingUserId) : Enumerable.Empty<Activity>(),
                Documents = share.AllowDocuments ? await documentRepository.GetByUserIdAsync(share.SharingUserId) : Enumerable.Empty<Document>(),
                Diseases = share.AllowDiseases ? await diseaseRepository.GetByUserIdAsync(share.SharingUserId) : Enumerable.Empty<Disease>(),
                AcuteDiseases = share.AllowAcuteDiseases ? await acuteDiseaseRepository.GetByUserIdAsync(share.SharingUserId) : Enumerable.Empty<AcuteDisease>(),
            };
        }
示例#3
0
        private async Task SyncDiseasesAsync(Guid userId, List <DiseaseType> diseaseTypes)
        {
            var existingDiseases = await diseaseRepository.GetByUserIdAsync(userId);

            foreach (var disease in existingDiseases)
            {
                await diseaseRepository.DeleteAsync(disease);
            }

            foreach (var diseaseType in diseaseTypes)
            {
                await diseaseRepository.InsertAsync(new Disease
                {
                    Id          = Guid.NewGuid(),
                    DiseaseType = diseaseType,
                    UserId      = userId,
                });
            }
        }