Browse Source

耗材参数

XMLWAN 4 years ago
parent
commit
1d6fbb7578

+ 59 - 3
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -956,15 +956,71 @@ func (c *PatientApiController) ExecDoctorAdvice() {
956 956
 			advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
957 957
 			for _, item := range advices {
958 958
 				if item.ExecutionState == 2 {
959
-					advice = item
959
+					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
960
+					count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
960 961
 
962
+					timeStr := time.Now().Format("2006-01-02")
963
+					timeArr := strings.Split(timeStr, "-")
964
+					total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.Org.Id)
965
+
966
+					total = total + 1
967
+					warehousing_out_order := strconv.FormatInt(adminUserInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
968
+					number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
969
+					number = number + total
970
+					warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
971
+					//插入自备药出库单
972
+					outStock := models.XtSelfOutStock{
973
+						DrugName:       item.AdviceName,
974
+						DrugNameId:     item.DrugId,
975
+						DrugSpec:       item.AdviceDesc,
976
+						OutstoreNumber: count,
977
+						AdminUserId:    adminUserInfo.AdminUser.Id,
978
+						StorckTime:     item.AdviceDate,
979
+						UserOrgId:      adminUserInfo.Org.Id,
980
+						CreatedTime:    time.Now().Unix(),
981
+						Status:         1,
982
+						PatientId:      item.PatientId,
983
+						ExitMode:       2,
984
+						MedicId:        item.DrugId,
985
+						StockOutNumber: warehousing_out_order,
986
+					}
987
+					service.CreateOutStock(&outStock)
961 988
 				}
962 989
 			}
963 990
 		} else {
991
+
964 992
 			advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
965 993
 			for _, item := range advices {
966
-				if item.ExecutionState == 2 {
967
-					advice = item
994
+				if item.ExecutionState == 1 {
995
+					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
996
+					count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
997
+
998
+					timeStr := time.Now().Format("2006-01-02")
999
+					timeArr := strings.Split(timeStr, "-")
1000
+					total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.Org.Id)
1001
+
1002
+					total = total + 1
1003
+					warehousing_out_order := strconv.FormatInt(adminUserInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1004
+					number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1005
+					number = number + total
1006
+					warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
1007
+					//插入自备药出库单
1008
+					outStock := models.XtSelfOutStock{
1009
+						DrugName:       item.AdviceName,
1010
+						DrugNameId:     item.DrugId,
1011
+						DrugSpec:       item.AdviceDesc,
1012
+						OutstoreNumber: count,
1013
+						AdminUserId:    adminUserInfo.AdminUser.Id,
1014
+						StorckTime:     item.AdviceDate,
1015
+						UserOrgId:      adminUserInfo.Org.Id,
1016
+						CreatedTime:    time.Now().Unix(),
1017
+						Status:         1,
1018
+						PatientId:      item.PatientId,
1019
+						ExitMode:       2,
1020
+						MedicId:        item.DrugId,
1021
+						StockOutNumber: warehousing_out_order,
1022
+					}
1023
+					service.CreateOutStock(&outStock)
968 1024
 
969 1025
 				}
970 1026
 			}

+ 109 - 119
controllers/patient_api_controller.go View File

@@ -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)
@@ -1594,7 +1594,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1594 1594
 			_, errcode := service.GetDrugWareseOut(theTime.Unix(), adminUserInfo.CurrentOrgId)
1595 1595
 			if errcode == gorm.ErrRecordNotFound {
1596 1596
 				timeArr := strings.Split(timeStr, "-")
1597
-				total, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
1597
+				total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1598 1598
 
1599 1599
 				total = total + 1
1600 1600
 				warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
@@ -1618,7 +1618,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1618 1618
 			}
1619 1619
 
1620 1620
 			timeArr := strings.Split(timeStr, "-")
1621
-			total, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
1621
+			total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1622 1622
 
1623 1623
 			total = total + 1
1624 1624
 			warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
@@ -1645,7 +1645,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1645 1645
 			prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
1646 1646
 			outStoreNumber, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1647 1647
 			timeArrs := strings.Split(timeStr, "-")
1648
-			totals, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
1648
+			totals, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1649 1649
 
1650 1650
 			totals = totals + 1
1651 1651
 			warehousing_out_orders := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArrs[0] + timeArrs[1] + timeArrs[2] + "000"
@@ -1664,15 +1664,15 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1664 1664
 				OrgId:                   adminUserInfo.CurrentOrgId,
1665 1665
 				IsCancel:                2,
1666 1666
 				WarehouseOutOrderNumber: warehousing_out_order,
1667
-				Type:          1,
1668
-				Manufacturer:  orderOut.Manufacturer,
1669
-				IsSys:         1,
1670
-				SysRecordTime: theTime.Unix(),
1667
+				Type:                    1,
1668
+				Manufacturer:            orderOut.Manufacturer,
1669
+				IsSys:                   1,
1670
+				SysRecordTime:           theTime.Unix(),
1671 1671
 			}
1672 1672
 			service.CreateWareHouseOutInfo(&info)
1673 1673
 
1674 1674
 			timeArrss := strings.Split(timeStr, "-")
1675
-			totalss, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
1675
+			totalss, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1676 1676
 
1677 1677
 			totalss = totalss + 1
1678 1678
 			warehousing_out_orderss := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArrss[0] + timeArrss[1] + timeArrss[2] + "000"
@@ -1705,7 +1705,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1705 1705
 
1706 1706
 			timeStr := time.Now().Format("2006-01-02")
1707 1707
 			timeArr := strings.Split(timeStr, "-")
1708
-			total, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
1708
+			total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1709 1709
 
1710 1710
 			total = total + 1
1711 1711
 			warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
@@ -1713,37 +1713,27 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1713 1713
 			number = number + total
1714 1714
 			warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
1715 1715
 
1716
-			medicalName, errcode := service.GetSelfMedicalByDrugName(adviceName.AdviceName, adviceName.AdviceDesc, adviceName.PatientId)
1717
-			if errcode == gorm.ErrRecordNotFound {
1718
-				c.ServeSuccessJSON(map[string]interface{}{
1719
-					"msg":    "ok",
1720
-					"advice": advice,
1721
-				})
1722
-				return
1723
-			} else if errcode == nil {
1724
-				outStock := models.XtSelfOutStock{
1725
-					DrugName:       adviceName.AdviceName,
1726
-					DrugSpec:       adviceName.AdviceDesc,
1727
-					OutstoreNumber: outStoreNumber,
1728
-					AdminUserId:    adminUserInfo.AdminUser.Id,
1729
-					CreatedTime:    time.Now().Unix(),
1730
-					Status:         1,
1731
-					PatientId:      adviceName.PatientId,
1732
-					StockOutNumber: warehousing_out_order,
1733
-					ExitMode:       2,
1734
-					StorckTime:     adviceName.AdviceDate,
1735
-					MedicId:        medicalName.ID,
1736
-					DrugNameId:     medicalName.DrugNameId,
1737
-					UserOrgId:      adminUserInfo.CurrentOrgId,
1738
-				}
1739
-				//创建出库单,自动出库
1740
-				service.CreateOutStock(&outStock)
1741
-				c.ServeSuccessJSON(map[string]interface{}{
1742
-					"msg":    "ok",
1743
-					"advice": advice,
1744
-				})
1745
-				return
1716
+			outStock := models.XtSelfOutStock{
1717
+				DrugName:       adviceName.AdviceName,
1718
+				DrugSpec:       adviceName.AdviceDesc,
1719
+				OutstoreNumber: outStoreNumber,
1720
+				AdminUserId:    adminUserInfo.AdminUser.Id,
1721
+				CreatedTime:    time.Now().Unix(),
1722
+				Status:         1,
1723
+				PatientId:      adviceName.PatientId,
1724
+				StockOutNumber: warehousing_out_order,
1725
+				ExitMode:       2,
1726
+				StorckTime:     adviceName.AdviceDate,
1727
+				MedicId:        adviceName.DrugId,
1728
+				UserOrgId:      adminUserInfo.CurrentOrgId,
1746 1729
 			}
1730
+			//创建出库单,自动出库
1731
+			service.CreateOutStock(&outStock)
1732
+			c.ServeSuccessJSON(map[string]interface{}{
1733
+				"msg":    "ok",
1734
+				"advice": advice,
1735
+			})
1736
+			return
1747 1737
 		}
1748 1738
 
1749 1739
 	}

+ 19 - 10
controllers/self_drug_api_congtroller.go View File

@@ -88,12 +88,14 @@ func (this *SelfDrugApiController) SaveDrugName() {
88 88
 	adminUserInfo := this.GetAdminUserInfo()
89 89
 	orgId := adminUserInfo.CurrentOrgId
90 90
 	drug_name := this.GetString("drug_name")
91
+	id, _ := this.GetInt64("id")
91 92
 	//fmt.Println("drug_name", drug_name)
92 93
 	drugName := models.XtDrugName{
93 94
 		UserOrgId:   orgId,
94 95
 		DrugName:    drug_name,
95 96
 		Status:      1,
96 97
 		CreatedTime: time.Now().Unix(),
98
+		DrugId:      id,
97 99
 	}
98 100
 	_, errcode := service.GetDrugName(drug_name, orgId)
99 101
 	if errcode == gorm.ErrRecordNotFound {
@@ -277,18 +279,25 @@ func (this *SelfDrugApiController) SaveSelfMedicines() {
277 279
 	for _, item := range medicineData {
278 280
 		items := item.(map[string]interface{})
279 281
 		drug_name := items["drug_name"].(string)
280
-		id := int64(items["id"].(float64))
282
+		drug_name_id := int64(items["drug_name_id"].(float64))
281 283
 		drug_spec := items["drug_spec"].(string)
282 284
 		min_unit := items["min_unit"].(string)
285
+
286
+		//根据drug_id
287
+		drugMedical, _ := service.GetBaseDrugMedical(drug_name_id)
283 288
 		medical := models.XtSelfMedical{
284
-			DrugName:    drug_name,
285
-			DrugNameId:  id,
286
-			DrugSpec:    drug_spec,
287
-			CreatedTime: time.Now().Unix(),
288
-			Status:      1,
289
-			UserOrgId:   orgId,
290
-			PatientId:   patient_id,
291
-			MinUnit:     min_unit,
289
+			DrugName:           drug_name,
290
+			DrugNameId:         drug_name_id,
291
+			DrugSpec:           drug_spec,
292
+			CreatedTime:        time.Now().Unix(),
293
+			Status:             1,
294
+			UserOrgId:          orgId,
295
+			PatientId:          patient_id,
296
+			MinUnit:            min_unit,
297
+			ExecutionFrequency: drugMedical.ExecutionFrequency,
298
+			PrescribingNumber:  drugMedical.PrescribingNumber,
299
+			DeliveryWay:        drugMedical.DeliveryWay,
300
+			SingleDose:         drugMedical.SingleDose,
292 301
 		}
293 302
 		//查询同个病人同个药品同个规格是否已存在
294 303
 		_, errcode := service.GetSelfMedicalByDrugName(drug_name, drug_spec, patient_id)
@@ -457,7 +466,7 @@ func (this *SelfDrugApiController) DeleteDrugById() {
457 466
 	orgId := adminUserInfo.CurrentOrgId
458 467
 
459 468
 	_, errcode := service.GetStandDrugByDrugName(drug_name, orgId)
460
-	fmt.Println("errcode", errcode)
469
+	fmt.Println("errcode2222222222222", errcode)
461 470
 	if errcode == gorm.ErrRecordNotFound {
462 471
 		service.DeleteDrugName(id)
463 472
 		returnData := make(map[string]interface{}, 0)

+ 1 - 1
models/self_drug_models.go View File

@@ -76,7 +76,7 @@ type XtDrugName struct {
76 76
 	Status      int64  `gorm:"column:status" json:"status" form:"status"`
77 77
 	CreatedTime int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
78 78
 	UpdatedTime int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
79
-	ParentId    int64  `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
79
+	DrugId      int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
80 80
 }
81 81
 
82 82
 func (XtDrugName) TableName() string {

+ 8 - 2
service/self_drug_service.go View File

@@ -92,6 +92,12 @@ func GetRullerListByDrugName(drugname string, orgid int64) (rullername []*models
92 92
 	return rullername, err
93 93
 }
94 94
 
95
+func GetBaseDrugMedical(id int64) (models.XtBaseDrug, error) {
96
+	drug := models.XtBaseDrug{}
97
+	err := XTReadDB().Model(&drug).Where("id = ? and status = 1", id).Find(&drug).Error
98
+	return drug, err
99
+}
100
+
95 101
 func GetSelfMedicalByDrugName(drugname string, drug_spec string, patientid int64) (*models.XtSelfMedical, error) {
96 102
 	medical := models.XtSelfMedical{}
97 103
 	err := XTReadDB().Model(&medical).Where("drug_name = ? and drug_spec = ? and patient_id = ? and status = 1", drugname, drug_spec, patientid).Find(&medical).Error
@@ -140,8 +146,8 @@ func GetStandDrugByDrugName(drugname string, orgid int64) (*models.XtStandName,
140 146
 	return &standname, nil
141 147
 }
142 148
 
143
-func DeleteDrugName(id int64) (models.XtStandName, error) {
144
-	standName := models.XtStandName{}
149
+func DeleteDrugName(id int64) (models.XtSelfMedical, error) {
150
+	standName := models.XtSelfMedical{}
145 151
 	err := XTWriteDB().Model(&standName).Where("id = ?", id).Update(map[string]interface{}{"status": 0}).Error
146 152
 	return standName, err
147 153
 }