瀏覽代碼

历史排班

28169 1 年之前
父節點
當前提交
aa94d944ad

+ 62 - 3
controllers/doctors_api_controller.go 查看文件

67
 	beego.Router("/api/patient/deletefirstdisease", &DoctorsApiController{}, "Get:DeleteFirstDisease")
67
 	beego.Router("/api/patient/deletefirstdisease", &DoctorsApiController{}, "Get:DeleteFirstDisease")
68
 
68
 
69
 	beego.Router("/api/schedule/new/long/advices", &DoctorsApiController{}, "Get:GetLongScheduleAdvicesList")
69
 	beego.Router("/api/schedule/new/long/advices", &DoctorsApiController{}, "Get:GetLongScheduleAdvicesList")
70
+
71
+	beego.Router("/api/schedule/getpatientbyname", &DoctorsApiController{}, "Get:GetPatientByName")
72
+	beego.Router("/api/schedule/getdocadvicebypatientid", &DoctorsApiController{}, "Get:GetDoctorAdviceByPatientId")
70
 }
73
 }
71
 
74
 
72
 func (c *DoctorsApiController) ScheduleAdvices() {
75
 func (c *DoctorsApiController) ScheduleAdvices() {
825
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
828
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
826
 	end_time := this.GetString("end_time")
829
 	end_time := this.GetString("end_time")
827
 	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
830
 	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
828
-	fmt.Println("endtime2323232233223232332", endTime)
831
+
829
 	prescription_list, _ := service.GetDialysisPrescriptionDataList(patient_id, startTime.Unix(), endTime.Unix())
832
 	prescription_list, _ := service.GetDialysisPrescriptionDataList(patient_id, startTime.Unix(), endTime.Unix())
830
 	befor_list, err := service.GetDialysisBeforInitDateList(patient_id, startTime.Unix(), endTime.Unix())
833
 	befor_list, err := service.GetDialysisBeforInitDateList(patient_id, startTime.Unix(), endTime.Unix())
831
 	after_list, err := service.GetDialysisAssementAfter(patient_id, startTime.Unix(), endTime.Unix())
834
 	after_list, err := service.GetDialysisAssementAfter(patient_id, startTime.Unix(), endTime.Unix())
1244
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1247
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1245
 	patient_id, _ := this.GetInt64("patient_id")
1248
 	patient_id, _ := this.GetInt64("patient_id")
1246
 	start_time := this.GetString("start_time")
1249
 	start_time := this.GetString("start_time")
1247
-	fmt.Println("start_tim232232323232323232323232332", start_time)
1250
+
1248
 	dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1251
 	dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1249
 	startime := dischargeTimes.Unix()
1252
 	startime := dischargeTimes.Unix()
1250
-	fmt.Println("startime1111111111111111111111", startime)
1253
+
1251
 	end_time := this.GetString("end_time")
1254
 	end_time := this.GetString("end_time")
1252
 	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
1255
 	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
1253
 	endtime := endTimes.Unix()
1256
 	endtime := endTimes.Unix()
1671
 	}
1674
 	}
1672
 
1675
 
1673
 }
1676
 }
1677
+
1678
+func (c *DoctorsApiController) GetPatientByName() {
1679
+
1680
+	keyword := c.GetString("keyword")
1681
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1682
+	patients, _ := service.GetPatientByName(keyword, orgId)
1683
+	c.ServeSuccessJSON(map[string]interface{}{
1684
+		"patients": patients,
1685
+	})
1686
+}
1687
+
1688
+func (c *DoctorsApiController) GetDoctorAdviceByPatientId() {
1689
+
1690
+	patient_id, _ := c.GetInt64("patient_id")
1691
+	limit, _ := c.GetInt64("limit")
1692
+	page, _ := c.GetInt64("page")
1693
+	start_time := c.GetString("start_time")
1694
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1695
+	end_time := c.GetString("end_time")
1696
+
1697
+	fmt.Println("patient_id", patient_id)
1698
+	fmt.Println("startdateunix", start_time)
1699
+	fmt.Println("enddateunix", end_time)
1700
+	fmt.Println("limit", limit)
1701
+	fmt.Println("page", page)
1702
+
1703
+	timeLayout := "2006-01-02"
1704
+	loc, _ := time.LoadLocation("Local")
1705
+
1706
+	var startTimeUnix int64
1707
+	if len(start_time) > 0 {
1708
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1709
+		if err != nil {
1710
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1711
+			return
1712
+		}
1713
+		startTimeUnix = theTime.Unix()
1714
+	}
1715
+
1716
+	var endTimeUnix int64
1717
+	if len(end_time) > 0 {
1718
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
1719
+		if err != nil {
1720
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1721
+			return
1722
+		}
1723
+		endTimeUnix = theTime.Unix()
1724
+	}
1725
+
1726
+	list, total, _ := service.GetDoctorAdviceByPatientId(patient_id, orgId, startTimeUnix, endTimeUnix, limit, page)
1727
+
1728
+	c.ServeSuccessJSON(map[string]interface{}{
1729
+		"list":  list,
1730
+		"total": total,
1731
+	})
1732
+}

+ 65 - 12
controllers/sign_api_controller.go 查看文件

510
 
510
 
511
 	admin_user_id, _ := this.GetInt64("admin_user_id")
511
 	admin_user_id, _ := this.GetInt64("admin_user_id")
512
 
512
 
513
+	creater := this.GetAdminUserInfo().AdminUser.Id
514
+
515
+	userName := service.GetLastAdminUserName(admin_user_id, orgId)
516
+	//查询医护是否完成认证
513
 	lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
517
 	lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
514
 
518
 
515
-	//personSeal, personSealId := service.CreateNewPersionSeal(lastPerson.UserId)
519
+	if lastPerson.ID > 0 {
520
+		this.ServeDynamicFailJsonSend("已完成认证,无需再次认证")
521
+		return
522
+	}
516
 
523
 
517
-	personSeal, personSealId := service.CreateSKDPersionSeal(lastPerson.UserId)
518
-	service.UpdatePerseEnterPriseById(lastPerson.ID, personSealId)
519
-	this.ServeSuccessJSON(map[string]interface{}{
520
-		"personSeal": personSeal,
521
-	})
522
-	return
524
+	if lastPerson.ID == 0 {
525
+		//去认证
526
+		personSeal, sealBase64 := service.CreateSKDPersionSeal(lastPerson.UserId, userName)
527
+
528
+		fmt.Println("sealBase64", sealBase64)
529
+		enterprise := models.XtDevicePersonEnterprise{
530
+			AdminUserId:  admin_user_id,
531
+			DisplayName:  "",
532
+			Phone:        "",
533
+			IdCardNum:    "",
534
+			UserOrgId:    orgId,
535
+			Status:       1,
536
+			Creater:      creater,
537
+			Ctime:        time.Now().Unix(),
538
+			Mtime:        0,
539
+			UserId:       "",
540
+			Personsealid: "",
541
+			Sealid:       "",
542
+			UserName:     userName,
543
+			Sealbase64:   sealBase64,
544
+		}
545
+		service.CreateEnterpriseUserName(enterprise)
546
+
547
+		this.ServeSuccessJSON(map[string]interface{}{
548
+			"personSeal": personSeal,
549
+		})
550
+		return
551
+	}
523
 
552
 
524
 }
553
 }
525
 
554
 
642
 
671
 
643
 func (this *SignApiController) CreateQianshuUserName() {
672
 func (this *SignApiController) CreateQianshuUserName() {
644
 
673
 
645
-	sign, userId := service.CreateQianshuUserName()
674
+	admin_user_id, _ := this.GetInt64("admin_user_id")
675
+
676
+	orgId := this.GetAdminUserInfo().CurrentOrgId
677
+	userName := service.GetLastAdminUserName(admin_user_id, orgId)
678
+
679
+	idCardNumber := service.GetLastAdminUserIdCardNumber(admin_user_id, orgId)
680
+
681
+	adminRole, _ := service.GetMobile(admin_user_id)
682
+
683
+	//查询该医护人员是否已经签署了
684
+	lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
685
+
686
+	if len(lastPerson.UserId) > 0 {
687
+		this.ServeDynamicFailJsonSend("已完成签署,无需再次签署")
688
+		return
689
+	}
690
+
691
+	if len(lastPerson.UserId) == 0 {
692
+		//去签署
693
+		sign, userId := service.CreateQianshuUserName(userName, adminRole.Mobile, idCardNumber)
694
+
695
+		err := service.UpdatePersionEnterPrise(lastPerson.ID, userId)
696
+		fmt.Println(err)
697
+		this.ServeSuccessJSON(map[string]interface{}{
698
+			"sign":   sign,
699
+			"userId": userId,
700
+		})
701
+
702
+	}
646
 
703
 
647
-	this.ServeSuccessJSON(map[string]interface{}{
648
-		"sign":   sign,
649
-		"userId": userId,
650
-	})
651
 }
704
 }
652
 
705
 
653
 func (this *SignApiController) CreateSdkSendInformation() {
706
 func (this *SignApiController) CreateSdkSendInformation() {

+ 2 - 0
models/sign.models.go 查看文件

124
 	UserId       string `gorm:"column:user_id" json:"user_id" form:"user_id"`
124
 	UserId       string `gorm:"column:user_id" json:"user_id" form:"user_id"`
125
 	Personsealid string `gorm:"column:person_seal_id" json:"person_seal_id" form:"person_seal_id"`
125
 	Personsealid string `gorm:"column:person_seal_id" json:"person_seal_id" form:"person_seal_id"`
126
 	Sealid       string `gorm:"column:seal_id" json:"seal_id" form:"seal_id"`
126
 	Sealid       string `gorm:"column:seal_id" json:"seal_id" form:"seal_id"`
127
+	UserName     string `gorm:"column:user_name" json:"user_name" form:"user_name"`
128
+	Sealbase64   string `gorm:"column:sealbase64" json:"sealbase64" form:"sealbase64"`
127
 }
129
 }
128
 
130
 
129
 func (XtDevicePersonEnterprise) TableName() string {
131
 func (XtDevicePersonEnterprise) TableName() string {

+ 42 - 0
service/doctor_advice_service.go 查看文件

491
 	err = XTReadDB().Where("advice_date = ? and user_org_id = ? and patient_id = ? and status = 1", record_time, org_id, patient_id).Order("created_time asc").Find(&advice).Error
491
 	err = XTReadDB().Where("advice_date = ? and user_org_id = ? and patient_id = ? and status = 1", record_time, org_id, patient_id).Order("created_time asc").Find(&advice).Error
492
 	return advice, err
492
 	return advice, err
493
 }
493
 }
494
+
495
+func GetPatientByName(keyword string, user_org_id int64) (patients []*models.XtPatients, err error) {
496
+
497
+	db := XTReadDB().Model(&patients).Where("status=1")
498
+	if len(keyword) > 0 {
499
+		likeKey := "%" + keyword + "%"
500
+		db = db.Where("name LIKE ? OR dialysis_no LIKE ?", likeKey, likeKey)
501
+	}
502
+
503
+	if user_org_id > 0 {
504
+		db = db.Where("user_org_id =?", user_org_id)
505
+	}
506
+
507
+	err = db.Find(&patients).Error
508
+
509
+	return patients, err
510
+}
511
+
512
+func GetDoctorAdviceByPatientId(patient_id int64, user_org_id int64, start_time int64, end_time int64, limit int64, page int64) (advice []*models.DoctorAdvice, total int64, err error) {
513
+
514
+	db := XTReadDB().Model(&advice).Where("status=1")
515
+	//offset := (page - 1) * limit
516
+	if patient_id > 0 {
517
+		db = db.Where("patient_id = ?", patient_id)
518
+	}
519
+
520
+	if user_org_id > 0 {
521
+		db = db.Where("user_org_id =?", user_org_id)
522
+	}
523
+
524
+	if start_time > 0 {
525
+		db = db.Where("advice_date >= ?", start_time)
526
+	}
527
+
528
+	if end_time > 0 {
529
+		db = db.Where("advice_date <= ?", end_time)
530
+	}
531
+
532
+	err = db.Find(&advice).Error
533
+
534
+	return advice, total, err
535
+}

+ 44 - 21
service/sign_service.go 查看文件

1102
 	return str, personSealId
1102
 	return str, personSealId
1103
 }
1103
 }
1104
 
1104
 
1105
-func CreateSKDPersionSeal(userId string) (string, string) {
1105
+func CreateSKDPersionSeal(userId string, user_name string) (string, string) {
1106
 
1106
 
1107
 	maprequest := make(map[string]interface{})
1107
 	maprequest := make(map[string]interface{})
1108
 
1108
 
1109
-	//maprequest["userId"] = userId
1110
-
1111
 	//印章字体 1宋体(默认)2 黑体
1109
 	//印章字体 1宋体(默认)2 黑体
1112
 	maprequest["fontType"] = 1
1110
 	maprequest["fontType"] = 1
1113
 	//个人姓名(1-42位字符)
1111
 	//个人姓名(1-42位字符)
1114
-	maprequest["personName"] = "王志文"
1112
+	maprequest["personName"] = user_name
1115
 	var url string
1113
 	var url string
1116
 	url = "http://localhost:8890/sdk/seal/createPersonSeal"
1114
 	url = "http://localhost:8890/sdk/seal/createPersonSeal"
1117
 	appId := beego.AppConfig.String("sign_appid")
1115
 	appId := beego.AppConfig.String("sign_appid")
1157
 	if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
1155
 	if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
1158
 		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
1156
 		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
1159
 	}
1157
 	}
1160
-	var personSealId string
1161
-	//personSealId = respJSON["data"].(map[string]interface{})["personSealId"].(string)
1162
-	//fmt.Println("str", personSealId)
1163
-	return str, personSealId
1158
+	var sealBase64 string
1159
+	sealBase64 = respJSON["data"].(map[string]interface{})["sealBase64"].(string)
1160
+
1161
+	return str, sealBase64
1164
 }
1162
 }
1165
 
1163
 
1166
 func UpdatePerseEnterPriseById(id int64, personSealId string) error {
1164
 func UpdatePerseEnterPriseById(id int64, personSealId string) error {
1524
 	return dataconfig, err
1522
 	return dataconfig, err
1525
 }
1523
 }
1526
 
1524
 
1527
-func CreateQianshuUserName() (string, string) {
1525
+func CreateQianshuUserName(user_name string, phone string, id_card_number string) (string, string) {
1528
 
1526
 
1529
 	var url string
1527
 	var url string
1530
 
1528
 
1531
 	url = "http://localhost:8890/sdk/user/create"
1529
 	url = "http://localhost:8890/sdk/user/create"
1532
-	var account string
1533
-
1534
-	account = "13318464642"
1535
-
1536
-	var realName string
1530
+	//var account string
1531
+	//
1532
+	//account = "13318464642"
1537
 
1533
 
1538
-	realName = "马文强"
1534
+	//var realName string
1535
+	//
1536
+	//realName = "马文强"
1539
 
1537
 
1540
 	maprequest := make(map[string]interface{})
1538
 	maprequest := make(map[string]interface{})
1541
 
1539
 
1542
-	maprequest["account"] = account
1540
+	maprequest["account"] = phone
1543
 
1541
 
1544
 	//账号类型:1手机号,2邮箱
1542
 	//账号类型:1手机号,2邮箱
1545
 	maprequest["accountType"] = 1
1543
 	maprequest["accountType"] = 1
1546
 
1544
 
1547
-	maprequest["realName"] = realName
1545
+	maprequest["realName"] = user_name
1548
 
1546
 
1549
 	//签署人类型 1个人 2.企业
1547
 	//签署人类型 1个人 2.企业
1550
 	maprequest["signerType"] = 1
1548
 	maprequest["signerType"] = 1
1552
 	// 0表示 身份证
1550
 	// 0表示 身份证
1553
 	maprequest["cardType"] = 0
1551
 	maprequest["cardType"] = 0
1554
 
1552
 
1555
-	maprequest["cardNumber"] = "430526199408156511"
1553
+	//maprequest["cardNumber"] = "430526199408156511"
1556
 
1554
 
1557
-	fmt.Println("maprequestwowowowowoowow", maprequest)
1555
+	maprequest["cardNumber"] = id_card_number
1558
 
1556
 
1559
 	byterequest, _ := json.Marshal(maprequest)
1557
 	byterequest, _ := json.Marshal(maprequest)
1560
 
1558
 
1597
 		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
1595
 		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
1598
 	}
1596
 	}
1599
 	var UserId string
1597
 	var UserId string
1600
-	//UserId = respJSON["data"].(map[string]interface{})["userId"].(string)
1601
-	//fmt.Println("str", UserId)
1598
+	UserId = respJSON["data"].(map[string]interface{})["userId"].(string)
1599
+	fmt.Println("str", UserId)
1602
 	return str, UserId
1600
 	return str, UserId
1603
 }
1601
 }
1604
 
1602
 
2014
 
2012
 
2015
 	return str
2013
 	return str
2016
 }
2014
 }
2015
+
2016
+func GetLastAdminUserName(doctor, orgid int64) string {
2017
+	var tmp models.VmUserAdminRole
2018
+	XTReadDB().Model(&models.VmUserAdminRole{}).Where("admin_user_id = ? and org_id = ? and status = 1", doctor, orgid).Last(&tmp)
2019
+	return tmp.UserName
2020
+}
2021
+
2022
+func GetLastAdminUserIdCardNumber(doctor, orgid int64) string {
2023
+	var tmp models.VmUserAdminRole
2024
+	XTReadDB().Model(&models.VmUserAdminRole{}).Where("admin_user_id = ? and org_id = ? and status = 1", doctor, orgid).Last(&tmp)
2025
+	return tmp.JobNumber
2026
+}
2027
+
2028
+func CreateEnterpriseUserName(enterprise models.XtDevicePersonEnterprise) error {
2029
+
2030
+	err := XTWriteDB().Create(&enterprise).Error
2031
+
2032
+	return err
2033
+}
2034
+
2035
+func UpdatePersionEnterPrise(id int64, userId string) error {
2036
+
2037
+	err := XTWriteDB().Model(&models.XtDevicePersonEnterprise{}).Where("id=? and status =1", id).Updates(map[string]interface{}{"user_id": userId}).Error
2038
+	return err
2039
+}