体检系统架构
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

107 lines
7.4 KiB

#region CopyRight
/****************************************************************
* Project:健康体检信息管理系统(PEIS)
* Author:张剑峰
* CLR Version:4.0.30319.42000
* CreateTime:2023-06-03 18:00:27
* Version:v2.0
*
* Description:
*
* History:
*
*****************************************************************
* Copyright @ 云南新八达科技有限公司 2023 All rights reserved
*****************************************************************/
#endregion CopyRight
using System;
using System.Collections.Generic;
using PEIS.Entity;
using PEIS.Utils;
namespace PEIS.Model.Enrollment
{
public class EnrollmentOrgFeeItemModel : IModel<EnrollmentOrgFeeItem>
{
public List<EnrollmentOrgFeeItem> GetItems()
{
throw new NotImplementedException();
}
public List<EnrollmentOrgFeeItem> GetItems(Int64 groupID)
{
return DAOHelp.GetDataBySQL<EnrollmentOrgFeeItem>($"SELECT ID, GroupID, PackId, PackName, FID,FeeItemCode, FeeItemName, Quantity, Unit,Price, SettlePrice, ItemClass, CreateTime, Creator, DeptCode, DeptName, KeyNo, IsOccupational, Part FROM Enrollment_OrgFeeItem WHERE GroupID = {groupID} Order by PackID, ItemClass, DeptCode, FeeItemCode");
}
public void AddPackFeeItem(Int64 packID, Int64 oeID, Int64 groupID, Int64 oID)
{
DAOHelp.ExecuteSql($"INSERT INTO dbo.Enrollment_OrgFeeItem(OID, OEID,GroupID,PackID,PackName,FID,FeeItemCode,FeeItemName,Quantity,Unit,Price,SettlePrice,ItemClass,CreateTime,CreatorCode,Creator,DeptCode,DeptName,KeyNo) SELECT {oID}, {oeID}, {groupID},a.ID,a.Name,c.ID,c.FeeItemCode,c.FeeItemName,1,c.Unit,c.Price,c.SettlePrice,c.ItemClass,GETDATE(),'{Global.currentUser.Code}', '{Global.currentUser.Name}', c.DeptCode, c.DeptName, c.KeyNo FROM dbo.Dict_Pack a LEFT JOIN dbo.Dict_PackToFeeItem b ON a.ID = b.PID LEFT JOIN dbo.vi_FeeItem c ON b.FID = c.ID WHERE a.ID = {packID}", false);
}
public void AddFeeItem(Int64 feeItemID, Int64 oeID, Int64 groupID, Int64 oID)
{
DAOHelp.ExecuteSql($"INSERT INTO dbo.Enrollment_OrgFeeItem(OID, OEID,GroupID,PackID,PackName,FID,FeeItemCode,FeeItemName,Quantity,Unit,Price,SettlePrice,ItemClass,CreateTime,CreatorCode,Creator,DeptCode,DeptName,KeyNo) SELECT '{oID}', '{oeID}', '{groupID}',NULL, NULL,ID, FeeItemCode,FeeItemName,1,Unit,Price,SettlePrice,ItemClass,GETDATE(),'{Global.currentUser.Code}', '{Global.currentUser.Name}', DeptCode, DeptName,KeyNo FROM dbo.vi_FeeItem WHERE ID = {feeItemID}", false);
}
public void ApplyOrgFeeItem(Int64 oeID, Int64 groupID)
{
// 个人登记信息
DAOHelp.ExecuteSql($@"Insert into Enrollment_Patient (Name, Sex, Nation, Age, AgeClass, CardType, CardNo, Tel1, Tel2, Contactor1,Contactor2,Address1, Address2, Marriage, Education, Occupation, Company, ExamDate, Type, PID, OID, OEID, OrgName, GroupID, GroupName, Description, JobTypes, JobStatus, HazardFactors, CreateTime, CreatorCode, Creator)
SELECT a.Name, a.Sex, a.Nation, DATEDIFF(YEAR, a.Birthday, GETDATE()) + CASE WHEN DATEDIFF(DAY,DATEADD(YEAR,DATEDIFF(YEAR, a.Birthday,GETDATE()), a.Birthday),GETDATE()) < 0 THEN -1 ELSE 0 END, '岁', CardType, CardNo, a.Tel1, a.Tel2, a.Contactor1, a.Contactor2, Address1, Address2, a.Marriage, Education, Occupation, Company, c.ExamDate, d.Type, a.ID, c.OID, c.ID, c.Name, d.ID, d.Name, a.Description, d.JobTypes, d.JobStatus, d.HazardFactors, GETDATE(), '{Global.currentUser.Code}', '{Global.currentUser.Name}'
FROM dbo.Base_Patient a
LEFT JOIN dbo.Enrollment_OrgPatient b ON a.ID = b.PID
LEFT JOIN dbo.Enrollment_Org c ON b.OID = c.ID
LEFT JOIN dbo.Enrollment_OrgGroup d ON b.GroupID = d.ID
WHERE c.ID = { oeID} AND d.ID = { groupID}
AND a.ID NOT IN (SELECT PID FROM Enrollment_Patient WHERE OEID = {oeID})");
// 备注信息作为一次性临时备注, 登记后清空Base_Patient的Description字段
DAOHelp.ExecuteSql($@"update Base_Patient set Description=null
from Base_Patient a join Enrollment_Patient b on a.id=b.PID
where b.OEID={oeID} and b.GroupID={groupID} and (a.Description is not null and a.Description<>'')
and (b.Description is not null and b.Description<>'');");
var groupFeeItem = DAOHelp.GetDataBySQL<EnrollmentOrgFeeItem>($@"SELECT * FROM Enrollment_OrgFeeItem WHERE GroupID = {groupID}");
if (groupFeeItem.Count != 0)
{
// 个人收费项目信息
DAOHelp.ExecuteSql($"INSERT INTO Enrollment_FeeItem(OEID, GroupID, EID, PackID, PackName, FID, FeeItemCode, FeeItemName, Quantity, Unit, Price, SettlePrice, ItemClass, CreateTime, CreatorCode, Creator, DeptCode, DeptName, Seq, KeyNo, Part) SELECT a.OEID, a.GroupID, a.ID, b.PackID, b.PackName, b.FID, b.FeeItemCode, b.FeeItemName, b.Quantity, b.Unit, b.Price, b.SettlePrice, b.ItemClass, GETDATE(), '{Global.currentUser.Code}', '{Global.currentUser.Name}', b.DeptCode, b.DeptName, b.Seq, b.KeyNo, B.Part FROM Enrollment_patient a LEFT JOIN dbo.Enrollment_OrgFeeItem b ON a.GroupID = b.GroupID WHERE a.GroupID = { groupID} AND a.OEID = {oeID} AND a.ID NOT IN ( SELECT EID FROM Enrollment_FeeItem )");
}
// 更新应用时间
DAOHelp.ExecuteSql($"UPDATE dbo.Enrollment_OrgGroup SET Checker = '{Global.currentUser.Name}', CheckerCode = '{Global.currentUser.Code}', CheckTime = GETDATE() WHERE OID = {oeID} AND ID = {groupID}");
}
public void CancelOrgFeeItem(Int64 oeID, Int64 groupID, string oeName)
{
// 删除登记信息前, 回写Description字段
DAOHelp.ExecuteSql($@"update Base_Patient set Description=b.Description
from Base_Patient a join Enrollment_Patient b on a.id=b.PID
where b.OEID={oeID} and b.GroupID={groupID} and (a.Description is null or a.Description='')
and (b.Description is not null and b.Description<>'');");
// 个人登记信息
int delPatient = DAOHelp.ExecuteSql($@"delete from Enrollment_Patient where OEID = {oeID} and GroupId = {groupID}");
// 个人收费信息
int delFeeItem = DAOHelp.ExecuteSql($@"delete from Enrollment_FeeItem where OEID = {oeID} and GroupId = {groupID}");
// 删除应用时间
DAOHelp.ExecuteSql($@"update Enrollment_OrgGroup set Checker = NULL, CheckerCode = NULL, CheckTime = NULL WHERE OID = {oeID} AND ID = {groupID}");
// 记录日志
if (delPatient > 0 && delFeeItem > 0)
{
List<EnrollmentOrgGroup> orgGroups = DAOHelp.GetDataBySQL<EnrollmentOrgGroup>($@"select * from Enrollment_OrgGroup where ID = {groupID} and OID = {oeID}");
EnrollmentOrgGroup group = orgGroups?.Count > 0 ? orgGroups[0] : null;
new Entity.Log($@"撤销团体分组成员的模版应用:团体={oeName},团体号={oeID}, 分组名称={group?.Name},分组ID={groupID}", "3").Save();
}
}
public void DelItemByPackID(Int64 groupId, Int64 packId)
{
var sql = $"DELETE FROM Enrollment_OrgFeeItem WHERE GroupID = {groupId} AND PackID = {packId}";
DAOHelp.ExecuteSql(sql, false);
}
}
}