陈少旭 1 неделю назад
Родитель
Сommit
bed8fde48a
1 измененных файлов: 212 добавлений и 24 удалений
  1. 212 24
      controllers/his_api_controller.go

+ 212 - 24
controllers/his_api_controller.go Просмотреть файл

@@ -1403,13 +1403,15 @@ func StrPtr(s string) uintptr {
1403 1403
 }
1404 1404
 
1405 1405
 func (c *HisApiController) GetHisPatientList() {
1406
-	//types, _ := c.GetInt64("type", 0)
1407 1406
 	record_date := c.GetString("record_date")
1408 1407
 	sch_type, _ := c.GetInt64("sch_type")
1408
+	patient_type, _ := c.GetInt64("patient_type")
1409 1409
 
1410
+	fmt.Println("patient_type")
1411
+
1412
+	fmt.Println(patient_type)
1410 1413
 	timeLayout := "2006-01-02"
1411 1414
 	loc, _ := time.LoadLocation("Local")
1412
-
1413 1415
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1414 1416
 	if err != nil {
1415 1417
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -1417,31 +1419,49 @@ func (c *HisApiController) GetHisPatientList() {
1417 1419
 	}
1418 1420
 	recordDateTime := theTime.Unix()
1419 1421
 	adminInfo := c.GetAdminUserInfo()
1420
-	//patients, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
1421
-	patients, _ := service.GetNewHisPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
1422
-	patients_two, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, sch_type)
1423
-	//patient_three, _ := service.GetNewHisPatientListTwo(adminInfo.CurrentOrgId, recordDateTime, sch_type)
1424
-
1425
-	//patients_two, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, sch_type)
1422
+	patients, _ := service.GetNewHisPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type, 0)
1423
+	patients_two, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, sch_type, 0)
1424
+
1425
+	if patient_type == 2 && c.GetAdminUserInfo().CurrentOrgId == 10721 {
1426
+		fmt.Println("111111")
1427
+		patients_three, _ := service.GetFuTouHisPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
1428
+		fmt.Println(patients_three)
1429
+		//获取当前用户的信息
1430
+		adminUserInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
1431
+		doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
1432
+		//获取所有科室信息
1433
+		department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
1434
+		//var aa []service.PatientThree
1435
+		noElementsSlice := make([]service.PatientThree, 0)
1436
+		c.ServeSuccessJSON(map[string]interface{}{
1437
+			"list":       patients_three,
1438
+			"list_two":   patients_three,
1439
+			"list_three": noElementsSlice,
1440
+			"info":       adminUserInfo,
1441
+			"doctors":    doctors,
1442
+			"department": department,
1443
+		})
1444
+	} else {
1426 1445
 
1427
-	//获取当前用户的信息
1428
-	adminUserInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
1429
-	doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
1430
-	//获取所有科室信息
1431
-	department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
1432
-	//var aa []service.PatientThree
1446
+		//获取当前用户的信息
1447
+		adminUserInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
1448
+		doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
1449
+		//获取所有科室信息
1450
+		department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
1451
+		//var aa []service.PatientThree
1452
+		noElementsSlice := make([]service.PatientThree, 0)
1433 1453
 
1434
-	noElementsSlice := make([]service.PatientThree, 0)
1435
-	c.ServeSuccessJSON(map[string]interface{}{
1454
+		c.ServeSuccessJSON(map[string]interface{}{
1455
+			"list":       patients,
1456
+			"list_two":   patients_two,
1457
+			"list_three": noElementsSlice,
1458
+			"info":       adminUserInfo,
1459
+			"doctors":    doctors,
1460
+			"department": department,
1461
+		})
1436 1462
 
1437
-		"list":       patients,
1438
-		"list_two":   patients_two,
1439
-		"list_three": noElementsSlice,
1463
+	}
1440 1464
 
1441
-		"info":       adminUserInfo,
1442
-		"doctors":    doctors,
1443
-		"department": department,
1444
-	})
1445 1465
 }
1446 1466
 
1447 1467
 type CustomTemplate struct {
@@ -1497,6 +1517,8 @@ func (c *HisApiController) GetHisPatientInfo() {
1497 1517
 
1498 1518
 	count, _ := service.GetHisPatientCount(admin.CurrentOrgId, patient_id, recordDateTime)
1499 1519
 
1520
+	pre, _ := service.GetDialysisPrescription(patient_id, admin.CurrentOrgId, recordDateTime)
1521
+
1500 1522
 	var prescriptions []*models.HisPrescription
1501 1523
 	var last_prescriptions []*models.HisPrescription
1502 1524
 	var sch_prescriptions []CustomTemplate
@@ -1672,7 +1694,6 @@ func (c *HisApiController) GetHisPatientInfo() {
1672 1694
 					subItem.Drug.MinPrice = info.RetailPrice
1673 1695
 
1674 1696
 					if admin.CurrentOrgId != 10598 {
1675
-
1676 1697
 						service.UpdatePrescriptionAdvice(subItem.DrugId, admin.CurrentOrgId, info.RetailPrice, subItem.PatientId)
1677 1698
 						service.UpdateBaseMinPrice(subItem.DrugId, admin.CurrentOrgId, info.RetailPrice)
1678 1699
 					}
@@ -1721,6 +1742,173 @@ func (c *HisApiController) GetHisPatientInfo() {
1721 1742
 	LastCaseHistory, _ := service.GetLastHisPatientCaseHistory(admin.CurrentOrgId, patient_id)
1722 1743
 
1723 1744
 	prescriptionInfo, _ := service.GetDialysisPresriptionById(admin.CurrentOrgId, patient_id, recordDateTime)
1745
+
1746
+	fmt.Println(prescriptions)
1747
+	fmt.Println(sch_prescriptions)
1748
+	fmt.Println(last_prescriptions)
1749
+
1750
+	if len(prescriptions) == 0 && c.GetAdminUserInfo().CurrentOrgId == 10721 {
1751
+		if len(sch_prescriptions) > 0 {
1752
+			var index = 0
1753
+			for subindex, item := range sch_prescriptions {
1754
+				if item.Type == 2 {
1755
+					index = subindex
1756
+				}
1757
+			}
1758
+			fmt.Println(index)
1759
+			fmt.Println(len(sch_prescriptions))
1760
+
1761
+			if index >= 0 && index < len(sch_prescriptions) {
1762
+				one, _ := service.GetGoodInformationByGoodId(pre.DialysisDialyszersId)
1763
+				two, _ := service.GetGoodInformationByGoodId(pre.DialysisIrrigationId)
1764
+				three, _ := service.GetGoodInformationByGoodId(pre.DialysisStrainerId)
1765
+				if one.ID > 0 {
1766
+					var hpt models.HisPrescriptionProjectTemplate
1767
+					hpt.Type = 3
1768
+					hpt.ID = 0
1769
+					hpt.PatientId = sch_prescriptions[index].PatientId
1770
+					hpt.Status = 1
1771
+					hpt.UserOrgId = sch_prescriptions[index].UserOrgId
1772
+					hpt.Mtime = time.Now().Unix()
1773
+					hpt.Ctime = time.Now().Unix()
1774
+					hpt.RecordDate = sch_prescriptions[index].RecordDate
1775
+					hpt.Count = "1"
1776
+					hpt.Price = one.RetailPrice
1777
+					hpt.ProjectId = one.ID
1778
+					hpt.FeedetlSn = ""
1779
+					hpt.PrescriptionId = sch_prescriptions[index].ID
1780
+					hpt.Unit = one.PackingUnit
1781
+					hpt.Day = "1"
1782
+					hpt.SingleDose = "1"
1783
+					hpt.GoodInfo = one
1784
+					sch_prescriptions[index].HisPrescriptionProjectTemplate = append(sch_prescriptions[index].HisPrescriptionProjectTemplate, &hpt)
1785
+				}
1786
+				if two.ID > 0 {
1787
+					var hpt models.HisPrescriptionProjectTemplate
1788
+					hpt.Type = 3
1789
+					hpt.ID = 0
1790
+					hpt.PatientId = sch_prescriptions[index].PatientId
1791
+					hpt.Status = 1
1792
+					hpt.UserOrgId = sch_prescriptions[index].UserOrgId
1793
+					hpt.Mtime = time.Now().Unix()
1794
+					hpt.Ctime = time.Now().Unix()
1795
+					hpt.RecordDate = sch_prescriptions[index].RecordDate
1796
+					hpt.Count = "1"
1797
+					hpt.Price = two.RetailPrice
1798
+					hpt.ProjectId = two.ID
1799
+					hpt.FeedetlSn = ""
1800
+					hpt.PrescriptionId = sch_prescriptions[index].ID
1801
+					hpt.Unit = two.PackingUnit
1802
+					hpt.Day = "1"
1803
+					hpt.SingleDose = "1"
1804
+					hpt.GoodInfo = two
1805
+					sch_prescriptions[index].HisPrescriptionProjectTemplate = append(sch_prescriptions[index].HisPrescriptionProjectTemplate, &hpt)
1806
+				}
1807
+				if three.ID > 0 {
1808
+					var hpt models.HisPrescriptionProjectTemplate
1809
+					hpt.Type = 3
1810
+					hpt.ID = 0
1811
+					hpt.PatientId = sch_prescriptions[index].PatientId
1812
+					hpt.Status = 1
1813
+					hpt.UserOrgId = sch_prescriptions[index].UserOrgId
1814
+					hpt.Mtime = time.Now().Unix()
1815
+					hpt.Ctime = time.Now().Unix()
1816
+					hpt.RecordDate = sch_prescriptions[index].RecordDate
1817
+					hpt.Count = "1"
1818
+					hpt.Price = three.RetailPrice
1819
+					hpt.ProjectId = three.ID
1820
+					hpt.FeedetlSn = ""
1821
+					hpt.PrescriptionId = sch_prescriptions[index].ID
1822
+					hpt.Unit = three.PackingUnit
1823
+					hpt.Day = "1"
1824
+					hpt.SingleDose = "1"
1825
+					hpt.GoodInfo = three
1826
+					sch_prescriptions[index].HisPrescriptionProjectTemplate = append(sch_prescriptions[index].HisPrescriptionProjectTemplate, &hpt)
1827
+				}
1828
+
1829
+				fmt.Println(sch_prescriptions)
1830
+			}
1831
+		} else {
1832
+			if len(last_prescriptions) > 0 {
1833
+				var index = 0
1834
+				for subindex, item := range last_prescriptions {
1835
+					if item.Type == 2 {
1836
+						index = subindex
1837
+					}
1838
+				}
1839
+				if index >= 0 && index < len(last_prescriptions) {
1840
+					one, _ := service.GetGoodInformationByGoodId(pre.DialysisDialyszersId)
1841
+					two, _ := service.GetGoodInformationByGoodId(pre.DialysisIrrigationId)
1842
+					three, _ := service.GetGoodInformationByGoodId(pre.DialysisStrainerId)
1843
+					if one.ID > 0 {
1844
+						var hpt models.HisPrescriptionProject
1845
+						hpt.Type = 3
1846
+						hpt.ID = 0
1847
+						hpt.PatientId = last_prescriptions[index].PatientId
1848
+						hpt.Status = 1
1849
+						hpt.UserOrgId = last_prescriptions[index].UserOrgId
1850
+						hpt.Mtime = time.Now().Unix()
1851
+						hpt.Ctime = time.Now().Unix()
1852
+						hpt.RecordDate = last_prescriptions[index].RecordDate
1853
+						hpt.Count = "1"
1854
+						hpt.Price = one.RetailPrice
1855
+						hpt.ProjectId = one.ID
1856
+						hpt.FeedetlSn = ""
1857
+						hpt.PrescriptionId = last_prescriptions[index].ID
1858
+						hpt.Unit = one.PackingUnit
1859
+						hpt.Day = "1"
1860
+						hpt.SingleDose = "1"
1861
+						hpt.GoodInfo = one
1862
+						last_prescriptions[index].HisPrescriptionProject = append(last_prescriptions[index].HisPrescriptionProject, &hpt)
1863
+
1864
+					}
1865
+					if two.ID > 0 {
1866
+						var hpt models.HisPrescriptionProject
1867
+						hpt.Type = 3
1868
+						hpt.ID = 0
1869
+						hpt.PatientId = last_prescriptions[index].PatientId
1870
+						hpt.Status = 1
1871
+						hpt.UserOrgId = last_prescriptions[index].UserOrgId
1872
+						hpt.Mtime = time.Now().Unix()
1873
+						hpt.Ctime = time.Now().Unix()
1874
+						hpt.RecordDate = last_prescriptions[index].RecordDate
1875
+						hpt.Count = "1"
1876
+						hpt.Price = two.RetailPrice
1877
+						hpt.ProjectId = two.ID
1878
+						hpt.FeedetlSn = ""
1879
+						hpt.PrescriptionId = last_prescriptions[index].ID
1880
+						hpt.Unit = two.PackingUnit
1881
+						hpt.Day = "1"
1882
+						hpt.SingleDose = "1"
1883
+						hpt.GoodInfo = two
1884
+						last_prescriptions[index].HisPrescriptionProject = append(last_prescriptions[index].HisPrescriptionProject, &hpt)
1885
+					}
1886
+					if three.ID > 0 {
1887
+						var hpt models.HisPrescriptionProject
1888
+						hpt.Type = 3
1889
+						hpt.ID = 0
1890
+						hpt.PatientId = last_prescriptions[index].PatientId
1891
+						hpt.Status = 1
1892
+						hpt.UserOrgId = last_prescriptions[index].UserOrgId
1893
+						hpt.Mtime = time.Now().Unix()
1894
+						hpt.Ctime = time.Now().Unix()
1895
+						hpt.RecordDate = last_prescriptions[index].RecordDate
1896
+						hpt.Count = "1"
1897
+						hpt.Price = three.RetailPrice
1898
+						hpt.ProjectId = three.ID
1899
+						hpt.FeedetlSn = ""
1900
+						hpt.PrescriptionId = last_prescriptions[index].ID
1901
+						hpt.Unit = three.PackingUnit
1902
+						hpt.Day = "1"
1903
+						hpt.SingleDose = "1"
1904
+						hpt.GoodInfo = three
1905
+						last_prescriptions[index].HisPrescriptionProject = append(last_prescriptions[index].HisPrescriptionProject, &hpt)
1906
+					}
1907
+				}
1908
+			}
1909
+		}
1910
+	}
1911
+
1724 1912
 	c.ServeSuccessJSON(map[string]interface{}{
1725 1913
 		"his_info":     his_patient_info,
1726 1914
 		"xt_info":      xt_patient_info,