351 lines
13 KiB
C#
351 lines
13 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using DocuMed.Domain.Dtos.LargDtos;
|
|
using DocuMed.Domain.Dtos.SmallDtos;
|
|
using DocuMed.Domain.Entities.Hospitals;
|
|
using DocuMed.Domain.Entities.MedicalHistoryTemplate;
|
|
|
|
namespace DocuMed.Domain.Mappers
|
|
{
|
|
public static partial class MedicalHistoryTemplateMapper
|
|
{
|
|
public static MedicalHistoryTemplate AdaptToMedicalHistoryTemplate(this MedicalHistoryTemplateLDto p1)
|
|
{
|
|
return p1 == null ? null : new MedicalHistoryTemplate()
|
|
{
|
|
ChiefComplaint = p1.ChiefComplaint,
|
|
SectionId = p1.SectionId,
|
|
Section = p1.Section == null ? null : new Section()
|
|
{
|
|
Name = p1.Section.Name,
|
|
Detail = p1.Section.Detail,
|
|
HospitalId = p1.Section.HospitalId,
|
|
Id = p1.Section.Id
|
|
},
|
|
Questions = funcMain1(p1.Questions),
|
|
Id = p1.Id,
|
|
CreatedAt = p1.CreatedAt
|
|
};
|
|
}
|
|
public static MedicalHistoryTemplate AdaptTo(this MedicalHistoryTemplateLDto p3, MedicalHistoryTemplate p4)
|
|
{
|
|
if (p3 == null)
|
|
{
|
|
return null;
|
|
}
|
|
MedicalHistoryTemplate result = p4 ?? new MedicalHistoryTemplate();
|
|
|
|
result.ChiefComplaint = p3.ChiefComplaint;
|
|
result.SectionId = p3.SectionId;
|
|
result.Section = funcMain2(p3.Section, result.Section);
|
|
result.Questions = funcMain3(p3.Questions, result.Questions);
|
|
result.Id = p3.Id;
|
|
result.CreatedAt = p3.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<MedicalHistoryTemplateLDto, MedicalHistoryTemplate>> ProjectToMedicalHistoryTemplate => p9 => new MedicalHistoryTemplate()
|
|
{
|
|
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
|
|
},
|
|
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
|
|
};
|
|
public static MedicalHistoryTemplateLDto AdaptToLDto(this MedicalHistoryTemplate p11)
|
|
{
|
|
return p11 == null ? null : new MedicalHistoryTemplateLDto()
|
|
{
|
|
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
|
|
},
|
|
CreatedAt = p11.CreatedAt,
|
|
Questions = funcMain4(p11.Questions),
|
|
Id = p11.Id
|
|
};
|
|
}
|
|
public static MedicalHistoryTemplateLDto AdaptTo(this MedicalHistoryTemplate p13, MedicalHistoryTemplateLDto p14)
|
|
{
|
|
if (p13 == null)
|
|
{
|
|
return null;
|
|
}
|
|
MedicalHistoryTemplateLDto result = p14 ?? new MedicalHistoryTemplateLDto();
|
|
|
|
result.ChiefComplaint = p13.ChiefComplaint;
|
|
result.SectionId = p13.SectionId;
|
|
result.Section = funcMain5(p13.Section, result.Section);
|
|
result.CreatedAt = p13.CreatedAt;
|
|
result.Questions = funcMain6(p13.Questions, result.Questions);
|
|
result.Id = p13.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<MedicalHistoryTemplate, MedicalHistoryTemplateLDto>> ProjectToLDto => p19 => new MedicalHistoryTemplateLDto()
|
|
{
|
|
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
|
|
},
|
|
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
|
|
};
|
|
public static MedicalHistoryTemplate AdaptToMedicalHistoryTemplate(this MedicalHistoryTemplateSDto p21)
|
|
{
|
|
return p21 == null ? null : new MedicalHistoryTemplate()
|
|
{
|
|
ChiefComplaint = p21.ChiefComplaint,
|
|
SectionId = p21.SectionId,
|
|
Id = p21.Id,
|
|
CreatedAt = p21.CreatedAt
|
|
};
|
|
}
|
|
public static MedicalHistoryTemplate AdaptTo(this MedicalHistoryTemplateSDto p22, MedicalHistoryTemplate p23)
|
|
{
|
|
if (p22 == null)
|
|
{
|
|
return null;
|
|
}
|
|
MedicalHistoryTemplate result = p23 ?? new MedicalHistoryTemplate();
|
|
|
|
result.ChiefComplaint = p22.ChiefComplaint;
|
|
result.SectionId = p22.SectionId;
|
|
result.Id = p22.Id;
|
|
result.CreatedAt = p22.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static MedicalHistoryTemplateSDto AdaptToSDto(this MedicalHistoryTemplate p24)
|
|
{
|
|
return p24 == null ? null : new MedicalHistoryTemplateSDto()
|
|
{
|
|
ChiefComplaint = p24.ChiefComplaint,
|
|
SectionName = p24.Section == null ? null : p24.Section.Name,
|
|
SectionId = p24.SectionId,
|
|
CreatedAt = p24.CreatedAt,
|
|
Id = p24.Id
|
|
};
|
|
}
|
|
public static MedicalHistoryTemplateSDto AdaptTo(this MedicalHistoryTemplate p25, MedicalHistoryTemplateSDto p26)
|
|
{
|
|
if (p25 == null)
|
|
{
|
|
return null;
|
|
}
|
|
MedicalHistoryTemplateSDto result = p26 ?? new MedicalHistoryTemplateSDto();
|
|
|
|
result.ChiefComplaint = p25.ChiefComplaint;
|
|
result.SectionName = p25.Section == null ? null : p25.Section.Name;
|
|
result.SectionId = p25.SectionId;
|
|
result.CreatedAt = p25.CreatedAt;
|
|
result.Id = p25.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<MedicalHistoryTemplate, MedicalHistoryTemplateSDto>> ProjectToSDto => p27 => new MedicalHistoryTemplateSDto()
|
|
{
|
|
ChiefComplaint = p27.ChiefComplaint,
|
|
SectionName = p27.Section.Name,
|
|
SectionId = p27.SectionId,
|
|
CreatedAt = p27.CreatedAt,
|
|
Id = p27.Id
|
|
};
|
|
|
|
private static List<MedicalHistoryQuestion> funcMain1(List<MedicalHistoryQuestionSDto> p2)
|
|
{
|
|
if (p2 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<MedicalHistoryQuestion> result = new List<MedicalHistoryQuestion>(p2.Count);
|
|
|
|
int i = 0;
|
|
int len = p2.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
MedicalHistoryQuestionSDto item = p2[i];
|
|
result.Add(item == null ? null : new MedicalHistoryQuestion()
|
|
{
|
|
Question = item.Question,
|
|
Part = item.Part,
|
|
QuestionType = item.QuestionType,
|
|
BodySystem = item.BodySystem,
|
|
IsSign = item.IsSign,
|
|
IsSymptom = item.IsSymptom,
|
|
MedicalHistoryTemplateId = item.MedicalHistoryTemplateId,
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static Section funcMain2(SectionSDto p5, Section p6)
|
|
{
|
|
if (p5 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Section result = p6 ?? new Section();
|
|
|
|
result.Name = p5.Name;
|
|
result.Detail = p5.Detail;
|
|
result.HospitalId = p5.HospitalId;
|
|
result.Id = p5.Id;
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<MedicalHistoryQuestion> funcMain3(List<MedicalHistoryQuestionSDto> p7, List<MedicalHistoryQuestion> p8)
|
|
{
|
|
if (p7 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<MedicalHistoryQuestion> result = new List<MedicalHistoryQuestion>(p7.Count);
|
|
|
|
int i = 0;
|
|
int len = p7.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
MedicalHistoryQuestionSDto item = p7[i];
|
|
result.Add(item == null ? null : new MedicalHistoryQuestion()
|
|
{
|
|
Question = item.Question,
|
|
Part = item.Part,
|
|
QuestionType = item.QuestionType,
|
|
BodySystem = item.BodySystem,
|
|
IsSign = item.IsSign,
|
|
IsSymptom = item.IsSymptom,
|
|
MedicalHistoryTemplateId = item.MedicalHistoryTemplateId,
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<MedicalHistoryQuestionSDto> funcMain4(List<MedicalHistoryQuestion> p12)
|
|
{
|
|
if (p12 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<MedicalHistoryQuestionSDto> result = new List<MedicalHistoryQuestionSDto>(p12.Count);
|
|
|
|
int i = 0;
|
|
int len = p12.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
MedicalHistoryQuestion item = p12[i];
|
|
result.Add(item == null ? null : new MedicalHistoryQuestionSDto()
|
|
{
|
|
Question = item.Question,
|
|
Part = item.Part,
|
|
QuestionType = item.QuestionType,
|
|
MedicalHistoryTemplateId = item.MedicalHistoryTemplateId,
|
|
BodySystem = item.BodySystem,
|
|
IsSign = item.IsSign,
|
|
IsSymptom = item.IsSymptom,
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static SectionSDto funcMain5(Section p15, SectionSDto p16)
|
|
{
|
|
if (p15 == null)
|
|
{
|
|
return null;
|
|
}
|
|
SectionSDto result = p16 ?? new SectionSDto();
|
|
|
|
result.Name = p15.Name;
|
|
result.Detail = p15.Detail;
|
|
result.HospitalId = p15.HospitalId;
|
|
result.Id = p15.Id;
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<MedicalHistoryQuestionSDto> funcMain6(List<MedicalHistoryQuestion> p17, List<MedicalHistoryQuestionSDto> p18)
|
|
{
|
|
if (p17 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<MedicalHistoryQuestionSDto> result = new List<MedicalHistoryQuestionSDto>(p17.Count);
|
|
|
|
int i = 0;
|
|
int len = p17.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
MedicalHistoryQuestion item = p17[i];
|
|
result.Add(item == null ? null : new MedicalHistoryQuestionSDto()
|
|
{
|
|
Question = item.Question,
|
|
Part = item.Part,
|
|
QuestionType = item.QuestionType,
|
|
MedicalHistoryTemplateId = item.MedicalHistoryTemplateId,
|
|
BodySystem = item.BodySystem,
|
|
IsSign = item.IsSign,
|
|
IsSymptom = item.IsSymptom,
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
}
|
|
} |