|
@@ -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)
|
|
@@ -1228,6 +1228,16 @@ func (c *PatientApiController) CreateGroupAdvice() {
|
1228
|
1228
|
advice.ExecutionFrequency = executionFrequency
|
1229
|
1229
|
}
|
1230
|
1230
|
|
|
1231
|
+ if adviceNameM["way"] != nil || reflect.TypeOf(adviceNameM["way"]).String() == "float64" {
|
|
1232
|
+ way := int64(adviceNameM["way"].(float64))
|
|
1233
|
+ advice.Way = way
|
|
1234
|
+ }
|
|
1235
|
+
|
|
1236
|
+ if adviceNameM["drug_id"] != nil || reflect.TypeOf(adviceNameM["drug_id"]).String() == "float64" {
|
|
1237
|
+ drug_id := int64(adviceNameM["drug_id"].(float64))
|
|
1238
|
+ advice.DrugId = drug_id
|
|
1239
|
+ }
|
|
1240
|
+
|
1231
|
1241
|
if adviceType == 1 {
|
1232
|
1242
|
|
1233
|
1243
|
if adviceNameM["frequency_type"] != nil || reflect.TypeOf(adviceNameM["frequency_type"]).String() == "float64" {
|
|
@@ -1493,6 +1503,7 @@ func (c *PatientApiController) ExecGroupAdvice() {
|
1493
|
1503
|
}
|
1494
|
1504
|
|
1495
|
1505
|
func (c *PatientApiController) ExecDoctorAdvice() {
|
|
1506
|
+
|
1496
|
1507
|
patient, _ := c.GetInt64("patient", 0)
|
1497
|
1508
|
id, _ := c.GetInt64("id", 0)
|
1498
|
1509
|
executionTime := c.GetString("execution_time")
|
|
@@ -1563,9 +1574,121 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
1563
|
1574
|
// advice.Checker = checker
|
1564
|
1575
|
|
1565
|
1576
|
adviceName, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
|
1566
|
|
-
|
|
1577
|
+ fmt.Println("adviceName", adviceName.Way)
|
|
1578
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
1579
|
+ fmt.Println("timestr", timeStr)
|
1567
|
1580
|
//如果医嘱已执行,生成自备药出库单
|
1568
|
|
- if adviceName.ExecutionState == 1 {
|
|
1581
|
+ //来自药品库
|
|
1582
|
+ if adviceName.ExecutionState == 1 && adviceName.Way == 1 {
|
|
1583
|
+ timeLayout := "2006-01-02"
|
|
1584
|
+ loc, _ := time.LoadLocation("Local")
|
|
1585
|
+ //产询今日是否存在出库单
|
|
1586
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
1587
|
+ theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", timeStr+" 00:00:00", loc)
|
|
1588
|
+ _, errcode := service.GetDrugWareseOut(theTime.Unix(), adminUserInfo.CurrentOrgId)
|
|
1589
|
+ if errcode == gorm.ErrRecordNotFound {
|
|
1590
|
+ timeArr := strings.Split(timeStr, "-")
|
|
1591
|
+ total, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
|
|
1592
|
+
|
|
1593
|
+ total = total + 1
|
|
1594
|
+ warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
|
1595
|
+ number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
|
1596
|
+ number = number + total
|
|
1597
|
+ warehousing_out_order = "YPRKD" + strconv.FormatInt(number, 10)
|
|
1598
|
+ //查询厂家
|
|
1599
|
+ drug, _ := service.GetManufacturer(adviceName.DrugId)
|
|
1600
|
+ //创建
|
|
1601
|
+ warehouse := models.XtDrugWarehouse{
|
|
1602
|
+ WarehousingOrder: warehousing_out_order,
|
|
1603
|
+ OperationTime: theTime.Unix(),
|
|
1604
|
+ Creater: adminUserInfo.AdminUser.Id,
|
|
1605
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
1606
|
+ Status: 1,
|
|
1607
|
+ WarehousingTime: theTime.Unix(),
|
|
1608
|
+ Manufacturer: drug.Manufacturer,
|
|
1609
|
+ Type: 1,
|
|
1610
|
+ }
|
|
1611
|
+ service.CreateDrugWarehoue(&warehouse)
|
|
1612
|
+ }
|
|
1613
|
+
|
|
1614
|
+ timeArr := strings.Split(timeStr, "-")
|
|
1615
|
+ total, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
|
|
1616
|
+
|
|
1617
|
+ total = total + 1
|
|
1618
|
+ warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
|
1619
|
+ number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
|
1620
|
+ number = number + total
|
|
1621
|
+ warehousing_out_order = "YPRKD" + strconv.FormatInt(number, 10)
|
|
1622
|
+ drug, _ := service.GetManufacturer(adviceName.DrugId)
|
|
1623
|
+ out := models.XtDrugWarehouseOut{
|
|
1624
|
+ WarehouseOutOrderNumber: warehousing_out_order,
|
|
1625
|
+ OperationTime: theTime.Unix(),
|
|
1626
|
+ Creater: adminUserInfo.AdminUser.Id,
|
|
1627
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
1628
|
+ Ctime: time.Now().Unix(),
|
|
1629
|
+ Status: 1,
|
|
1630
|
+ WarehouseOutTime: theTime.Unix(),
|
|
1631
|
+ Manufacturer: drug.Manufacturer,
|
|
1632
|
+ Type: 1,
|
|
1633
|
+ IsSys: 1,
|
|
1634
|
+ }
|
|
1635
|
+ service.CreateDrugWareHouseOut(&out)
|
|
1636
|
+
|
|
1637
|
+ //查询今日的出库单号
|
|
1638
|
+ orderOut, _ := service.GetTodayWareHousringOrder(theTime.Unix(), adminUserInfo.CurrentOrgId)
|
|
1639
|
+ prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
|
|
1640
|
+ outStoreNumber, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
1641
|
+ timeArrs := strings.Split(timeStr, "-")
|
|
1642
|
+ totals, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
|
|
1643
|
+
|
|
1644
|
+ totals = totals + 1
|
|
1645
|
+ warehousing_out_orders := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArrs[0] + timeArrs[1] + timeArrs[2] + "000"
|
|
1646
|
+ numbers, _ := strconv.ParseInt(warehousing_out_orders, 10, 64)
|
|
1647
|
+ number = numbers + totals
|
|
1648
|
+ warehousing_out_order = "YPCKD" + strconv.FormatInt(numbers, 10)
|
|
1649
|
+ info := models.XtDrugWarehouseOutInfo{
|
|
1650
|
+ WarehouseOutId: orderOut.ID,
|
|
1651
|
+ DrugId: adviceName.DrugId,
|
|
1652
|
+ Count: outStoreNumber,
|
|
1653
|
+ Price: drug.RetailPrice,
|
|
1654
|
+ TotalPrice: drug.RetailPrice,
|
|
1655
|
+ ProductDate: theTime.Unix(),
|
|
1656
|
+ Ctime: time.Now().Unix(),
|
|
1657
|
+ Status: 1,
|
|
1658
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
1659
|
+ IsCancel: 2,
|
|
1660
|
+ WarehouseOutOrderNumber: warehousing_out_order,
|
|
1661
|
+ Type: 1,
|
|
1662
|
+ Manufacturer: orderOut.Manufacturer,
|
|
1663
|
+ IsSys: 1,
|
|
1664
|
+ SysRecordTime: theTime.Unix(),
|
|
1665
|
+ }
|
|
1666
|
+ service.CreateWareHouseOutInfo(&info)
|
|
1667
|
+
|
|
1668
|
+ timeArrss := strings.Split(timeStr, "-")
|
|
1669
|
+ totalss, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
|
|
1670
|
+
|
|
1671
|
+ totalss = totalss + 1
|
|
1672
|
+ warehousing_out_orderss := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArrss[0] + timeArrss[1] + timeArrss[2] + "000"
|
|
1673
|
+ numberss, _ := strconv.ParseInt(warehousing_out_orderss, 10, 64)
|
|
1674
|
+ number = numberss + totalss
|
|
1675
|
+ warehousing_out_order = "YPCKD" + strconv.FormatInt(numberss, 10)
|
|
1676
|
+ detail := models.XtDrugAutomaticReduceDetail{
|
|
1677
|
+ WarehouseOutOrderNumber: warehousing_out_order,
|
|
1678
|
+ WarehouseOutId: orderOut.ID,
|
|
1679
|
+ PatientId: adviceName.PatientId,
|
|
1680
|
+ Ctime: time.Now().Unix(),
|
|
1681
|
+ RecordTime: theTime.Unix(),
|
|
1682
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
1683
|
+ GoodId: adviceName.DrugId,
|
|
1684
|
+ Count: outStoreNumber,
|
|
1685
|
+ Status: 1,
|
|
1686
|
+ }
|
|
1687
|
+ service.CreateAotoMaticReduceDetail(&detail)
|
|
1688
|
+ }
|
|
1689
|
+
|
|
1690
|
+ if adviceName.ExecutionState == 1 && adviceName.Way == 2 {
|
|
1691
|
+
|
1569
|
1692
|
prescribingNumber := strconv.FormatFloat(math.Abs(adviceName.PrescribingNumber), 'f', 0, 64)
|
1570
|
1693
|
outStoreNumber, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1571
|
1694
|
|