28169 2 mesi fa
parent
commit
343a50aba9

+ 34 - 0
controllers/patient_api_controller.go Vedi File

@@ -133,6 +133,8 @@ func PatientApiRegistRouters() {
133 133
 
134 134
 	beego.Router("api/patient/gettherapyinformed", &PatientApiController{}, "Get:GetTherapyInformed")
135 135
 
136
+	beego.Router("/api/patient/savemedicalhistory", &PatientApiController{}, "Post:SaveMedicalHistory")
137
+
136 138
 }
137 139
 func (c *PatientApiController) GetExportList() {
138 140
 	startTime := c.GetString("start_time")
@@ -6653,3 +6655,35 @@ func (c *PatientApiController) GetTherapyInformed() {
6653 6655
 		"list": theapyInformed,
6654 6656
 	})
6655 6657
 }
6658
+
6659
+func (c *PatientApiController) SaveMedicalHistory() {
6660
+
6661
+	orgId := c.GetAdminUserInfo().CurrentOrgId
6662
+	dataBody := make(map[string]interface{}, 0)
6663
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
6664
+	fmt.Println("err", err)
6665
+	content := dataBody["content"].(string)
6666
+	patient_id := int64(dataBody["patient_id"].(float64))
6667
+	medicalHistory := models.XtMedicalHistory{
6668
+		UserOrgId: orgId,
6669
+		PatientId: patient_id,
6670
+		Ctime:     time.Now().Unix(),
6671
+		Mtime:     0,
6672
+		Status:    1,
6673
+		Content:   content,
6674
+	}
6675
+
6676
+	//
6677
+	history, _ := service.GetPatientMedicalHistory(patient_id, orgId)
6678
+
6679
+	if history.ID > 0 {
6680
+		service.UpdatePatientMedicalHistory(history.ID, content)
6681
+	}
6682
+	if history.ID == 0 {
6683
+		service.CreatePatientMedicalHistory(medicalHistory)
6684
+	}
6685
+	c.ServeSuccessJSON(map[string]interface{}{
6686
+		"medicalHistory": medicalHistory,
6687
+	})
6688
+
6689
+}

+ 12 - 0
controllers/patient_dataconfig_api_controller.go Vedi File

@@ -50,6 +50,8 @@ func PatientDataConfigAPIControllerRegistRouters() {
50 50
 
51 51
 	beego.Router("/api/patient/getpatientdetailinformedconsent", &PatientDataConfigAPIController{}, "Get:GetPatientDetailInformedConsent")
52 52
 
53
+	beego.Router("/api/patient/getpatientmedicallist", &PatientDataConfigAPIController{}, "Get:GetPatientMedicalList")
54
+
53 55
 }
54 56
 
55 57
 type PatientDataConfigAPIController struct {
@@ -1614,3 +1616,13 @@ func (this *PatientDataConfigAPIController) GetPatientDetailInformedConsent() {
1614 1616
 		"patients": patients,
1615 1617
 	})
1616 1618
 }
1619
+
1620
+func (this *PatientDataConfigAPIController) GetPatientMedicalList() {
1621
+
1622
+	patient_id, _ := this.GetInt64("patient_id")
1623
+	orgId := this.GetAdminUserInfo().CurrentOrgId
1624
+	list, _ := service.GetPatientMedicalList(patient_id, orgId)
1625
+	this.ServeSuccessJSON(map[string]interface{}{
1626
+		"list": list,
1627
+	})
1628
+}

+ 14 - 0
models/patient_models.go Vedi File

@@ -2532,3 +2532,17 @@ type XtTheapyinformedPrint struct {
2532 2532
 func (XtTheapyinformedPrint) TableName() string {
2533 2533
 	return "xt_theapyinformed_print"
2534 2534
 }
2535
+
2536
+type XtMedicalHistory struct {
2537
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
2538
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2539
+	PatientId int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2540
+	Ctime     int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2541
+	Mtime     int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2542
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
2543
+	Content   string `gorm:"column:content" json:"content" form:"content"`
2544
+}
2545
+
2546
+func (XtMedicalHistory) TableName() string {
2547
+	return "xt_medical_history"
2548
+}

+ 31 - 0
service/patient_service.go Vedi File

@@ -3682,3 +3682,34 @@ func UpdateTheaphInformed(id int64, content string) error {
3682 3682
 	err := XTWriteDB().Model(&models.XtTheapyinformedPrint{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"content": content}).Error
3683 3683
 	return err
3684 3684
 }
3685
+
3686
+func GetPatientMedicalHistory(patient_id int64, user_org_id int64) (models.XtMedicalHistory, error) {
3687
+
3688
+	history := models.XtMedicalHistory{}
3689
+
3690
+	err := XTReadDB().Model(&history).Where("patient_id = ? and user_org_id = ? and status=1", patient_id, user_org_id).Find(&history).Error
3691
+
3692
+	return history, err
3693
+}
3694
+
3695
+func UpdatePatientMedicalHistory(id int64, content string) error {
3696
+
3697
+	history := models.XtMedicalHistory{}
3698
+
3699
+	err := XTWriteDB().Model(&history).Where("id = ? and status=1", id).Updates(map[string]interface{}{"content": content}).Error
3700
+	return err
3701
+}
3702
+
3703
+func CreatePatientMedicalHistory(history models.XtMedicalHistory) error {
3704
+
3705
+	err := XTWriteDB().Create(&history).Error
3706
+
3707
+	return err
3708
+}
3709
+
3710
+func GetPatientMedicalList(patient_id int64, user_org_id int64) (models.XtMedicalHistory, error) {
3711
+
3712
+	history := models.XtMedicalHistory{}
3713
+	err := XTReadDB().Where("patient_id = ? and user_org_id = ? and status=1", patient_id, user_org_id).Find(&history).Error
3714
+	return history, err
3715
+}