Api-PWA/DocuMed.Domain/Mappers/MedicalHistoryTemplateMappe...

362 lines
14 KiB
C#
Raw Normal View History

2023-10-19 21:28:09 +03:30
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using DocuMed.Domain.Dtos.LargDtos;
using DocuMed.Domain.Dtos.SmallDtos;
2024-09-28 12:34:36 +03:30
using DocuMed.Domain.Entities.Hospitals;
2023-10-19 21:28:09 +03:30
using DocuMed.Domain.Entities.MedicalHistoryTemplate;
namespace DocuMed.Domain.Mappers
{
public static partial class MedicalHistoryTemplateMapper
{
2024-09-28 12:34:36 +03:30
public static MedicalHistoryTemplate AdaptToMedicalHistoryTemplate(this MedicalHistoryTemplateLDto p1)
2023-10-19 21:28:09 +03:30
{
return p1 == null ? null : new MedicalHistoryTemplate()
{
ChiefComplaint = p1.ChiefComplaint,
2023-10-22 15:51:11 +03:30
SectionId = p1.SectionId,
2024-09-28 12:34:36 +03:30
Section = p1.Section == null ? null : new Section()
{
Name = p1.Section.Name,
Detail = p1.Section.Detail,
HospitalId = p1.Section.HospitalId,
Id = p1.Section.Id
},
ApplicationUserId = p1.ApplicationUserId,
2024-09-28 12:34:36 +03:30
Questions = funcMain1(p1.Questions),
Id = p1.Id,
CreatedAt = p1.CreatedAt
2023-10-19 21:28:09 +03:30
};
}
2024-09-28 12:34:36 +03:30
public static MedicalHistoryTemplate AdaptTo(this MedicalHistoryTemplateLDto p3, MedicalHistoryTemplate p4)
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
if (p3 == null)
2023-10-19 21:28:09 +03:30
{
return null;
}
2024-09-28 12:34:36 +03:30
MedicalHistoryTemplate result = p4 ?? new MedicalHistoryTemplate();
2023-10-19 21:28:09 +03:30
2024-09-28 12:34:36 +03:30
result.ChiefComplaint = p3.ChiefComplaint;
result.SectionId = p3.SectionId;
result.Section = funcMain2(p3.Section, result.Section);
result.ApplicationUserId = p3.ApplicationUserId;
result.Questions = funcMain3(p3.Questions, result.Questions);
result.Id = p3.Id;
result.CreatedAt = p3.CreatedAt;
2023-10-19 21:28:09 +03:30
return result;
}
2024-09-28 12:34:36 +03:30
public static Expression<Func<MedicalHistoryTemplateLDto, MedicalHistoryTemplate>> ProjectToMedicalHistoryTemplate => p9 => new MedicalHistoryTemplate()
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
ChiefComplaint = p9.ChiefComplaint,
SectionId = p9.SectionId,
Section = p9.Section == null ? null : new Section()
{
Name = p9.Section.Name,
Detail = p9.Section.Detail,
HospitalId = p9.Section.HospitalId,
Id = p9.Section.Id
},
ApplicationUserId = p9.ApplicationUserId,
Questions = p9.Questions.Select<MedicalHistoryQuestionSDto, MedicalHistoryQuestion>(p10 => new MedicalHistoryQuestion()
{
Question = p10.Question,
Part = p10.Part,
QuestionType = p10.QuestionType,
BodySystem = p10.BodySystem,
IsSign = p10.IsSign,
IsSymptom = p10.IsSymptom,
MedicalHistoryTemplateId = p10.MedicalHistoryTemplateId,
Id = p10.Id
}).ToList<MedicalHistoryQuestion>(),
Id = p9.Id,
CreatedAt = p9.CreatedAt
2023-10-19 21:28:09 +03:30
};
2024-09-28 12:34:36 +03:30
public static MedicalHistoryTemplateLDto AdaptToLDto(this MedicalHistoryTemplate p11)
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
return p11 == null ? null : new MedicalHistoryTemplateLDto()
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
ChiefComplaint = p11.ChiefComplaint,
SectionId = p11.SectionId,
Section = p11.Section == null ? null : new SectionSDto()
{
Name = p11.Section.Name,
Detail = p11.Section.Detail,
HospitalId = p11.Section.HospitalId,
Id = p11.Section.Id
},
ApplicationUserId = p11.ApplicationUserId,
CreatedAt = p11.CreatedAt,
Questions = funcMain4(p11.Questions),
Id = p11.Id
2023-10-19 21:28:09 +03:30
};
}
2024-09-28 12:34:36 +03:30
public static MedicalHistoryTemplateLDto AdaptTo(this MedicalHistoryTemplate p13, MedicalHistoryTemplateLDto p14)
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
if (p13 == null)
2023-10-19 21:28:09 +03:30
{
return null;
}
2024-09-28 12:34:36 +03:30
MedicalHistoryTemplateLDto result = p14 ?? new MedicalHistoryTemplateLDto();
2023-10-19 21:28:09 +03:30
2024-09-28 12:34:36 +03:30
result.ChiefComplaint = p13.ChiefComplaint;
result.SectionId = p13.SectionId;
result.Section = funcMain5(p13.Section, result.Section);
result.ApplicationUserId = p13.ApplicationUserId;
result.CreatedAt = p13.CreatedAt;
result.Questions = funcMain6(p13.Questions, result.Questions);
result.Id = p13.Id;
2023-10-19 21:28:09 +03:30
return result;
}
2024-09-28 12:34:36 +03:30
public static Expression<Func<MedicalHistoryTemplate, MedicalHistoryTemplateLDto>> ProjectToLDto => p19 => new MedicalHistoryTemplateLDto()
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
ChiefComplaint = p19.ChiefComplaint,
SectionId = p19.SectionId,
Section = p19.Section == null ? null : new SectionSDto()
{
Name = p19.Section.Name,
Detail = p19.Section.Detail,
HospitalId = p19.Section.HospitalId,
Id = p19.Section.Id
},
ApplicationUserId = p19.ApplicationUserId,
CreatedAt = p19.CreatedAt,
Questions = p19.Questions.Select<MedicalHistoryQuestion, MedicalHistoryQuestionSDto>(p20 => new MedicalHistoryQuestionSDto()
{
Question = p20.Question,
Part = p20.Part,
QuestionType = p20.QuestionType,
MedicalHistoryTemplateId = p20.MedicalHistoryTemplateId,
BodySystem = p20.BodySystem,
IsSign = p20.IsSign,
IsSymptom = p20.IsSymptom,
Id = p20.Id
}).ToList<MedicalHistoryQuestionSDto>(),
Id = p19.Id
2023-10-19 21:28:09 +03:30
};
2024-09-28 12:34:36 +03:30
public static MedicalHistoryTemplate AdaptToMedicalHistoryTemplate(this MedicalHistoryTemplateSDto p21)
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
return p21 == null ? null : new MedicalHistoryTemplate()
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
ChiefComplaint = p21.ChiefComplaint,
SectionId = p21.SectionId,
ApplicationUserId = p21.ApplicationUserId,
Id = p21.Id,
CreatedAt = p21.CreatedAt
2023-10-19 21:28:09 +03:30
};
}
2024-09-28 12:34:36 +03:30
public static MedicalHistoryTemplate AdaptTo(this MedicalHistoryTemplateSDto p22, MedicalHistoryTemplate p23)
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
if (p22 == null)
2023-10-19 21:28:09 +03:30
{
return null;
}
2024-09-28 12:34:36 +03:30
MedicalHistoryTemplate result = p23 ?? new MedicalHistoryTemplate();
2023-10-19 21:28:09 +03:30
2024-09-28 12:34:36 +03:30
result.ChiefComplaint = p22.ChiefComplaint;
result.SectionId = p22.SectionId;
result.ApplicationUserId = p22.ApplicationUserId;
result.Id = p22.Id;
result.CreatedAt = p22.CreatedAt;
2023-10-19 21:28:09 +03:30
return result;
}
2024-09-28 12:34:36 +03:30
public static MedicalHistoryTemplateSDto AdaptToSDto(this MedicalHistoryTemplate p24)
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
return p24 == null ? null : new MedicalHistoryTemplateSDto()
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
ChiefComplaint = p24.ChiefComplaint,
SectionName = p24.Section == null ? null : p24.Section.Name,
SectionId = p24.SectionId,
ApplicationUserId = p24.ApplicationUserId,
CreatedAt = p24.CreatedAt,
Id = p24.Id
2023-10-19 21:28:09 +03:30
};
}
2024-09-28 12:34:36 +03:30
public static MedicalHistoryTemplateSDto AdaptTo(this MedicalHistoryTemplate p25, MedicalHistoryTemplateSDto p26)
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
if (p25 == null)
2023-10-19 21:28:09 +03:30
{
return null;
}
2024-09-28 12:34:36 +03:30
MedicalHistoryTemplateSDto result = p26 ?? new MedicalHistoryTemplateSDto();
2023-10-19 21:28:09 +03:30
2024-09-28 12:34:36 +03:30
result.ChiefComplaint = p25.ChiefComplaint;
result.SectionName = p25.Section == null ? null : p25.Section.Name;
result.SectionId = p25.SectionId;
result.ApplicationUserId = p25.ApplicationUserId;
result.CreatedAt = p25.CreatedAt;
result.Id = p25.Id;
2023-10-19 21:28:09 +03:30
return result;
}
2024-09-28 12:34:36 +03:30
public static Expression<Func<MedicalHistoryTemplate, MedicalHistoryTemplateSDto>> ProjectToSDto => p27 => new MedicalHistoryTemplateSDto()
2023-10-19 21:28:09 +03:30
{
2023-10-24 12:45:25 +03:30
ChiefComplaint = p27.ChiefComplaint,
2024-09-28 12:34:36 +03:30
SectionName = p27.Section.Name,
2023-10-24 12:45:25 +03:30
SectionId = p27.SectionId,
ApplicationUserId = p27.ApplicationUserId,
CreatedAt = p27.CreatedAt,
2023-10-24 12:45:25 +03:30
Id = p27.Id
2023-10-19 21:28:09 +03:30
};
2024-09-28 12:34:36 +03:30
private static List<MedicalHistoryQuestion> funcMain1(List<MedicalHistoryQuestionSDto> p2)
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
if (p2 == null)
2023-10-19 21:28:09 +03:30
{
return null;
}
2024-09-28 12:34:36 +03:30
List<MedicalHistoryQuestion> result = new List<MedicalHistoryQuestion>(p2.Count);
2023-10-19 21:28:09 +03:30
int i = 0;
2024-09-28 12:34:36 +03:30
int len = p2.Count;
2023-10-19 21:28:09 +03:30
while (i < len)
{
2024-09-28 12:34:36 +03:30
MedicalHistoryQuestionSDto item = p2[i];
2023-10-19 21:28:09 +03:30
result.Add(item == null ? null : new MedicalHistoryQuestion()
{
Question = item.Question,
Part = item.Part,
QuestionType = item.QuestionType,
2023-10-28 23:57:28 +03:30
BodySystem = item.BodySystem,
IsSign = item.IsSign,
IsSymptom = item.IsSymptom,
2023-10-19 21:28:09 +03:30
MedicalHistoryTemplateId = item.MedicalHistoryTemplateId,
Id = item.Id
});
i++;
}
return result;
}
2024-09-28 12:34:36 +03:30
private static Section funcMain2(SectionSDto p5, Section p6)
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
if (p5 == null)
2023-10-19 21:28:09 +03:30
{
return null;
}
2024-09-28 12:34:36 +03:30
Section result = p6 ?? new Section();
2023-10-24 12:45:25 +03:30
2024-09-28 12:34:36 +03:30
result.Name = p5.Name;
result.Detail = p5.Detail;
result.HospitalId = p5.HospitalId;
result.Id = p5.Id;
2023-10-24 12:45:25 +03:30
return result;
}
2024-09-28 12:34:36 +03:30
private static List<MedicalHistoryQuestion> funcMain3(List<MedicalHistoryQuestionSDto> p7, List<MedicalHistoryQuestion> p8)
2023-10-24 12:45:25 +03:30
{
2024-09-28 12:34:36 +03:30
if (p7 == null)
2023-10-24 12:45:25 +03:30
{
return null;
}
2024-09-28 12:34:36 +03:30
List<MedicalHistoryQuestion> result = new List<MedicalHistoryQuestion>(p7.Count);
2023-10-19 21:28:09 +03:30
int i = 0;
2024-09-28 12:34:36 +03:30
int len = p7.Count;
2023-10-19 21:28:09 +03:30
while (i < len)
{
2024-09-28 12:34:36 +03:30
MedicalHistoryQuestionSDto item = p7[i];
2023-10-19 21:28:09 +03:30
result.Add(item == null ? null : new MedicalHistoryQuestion()
{
Question = item.Question,
Part = item.Part,
QuestionType = item.QuestionType,
2023-10-28 23:57:28 +03:30
BodySystem = item.BodySystem,
IsSign = item.IsSign,
IsSymptom = item.IsSymptom,
2023-10-19 21:28:09 +03:30
MedicalHistoryTemplateId = item.MedicalHistoryTemplateId,
Id = item.Id
});
i++;
}
return result;
}
2024-09-28 12:34:36 +03:30
private static List<MedicalHistoryQuestionSDto> funcMain4(List<MedicalHistoryQuestion> p12)
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
if (p12 == null)
2023-10-19 21:28:09 +03:30
{
return null;
}
2024-09-28 12:34:36 +03:30
List<MedicalHistoryQuestionSDto> result = new List<MedicalHistoryQuestionSDto>(p12.Count);
2023-10-19 21:28:09 +03:30
int i = 0;
2024-09-28 12:34:36 +03:30
int len = p12.Count;
2023-10-19 21:28:09 +03:30
while (i < len)
{
2024-09-28 12:34:36 +03:30
MedicalHistoryQuestion item = p12[i];
2023-10-19 21:28:09 +03:30
result.Add(item == null ? null : new MedicalHistoryQuestionSDto()
{
Question = item.Question,
Part = item.Part,
QuestionType = item.QuestionType,
MedicalHistoryTemplateId = item.MedicalHistoryTemplateId,
2023-10-28 23:57:28 +03:30
BodySystem = item.BodySystem,
IsSign = item.IsSign,
IsSymptom = item.IsSymptom,
2023-10-19 21:28:09 +03:30
Id = item.Id
});
i++;
}
return result;
}
2024-09-28 12:34:36 +03:30
private static SectionSDto funcMain5(Section p15, SectionSDto p16)
2023-10-19 21:28:09 +03:30
{
2024-09-28 12:34:36 +03:30
if (p15 == null)
2023-10-24 12:45:25 +03:30
{
return null;
}
2024-09-28 12:34:36 +03:30
SectionSDto result = p16 ?? new SectionSDto();
2023-10-24 12:45:25 +03:30
2024-09-28 12:34:36 +03:30
result.Name = p15.Name;
result.Detail = p15.Detail;
result.HospitalId = p15.HospitalId;
result.Id = p15.Id;
2023-10-24 12:45:25 +03:30
return result;
}
2024-09-28 12:34:36 +03:30
private static List<MedicalHistoryQuestionSDto> funcMain6(List<MedicalHistoryQuestion> p17, List<MedicalHistoryQuestionSDto> p18)
2023-10-24 12:45:25 +03:30
{
2024-09-28 12:34:36 +03:30
if (p17 == null)
2023-10-19 21:28:09 +03:30
{
return null;
}
2024-09-28 12:34:36 +03:30
List<MedicalHistoryQuestionSDto> result = new List<MedicalHistoryQuestionSDto>(p17.Count);
2023-10-19 21:28:09 +03:30
int i = 0;
2024-09-28 12:34:36 +03:30
int len = p17.Count;
2023-10-19 21:28:09 +03:30
while (i < len)
{
2024-09-28 12:34:36 +03:30
MedicalHistoryQuestion item = p17[i];
2023-10-19 21:28:09 +03:30
result.Add(item == null ? null : new MedicalHistoryQuestionSDto()
{
Question = item.Question,
Part = item.Part,
QuestionType = item.QuestionType,
MedicalHistoryTemplateId = item.MedicalHistoryTemplateId,
2023-10-28 23:57:28 +03:30
BodySystem = item.BodySystem,
IsSign = item.IsSign,
IsSymptom = item.IsSymptom,
2023-10-19 21:28:09 +03:30
Id = item.Id
});
i++;
}
return result;
}
}
}