Sfoglia il codice sorgente

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

XMLWAN 4 anni fa
parent
commit
fdd3c93e43

+ 114 - 37
controllers/his_api_controller.go Vedi File

32
 	beego.Router("/api/hisprescription/delete", &HisApiController{}, "post:DeletePrescription")
32
 	beego.Router("/api/hisprescription/delete", &HisApiController{}, "post:DeletePrescription")
33
 	beego.Router("/api/advice/delete", &HisApiController{}, "post:DeleteDoctorAdvice")
33
 	beego.Router("/api/advice/delete", &HisApiController{}, "post:DeleteDoctorAdvice")
34
 	beego.Router("/api/project/delete", &HisApiController{}, "post:DeleteProject")
34
 	beego.Router("/api/project/delete", &HisApiController{}, "post:DeleteProject")
35
+	beego.Router("/api/addition_charge/delete", &HisApiController{}, "post:DeleteAddition")
35
 
36
 
36
 	beego.Router("/api/hisprescription/list", &HisApiController{}, "get:GetHisPrescriptionList")
37
 	beego.Router("/api/hisprescription/list", &HisApiController{}, "get:GetHisPrescriptionList")
37
 	beego.Router("/api/hisprescription/info", &HisApiController{}, "get:GetHisPrescriptionInfo")
38
 	beego.Router("/api/hisprescription/info", &HisApiController{}, "get:GetHisPrescriptionInfo")
145
 	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
146
 	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
146
 	lastPatientPrescriptionInfo, _ := service.FindLastPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
147
 	lastPatientPrescriptionInfo, _ := service.FindLastPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
147
 	order, _ := service.GetHisOrder(admin.CurrentOrgId, number, patient_id)
148
 	order, _ := service.GetHisOrder(admin.CurrentOrgId, number, patient_id)
148
-	addtions, _ := service.GetAllAdditionCharge(admin.CurrentOrgId, patient_id, recordDateTime)
149
+	//addtions, _ := service.GetAllAdditionCharge(admin.CurrentOrgId, patient_id, recordDateTime)
149
 
150
 
150
 	c.ServeSuccessJSON(map[string]interface{}{
151
 	c.ServeSuccessJSON(map[string]interface{}{
151
-		"his_info":        his_patient_info,
152
-		"xt_info":         xt_patient_info,
153
-		"prescription":    prescriptions,
154
-		"case_history":    case_history,
155
-		"info":            patientPrescriptionInfo,
156
-		"last_info":       lastPatientPrescriptionInfo,
157
-		"order":           order,
158
-		"addtions_charge": addtions,
152
+		"his_info":     his_patient_info,
153
+		"xt_info":      xt_patient_info,
154
+		"prescription": prescriptions,
155
+		"case_history": case_history,
156
+		"info":         patientPrescriptionInfo,
157
+		"last_info":    lastPatientPrescriptionInfo,
158
+		"order":        order,
159
 	})
159
 	})
160
 	return
160
 	return
161
 
161
 
200
 	diagnose := c.GetString("diagnose")
200
 	diagnose := c.GetString("diagnose")
201
 	sick_history := c.GetString("sick_history")
201
 	sick_history := c.GetString("sick_history")
202
 	doctor_id, _ := c.GetInt64("doctor", 0)
202
 	doctor_id, _ := c.GetInt64("doctor", 0)
203
-	department := c.GetString("department")
203
+	department, _ := c.GetInt64("department", 0)
204
 	his_patient_id, _ := c.GetInt64("his_patient_id")
204
 	his_patient_id, _ := c.GetInt64("his_patient_id")
205
 	dataBody := make(map[string]interface{}, 0)
205
 	dataBody := make(map[string]interface{}, 0)
206
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
206
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
386
 						}
386
 						}
387
 					}
387
 					}
388
 				}
388
 				}
389
+				if items["addition"] != nil && reflect.TypeOf(items["addition"]).String() == "[]interface {}" {
390
+					addition := items["addition"].([]interface{})
391
+					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
392
+					ctime := time.Now().Unix()
393
+					mtime := ctime
394
+					if len(addition) > 0 {
395
+						for _, item := range addition {
396
+							var s models.HisAdditionalCharge
397
+							s.PrescriptionId = prescription.ID
398
+							s.Status = 1
399
+							s.UserOrgId = adminInfo.CurrentOrgId
400
+							s.RecordDate = recordDateTime
401
+							s.CreatedTime = ctime
402
+							s.UpdatedTime = mtime
403
+							s.PatientId = patient_id
404
+							s.HisPatientId = his_patient_id
405
+							errcode := c.setAddtionWithJSON(&s, item.(map[string]interface{}))
406
+							if errcode > 0 {
407
+								c.ServeFailJSONWithSGJErrorCode(errcode)
408
+								return
409
+							}
410
+							service.CreateAdditionalCharge(&s)
411
+							var randNum int
412
+							randNum = rand.Intn(10000) + 1000
413
+							timestamp := time.Now().Unix()
414
+							tempTime := time.Unix(timestamp, 0)
415
+							timeFormat := tempTime.Format("20060102150405")
416
+							s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "3" + "-" + strconv.FormatInt(s.ID, 10)
417
+							service.CreateAdditionalCharge(&s)
418
+
419
+						}
420
+					}
421
+				}
422
+
389
 			}
423
 			}
390
 		}
424
 		}
391
 	}
425
 	}
864
 	return 0
898
 	return 0
865
 }
899
 }
866
 
900
 
901
+func (c *HisApiController) setAddtionWithJSON(additionalCharge *models.HisAdditionalCharge, json map[string]interface{}) int {
902
+	if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
903
+		id := int64(json["id"].(float64))
904
+		additionalCharge.ID = id
905
+	}
906
+	if json["item_id"] != nil || reflect.TypeOf(json["item_id"]).String() == "float64" {
907
+		item_id := int64(json["item_id"].(float64))
908
+		additionalCharge.ItemId = item_id
909
+	}
910
+	if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
911
+		price := int64(json["price"].(float64))
912
+		formatInt_price := strconv.FormatInt(price, 10)
913
+		float_price, _ := strconv.ParseFloat(formatInt_price, 64)
914
+		additionalCharge.Price = float_price
915
+	}
916
+	if json["count"] != nil && reflect.TypeOf(json["count"]).String() == "string" {
917
+		count, _ := json["count"].(string)
918
+		counts, _ := strconv.ParseInt(count, 10, 64)
919
+		additionalCharge.Count = counts
920
+	}
921
+	if json["item_name"] != nil && reflect.TypeOf(json["item_name"]).String() == "string" {
922
+		item_name, _ := json["item_name"].(string)
923
+		additionalCharge.ItemName = item_name
924
+	}
925
+
926
+	return 0
927
+}
928
+
867
 func (c *HisApiController) GetHisOrderList() {
929
 func (c *HisApiController) GetHisOrderList() {
868
 	adminUser := c.GetAdminUserInfo()
930
 	adminUser := c.GetAdminUserInfo()
869
 	org_id := adminUser.CurrentOrgId
931
 	org_id := adminUser.CurrentOrgId
1202
 		ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
1264
 		ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
1203
 
1265
 
1204
 		count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
1266
 		count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
1267
+
1268
+		department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
1269
+
1205
 		if count <= 0 {
1270
 		if count <= 0 {
1206
 			api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
1271
 			api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
1207
 				res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1272
 				res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
1208
 				"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
1273
 				"&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
1209
-				"&dept=" + patientPrescription.Departments + "&fixmedins_code=" + miConfig.Code
1274
+				"&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code
1210
 			resp, requestErr := http.Get(api)
1275
 			resp, requestErr := http.Get(api)
1211
 			if requestErr != nil {
1276
 			if requestErr != nil {
1212
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1277
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1256
 			err := service.CreateHisPatientTwo(&his)
1321
 			err := service.CreateHisPatientTwo(&his)
1257
 			if err == nil {
1322
 			if err == nil {
1258
 				api := "http://127.0.0.1:9531/" + "gdyb/four?psn_no=" + his.PsnNo +
1323
 				api := "http://127.0.0.1:9531/" + "gdyb/four?psn_no=" + his.PsnNo +
1259
-					"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + patientPrescription.Departments +
1324
+					"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
1260
 					"&diag=" + patientPrescription.Diagnosis + "&org_name=" + miConfig.OrgName + "&med_type=" + "11" + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code
1325
 					"&diag=" + patientPrescription.Diagnosis + "&org_name=" + miConfig.OrgName + "&med_type=" + "11" + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code
1261
 				resp, requestErr := http.Get(api)
1326
 				resp, requestErr := http.Get(api)
1262
 				if requestErr != nil {
1327
 				if requestErr != nil {
1345
 	recordDateTime := theTime.Unix()
1410
 	recordDateTime := theTime.Unix()
1346
 	adminUser := c.GetAdminUserInfo()
1411
 	adminUser := c.GetAdminUserInfo()
1347
 	prescriptions, _ := service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
1412
 	prescriptions, _ := service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
1348
-	additions, _ := service.GetAllAdditionCharge(adminUser.CurrentOrgId, id, recordDateTime)
1349
 
1413
 
1350
 	his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
1414
 	his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
1351
 
1415
 
1372
 	data["fixmedins_code"] = miConfig.Code
1436
 	data["fixmedins_code"] = miConfig.Code
1373
 
1437
 
1374
 	var ids []int64
1438
 	var ids []int64
1375
-	var idsTwo []int64
1376
-
1439
+	//var idsTwo []int64
1440
+	//
1377
 	for _, item := range prescriptions {
1441
 	for _, item := range prescriptions {
1378
 		ids = append(ids, item.ID)
1442
 		ids = append(ids, item.ID)
1379
 	}
1443
 	}
1380
 
1444
 
1381
-	for _, item := range additions {
1382
-		idsTwo = append(idsTwo, item.ID)
1383
-	}
1384
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1445
 	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1385
 
1446
 
1386
 	if config.IsOpen == 1 { //对接了医保,走医保流程
1447
 	if config.IsOpen == 1 { //对接了医保,走医保流程
1631
 					total = total + (subItem.Price * float64(subItem.Count))
1692
 					total = total + (subItem.Price * float64(subItem.Count))
1632
 				}
1693
 				}
1633
 			}
1694
 			}
1634
-		}
1635
-
1636
-		for _, item := range additions {
1637
-			total = total + item.Price
1638
 
1695
 
1696
+			for _, subItem := range item.HisAdditionalCharge {
1697
+				total = total + (subItem.Price * float64(subItem.Count))
1698
+			}
1639
 		}
1699
 		}
1640
 
1700
 
1641
 		allTotal := fmt.Sprintf("%.2f", total)
1701
 		allTotal := fmt.Sprintf("%.2f", total)
1679
 
1739
 
1680
 			if item.Type == 2 { //项目
1740
 			if item.Type == 2 { //项目
1681
 				for _, subItem := range item.HisPrescriptionProject {
1741
 				for _, subItem := range item.HisPrescriptionProject {
1742
+
1682
 					cus := &Custom{
1743
 					cus := &Custom{
1683
 						AdviceId:         0,
1744
 						AdviceId:         0,
1684
 						ProjectId:        subItem.ID,
1745
 						ProjectId:        subItem.ID,
1693
 					customs = append(customs, cus)
1754
 					customs = append(customs, cus)
1694
 				}
1755
 				}
1695
 			}
1756
 			}
1696
-		}
1697
 
1757
 
1698
-		for _, item := range additions {
1699
-			cus := &Custom{
1700
-				ItemId:           item.ID,
1701
-				AdviceId:         0,
1702
-				ProjectId:        0,
1703
-				DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
1704
-				Cut:              fmt.Sprintf("%.2f", float64(1)),
1705
-				FeedetlSn:        item.FeedetlSn,
1706
-				Price:            fmt.Sprintf("%.2f", float64(item.Price)),
1707
-				MedListCodg:      item.XtHisAddtionConfig.Code,
1708
-				Type:             3,
1758
+			for _, item := range item.HisAdditionalCharge {
1759
+				cus := &Custom{
1760
+					ItemId:           item.ID,
1761
+					AdviceId:         0,
1762
+					ProjectId:        0,
1763
+					DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
1764
+					Cut:              fmt.Sprintf("%.2f", float64(item.Count)),
1765
+					FeedetlSn:        item.FeedetlSn,
1766
+					Price:            fmt.Sprintf("%.2f", float64(item.Price)),
1767
+					MedListCodg:      item.XtHisAddtionConfig.Code,
1768
+					Type:             3,
1769
+				}
1770
+
1771
+				customs = append(customs, cus)
1709
 			}
1772
 			}
1710
 
1773
 
1711
-			customs = append(customs, cus)
1712
 		}
1774
 		}
1713
 
1775
 
1714
 		for _, item := range customs {
1776
 		for _, item := range customs {
1730
 			} else if item.Type == 3 {
1792
 			} else if item.Type == 3 {
1731
 				advice_id = 0
1793
 				advice_id = 0
1732
 				item_id = item.ItemId
1794
 				item_id = item.ItemId
1733
-
1734
 				project_id = 0
1795
 				project_id = 0
1735
 			}
1796
 			}
1736
 
1797
 
1758
 			}
1819
 			}
1759
 			service.CreateOrderInfo(info)
1820
 			service.CreateOrderInfo(info)
1760
 		}
1821
 		}
1761
-		err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, idsTwo, chrg_bchno)
1822
+		//err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
1762
 		err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
1823
 		err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
1763
 		err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
1824
 		err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
1764
 		err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
1825
 		err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
1856
 		"additional_charges": additionalCharges,
1917
 		"additional_charges": additionalCharges,
1857
 	})
1918
 	})
1858
 }
1919
 }
1920
+
1921
+func (this *HisApiController) DeleteAddition() {
1922
+	id, _ := this.GetInt64("id")
1923
+	//TODO 需要判断是否已经结算
1924
+	err := service.DelelteAddition(id, this.GetAdminUserInfo().CurrentOrgId)
1925
+	if err == nil {
1926
+		this.ServeSuccessJSON(map[string]interface{}{
1927
+			"msg": "删除成功",
1928
+		})
1929
+		return
1930
+	} else {
1931
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1932
+		return
1933
+	}
1934
+
1935
+}

+ 25 - 13
controllers/his_project_api_controller.go Vedi File

750
 			IsNeedCostOfProduction: cost_checked,
750
 			IsNeedCostOfProduction: cost_checked,
751
 			TreatmentCost:          medicalExpense_float,
751
 			TreatmentCost:          medicalExpense_float,
752
 			MedicalInsuranceNumber: medicalinsurancecard,
752
 			MedicalInsuranceNumber: medicalinsurancecard,
753
-			Name:                   name,
754
-			RegisterType:           register,
755
-			RegisterCost:           registrationfees_float,
756
-			BalanceAccountsType:    settlementValue,
757
-			Gender:                 sex,
758
-			Total:                  totals_float,
759
-			UserOrgId:              orgId,
760
-			Status:                 1,
761
-			RecordDate:             nowtime,
762
-			IsReturn:               1,
763
-			Ctime:                  time.Now().Unix(),
764
-			Phone:                  phone,
765
-			SocialType:             social_type,
753
+			Name:                name,
754
+			RegisterType:        register,
755
+			RegisterCost:        registrationfees_float,
756
+			BalanceAccountsType: settlementValue,
757
+			Gender:              sex,
758
+			Total:               totals_float,
759
+			UserOrgId:           orgId,
760
+			Status:              1,
761
+			RecordDate:          nowtime,
762
+			IsReturn:            1,
763
+			Ctime:               time.Now().Unix(),
764
+			Phone:               phone,
765
+			SocialType:          social_type,
766
 		}
766
 		}
767
 		err := service.CreateHisPatient(&patient)
767
 		err := service.CreateHisPatient(&patient)
768
 		lastPatient, err := service.GetLastPatient(orgId)
768
 		lastPatient, err := service.GetLastPatient(orgId)
809
 			RecordDate:             nowtime,
809
 			RecordDate:             nowtime,
810
 			Status:                 1,
810
 			Status:                 1,
811
 			IsReturn:               1,
811
 			IsReturn:               1,
812
+			Name:                name,
813
+			RegisterType:        register,
814
+			RegisterCost:        registrationfees_float,
815
+			BalanceAccountsType: settlementValue,
816
+			Gender:              sex,
817
+			Total:               totals_float,
818
+			UserOrgId:           orgId,
819
+			PatientId:           bloodPatient.ID,
820
+			Ctime:               time.Now().Unix(),
821
+			Phone:               phone,
822
+			SocialType:          social_type,
823
+			RecordDate:          nowtime,
812
 		}
824
 		}
813
 		err := service.CreateHisPatient(&patient)
825
 		err := service.CreateHisPatient(&patient)
814
 		lastPatient, err := service.GetLastPatient(orgId)
826
 		lastPatient, err := service.GetLastPatient(orgId)

+ 0 - 3
controllers/manager_center_api_controller.go Vedi File

76
 
76
 
77
 func (c *ManagerCenterApiController) CreateBaseDrugLib() {
77
 func (c *ManagerCenterApiController) CreateBaseDrugLib() {
78
 	drug_name := c.GetString("drug_name")
78
 	drug_name := c.GetString("drug_name")
79
-	fmt.Println("0000000")
80
-
81
-	fmt.Println(drug_name)
82
 	pinyin := c.GetString("pinyin")
79
 	pinyin := c.GetString("pinyin")
83
 	wubi := c.GetString("wubi")
80
 	wubi := c.GetString("wubi")
84
 	drug_alias := c.GetString("drug_alias")
81
 	drug_alias := c.GetString("drug_alias")

+ 2 - 2
controllers/mobile_api_controllers/dialysis_api_controller.go Vedi File

1136
 		PreImpulse:                 pre_impulse,
1136
 		PreImpulse:                 pre_impulse,
1137
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
1137
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
1138
 		AnticoagulantStopTimeMin:   anticoagulant_stop_time_min,
1138
 		AnticoagulantStopTimeMin:   anticoagulant_stop_time_min,
1139
-		Blood:                      blood,
1139
+		Blood: blood,
1140
 	}
1140
 	}
1141
 
1141
 
1142
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1142
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1899
 		ALiquid:                   a_liquid,
1899
 		ALiquid:                   a_liquid,
1900
 		AnticoagulantStopTimeMin:  anticoagulant_stop_time_min,
1900
 		AnticoagulantStopTimeMin:  anticoagulant_stop_time_min,
1901
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
1901
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
1902
-		Blood:                     blood,
1902
+		Blood: blood,
1903
 	}
1903
 	}
1904
 
1904
 
1905
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1905
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)

+ 4 - 2
models/his_models.go Vedi File

261
 	Diagnosis          string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
261
 	Diagnosis          string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
262
 	RegisterType       string `gorm:"column:register_type" json:"register_type" form:"register_type"`
262
 	RegisterType       string `gorm:"column:register_type" json:"register_type" form:"register_type"`
263
 	Doctor             string `gorm:"column:doctor" json:"doctor" form:"doctor"`
263
 	Doctor             string `gorm:"column:doctor" json:"doctor" form:"doctor"`
264
-	Departments        string `gorm:"column:departments" json:"departments" form:"departments"`
264
+	Departments        int64  `gorm:"column:departments" json:"departments" form:"departments"`
265
 	SickHistory        string `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
265
 	SickHistory        string `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
266
 	PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
266
 	PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
267
 	PrescriptionStatus int64  `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
267
 	PrescriptionStatus int64  `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
294
 	HisPatient             VMHisPatient              `gorm:"ForeignKey:PatientId;AssociationForeignKey:patient_id" json:"hisPatient"`
294
 	HisPatient             VMHisPatient              `gorm:"ForeignKey:PatientId;AssociationForeignKey:patient_id" json:"hisPatient"`
295
 	HisDoctorAdviceInfo    []*HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
295
 	HisDoctorAdviceInfo    []*HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
296
 	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
296
 	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
297
-	XtHisAdditionalCharge  []*XtHisAdditionalCharge  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"additionalcharge"`
297
+	HisAdditionalCharge    []*HisAdditionalCharge    `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"addition"`
298
 }
298
 }
299
 
299
 
300
 func (HisPrescription) TableName() string {
300
 func (HisPrescription) TableName() string {
376
 	PrescriptionNumber string             `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
376
 	PrescriptionNumber string             `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
377
 	XtHisAddtionConfig XtHisAddtionConfig `gorm:"ForeignKey:ID;AssociationForeignKey:ItemId" json:"config"`
377
 	XtHisAddtionConfig XtHisAddtionConfig `gorm:"ForeignKey:ID;AssociationForeignKey:ItemId" json:"config"`
378
 	FeedetlSn          string             `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
378
 	FeedetlSn          string             `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
379
+	PrescriptionId     int64              `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
380
+	Count              int64              `gorm:"column:count" json:"count" form:"count"`
379
 }
381
 }
380
 
382
 
381
 func (HisAdditionalCharge) TableName() string {
383
 func (HisAdditionalCharge) TableName() string {

+ 29 - 14
service/gdyb_service.go Vedi File

349
 	for _, item := range hisPrescription {
349
 	for _, item := range hisPrescription {
350
 		if item.Type == 1 { //药品
350
 		if item.Type == 1 { //药品
351
 			for _, subItem := range item.HisDoctorAdviceInfo {
351
 			for _, subItem := range item.HisDoctorAdviceInfo {
352
-
353
-				//var randNum int
354
-				//randNum = rand.Intn(10000) + 1000
355
-				cus := &Custom{
356
-					DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
357
-					Cut:              fmt.Sprintf("%.2f", subItem.PrescribingNumber),
358
-					FeedetlSn:        subItem.FeedetlSn,
359
-					Price:            fmt.Sprintf("%.2f", subItem.Price),
360
-					MedListCodg:      subItem.MedListCodg,
352
+				if len(subItem.MedListCodg) > 0 {
353
+					//var randNum int
354
+					//randNum = rand.Intn(10000) + 1000
355
+					cus := &Custom{
356
+						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
357
+						Cut:              fmt.Sprintf("%.2f", subItem.PrescribingNumber),
358
+						FeedetlSn:        subItem.FeedetlSn,
359
+						Price:            fmt.Sprintf("%.2f", subItem.Price),
360
+						MedListCodg:      subItem.MedListCodg,
361
+					}
362
+
363
+					customs = append(customs, cus)
361
 				}
364
 				}
362
-
363
-				customs = append(customs, cus)
364
 			}
365
 			}
365
 		}
366
 		}
366
 
367
 
368
 			for _, subItem := range item.HisPrescriptionProject {
369
 			for _, subItem := range item.HisPrescriptionProject {
369
 				//var randNum int
370
 				//var randNum int
370
 				//randNum = rand.Intn(10000) + 1000
371
 				//randNum = rand.Intn(10000) + 1000
372
+				if len(subItem.MedListCodg) > 0 {
373
+
374
+					cus := &Custom{
375
+						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
376
+						Cut:              fmt.Sprintf("%.2f", float64(subItem.Count)),
377
+						FeedetlSn:        subItem.FeedetlSn,
378
+						Price:            fmt.Sprintf("%.2f", float64(subItem.Price)),
379
+						MedListCodg:      subItem.MedListCodg,
380
+					}
381
+					customs = append(customs, cus)
382
+				}
383
+			}
384
+		}
385
+
386
+		for _, subItem := range item.HisAdditionalCharge {
387
+			if len(subItem.XtHisAddtionConfig.Code) > 0 {
371
 				cus := &Custom{
388
 				cus := &Custom{
372
 					DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
389
 					DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
373
 					Cut:              fmt.Sprintf("%.2f", float64(subItem.Count)),
390
 					Cut:              fmt.Sprintf("%.2f", float64(subItem.Count)),
374
 					FeedetlSn:        subItem.FeedetlSn,
391
 					FeedetlSn:        subItem.FeedetlSn,
375
 					Price:            fmt.Sprintf("%.2f", float64(subItem.Price)),
392
 					Price:            fmt.Sprintf("%.2f", float64(subItem.Price)),
376
-					MedListCodg:      subItem.MedListCodg,
393
+					MedListCodg:      subItem.XtHisAddtionConfig.Code,
377
 				}
394
 				}
378
-				fmt.Println(cus.FeedetlSn)
379
-
380
 				customs = append(customs, cus)
395
 				customs = append(customs, cus)
381
 			}
396
 			}
382
 		}
397
 		}

+ 7 - 3
service/his_service.go Vedi File

194
 
194
 
195
 func GetHisPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
195
 func GetHisPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
196
 	err = readDb.Model(&models.HisPrescription{}).
196
 	err = readDb.Model(&models.HisPrescription{}).
197
+		Preload("HisAdditionalCharge", "status = 1 AND user_org_id = ?", org_id).
197
 		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
198
 		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
198
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
199
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
199
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
200
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
370
 	Diagnosis             string                       `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
371
 	Diagnosis             string                       `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
371
 	RegisterType          string                       `gorm:"column:register_type" json:"register_type" form:"register_type"`
372
 	RegisterType          string                       `gorm:"column:register_type" json:"register_type" form:"register_type"`
372
 	Doctor                string                       `gorm:"column:doctor" json:"doctor" form:"doctor"`
373
 	Doctor                string                       `gorm:"column:doctor" json:"doctor" form:"doctor"`
373
-	Departments           string                       `gorm:"column:departments" json:"departments" form:"departments"`
374
+	Departments           int64                        `gorm:"column:departments" json:"departments" form:"departments"`
374
 	SickHistory           string                       `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
375
 	SickHistory           string                       `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
375
 	Patients              models.Patients              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
376
 	Patients              models.Patients              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
376
 	HisPatient            models.HisPatient            `gorm:"ForeignKey:HisPatientId,RecordDate;AssociationForeignKey:ID,RecordDate" json:"his_patient"`
377
 	HisPatient            models.HisPatient            `gorm:"ForeignKey:HisPatientId,RecordDate;AssociationForeignKey:ID,RecordDate" json:"his_patient"`
450
 func UpdataOrderStatusTwo(number string, user_org_id int64) (err error) {
451
 func UpdataOrderStatusTwo(number string, user_org_id int64) (err error) {
451
 	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 2, "mtime": time.Now().Unix()}).Error
452
 	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 2, "mtime": time.Now().Unix()}).Error
452
 	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 3, "mtime": time.Now().Unix()}).Error
453
 	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 3, "mtime": time.Now().Unix()}).Error
453
-	err = writeDb.Model(&models.HisAdditionalCharge{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 2, "mtime": time.Now().Unix()}).Error
454
-
455
 	return
454
 	return
456
 }
455
 }
457
 
456
 
526
 	return
525
 	return
527
 
526
 
528
 }
527
 }
528
+
529
+func DelelteAddition(id int64, user_org_id int64) (err error) {
530
+	err = writeDb.Model(&models.HisAdditionalCharge{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
531
+	return
532
+}