28169 преди 1 месец
родител
ревизия
3b6ae5f239
променени са 3 файла, в които са добавени 87 реда и са изтрити 2 реда
  1. 41 0
      controllers/patient_api_controller.go
  2. 13 0
      models/patient_models.go
  3. 33 2
      service/patient_service.go

+ 41 - 0
controllers/patient_api_controller.go Целия файл

@@ -141,6 +141,8 @@ func PatientApiRegistRouters() {
141 141
 
142 142
 	beego.Router("/api/patient/savepatientcriticalcalinformedone", &PatientApiController{}, "Post:SavePatientCriticalInformedOne")
143 143
 
144
+	beego.Router("/api/patient/getpatientcriticalonelist", &PatientApiController{}, "Get:GetPatientCriticalOneList")
145
+
144 146
 }
145 147
 func (c *PatientApiController) GetExportList() {
146 148
 	startTime := c.GetString("start_time")
@@ -6734,4 +6736,43 @@ func (c *PatientApiController) GetPatientCriticalList() {
6734 6736
 
6735 6737
 func (c *PatientApiController) SavePatientCriticalInformedOne() {
6736 6738
 
6739
+	orgId := c.GetAdminUserInfo().CurrentOrgId
6740
+	dataBody := make(map[string]interface{}, 0)
6741
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
6742
+	fmt.Println("err", err)
6743
+	content := dataBody["content"].(string)
6744
+
6745
+	criticalOne := models.XtPatientCriticalOne{
6746
+		UserOrgId: orgId,
6747
+		Content:   content,
6748
+		Status:    1,
6749
+		Ctime:     time.Now().Unix(),
6750
+		Mtime:     time.Now().Unix(),
6751
+	}
6752
+
6753
+	critical, _ := service.GetPatientCriticalByUserOrgId(orgId)
6754
+
6755
+	if critical.ID == 0 {
6756
+		service.CreatePatientCritical(criticalOne)
6757
+	}
6758
+
6759
+	if critical.ID > 0 {
6760
+		service.UpdatePatientCriticalOne(orgId, content)
6761
+	}
6762
+
6763
+	c.ServeSuccessJSON(map[string]interface{}{
6764
+		"criticalOne": criticalOne,
6765
+	})
6766
+
6767
+}
6768
+
6769
+func (c *PatientApiController) GetPatientCriticalOneList() {
6770
+
6771
+	orgId := c.GetAdminUserInfo().CurrentOrgId
6772
+
6773
+	list, _ := service.GetPatientCriticalOneList(orgId)
6774
+
6775
+	c.ServeSuccessJSON(map[string]interface{}{
6776
+		"list": list,
6777
+	})
6737 6778
 }

+ 13 - 0
models/patient_models.go Целия файл

@@ -2863,3 +2863,16 @@ type XtPatientCritical struct {
2863 2863
 func (XtPatientCritical) TableName() string {
2864 2864
 	return "xt_patient_critical"
2865 2865
 }
2866
+
2867
+type XtPatientCriticalOne struct {
2868
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
2869
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2870
+	Content   string `gorm:"column:content" json:"content" form:"content"`
2871
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
2872
+	Ctime     int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2873
+	Mtime     int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2874
+}
2875
+
2876
+func (XtPatientCriticalOne) TableName() string {
2877
+	return "xt_patient_critical_one"
2878
+}

+ 33 - 2
service/patient_service.go Целия файл

@@ -4104,9 +4104,9 @@ func GetBedDiatricFallassessmentList(patient_id int64, is_type int64, user_org_i
4104 4104
 	return list, total, err
4105 4105
 }
4106 4106
 
4107
-func GetPedPatientFallassessmentById(id int64) (models.XtPatientFallassessment, error) {
4107
+func GetPedPatientFallassessmentById(id int64) (models.XtPatientPedFallssessment, error) {
4108 4108
 
4109
-	fallassessment := models.XtPatientFallassessment{}
4109
+	fallassessment := models.XtPatientPedFallssessment{}
4110 4110
 
4111 4111
 	err := XTReadDB().Where("id = ? and status=1", id).Find(&fallassessment).Error
4112 4112
 
@@ -4141,3 +4141,34 @@ func UpdatePatientCritaicalInformed(id int64, content string) error {
4141 4141
 	err := XTWriteDB().Model(&models.XtPatientCritical{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"content": content}).Error
4142 4142
 	return err
4143 4143
 }
4144
+
4145
+func GetPatientCriticalByUserOrgId(user_org_id int64) (models.XtPatientCriticalOne, error) {
4146
+
4147
+	criticalOne := models.XtPatientCriticalOne{}
4148
+
4149
+	err := XTReadDB().Where("user_org_id = ? and status=1", user_org_id).Find(&criticalOne).Error
4150
+
4151
+	return criticalOne, err
4152
+}
4153
+
4154
+func CreatePatientCritical(patient models.XtPatientCriticalOne) error {
4155
+
4156
+	err := XTWriteDB().Create(&patient).Error
4157
+
4158
+	return err
4159
+}
4160
+
4161
+func UpdatePatientCriticalOne(user_org_id int64, content string) error {
4162
+
4163
+	err := XTWriteDB().Model(&models.XtPatientCriticalOne{}).Where("user_org_id = ? and status=1", user_org_id).Updates(map[string]interface{}{"content": content}).Error
4164
+	return err
4165
+}
4166
+
4167
+func GetPatientCriticalOneList(user_org_id int64) (models.XtPatientCriticalOne, error) {
4168
+
4169
+	criticalOne := models.XtPatientCriticalOne{}
4170
+
4171
+	err := XTReadDB().Where("user_org_id = ? and status =1", user_org_id).Find(&criticalOne).Error
4172
+
4173
+	return criticalOne, err
4174
+}