Bläddra i källkod

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

csx 4 år sedan
förälder
incheckning
358372df1d

+ 7 - 3
controllers/data_api_controller.go Visa fil

@@ -1015,8 +1015,7 @@ func (c *DataApiController) UpdateAdviceTemplate() {
1015 1015
 
1016 1016
 	adminUserInfo := c.GetAdminUserInfo()
1017 1017
 	id, _ := c.GetInt64("id", 0)
1018
-	drug_id, _ := c.GetInt64("drug_id", 0)
1019
-	fmt.Println("drug_id-------", drug_id)
1018
+
1020 1019
 	if id <= 0 {
1021 1020
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1022 1021
 		return
@@ -1070,7 +1069,8 @@ func (c *DataApiController) UpdateAdviceTemplate() {
1070 1069
 	template.FrequencyType = templatedata.FrequencyType
1071 1070
 	template.DayCount = templatedata.DayCount
1072 1071
 	template.WeekDays = templatedata.WeekDays
1073
-	template.DrugId = drug_id
1072
+	template.DrugId = template.DrugId
1073
+	template.Way = template.Way
1074 1074
 
1075 1075
 	err = service.UpdateAdviceTemplate(template)
1076 1076
 	if err != nil {
@@ -1251,6 +1251,8 @@ func (c *DataApiController) CreateSubAdviceTemplate() {
1251 1251
 	execution_frequency := c.GetString("execution_frequency")
1252 1252
 	template_id, _ := c.GetInt64("template_id", 0)
1253 1253
 	parent_id, _ := c.GetInt64("parent_id", 0)
1254
+	drug_id, _ := c.GetInt64("drug_id")
1255
+	way, _ := c.GetInt64("way")
1254 1256
 	adminUserInfo := c.GetAdminUserInfo()
1255 1257
 
1256 1258
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
@@ -1283,6 +1285,8 @@ func (c *DataApiController) CreateSubAdviceTemplate() {
1283 1285
 		ExecutionFrequency:    execution_frequency,
1284 1286
 		TemplateId:            template_id,
1285 1287
 		ParentId:              parent_id,
1288
+		DrugId:                drug_id,
1289
+		Way:                   way,
1286 1290
 	}
1287 1291
 
1288 1292
 	if template.AdviceName == "" {

+ 7 - 1
controllers/dialysis_api_controller.go Visa fil

@@ -1046,7 +1046,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1046 1046
 	catheter_suture_other := c.GetString("catheter_suture_other")
1047 1047
 	edema := c.GetString("edema")
1048 1048
 	urine_volume, _ := c.GetFloat("urine_volume", 0)
1049
-
1049
+	special_treatment := c.GetString("special_treatment")
1050 1050
 	assessmentBeforeDislysis := models.PredialysisEvaluation{
1051 1051
 		DialysisCount:                  dialysis_count,
1052 1052
 		EmergencyTreatment:             emergency_treatment,
@@ -1102,6 +1102,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1102 1102
 		CatheterSutureOther:            catheter_suture_other,
1103 1103
 		Edema:                          edema,
1104 1104
 		UrineVolume:                    urine_volume,
1105
+		SpecialTreatment:               special_treatment,
1105 1106
 	}
1106 1107
 
1107 1108
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
@@ -2571,6 +2572,11 @@ func (c *DialysisApiController) CreateRemindDoctorAdvice() {
2571 2572
 			advice.DrugId = drug_id
2572 2573
 		}
2573 2574
 
2575
+		if adviceNameM["drug_name_id"] != nil || reflect.TypeOf(adviceNameM["drug_name_id"]).String() == "float64" {
2576
+			drug_name_id := int64(adviceNameM["drug_name_id"].(float64))
2577
+			advice.DrugNameId = drug_name_id
2578
+		}
2579
+
2574 2580
 		if adviceNameM["week_day"] != nil && reflect.TypeOf(adviceNameM["week_day"]).String() == "string" {
2575 2581
 			week_day, _ := adviceNameM["week_day"].(string)
2576 2582
 			advice.WeekDay = week_day

+ 0 - 30
controllers/new_mobile_api_controllers/dialysis_parameter_api_controller.go Visa fil

@@ -149,7 +149,6 @@ func (this *DialysisParamerterApiController) GetMobileCollectList() {
149 149
 	fmt.Println(start_time)
150 150
 	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
151 151
 	orgId := this.GetMobileAdminUserInfo().Org.Id
152
-	//endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 23:59:59", loc)
153 152
 	keyword := this.GetString("keyword")
154 153
 	//获取透析参数数据
155 154
 	schedule, err, _ := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
@@ -158,37 +157,9 @@ func (this *DialysisParamerterApiController) GetMobileCollectList() {
158 157
 	var vlist []interface{}
159 158
 	var clist []interface{}
160 159
 	for _, item := range patient {
161
-
162
-		////查询当前日期的病人是否存在数据
163
-		//_, errcode := service.GetToDayDialysisPrescription(item.PatientId, orgId, startime.Unix())
164
-		//if errcode == gorm.ErrRecordNotFound {
165
-		//	//查询每个病人透析处方的最后一次数据
166
-		//	prescription, _ := service.GetLastDialysisPrescription(item.PatientId, orgId)
167
-		//	vlist = append(vlist, prescription)
168
-		//} else if errcode == nil {
169
-		//	//获取当前日期
170
-		//	prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgId, startime.Unix())
171
-		//	vlist = append(vlist, prescription)
172
-		//}
173
-
174
-		//查询每个病人当前日期是否存在数据
175
-		//_, errco := service.GetAotoMaticReduceByPatientId(item.PatientId, orgId, startime.Unix(), endtime.Unix())
176
-		//if errco == gorm.ErrRecordNotFound {
177
-		//	reduece, _ := service.GetMaticReduece(item.PatientId, orgId)
178
-		//	clist = append(clist, reduece)
179
-		//} else if errco == nil {
180
-		//	reduece, _ := service.GetMaticeReduceByPatientId(item.PatientId, orgId, startime.Unix(), endtime.Unix())
181
-		//	clist = append(clist, reduece)
182
-		//}
183
-
184 160
 		prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgId, startime.Unix())
185 161
 		vlist = append(vlist, prescription)
186
-		//reduece, _ := service.GetMaticeReduceByPatientId(item.PatientId, orgId, startime.Unix(), endtime.Unix())
187
-		//clist = append(clist, reduece)
188 162
 	}
189
-	//获取透析耗材数据
190
-	//consumables, err := service.GetDialysisConsumables(startime.Unix(), endtime.Unix(), orgId)
191
-
192 163
 	_, errors := service.FindStockOutByIsSys(orgId, 1, startime.Unix())
193 164
 
194 165
 	goodTypes, _ := service.FindAllGoodType(orgId) //two, err, i := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
@@ -196,7 +167,6 @@ func (this *DialysisParamerterApiController) GetMobileCollectList() {
196 167
 	if errors == gorm.ErrRecordNotFound {
197 168
 		dialysisGoods, _, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
198 169
 		for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
199
-
200 170
 			goodUser, _ := service.GetLastDialysisGoods(item.PatientId, orgId, startime.Unix())
201 171
 			lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, orgId, startime.Unix())
202 172
 			item.LastAutomaticReduceDetail = goodUser

+ 315 - 399
controllers/patient_api_controller.go Visa fil

@@ -254,29 +254,29 @@ func (c *PatientApiController) CreatePatient() {
254 254
 	//获取老表的最后一条数据
255 255
 	patients, err := service.GetLastPatientData(adminUserInfo.CurrentOrgId)
256 256
 	patientsNew := models.XtPatientsNew{
257
-		UserOrgId:                    adminUserInfo.CurrentOrgId,
258
-		UserId:                       0,
259
-		Avatar:                       patients.Avatar,
260
-		PatientType:                  patients.PatientType,
261
-		DialysisNo:                   patients.DialysisNo,
262
-		AdmissionNumber:              patients.AdmissionNumber,
263
-		Source:                       patients.Source,
264
-		Lapseto:                      patients.Lapseto,
265
-		PartitionId:                  patients.PartitionId,
266
-		BedId:                        patients.BedId,
267
-		Name:                         patients.Name,
268
-		Alias:                        patients.Alias,
269
-		Gender:                       patients.Gender,
270
-		MaritalStatus:                patients.MaritalStatus,
271
-		IdCardNo:                     patients.IdCardNo,
272
-		Birthday:                     patients.Birthday,
273
-		ReimbursementWayId:           patients.ReimbursementWayId,
274
-		HealthCareType:               patients.HealthCareType,
275
-		HealthCareNo:                 patients.HealthCareNo,
276
-		HealthCareDueDate:            patients.HealthCareDueDate,
277
-		Height:                       patients.Height,
278
-		BloodType:                    patients.BloodType,
279
-		Rh:                           patients.Rh,
257
+		UserOrgId:          adminUserInfo.CurrentOrgId,
258
+		UserId:             0,
259
+		Avatar:             patients.Avatar,
260
+		PatientType:        patients.PatientType,
261
+		DialysisNo:         patients.DialysisNo,
262
+		AdmissionNumber:    patients.AdmissionNumber,
263
+		Source:             patients.Source,
264
+		Lapseto:            patients.Lapseto,
265
+		PartitionId:        patients.PartitionId,
266
+		BedId:              patients.BedId,
267
+		Name:               patients.Name,
268
+		Alias:              patients.Alias,
269
+		Gender:             patients.Gender,
270
+		MaritalStatus:      patients.MaritalStatus,
271
+		IdCardNo:           patients.IdCardNo,
272
+		Birthday:           patients.Birthday,
273
+		ReimbursementWayId: patients.ReimbursementWayId,
274
+		HealthCareType:     patients.HealthCareType,
275
+		HealthCareNo:       patients.HealthCareNo,
276
+		HealthCareDueDate:  patients.HealthCareDueDate,
277
+		Height:             patients.Height,
278
+		BloodType:          patients.BloodType,
279
+		Rh:                 patients.Rh,
280 280
 		HealthCareDueAlertDate:       patients.HealthCareDueAlertDate,
281 281
 		EducationLevel:               patients.EducationLevel,
282 282
 		Profession:                   patients.Profession,
@@ -322,28 +322,28 @@ func (c *PatientApiController) CreatePatient() {
322 322
 		Nation:                       patients.Nation,
323 323
 		NativePlace:                  patients.NativePlace,
324 324
 		Age:                          patients.Age,
325
-		InfectiousNextRecordTime:     patients.InfectiousNextRecordTime,
326
-		IsInfectious:                 patients.IsInfectious,
327
-		RemindCycle:                  patients.RemindCycle,
328
-		ResponseResult:               patients.ResponseResult,
329
-		IsOpenRemind:                 patients.IsOpenRemind,
330
-		FirstTreatmentDate:           patients.FirstTreatmentDate,
331
-		DialysisAge:                  patients.DialysisAge,
332
-		ExpenseKind:                  patients.ExpenseKind,
333
-		TellPhone:                    patients.TellPhone,
334
-		ContactName:                  patients.ContactName,
335
-		BloodPatients:                1,
336
-		SlowPatients:                 0,
337
-		MemberPatients:               0,
338
-		EcommerPatients:              "",
339
-		BloodId:                      patients.ID,
340
-		SlowId:                       0,
341
-		MemberId:                     0,
342
-		MemberFistdate:               0,
343
-		MemberPatienttype:            0,
344
-		MemberTreatement:             0,
345
-		EquitmentId:                  "",
346
-		UserSysBeforeCount:           patient.UserSysBeforeCount,
325
+		InfectiousNextRecordTime: patients.InfectiousNextRecordTime,
326
+		IsInfectious:             patients.IsInfectious,
327
+		RemindCycle:              patients.RemindCycle,
328
+		ResponseResult:           patients.ResponseResult,
329
+		IsOpenRemind:             patients.IsOpenRemind,
330
+		FirstTreatmentDate:       patients.FirstTreatmentDate,
331
+		DialysisAge:              patients.DialysisAge,
332
+		ExpenseKind:              patients.ExpenseKind,
333
+		TellPhone:                patients.TellPhone,
334
+		ContactName:              patients.ContactName,
335
+		BloodPatients:            1,
336
+		SlowPatients:             0,
337
+		MemberPatients:           0,
338
+		EcommerPatients:          "",
339
+		BloodId:                  patients.ID,
340
+		SlowId:                   0,
341
+		MemberId:                 0,
342
+		MemberFistdate:           0,
343
+		MemberPatienttype:        0,
344
+		MemberTreatement:         0,
345
+		EquitmentId:              "",
346
+		UserSysBeforeCount:       patient.UserSysBeforeCount,
347 347
 	}
348 348
 
349 349
 	err = service.CreatePatientsNew(&patientsNew)
@@ -481,28 +481,28 @@ func (c *PatientApiController) EditPatient() {
481 481
 		return
482 482
 	}
483 483
 	patientsNew := models.XtPatientsNew{
484
-		UserOrgId:                 patient.UserOrgId,
485
-		UserId:                    patient.UserId,
486
-		Avatar:                    patient.Avatar,
487
-		PatientType:               patient.PatientType,
488
-		DialysisNo:                patient.DialysisNo,
489
-		AdmissionNumber:           patient.AdmissionNumber,
490
-		Source:                    patient.Source,
491
-		PartitionId:               patient.PartitionId,
492
-		BedId:                     patient.BedId,
493
-		Name:                      patient.Name,
494
-		Alias:                     patient.Alias,
495
-		Gender:                    patient.Gender,
496
-		MaritalStatus:             patient.MaritalStatus,
497
-		IdCardNo:                  patient.IdCardNo,
498
-		Birthday:                  patient.Birthday,
499
-		ReimbursementWayId:        patient.ReimbursementWayId,
500
-		HealthCareType:            patient.HealthCareType,
501
-		HealthCareNo:              patient.HealthCareNo,
502
-		HealthCareDueDate:         patient.HealthCareDueDate,
503
-		Height:                    patient.Height,
504
-		BloodType:                 patient.BloodType,
505
-		Rh:                        patient.Rh,
484
+		UserOrgId:          patient.UserOrgId,
485
+		UserId:             patient.UserId,
486
+		Avatar:             patient.Avatar,
487
+		PatientType:        patient.PatientType,
488
+		DialysisNo:         patient.DialysisNo,
489
+		AdmissionNumber:    patient.AdmissionNumber,
490
+		Source:             patient.Source,
491
+		PartitionId:        patient.PartitionId,
492
+		BedId:              patient.BedId,
493
+		Name:               patient.Name,
494
+		Alias:              patient.Alias,
495
+		Gender:             patient.Gender,
496
+		MaritalStatus:      patient.MaritalStatus,
497
+		IdCardNo:           patient.IdCardNo,
498
+		Birthday:           patient.Birthday,
499
+		ReimbursementWayId: patient.ReimbursementWayId,
500
+		HealthCareType:     patient.HealthCareType,
501
+		HealthCareNo:       patient.HealthCareNo,
502
+		HealthCareDueDate:  patient.HealthCareDueDate,
503
+		Height:             patient.Height,
504
+		BloodType:          patient.BloodType,
505
+		Rh:                 patient.Rh,
506 506
 		HealthCareDueAlertDate:    patient.HealthCareDueAlertDate,
507 507
 		EducationLevel:            patient.EducationLevel,
508 508
 		Profession:                patient.Profession,
@@ -544,19 +544,19 @@ func (c *PatientApiController) EditPatient() {
544 544
 		Nation:                    patient.Nation,
545 545
 		NativePlace:               patient.NativePlace,
546 546
 		Age:                       patient.Age,
547
-		InfectiousNextRecordTime:  patient.InfectiousNextRecordTime,
548
-		IsInfectious:              patient.IsInfectious,
549
-		RemindCycle:               patient.RemindCycle,
550
-		ResponseResult:            patient.ResponseResult,
551
-		IsOpenRemind:              patient.IsOpenRemind,
552
-		FirstTreatmentDate:        patient.FirstTreatmentDate,
553
-		DialysisAge:               patient.DialysisAge,
554
-		ExpenseKind:               patient.ExpenseKind,
555
-		TellPhone:                 patient.TellPhone,
556
-		ContactName:               patient.ContactName,
557
-		UpdatedTime:               time.Now().Unix(),
558
-		BloodPatients:             1,
559
-		Lapseto:                   patient.Lapseto,
547
+		InfectiousNextRecordTime: patient.InfectiousNextRecordTime,
548
+		IsInfectious:             patient.IsInfectious,
549
+		RemindCycle:              patient.RemindCycle,
550
+		ResponseResult:           patient.ResponseResult,
551
+		IsOpenRemind:             patient.IsOpenRemind,
552
+		FirstTreatmentDate:       patient.FirstTreatmentDate,
553
+		DialysisAge:              patient.DialysisAge,
554
+		ExpenseKind:              patient.ExpenseKind,
555
+		TellPhone:                patient.TellPhone,
556
+		ContactName:              patient.ContactName,
557
+		UpdatedTime:              time.Now().Unix(),
558
+		BloodPatients:            1,
559
+		Lapseto:                  patient.Lapseto,
560 560
 	}
561 561
 	//	//更新病人ID获取新表病人ID
562 562
 	err = service.UpdatepatientTwo(&patientsNew, id)
@@ -1334,6 +1334,21 @@ func (c *PatientApiController) CreateGroupAdvice() {
1334 1334
 						child.PrescribingNumberUnit = childPrescribingNumberUnit
1335 1335
 					}
1336 1336
 
1337
+					if childMap["drug_id"] != nil && reflect.TypeOf(childMap["drug_id"]).String() == "float64" {
1338
+						drug_id := int64(childMap["drug_id"].(float64))
1339
+						child.DrugId = drug_id
1340
+					}
1341
+
1342
+					if childMap["way"] != nil && reflect.TypeOf(childMap["way"]).String() == "float64" {
1343
+						way := int64(childMap["way"].(float64))
1344
+						child.Way = way
1345
+					}
1346
+
1347
+					if childMap["drug_name_id"] != nil && reflect.TypeOf(childMap["drug_name_id"]).String() == "float64" {
1348
+						drug_name_id := int64(childMap["drug_name_id"].(float64))
1349
+						child.DrugNameId = drug_name_id
1350
+					}
1351
+
1337 1352
 					child.DeliveryWay = advice.DeliveryWay
1338 1353
 					child.ExecutionFrequency = advice.ExecutionFrequency
1339 1354
 					advice.Children = append(advice.Children, &child)
@@ -1395,6 +1410,7 @@ func (c *PatientApiController) CreateDoctorAdvice() {
1395 1410
 	}
1396 1411
 
1397 1412
 	if advice.ParentId > 0 {
1413
+
1398 1414
 		old, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, advice.ParentId)
1399 1415
 		if old.ID == 0 || old.PatientId != patient {
1400 1416
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParentAdviceNotExist)
@@ -1414,6 +1430,7 @@ func (c *PatientApiController) CreateDoctorAdvice() {
1414 1430
 		advice.DeliveryWay = old.DeliveryWay
1415 1431
 		advice.ExecutionFrequency = old.ExecutionFrequency
1416 1432
 		advice.GroupNo = old.GroupNo
1433
+
1417 1434
 	}
1418 1435
 
1419 1436
 	advice.Status = 1
@@ -1578,9 +1595,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1578 1595
 	advice.ExecutionTime = theTime.Unix()
1579 1596
 	// advice.Checker = checker
1580 1597
 
1581
-	//adviceName, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
1582
-	//fmt.Println("adviceName", adviceName.Way)
1583
-
1584 1598
 	//处理出库相关逻辑
1585 1599
 
1586 1600
 	//1.判断是否启用药品管理和自备药出库功能
@@ -1590,49 +1604,134 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1590 1604
 
1591 1605
 	//自备药信息
1592 1606
 	privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.CurrentOrgId)
1593
-	fmt.Println("drugStockConfig9999999999999", drugStockConfig.IsOpen)
1607
+	fmt.Println("", drugStockConfig.IsOpen)
1594 1608
 	if drugStockConfig.IsOpen == 1 {
1595
-		adviceName, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
1596
-		//isHasWay := false //用来判断是否包含来自药品库的医嘱
1597
-
1598
-		if adviceName.Way == 1 {
1599
-			fmt.Println("药品库进来没有--------------------")
1600
-			out, err := service.FindDrugStockOutByIsSys(adminUserInfo.CurrentOrgId, 1, adviceName.RecordDate)
1601
-			fmt.Println("err================", err)
1602
-			if err == gorm.ErrRecordNotFound {
1603
-				//没有记录,则创建出库单
1604
-				timeStr := time.Now().Format("2006-01-02")
1605
-				timeArr := strings.Split(timeStr, "-")
1606
-				total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1607
-				total = total + 1
1608
-				warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1609
-				number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1610
-				number = number + total
1611
-				warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1612
-				creater := adminUserInfo.AdminUser.Id
1613
-				warehouseOut := models.DrugWarehouseOut{
1614
-					WarehouseOutOrderNumber: warehousing_out_order,
1615
-					OperationTime:           time.Now().Unix(),
1616
-					OrgId:                   adminUserInfo.CurrentOrgId,
1617
-					Creater:                 creater,
1618
-					Ctime:                   time.Now().Unix(),
1619
-					Status:                  1,
1620
-					WarehouseOutTime:        adviceName.RecordDate,
1621
-					Dealer:                  0,
1622
-					Manufacturer:            0,
1623
-					Type:                    1,
1624
-					IsSys:                   1,
1625
-				}
1626
-				fmt.Println("触发了梅花园")
1627
-				err := service.AddSigleDrugWarehouseOut(&warehouseOut)
1628
-				if err != nil {
1629
-					utils.TraceLog("创建出库单失败 err = %v", err)
1630
-				} else {
1631
-					if adviceName.Way == 1 {
1632
-						if adviceName.PrescribingNumber > 0 {
1609
+		//查询已经执行的医嘱
1610
+		advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1611
+		for _, item := range advices {
1612
+			fmt.Println("非自备要22222")
1613
+			if item.Way == 1 {
1614
+				out, err := service.FindDrugStockOutByIsSys(adminUserInfo.CurrentOrgId, 1, item.RecordDate)
1615
+				if err == gorm.ErrRecordNotFound {
1616
+					//没有记录,则创建出库单
1617
+					timeStr := time.Now().Format("2006-01-02")
1618
+					timeArr := strings.Split(timeStr, "-")
1619
+					total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1620
+					total = total + 1
1621
+					warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1622
+					number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1623
+					number = number + total
1624
+					warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1625
+					creater := adminUserInfo.AdminUser.Id
1626
+					warehouseOut := models.DrugWarehouseOut{
1627
+						WarehouseOutOrderNumber: warehousing_out_order,
1628
+						OperationTime:           time.Now().Unix(),
1629
+						OrgId:                   adminUserInfo.CurrentOrgId,
1630
+						Creater:                 creater,
1631
+						Ctime:                   time.Now().Unix(),
1632
+						Status:                  1,
1633
+						WarehouseOutTime:        item.RecordDate,
1634
+						Dealer:                  0,
1635
+						Manufacturer:            0,
1636
+						Type:                    1,
1637
+						IsSys:                   1,
1638
+					}
1639
+
1640
+					err := service.AddSigleDrugWarehouseOut(&warehouseOut)
1641
+					if err != nil {
1642
+						utils.TraceLog("创建出库单失败 err = %v", err)
1643
+					} else {
1644
+						if item.Way == 1 {
1645
+							if item.PrescribingNumber > 0 {
1646
+								warehouseOutInfo := &models.DrugWarehouseOutInfo{
1647
+									WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1648
+									WarehouseOutId:          warehouseOut.ID,
1649
+									Status:                  1,
1650
+									Ctime:                   time.Now().Unix(),
1651
+									Remark:                  "",
1652
+									OrgId:                   adminUserInfo.CurrentOrgId,
1653
+									Type:                    1,
1654
+									Manufacturer:            0,
1655
+									Dealer:                  0,
1656
+									IsSys:                   1,
1657
+									SysRecordTime:           item.RecordDate,
1658
+									DrugId:                  item.DrugId,
1659
+								}
1660
+								prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1661
+								count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1662
+								warehouseOutInfo.Count = count
1663
+								stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
1664
+								warehouseOutInfo.Price = stockInInfo.Price
1665
+								err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1666
+								if err == nil {
1667
+									details := &models.DrugAutomaticReduceDetail{
1668
+										WarehouseOutId:          warehouseOutInfo.ID,
1669
+										WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1670
+										PatientId:               item.PatientId,
1671
+										Ctime:                   time.Now().Unix(),
1672
+										Mtime:                   time.Now().Unix(),
1673
+										Status:                  1,
1674
+										RecordTime:              item.RecordDate,
1675
+										OrgId:                   adminUserInfo.CurrentOrgId,
1676
+										DrugId:                  item.DrugId,
1677
+										Count:                   count,
1678
+									}
1679
+									service.AddSigleDrugAutoReduceRecordInfo(details)
1680
+									if err != nil {
1681
+										utils.TraceLog("创建出库单失败 err = %v", err)
1682
+									} else {
1683
+										if item.Way == 1 {
1684
+											if item.PrescribingNumber > 0 {
1685
+												warehouseOutInfo := &models.DrugWarehouseOutInfo{
1686
+													WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1687
+													WarehouseOutId:          warehouseOut.ID,
1688
+													Status:                  1,
1689
+													Ctime:                   time.Now().Unix(),
1690
+													Remark:                  "",
1691
+													OrgId:                   adminUserInfo.CurrentOrgId,
1692
+													Type:                    1,
1693
+													Manufacturer:            0,
1694
+													Dealer:                  0,
1695
+													IsSys:                   1,
1696
+													SysRecordTime:           item.RecordDate,
1697
+													DrugId:                  item.DrugId,
1698
+												}
1699
+												prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1700
+												count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1701
+												warehouseOutInfo.Count = count
1702
+												stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
1703
+												warehouseOutInfo.Price = stockInInfo.Price
1704
+												err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1705
+												if err == nil {
1706
+													details := &models.DrugAutomaticReduceDetail{
1707
+														WarehouseOutId:          warehouseOutInfo.ID,
1708
+														WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1709
+														PatientId:               item.PatientId,
1710
+														Ctime:                   time.Now().Unix(),
1711
+														Mtime:                   time.Now().Unix(),
1712
+														Status:                  1,
1713
+														RecordTime:              item.RecordDate,
1714
+														OrgId:                   adminUserInfo.CurrentOrgId,
1715
+														DrugId:                  item.DrugId,
1716
+														Count:                   count,
1717
+													}
1718
+													service.AddSigleDrugAutoReduceRecordInfo(details)
1719
+												}
1720
+											}
1721
+										}
1722
+									}
1723
+
1724
+								}
1725
+							}
1726
+						}
1727
+					}
1728
+				} else if err == nil {
1729
+					if item.Way == 1 {
1730
+						outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.CurrentOrgId, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
1731
+						if err == gorm.ErrRecordNotFound {
1633 1732
 							warehouseOutInfo := &models.DrugWarehouseOutInfo{
1634
-								WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1635
-								WarehouseOutId:          warehouseOut.ID,
1733
+								WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
1734
+								WarehouseOutId:          out.ID,
1636 1735
 								Status:                  1,
1637 1736
 								Ctime:                   time.Now().Unix(),
1638 1737
 								Remark:                  "",
@@ -1641,151 +1740,113 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1641 1740
 								Manufacturer:            0,
1642 1741
 								Dealer:                  0,
1643 1742
 								IsSys:                   1,
1644
-								SysRecordTime:           adviceName.RecordDate,
1645
-								DrugId:                  adviceName.DrugId,
1743
+								SysRecordTime:           item.RecordDate,
1646 1744
 							}
1647
-							prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
1745
+
1746
+							stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
1747
+							warehouseOutInfo.Price = stockInInfo.Price
1748
+							warehouseOutInfo.DrugId = item.DrugId
1749
+							prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1648 1750
 							count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1649 1751
 							warehouseOutInfo.Count = count
1650
-							stockInInfo, _ := service.FindLastDrugStockInInfoRecord(adviceName.DrugId, adminUserInfo.CurrentOrgId)
1651
-							warehouseOutInfo.Price = stockInInfo.Price
1652 1752
 							err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1653 1753
 							if err == nil {
1654 1754
 								details := &models.DrugAutomaticReduceDetail{
1655 1755
 									WarehouseOutId:          warehouseOutInfo.ID,
1656 1756
 									WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1657
-									PatientId:               adviceName.PatientId,
1757
+									PatientId:               item.PatientId,
1658 1758
 									Ctime:                   time.Now().Unix(),
1659 1759
 									Mtime:                   time.Now().Unix(),
1660 1760
 									Status:                  1,
1661
-									RecordTime:              adviceName.RecordDate,
1761
+									RecordTime:              item.RecordDate,
1662 1762
 									OrgId:                   adminUserInfo.CurrentOrgId,
1663
-									DrugId:                  adviceName.DrugId,
1763
+									DrugId:                  item.DrugId,
1664 1764
 									Count:                   count,
1665 1765
 								}
1666 1766
 								service.AddSigleDrugAutoReduceRecordInfo(details)
1667 1767
 							}
1668
-						}
1669
-					}
1670
-				}
1671
-			} else if err == nil {
1672
-
1673
-				if adviceName.Way == 1 {
1674
-					outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.CurrentOrgId, adviceName.DrugId, out.ID, out.WarehouseOutOrderNumber)
1675
-					if err == gorm.ErrRecordNotFound {
1676
-						warehouseOutInfo := &models.DrugWarehouseOutInfo{
1677
-							WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
1678
-							WarehouseOutId:          out.ID,
1679
-							Status:                  1,
1680
-							Ctime:                   time.Now().Unix(),
1681
-							Remark:                  "",
1682
-							OrgId:                   adminUserInfo.CurrentOrgId,
1683
-							Type:                    1,
1684
-							Manufacturer:            0,
1685
-							Dealer:                  0,
1686
-							IsSys:                   1,
1687
-							SysRecordTime:           adviceName.RecordDate,
1688
-						}
1689 1768
 
1690
-						stockInInfo, _ := service.FindLastDrugStockInInfoRecord(adviceName.DrugId, adminUserInfo.CurrentOrgId)
1691
-						warehouseOutInfo.Price = stockInInfo.Price
1692
-						warehouseOutInfo.DrugId = adviceName.DrugId
1693
-						prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
1694
-						count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1695
-						warehouseOutInfo.Count = count
1696
-						err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1697
-						if err == nil {
1698
-							details := &models.DrugAutomaticReduceDetail{
1699
-								WarehouseOutId:          warehouseOutInfo.ID,
1700
-								WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1701
-								PatientId:               adviceName.PatientId,
1702
-								Ctime:                   time.Now().Unix(),
1703
-								Mtime:                   time.Now().Unix(),
1704
-								Status:                  1,
1705
-								RecordTime:              adviceName.RecordDate,
1706
-								OrgId:                   adminUserInfo.CurrentOrgId,
1707
-								DrugId:                  adviceName.DrugId,
1708
-								Count:                   count,
1769
+						} else if err == nil { //记录存在,则将增加数量
1770
+							if outInfo.ID > 0 {
1771
+								prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1772
+								count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1773
+								service.UpdateDrugStockOutInfoCount2(adminUserInfo.CurrentOrgId, outInfo.ID, count)
1709 1774
 							}
1710
-							service.AddSigleDrugAutoReduceRecordInfo(details)
1711
-						}
1712
-
1713
-					} else if err == nil { //记录存在,则将增加数量
1714
-						if outInfo.ID > 0 {
1715
-							prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
1716
-							count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1717
-							service.UpdateDrugStockOutInfoCount2(adminUserInfo.CurrentOrgId, outInfo.ID, count)
1718
-						}
1719 1775
 
1720
-						count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.CurrentOrgId, adviceName.RecordDate, adviceName.DrugId, adviceName.PatientId)
1721
-						if count == 0 {
1722
-							prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
1723
-							count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1724
-							details := &models.DrugAutomaticReduceDetail{
1725
-								WarehouseOutId:          outInfo.ID,
1726
-								WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
1727
-								PatientId:               adviceName.PatientId,
1728
-								Ctime:                   time.Now().Unix(),
1729
-								Mtime:                   time.Now().Unix(),
1730
-								Status:                  1,
1731
-								RecordTime:              adviceName.RecordDate,
1732
-								OrgId:                   adminUserInfo.CurrentOrgId,
1733
-								DrugId:                  adviceName.DrugId,
1734
-								Count:                   count,
1776
+							count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.CurrentOrgId, item.RecordDate, item.DrugId, item.PatientId)
1777
+							if count == 0 {
1778
+								prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1779
+								count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1780
+								details := &models.DrugAutomaticReduceDetail{
1781
+									WarehouseOutId:          outInfo.ID,
1782
+									WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
1783
+									PatientId:               item.PatientId,
1784
+									Ctime:                   time.Now().Unix(),
1785
+									Mtime:                   time.Now().Unix(),
1786
+									Status:                  1,
1787
+									RecordTime:              item.RecordDate,
1788
+									OrgId:                   adminUserInfo.CurrentOrgId,
1789
+									DrugId:                  item.DrugId,
1790
+									Count:                   count,
1791
+								}
1792
+								service.AddSigleDrugAutoReduceRecordInfo(details)
1793
+							} else if count == 1 {
1794
+								prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1795
+								count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1796
+								service.UpdateDrugUserInfoDetails(item.DrugId, item.RecordDate, adminUserInfo.CurrentOrgId, item.PatientId, count, &outInfo)
1735 1797
 							}
1736
-							service.AddSigleDrugAutoReduceRecordInfo(details)
1737
-						} else if count == 1 {
1738
-							prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
1739
-							count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1740
-							service.UpdateDrugUserInfoDetails(adviceName.DrugId, adviceName.RecordDate, adminUserInfo.CurrentOrgId, adviceName.PatientId, count, &outInfo)
1741
-						}
1742 1798
 
1799
+						}
1743 1800
 					}
1744 1801
 				}
1745
-
1746 1802
 			}
1747 1803
 		}
1748 1804
 	}
1749 1805
 
1750
-	//fmt.Println("222222222222", privateDrugConfig.DrugStart)
1751
-	adviceName, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
1752
-	if adviceName.Way == 2 {
1753
-		if privateDrugConfig != nil && privateDrugConfig.DrugStart == 1 {
1754
-			//fmt.Println("进来了没有-------------------------------")
1755
-			adviceName, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
1756
-			//fmt.Println("3333333333", adviceName.ExecutionState)
1757
-			if adviceName.ExecutionState == 1 {
1758
-				prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
1759
-				count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1760
-
1761
-				timeStr := time.Now().Format("2006-01-02")
1762
-				timeArr := strings.Split(timeStr, "-")
1763
-				total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1764
-
1765
-				total = total + 1
1766
-				warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1767
-				number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1768
-				number = number + total
1769
-				warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
1770
-				//插入自备药出库单
1771
-				outStock := models.XtSelfOutStock{
1772
-					DrugName:       adviceName.AdviceName,
1773
-					DrugNameId:     adviceName.DrugId,
1774
-					DrugSpec:       adviceName.AdviceDesc,
1775
-					OutstoreNumber: count,
1776
-					AdminUserId:    adminUserInfo.AdminUser.Id,
1777
-					StorckTime:     adviceName.RecordDate,
1778
-					UserOrgId:      adminUserInfo.CurrentOrgId,
1779
-					CreatedTime:    time.Now().Unix(),
1780
-					Status:         1,
1781
-					PatientId:      adviceName.PatientId,
1782
-					ExitMode:       2,
1783
-					MedicId:        adviceName.DrugId,
1784
-					StockOutNumber: warehousing_out_order,
1806
+	advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1807
+	for _, item := range advices {
1808
+		fmt.Println("33333", item.ExecutionState)
1809
+		fmt.Println("医嘱名称", item.AdviceName)
1810
+		fmt.Println("item", item.Way)
1811
+		if item.Way == 2 {
1812
+			if privateDrugConfig != nil && privateDrugConfig.DrugStart == 1 {
1813
+
1814
+				//adviceName, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
1815
+
1816
+				if item.ExecutionState == 1 {
1817
+					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1818
+					count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1819
+
1820
+					timeStr := time.Now().Format("2006-01-02")
1821
+					timeArr := strings.Split(timeStr, "-")
1822
+					total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1823
+
1824
+					total = total + 1
1825
+					warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1826
+					number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1827
+					number = number + total
1828
+					warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
1829
+					//插入自备药出库单
1830
+					outStock := models.XtSelfOutStock{
1831
+						DrugName:       item.AdviceName,
1832
+						DrugNameId:     item.DrugId,
1833
+						DrugSpec:       item.AdviceDesc,
1834
+						OutstoreNumber: count,
1835
+						AdminUserId:    adminUserInfo.AdminUser.Id,
1836
+						StorckTime:     item.RecordDate,
1837
+						UserOrgId:      adminUserInfo.CurrentOrgId,
1838
+						CreatedTime:    time.Now().Unix(),
1839
+						Status:         1,
1840
+						PatientId:      item.PatientId,
1841
+						ExitMode:       2,
1842
+						MedicId:        item.DrugId,
1843
+						StockOutNumber: warehousing_out_order,
1844
+					}
1845
+					service.CreateOutStock(&outStock)
1785 1846
 				}
1786
-				service.CreateOutStock(&outStock)
1787 1847
 			}
1788 1848
 		}
1849
+
1789 1850
 	}
1790 1851
 
1791 1852
 	c.ServeSuccessJSON(map[string]interface{}{
@@ -1794,166 +1855,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1794 1855
 	})
1795 1856
 	return
1796 1857
 
1797
-	////如果医嘱已执行,生成自备药出库单
1798
-	//  //来自药品库
1799
-	//  if adviceName.ExecutionState == 1 && adviceName.Way == 1 {
1800
-	//
1801
-	//    //查询是否开启药品库
1802
-	//    stockConfig, _ := service.GetDrugStockConfig(adminUserInfo.CurrentOrgId)
1803
-	//    //开启药品库
1804
-	//    if stockConfig.IsOpen == 1 {
1805
-	//      timeLayout := "2006-01-02"
1806
-	//      loc, _ := time.LoadLocation("Local")
1807
-	//      //产询今日是否存在出库单
1808
-	//      timeStr := time.Now().Format("2006-01-02")
1809
-	//      theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", timeStr+" 00:00:00", loc)
1810
-	//      _, errcode := service.GetDrugWareseOut(theTime.Unix(), adminUserInfo.CurrentOrgId)
1811
-	//      if errcode == gorm.ErrRecordNotFound {
1812
-	//        timeArr := strings.Split(timeStr, "-")
1813
-	//        total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1814
-	//
1815
-	//        total = total + 1
1816
-	//        warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1817
-	//        number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1818
-	//        number = number + total
1819
-	//        warehousing_out_order = "YPRKD" + strconv.FormatInt(number, 10)
1820
-	//        //查询厂家
1821
-	//        drug, _ := service.GetManufacturer(adviceName.DrugId)
1822
-	//        //创建
1823
-	//        warehouse := models.XtDrugWarehouse{
1824
-	//          WarehousingOrder: warehousing_out_order,
1825
-	//          OperationTime:    theTime.Unix(),
1826
-	//          Creater:          adminUserInfo.AdminUser.Id,
1827
-	//          OrgId:            adminUserInfo.CurrentOrgId,
1828
-	//          Status:           1,
1829
-	//          WarehousingTime:  theTime.Unix(),
1830
-	//          Manufacturer:     drug.Manufacturer,
1831
-	//          Type:             1,
1832
-	//        }
1833
-	//        service.CreateDrugWarehoue(&warehouse)
1834
-	//      }
1835
-	//
1836
-	//      timeArr := strings.Split(timeStr, "-")
1837
-	//      total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1838
-	//
1839
-	//      total = total + 1
1840
-	//      warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1841
-	//      number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1842
-	//      number = number + total
1843
-	//      warehousing_out_order = "YPRKD" + strconv.FormatInt(number, 10)
1844
-	//      drug, _ := service.GetManufacturer(adviceName.DrugId)
1845
-	//      out := models.XtDrugWarehouseOut{
1846
-	//        WarehouseOutOrderNumber: warehousing_out_order,
1847
-	//        OperationTime:           theTime.Unix(),
1848
-	//        Creater:                 adminUserInfo.AdminUser.Id,
1849
-	//        OrgId:                   adminUserInfo.CurrentOrgId,
1850
-	//        Ctime:                   time.Now().Unix(),
1851
-	//        Status:                  1,
1852
-	//        WarehouseOutTime:        theTime.Unix(),
1853
-	//        Manufacturer:            drug.Manufacturer,
1854
-	//        Type:                    1,
1855
-	//        IsSys:                   1,
1856
-	//      }
1857
-	//      service.CreateDrugWareHouseOut(&out)
1858
-	//
1859
-	//      //查询今日的出库单号
1860
-	//      orderOut, _ := service.GetTodayWareHousringOrder(theTime.Unix(), adminUserInfo.CurrentOrgId)
1861
-	//      prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
1862
-	//      outStoreNumber, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1863
-	//      timeArrs := strings.Split(timeStr, "-")
1864
-	//      totals, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1865
-	//
1866
-	//      totals = totals + 1
1867
-	//      warehousing_out_orders := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArrs[0] + timeArrs[1] + timeArrs[2] + "000"
1868
-	//      numbers, _ := strconv.ParseInt(warehousing_out_orders, 10, 64)
1869
-	//      number = numbers + totals
1870
-	//      warehousing_out_order = "YPCKD" + strconv.FormatInt(numbers, 10)
1871
-	//      info := models.XtDrugWarehouseOutInfo{
1872
-	//        WarehouseOutId:          orderOut.ID,
1873
-	//        DrugId:                  adviceName.DrugId,
1874
-	//        Count:                   outStoreNumber,
1875
-	//        Price:                   drug.RetailPrice,
1876
-	//        TotalPrice:              drug.RetailPrice,
1877
-	//        ProductDate:             theTime.Unix(),
1878
-	//        Ctime:                   time.Now().Unix(),
1879
-	//        Status:                  1,
1880
-	//        OrgId:                   adminUserInfo.CurrentOrgId,
1881
-	//        IsCancel:                2,
1882
-	//        WarehouseOutOrderNumber: warehousing_out_order,
1883
-	//        Type:                    1,
1884
-	//        Manufacturer:            orderOut.Manufacturer,
1885
-	//        IsSys:                   1,
1886
-	//        SysRecordTime:           theTime.Unix(),
1887
-	//      }
1888
-	//      service.CreateWareHouseOutInfo(&info)
1889
-	//
1890
-	//      timeArrss := strings.Split(timeStr, "-")
1891
-	//      totalss, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1892
-	//
1893
-	//      totalss = totalss + 1
1894
-	//      warehousing_out_orderss := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArrss[0] + timeArrss[1] + timeArrss[2] + "000"
1895
-	//      numberss, _ := strconv.ParseInt(warehousing_out_orderss, 10, 64)
1896
-	//      number = numberss + totalss
1897
-	//      warehousing_out_order = "YPCKD" + strconv.FormatInt(numberss, 10)
1898
-	//      detail := models.XtDrugAutomaticReduceDetail{
1899
-	//        WarehouseOutOrderNumber: warehousing_out_order,
1900
-	//        WarehouseOutId:          orderOut.ID,
1901
-	//        PatientId:               adviceName.PatientId,
1902
-	//        Ctime:                   time.Now().Unix(),
1903
-	//        RecordTime:              theTime.Unix(),
1904
-	//        OrgId:                   adminUserInfo.CurrentOrgId,
1905
-	//        GoodId:                  adviceName.DrugId,
1906
-	//        Count:                   outStoreNumber,
1907
-	//        Status:                  1,
1908
-	//      }
1909
-	//      service.CreateAotoMaticReduceDetail(&detail)
1910
-	//    }
1911
-	//}
1912
-
1913
-	//if adviceName.ExecutionState == 1 && adviceName.Way == 2 {
1914
-	//
1915
-	//	//是否开启自备药
1916
-	//	medicalSet, _ := service.GetSetSelfMedical(adminUserInfo.CurrentOrgId)
1917
-	//	//开启自备药,生成出库单
1918
-	//	if medicalSet.DrugStart == 1 {
1919
-	//		prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
1920
-	//		outStoreNumber, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1921
-	//
1922
-	//		timeStr := time.Now().Format("2006-01-02")
1923
-	//		timeArr := strings.Split(timeStr, "-")
1924
-	//		total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1925
-	//
1926
-	//		total = total + 1
1927
-	//		warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1928
-	//		number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1929
-	//		number = number + total
1930
-	//		warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
1931
-	//
1932
-	//		outStock := models.XtSelfOutStock{
1933
-	//			DrugName:       adviceName.AdviceName,
1934
-	//			DrugSpec:       adviceName.AdviceDesc,
1935
-	//			OutstoreNumber: outStoreNumber,
1936
-	//			AdminUserId:    adminUserInfo.AdminUser.Id,
1937
-	//			CreatedTime:    time.Now().Unix(),
1938
-	//			Status:         1,
1939
-	//			PatientId:      adviceName.PatientId,
1940
-	//			StockOutNumber: warehousing_out_order,
1941
-	//			ExitMode:       2,
1942
-	//			StorckTime:     adviceName.AdviceDate,
1943
-	//			MedicId:        adviceName.DrugId,
1944
-	//			UserOrgId:      adminUserInfo.CurrentOrgId,
1945
-	//		}
1946
-	//		//创建出库单,自动出库
1947
-	//		service.CreateOutStock(&outStock)
1948
-	//		c.ServeSuccessJSON(map[string]interface{}{
1949
-	//			"msg":    "ok",
1950
-	//			"advice": advice,
1951
-	//		})
1952
-	//		return
1953
-	//	}
1954
-	//
1955
-	//}
1956
-
1957 1858
 }
1958 1859
 
1959 1860
 func (c *PatientApiController) CheckGroupAdvice() {
@@ -2770,6 +2671,21 @@ func adviceFormData(advice *models.DoctorAdvice, data []byte, action string) (co
2770 2671
 		advice.Remark = remark
2771 2672
 	}
2772 2673
 
2674
+	if dataBody["drug_id"] != nil && reflect.TypeOf(dataBody["drug_id"]).String() == "float64" {
2675
+		drug_id, _ := dataBody["drug_id"].(float64)
2676
+		advice.DrugId = int64(drug_id)
2677
+	}
2678
+
2679
+	if dataBody["drug_name_id"] != nil && reflect.TypeOf(dataBody["drug_name_id"]).String() == "float64" {
2680
+		drug_name_id, _ := dataBody["drug_name_id"].(float64)
2681
+		advice.DrugNameId = int64(drug_name_id)
2682
+	}
2683
+
2684
+	if dataBody["way"] != nil && reflect.TypeOf(dataBody["way"]).String() == "float64" {
2685
+		way, _ := dataBody["way"].(float64)
2686
+		advice.Way = int64(way)
2687
+	}
2688
+
2773 2689
 	return
2774 2690
 }
2775 2691
 

+ 34 - 2
controllers/self_drug_api_congtroller.go Visa fil

@@ -49,6 +49,8 @@ func SelfDrugRouters() {
49 49
 	beego.Router("/api/drug/getstandname", &SelfDrugApiController{}, "Get:GetStandName")
50 50
 	beego.Router("/api/drug/getrullerlist", &SelfDrugApiController{}, "Get:GetRullerList")
51 51
 	beego.Router("/api/drug/deleteDrugNamebyid", &SelfDrugApiController{}, "Get:DeleteDrugNameById")
52
+	beego.Router("/api/drug/getpatientdetail", &SelfDrugApiController{}, "Get:GetPatientDetail")
53
+	//beego.Router("/api/drug/getpatientdetail",&SelfDrugApiController{},"Get:ToPatientDetail")
52 54
 }
53 55
 
54 56
 func (this *SelfDrugApiController) GetCurrentPatient() {
@@ -264,12 +266,15 @@ func (this *SelfDrugApiController) GetAllDrugNameList() {
264 266
 	orgId := adminUserInfo.CurrentOrgId
265 267
 	rullerName, err := service.GetAllDrugNameList(orgId)
266 268
 
269
+	list, err := service.GetMedicalDrugNameList(orgId)
270
+
267 271
 	if err != nil {
268 272
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
269 273
 		return
270 274
 	}
271 275
 	this.ServeSuccessJSON(map[string]interface{}{
272 276
 		"rullerName": rullerName,
277
+		"list":       list,
273 278
 	})
274 279
 }
275 280
 
@@ -831,9 +836,7 @@ func (this *SelfDrugApiController) GetRullerList() {
831 836
 func (this *SelfDrugApiController) DeleteDrugNameById() {
832 837
 
833 838
 	id, _ := this.GetInt64("id")
834
-	fmt.Println("id------------------------------------", id)
835 839
 	drug_name := this.GetString("drug_name")
836
-	fmt.Println("drug_name2222222222222222222222222", drug_name)
837 840
 	adminUserInfo := this.GetAdminUserInfo()
838 841
 	orgId := adminUserInfo.CurrentOrgId
839 842
 
@@ -849,3 +852,32 @@ func (this *SelfDrugApiController) DeleteDrugNameById() {
849 852
 		return
850 853
 	}
851 854
 }
855
+
856
+func (this *SelfDrugApiController) GetPatientDetail() {
857
+
858
+	id, _ := this.GetInt64("id")
859
+	adminUserInfo := this.GetAdminUserInfo()
860
+	patientDetail, err := service.GetPatientDetail(id, adminUserInfo.CurrentOrgId)
861
+	if err != nil {
862
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
863
+		return
864
+	}
865
+	this.ServeSuccessJSON(map[string]interface{}{
866
+		"patientDetail": patientDetail,
867
+	})
868
+}
869
+
870
+//func (this *SelfDrugApiController) ToPatientDetail()  {
871
+//
872
+//  keyword := this.GetString("keyword")
873
+//  adminUser := this.GetAdminUserInfo()
874
+//  orgId := adminUser.CurrentOrgId
875
+//  patient, err := service.ToSeachPatient(keyword, orgId)
876
+//  if err != nil {
877
+//    this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
878
+//    return
879
+//  }
880
+//  this.ServeSuccessJSON(map[string]interface{}{
881
+//    "patient": patient,
882
+//  })
883
+//}

+ 5 - 11
controllers/sign_weigh_api_controller.go Visa fil

@@ -502,7 +502,7 @@ func (c *SignWeighAPIController) UpdateSignweight() {
502 502
 	weight_before, _ := c.GetFloat("weight_before", 0)
503 503
 	dry_weight, _ := c.GetFloat("dry_weight", 0)
504 504
 	temperature, _ := c.GetFloat("temperature", 0)
505
-	fmt.Println("温度========================", temperature)
505
+	fmt.Println("温度", temperature)
506 506
 	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
507 507
 	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
508 508
 	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
@@ -521,14 +521,12 @@ func (c *SignWeighAPIController) UpdateSignweight() {
521 521
 	predialysisevaluation.Status = 1
522 522
 
523 523
 	predialysis, errcode := service.GetDislysisBerfore(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
524
-	fmt.Println("sigh是什么东西", predialysis)
525
-	fmt.Println("错误装太:", errcode)
524
+	fmt.Println("sigh", predialysis)
525
+	fmt.Println("错误:", errcode)
526 526
 	if errcode == gorm.ErrRecordNotFound {
527
-		fmt.Println("aaaaa")
528 527
 		service.SaveDislysisiBefore(&predialysisevaluation)
529 528
 	} else if errcode == nil {
530
-		fmt.Println("bbbbbbbbb")
531
-		fmt.Println("predialysisevaluation", predialysisevaluation)
529
+
532 530
 		service.UpdataDislysisiBefore(&predialysisevaluation, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
533 531
 	} else {
534 532
 		service.UpdataDislysisiBefore(&predialysisevaluation, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
@@ -541,8 +539,6 @@ func (c *SignWeighAPIController) UpdateSignweight() {
541 539
 	pulsefrequencyafter, _ := c.GetFloat("pulse_frequencyafter", 0)
542 540
 	systolicbloodpressureafter, _ := c.GetFloat("systolic_blood_pressureafter", 0)
543 541
 	diastolicbloodpressureafter, _ := c.GetFloat("diastolic_blood_pressureafter", 0)
544
-	fmt.Println("aaaa")
545
-	fmt.Println(weight_after, temperatureafter, pulsefrequencyafter, systolicbloodpressureafter, diastolicbloodpressureafter)
546 542
 
547 543
 	var assessmentafterdislysis models.AssessmentAfterDislysis
548 544
 	assessmentafterdislysis.PatientId = patientID
@@ -556,17 +552,15 @@ func (c *SignWeighAPIController) UpdateSignweight() {
556 552
 	assessmentafterdislysis.CreatedTime = time.Now().Unix()
557 553
 	assessmentafterdislysis.Status = 1
558 554
 	dislysis, errcoder := service.GetAssessmentaafterdislysis(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
559
-	fmt.Println("sigh是什么东西", dislysis)
555
+	fmt.Println("sigh", dislysis)
560 556
 	fmt.Println("错误装太:", errcoder)
561 557
 
562 558
 	if errcoder == gorm.ErrRecordNotFound {
563
-		fmt.Println("oooooooo")
564 559
 		service.SaveAssessmentafter(&assessmentafterdislysis)
565 560
 		c.ServeSuccessJSON(map[string]interface{}{
566 561
 			"signs": predialysisevaluation,
567 562
 		})
568 563
 	} else if errcoder == nil {
569
-		fmt.Println("ffffffffffffffff")
570 564
 		service.UpdataAssessment(&assessmentafterdislysis, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
571 565
 		c.ServeSuccessJSON(map[string]interface{}{
572 566
 			"signs": predialysisevaluation,

+ 1 - 0
models/dialysis.go Visa fil

@@ -274,6 +274,7 @@ type PredialysisEvaluation struct {
274 274
 	CatheterSutureOther            string  `gorm:"column:catheter_suture_other" json:"catheter_suture_other" form:"catheter_suture_other"`
275 275
 	UrineVolume                    float64 `gorm:"column:urine_volume" json:"urine_volume" form:"urine_volume"`
276 276
 	Edema                          string  `gorm:"column:edema" json:"edema" form:"edema"`
277
+	SpecialTreatment               string  `gorm:"column:special_treatment" json:"special_treatment" form:"special_treatment"`
277 278
 }
278 279
 
279 280
 func (PredialysisEvaluation) TableName() string {

+ 7 - 6
models/patient_models.go Visa fil

@@ -231,12 +231,13 @@ func (DialysisPrescription) TableName() string {
231 231
 }
232 232
 
233 233
 type DialysisPrescriptionList struct {
234
-	ID         int64 `gorm:"column:id" json:"id"`
235
-	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id"`
236
-	PatientId  int64 `gorm:"column:patient_id" json:"patient_id"`
237
-	RecordDate int64 `gorm:"column:record_date" json:"record_date"`
238
-	RecordId   int64 `gorm:"column:record_id" json:"record_id"`
239
-	Creater    int64 `gorm:"column:creater" json:"creater"`
234
+	ID                         int64  `gorm:"column:id" json:"id"`
235
+	UserOrgId                  int64  `gorm:"column:user_org_id" json:"user_org_id"`
236
+	PatientId                  int64  `gorm:"column:patient_id" json:"patient_id"`
237
+	RecordDate                 int64  `gorm:"column:record_date" json:"record_date"`
238
+	RecordId                   int64  `gorm:"column:record_id" json:"record_id"`
239
+	Creater                    int64  `gorm:"column:creater" json:"creater"`
240
+	DialyzerPerfusionApparatus string `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
240 241
 }
241 242
 
242 243
 func (DialysisPrescriptionList) TableName() string {

+ 15 - 0
models/self_drug_models.go Visa fil

@@ -69,6 +69,21 @@ func (XtBaseDrug) TableName() string {
69 69
 	return "xt_base_drug"
70 70
 }
71 71
 
72
+type DrugName struct {
73
+	ID          int64         `gorm:"column:id" json:"id" form:"id"`
74
+	DrugName    string        `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
75
+	UserOrgId   int64         `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
76
+	Status      int64         `gorm:"column:status" json:"status" form:"status"`
77
+	CreatedTime int64         `gorm:"column:created_time" json:"created_time" form:"created_time"`
78
+	UpdatedTime int64         `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
79
+	DrugId      int64         `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
80
+	XtStandName []XtStandName `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"XtStandName"`
81
+}
82
+
83
+func (DrugName) TableName() string {
84
+	return "xt_drug_name"
85
+}
86
+
72 87
 type XtDrugName struct {
73 88
 	ID          int64  `gorm:"column:id" json:"id" form:"id"`
74 89
 	DrugName    string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`

+ 2 - 3
service/dialysis_parameter_service.go Visa fil

@@ -383,13 +383,12 @@ func PCGetDialysisGoodsTwo(orgID int64, scheduleDate int64, schedule_type int64,
383 383
 	var total int64
384 384
 
385 385
 	db := readDb.
386
-		Model(&models.Schedule{}).
387
-		Select("patient_id,mode_id").
386
+		Model(&models.Schedule{}).Select("patient_id,mode_id").
388 387
 		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
389 388
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
390 389
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
391 390
 		Preload("DialysisBeforePrepare", func(db *gorm.DB) *gorm.DB {
392
-			return db.Preload("VMGoodInfo", "status = 1 AND org_id = ?   ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0) ", orgID).Where("status = 1 AND user_org_id = ? AND record_date = ? AND count > 0 ", orgID, scheduleDate)
391
+			return db.Preload("VMGoodInfo", "status = 1 AND org_id = ?", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0) ", orgID).Where("status = 1 AND user_org_id = ? AND record_date = ? AND count > 0 ", orgID, scheduleDate)
393 392
 		}).
394 393
 		Preload("AutomaticReduceDetail", func(db *gorm.DB) *gorm.DB {
395 394
 			return db.Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Where("status = 1 AND org_id = ? AND record_time = ?  AND count > 0", orgID, scheduleDate)

+ 6 - 0
service/dialysis_service.go Visa fil

@@ -1103,3 +1103,9 @@ func FindDialysisBeforePrepare(patient_id int64, good_id int64, good_type_id int
1103 1103
 	return
1104 1104
 
1105 1105
 }
1106
+
1107
+func GetExecutionDoctors(orgid int64, patientid int64, id int64) (doctorAdvice []*models.DoctorAdvice, err error) {
1108
+
1109
+	err = readDb.Model(&doctorAdvice).Where("user_org_id = ? and patient_id = ? AND (id = ? Or parent_id=?) and status = 1", orgid, patientid, id, id).Find(&doctorAdvice).Error
1110
+	return doctorAdvice, err
1111
+}

+ 15 - 13
service/mobile_dialysis_service.go Visa fil

@@ -694,19 +694,20 @@ func GetMonitor(orgID int64, patientID int64, id int64) (*models.MonitoringRecor
694 694
 }
695 695
 
696 696
 type MScheduleDoctorAdviceVM struct {
697
-	ID              int64               `gorm:"column:id" json:"id"`
698
-	UserOrgId       int64               `gorm:"column:user_org_id" json:"user_org_id"`
699
-	PartitionId     int64               `gorm:"column:partition_id" json:"partition_id"`
700
-	BedId           int64               `gorm:"column:bed_id" json:"bed_id"`
701
-	PatientId       int64               `gorm:"column:patient_id" json:"patient_id"`
702
-	ScheduleDate    int64               `gorm:"column:schedule_date" json:"schedule_date"`
703
-	ScheduleType    int64               `gorm:"column:schedule_type" json:"schedule_type"`
704
-	ModeId          int64               `gorm:"column:mode_id" json:"mode_id"`
705
-	Status          int64               `gorm:"column:status" json:"status"`
706
-	DialysisOrder   *MDialysisOrderVM   `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
707
-	SchedualPatient *MSchedualPatientVM `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
708
-	DeviceNumber    *MDeviceNumberVM    `gorm:"ForeignKey:BedId" json:"device_number"`
709
-	DoctorAdvices   []*MDoctorAdviceVM  `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
697
+	ID              int64                            `gorm:"column:id" json:"id"`
698
+	UserOrgId       int64                            `gorm:"column:user_org_id" json:"user_org_id"`
699
+	PartitionId     int64                            `gorm:"column:partition_id" json:"partition_id"`
700
+	BedId           int64                            `gorm:"column:bed_id" json:"bed_id"`
701
+	PatientId       int64                            `gorm:"column:patient_id" json:"patient_id"`
702
+	ScheduleDate    int64                            `gorm:"column:schedule_date" json:"schedule_date"`
703
+	ScheduleType    int64                            `gorm:"column:schedule_type" json:"schedule_type"`
704
+	ModeId          int64                            `gorm:"column:mode_id" json:"mode_id"`
705
+	Status          int64                            `gorm:"column:status" json:"status"`
706
+	DialysisOrder   *MDialysisOrderVM                `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
707
+	SchedualPatient *MSchedualPatientVM              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
708
+	DeviceNumber    *MDeviceNumberVM                 `gorm:"ForeignKey:BedId" json:"device_number"`
709
+	DoctorAdvices   []*MDoctorAdviceVM               `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
710
+	Prescription    *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
710 711
 }
711 712
 
712 713
 func (MScheduleDoctorAdviceVM) TableName() string {
@@ -835,6 +836,7 @@ func MobileGetScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType
835 836
 		}).
836 837
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
837 838
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
839
+		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
838 840
 		Preload("DoctorAdvices", adviceCondition...).
839 841
 		Where("status = 1 AND user_org_id = ?", orgID)
840 842
 	if scheduleDate != 0 {

+ 18 - 0
service/self_drug_service.go Visa fil

@@ -529,6 +529,7 @@ type Drugs struct {
529 529
 	PrescribingNumber  float64  `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
530 530
 	Status             int64    `gorm:"column:status" json:"status" form:"status"`
531 531
 	OrgId              int64    `gorm:"column:org_id" json:"org_id" form:"org_id"`
532
+	MinUnit            string   `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
532 533
 	Drugs              []*Drugs `gorm:"ForeignKey:DrugName;AssociationForeignKey:DrugName" json:"drug_specs"`
533 534
 }
534 535
 
@@ -629,3 +630,20 @@ func UpdatedDoctorAdviceTemplate(id int64, orgid int64, template *models.DoctorA
629 630
 	err := XTWriteDB().Model(&template).Where("drug_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"advice_name": template.AdviceName, "advice_desc": template.AdviceDesc, "single_dose": template.SingleDose, "single_dose_unit": template.SingleDoseUnit, "delivery_way": template.DeliveryWay, "execution_frequency": template.ExecutionFrequency}).Error
630 631
 	return err
631 632
 }
633
+
634
+func ToSeachPatient(keyword string, orgid int64) (patients []*models.Patients, err error) {
635
+
636
+	likeKey := "%" + keyword + "%"
637
+	err = XTReadDB().Model(&patients).Where("name like ? and user_org_id = ? and status = 1", likeKey, orgid).Find(&patients).Error
638
+	return patients, err
639
+}
640
+
641
+func GetMedicalDrugNameList(orgid int64) (drugName []*models.DrugName, err error) {
642
+
643
+	db := XTReadDB().Model(&drugName).Where("user_org_id = ? and status = 1", orgid)
644
+
645
+	err = db.Preload("XtStandName", "status =1 and user_org_id = ?", orgid).Find(&drugName).Error
646
+
647
+	return drugName, err
648
+
649
+}