From 8f77fa025e0ed24651ea0085aa2b72bfd21a1a87 Mon Sep 17 00:00:00 2001
From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com>
Date: Thu, 13 Jun 2024 18:04:52 +0800
Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E7=BA=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
 .../QuestionRegisterAnswerDto.cs              |  52 +++++++
 .../QuestionRegisters/QuestionRegisterDto.cs  |  26 ++++
 .../QuestionRegisterItemDto.cs                |  34 +++++
 .../QuestionRegisterAppService.cs             | 144 +++++++++++++++++-
 .../Enums/AnswerResultTypeFlag.cs             |  16 ++
 .../Enums/AnswerTypeFlag.cs                   |  16 ++
 .../Models/QuestionAnswer.cs                  |  17 ++-
 .../Models/QuestionRegisterAnswer.cs          |   6 +-
 .../Configures/QuestionAnswerConfigure.cs     |  23 ++-
 .../Configures/QuestionConfigure.cs           |   4 +-
 .../QuestionRegisterAnswerChildConfigure.cs   |   2 +-
 .../QuestionRegisterAnswerConfigure.cs        |   4 +
 12 files changed, 330 insertions(+), 14 deletions(-)
 create mode 100644 src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterAnswerDto.cs
 create mode 100644 src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterDto.cs
 create mode 100644 src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterItemDto.cs
 create mode 100644 src/Shentun.WebPeis.Domain.Shared/Enums/AnswerResultTypeFlag.cs
 create mode 100644 src/Shentun.WebPeis.Domain.Shared/Enums/AnswerTypeFlag.cs
diff --git a/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterAnswerDto.cs b/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterAnswerDto.cs
new file mode 100644
index 0000000..2792a3e
--- /dev/null
+++ b/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterAnswerDto.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.WebPeis.QuestionRegisters
+{
+    /// 
+    /// 问卷答案
+    /// 
+    public class QuestionRegisterAnswerDto
+    {
+        /// 
+        /// 主键
+        /// 
+        public Guid QuestionRegisterAnswerId { get; set; }
+        /// 
+        /// 答案ID
+        /// 
+        public Guid QuestionAnswerId { get; set; }
+
+        /// 
+        /// 自填写内容
+        /// 
+
+        public string? Content { get; set; }
+
+        /// 
+        /// 答案
+        /// 
+
+        public string QuestionAnswerName { get; set; } = null!;
+
+
+        public int DisplayOrder { get; set; }
+
+        /// 
+        /// 子答案类别
+        /// 
+
+        public char? ChildAnswerType { get; set; }
+        /// 
+        /// 答案结果类别
+        /// 
+
+        public char? AnswerResultType { get; set; }
+
+        public char IsSelected { get; set; } = 'N';
+
+        public List Childs = new List();
+
+    }
+}
diff --git a/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterDto.cs b/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterDto.cs
new file mode 100644
index 0000000..9f45e3f
--- /dev/null
+++ b/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterDto.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.WebPeis.QuestionRegisters
+{
+    public class QuestionRegisterDto
+    {
+        /// 
+        /// 主键
+        /// 
+        public Guid QuestionRegisterId { get; set; }
+        /// 
+        /// 人员ID
+        /// 
+
+        public Guid PersonId { get; set; }
+
+        /// 
+        /// 登记的问卷项目
+        /// 
+
+        public virtual ICollection QuestionRegisterItems { get; set; } = new List();
+ 
+    }
+}
diff --git a/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterItemDto.cs b/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterItemDto.cs
new file mode 100644
index 0000000..73e0465
--- /dev/null
+++ b/src/Shentun.WebPeis.Application.Contracts/QuestionRegisters/QuestionRegisterItemDto.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.WebPeis.QuestionRegisters
+{
+    public class QuestionRegisterItemDto
+    {
+        /// 
+        /// 主键
+        /// 
+        public Guid QuestionRegisterItemId { get; set; }
+        public Guid QuestionId { get; set; }
+        /// 
+        /// 题目
+        /// 
+
+        public string QuestionName { get; set; } = null!;
+
+
+        /// 
+        /// 显示顺序
+        /// 
+        public int DisplayOrder { get; set; }
+
+        /// 
+        /// 答案类别
+        /// 
+
+        public char? AnswerType { get; set; }
+
+        public virtual ICollection QuestionRegisterAnswers { get; set; } = new List();
+    }
+}
diff --git a/src/Shentun.WebPeis.Application/QuestionRegisters/QuestionRegisterAppService.cs b/src/Shentun.WebPeis.Application/QuestionRegisters/QuestionRegisterAppService.cs
index 5b85c9b..2bda7d2 100644
--- a/src/Shentun.WebPeis.Application/QuestionRegisters/QuestionRegisterAppService.cs
+++ b/src/Shentun.WebPeis.Application/QuestionRegisters/QuestionRegisterAppService.cs
@@ -1,4 +1,6 @@
-using Shentun.WebPeis.Models;
+using Shentun.WebPeis.Enums;
+using Shentun.WebPeis.Models;
+using Shentun.WebPeis.Persons;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -9,7 +11,7 @@ using Volo.Abp.Domain.Repositories;
 
 namespace Shentun.WebPeis.QuestionRegisters
 {
-    public class QuestionRegisterAppService:ApplicationService
+    public class QuestionRegisterAppService : ApplicationService
     {
         private readonly IRepository _repository;
         public QuestionRegisterAppService(IRepository repository)
@@ -17,6 +19,142 @@ namespace Shentun.WebPeis.QuestionRegisters
             _repository = repository;
         }
 
-        //public async Task Get
+        public async Task GetByPersonId(PersonIdInputDto input)
+        {
+            var questionRegisterDto = new QuestionRegisterDto()
+            {
+                QuestionRegisterId = Guid.NewGuid(),
+                PersonId = input.PersonId,
+            };
+            //
+            var questionRegisterItemDto = new QuestionRegisterItemDto()
+            {
+                QuestionId = Guid.NewGuid(),
+                QuestionName = "你最近3-6个月是否有生育计划",
+                AnswerType = AnswerTypeFlag.SingleChoice,
+                DisplayOrder = 1
+            };
+            questionRegisterDto.QuestionRegisterItems.Add(questionRegisterItemDto);
+
+            var questionRegisterAnswerDto = new QuestionRegisterAnswerDto()
+            {
+                QuestionAnswerId = Guid.NewGuid(),
+                QuestionAnswerName = "无",
+                DisplayOrder = 1,
+                AnswerResultType = '0'
+            };
+
+            questionRegisterAnswerDto = new QuestionRegisterAnswerDto()
+            {
+                QuestionAnswerId = Guid.NewGuid(),
+                QuestionAnswerName = "有",
+                DisplayOrder = 2,
+                AnswerResultType = '0'
+            };
+            questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto);
+            //
+            questionRegisterItemDto = new QuestionRegisterItemDto()
+            {
+                QuestionId = Guid.NewGuid(),
+                QuestionName = "您的父亲、母亲、兄弟、姐妹、目前或曾经是否有以下明确诊断的病?",
+                AnswerType = AnswerTypeFlag.MultipleChoice,
+                DisplayOrder = 2
+            };
+            questionRegisterDto.QuestionRegisterItems.Add(questionRegisterItemDto);
+
+            questionRegisterAnswerDto = new QuestionRegisterAnswerDto()
+            {
+                QuestionAnswerId = Guid.NewGuid(),
+                QuestionAnswerName = "恶性肿瘤",
+                DisplayOrder = 1,
+                AnswerResultType = '0'
+            };
+            questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto);
+            questionRegisterAnswerDto = new QuestionRegisterAnswerDto()
+            {
+                QuestionAnswerId = Guid.NewGuid(),
+                QuestionAnswerName = "心脏病",
+                DisplayOrder = 2,
+                AnswerResultType = '0'
+            };
+            questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto);
+
+            questionRegisterAnswerDto = new QuestionRegisterAnswerDto()
+            {
+                QuestionAnswerId = Guid.NewGuid(),
+                QuestionAnswerName = "脑血管病",
+                DisplayOrder = 3,
+                AnswerResultType = '0'
+            };
+            questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto);
+
+            //
+            questionRegisterItemDto = new QuestionRegisterItemDto()
+            {
+                QuestionId = Guid.NewGuid(),
+                QuestionName = "您目前或曾经是否有以下明确诊断的疾病",
+                AnswerType = AnswerTypeFlag.MultipleChoice,
+                DisplayOrder = 3
+            };
+            questionRegisterDto.QuestionRegisterItems.Add(questionRegisterItemDto);
+
+            questionRegisterAnswerDto = new QuestionRegisterAnswerDto()
+            {
+                QuestionAnswerId = Guid.NewGuid(),
+                QuestionAnswerName = "头部疾病",
+                DisplayOrder = 1,
+                AnswerResultType = '0',
+                ChildAnswerType = AnswerTypeFlag.MultipleChoice,
+                
+            };
+            questionRegisterAnswerDto.Childs.Add(new QuestionRegisterAnswerDto()
+            {
+                QuestionAnswerId = Guid.NewGuid(),
+                QuestionAnswerName = "脑中风",
+                DisplayOrder = 1,
+                AnswerResultType = '0',
+            });
+            questionRegisterAnswerDto.Childs.Add(new QuestionRegisterAnswerDto()
+            {
+                QuestionAnswerId = Guid.NewGuid(),
+                QuestionAnswerName = "抑郁症",
+                DisplayOrder = 1,
+                AnswerResultType = '0',
+            });
+            questionRegisterAnswerDto.Childs.Add(new QuestionRegisterAnswerDto()
+            {
+                QuestionAnswerId = Guid.NewGuid(),
+                QuestionAnswerName = "癫痫",
+                DisplayOrder = 1,
+                AnswerResultType = '0',
+            });
+            questionRegisterAnswerDto.Childs.Add(new QuestionRegisterAnswerDto()
+            {
+                QuestionAnswerId = Guid.NewGuid(),
+                QuestionAnswerName = "其它",
+                DisplayOrder = 1,
+                AnswerResultType = '1',
+            });
+            questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto);
+            questionRegisterAnswerDto = new QuestionRegisterAnswerDto()
+            {
+                QuestionAnswerId = Guid.NewGuid(),
+                QuestionAnswerName = "甲状腺疾病",
+                DisplayOrder = 2,
+                AnswerResultType = '0'
+            };
+            questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto);
+
+            questionRegisterAnswerDto = new QuestionRegisterAnswerDto()
+            {
+                QuestionAnswerId = Guid.NewGuid(),
+                QuestionAnswerName = "肺部疾病",
+                DisplayOrder = 3,
+                AnswerResultType = '0'
+            };
+            questionRegisterItemDto.QuestionRegisterAnswers.Add(questionRegisterAnswerDto);
+
+
+        }
     }
 }
diff --git a/src/Shentun.WebPeis.Domain.Shared/Enums/AnswerResultTypeFlag.cs b/src/Shentun.WebPeis.Domain.Shared/Enums/AnswerResultTypeFlag.cs
new file mode 100644
index 0000000..2f2bf9d
--- /dev/null
+++ b/src/Shentun.WebPeis.Domain.Shared/Enums/AnswerResultTypeFlag.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Text;
+
+namespace Shentun.WebPeis.Enums
+{
+    public class AnswerResultTypeFlag
+    {
+        [Description("选择")]
+        public const char Choice = '0';
+
+        [Description("自己填写")]
+        public const char Content = '1';
+    }
+}
diff --git a/src/Shentun.WebPeis.Domain.Shared/Enums/AnswerTypeFlag.cs b/src/Shentun.WebPeis.Domain.Shared/Enums/AnswerTypeFlag.cs
new file mode 100644
index 0000000..5be58a3
--- /dev/null
+++ b/src/Shentun.WebPeis.Domain.Shared/Enums/AnswerTypeFlag.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Text;
+
+namespace Shentun.WebPeis.Enums
+{
+    public class AnswerTypeFlag
+    {
+        [Description("单选")]
+        public const char SingleChoice = '0';
+
+        [Description("多选")]
+        public const char MultipleChoice = '1';
+    }
+}
diff --git a/src/Shentun.WebPeis.Domain/Models/QuestionAnswer.cs b/src/Shentun.WebPeis.Domain/Models/QuestionAnswer.cs
index 23e437d..b5e142d 100644
--- a/src/Shentun.WebPeis.Domain/Models/QuestionAnswer.cs
+++ b/src/Shentun.WebPeis.Domain/Models/QuestionAnswer.cs
@@ -29,11 +29,6 @@ public partial class QuestionAnswer : AuditedEntity, IHasConcurrencyStamp
 
     public int DisplayOrder { get; set; }
 
-    /// 
-    /// 有子答案
-    /// 
-
-    public char? IsHaveChild { get; set; }
     /// 
     /// 子答案类别
     /// 
@@ -50,6 +45,18 @@ public partial class QuestionAnswer : AuditedEntity, IHasConcurrencyStamp
 
     public Guid? DiseaseRiskLevelId { get; set; }
 
+    /// 
+    /// 父答案ID
+    /// 
+
+    public Guid? ParentId { get; set; }
+    /// 
+    /// 编码路径
+    /// 
+
+    public string? PathCode { get; set; }
+
+    public string? ChildAnswerTitle { get; set; }
     public virtual ICollection QuestionRegisterAnswers { get; set; } = new List();
     public string? ConcurrencyStamp { get; set; }
 
diff --git a/src/Shentun.WebPeis.Domain/Models/QuestionRegisterAnswer.cs b/src/Shentun.WebPeis.Domain/Models/QuestionRegisterAnswer.cs
index 28e98ad..64a2913 100644
--- a/src/Shentun.WebPeis.Domain/Models/QuestionRegisterAnswer.cs
+++ b/src/Shentun.WebPeis.Domain/Models/QuestionRegisterAnswer.cs
@@ -25,7 +25,11 @@ public partial class QuestionRegisterAnswer : AuditedEntity, IHasConcurrencyStam
 
     public Guid QuestionAnswerId { get; set; }
 
-   
+    /// 
+    /// 自填写内容
+    /// 
+
+    public string? Content { get; set; }
 
     public string? ConcurrencyStamp { get; set; }
 
diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionAnswerConfigure.cs b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionAnswerConfigure.cs
index 560fa20..0be588c 100644
--- a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionAnswerConfigure.cs
+++ b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionAnswerConfigure.cs
@@ -31,15 +31,34 @@ namespace Shentun.WebPeis.Configures
                 .HasColumnName("last_modification_time");
             entity.Property(e => e.LastModifierId).HasColumnName("last_modifier_id");
             entity.Property(e => e.QuestionAnswerName)
-                .HasMaxLength(20)
+                .HasMaxLength(100)
                 .HasColumnName("question_answer_name");
+
+            entity.Property(e => e.ChildAnswerTitle)
+              .HasMaxLength(50)
+              .HasColumnName("child_answer_title");
+
+            entity.Property(e => e.ChildAnswerType)
+               .HasMaxLength(1)
+               .HasColumnName("child_answer_type");
+
+            entity.Property(e => e.AnswerResultType)
+               .HasMaxLength(1)
+               .HasColumnName("answer_result_type");
+
             entity.Property(e => e.QuestionId).HasColumnName("question_id");
             entity.Property(e => e.SimpleCode)
-                .HasMaxLength(20)
+                .HasMaxLength(100)
                 .HasColumnName("simple_code");
             entity.Property(e => e.ConcurrencyStamp)
               .HasMaxLength(40)
               .HasColumnName("concurrency_stamp");
+
+            entity.Property(e => e.ParentId)
+           .HasColumnName("parent_id");
+            entity.Property(e => e.PathCode)
+                .HasMaxLength(60)
+                .HasColumnName("path_code");
         }
     }
 }
diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionConfigure.cs b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionConfigure.cs
index d905753..f2572bd 100644
--- a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionConfigure.cs
+++ b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionConfigure.cs
@@ -45,11 +45,11 @@ namespace Shentun.WebPeis.Configures
                 .HasColumnName("last_modification_time");
             entity.Property(e => e.LastModifierId).HasColumnName("last_modifier_id");
             entity.Property(e => e.QuestionName)
-                .HasMaxLength(20)
+                .HasMaxLength(100)
                 .HasColumnName("question_name");
             entity.Property(e => e.QuestionTypeId).HasMaxLength(2).HasColumnName("question_type_id");
             entity.Property(e => e.SimpleCode)
-                .HasMaxLength(20)
+                .HasMaxLength(100)
                 .HasColumnName("simple_code");
             entity.Property(e => e.ConcurrencyStamp)
               .HasMaxLength(40)
diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionRegisterAnswerChildConfigure.cs b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionRegisterAnswerChildConfigure.cs
index 4175cae..713d2b1 100644
--- a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionRegisterAnswerChildConfigure.cs
+++ b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionRegisterAnswerChildConfigure.cs
@@ -22,7 +22,7 @@ namespace Shentun.WebPeis.Configures
                 .ValueGeneratedNever()
                 .HasColumnName("question_register_answer_child_id");
             entity.Property(e => e.Content)
-                .HasMaxLength(20)
+                .HasMaxLength(50)
                 .HasColumnName("content");
             entity.Property(e => e.CreationTime)
                 .HasColumnType("timestamp(6) without time zone")
diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionRegisterAnswerConfigure.cs b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionRegisterAnswerConfigure.cs
index 2c6fc01..d3a0133 100644
--- a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionRegisterAnswerConfigure.cs
+++ b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/QuestionRegisterAnswerConfigure.cs
@@ -22,6 +22,10 @@ namespace Shentun.WebPeis.Configures
 
             entity.HasIndex(e => e.QuestionRegisterItemId, "IX_question_register_answer_question_register_item_id");
 
+            entity.Property(e => e.Content)
+               .HasMaxLength(50)
+               .HasColumnName("content");
+
             entity.Property(e => e.QuestionRegisterAnswerId)
                 .ValueGeneratedNever()
                 .HasColumnName("question_register_answer_id");