소스 검색

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

csx 4 년 전
부모
커밋
da5524956c
6개의 변경된 파일129개의 추가작업 그리고 63개의 파일을 삭제
  1. 51 59
      controllers/his_api_controller.go
  2. 42 1
      controllers/his_project_api_controller.go
  3. 0 2
      models/his_models.go
  4. 25 0
      service/his_project_service.go
  5. 10 0
      service/his_service.go
  6. 1 1
      service/patient_service.go

+ 51 - 59
controllers/his_api_controller.go 파일 보기

@@ -9,7 +9,6 @@ import (
9 9
 	"github.com/astaxie/beego"
10 10
 	"reflect"
11 11
 	"strconv"
12
-	"strings"
13 12
 	"time"
14 13
 )
15 14
 
@@ -24,10 +23,6 @@ func HisManagerApiRegistRouters() {
24 23
 	beego.Router("/api/hisprescription/config", &HisApiController{}, "get:GetHisPrescriptionConfig")
25 24
 
26 25
 	beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
27
-	beego.Router("/api/hisdoctoradvice/create", &HisApiController{}, "post:CreateHisDoctorAdvice")
28
-	//beego.Router("/api/hisproject/create", &HisApiController{}, "post:CreateHisProject")
29
-	//beego.Router("/api/hisorder/create", &HisApiController{}, "post:CreateHisOrder")
30
-	//beego.Router("/api/hisadditional/create", &HisApiController{}, "post:CreateHisAdditionalCharge")
31 26
 
32 27
 	beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
33 28
 	beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
@@ -121,25 +116,24 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
121 116
 	//drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
122 117
 	drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
123 118
 	efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
124
-	//获取所有项目
125
-	projects, _ := service.GetAllProjectList(adminInfo.CurrentOrgId)
126
-	//获取所有项目组套
119
+
120
+	doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
127 121
 
128 122
 	c.ServeSuccessJSON(map[string]interface{}{
129 123
 		"drugs":            drugs,
130 124
 		"advices_template": advices,
131
-		"projects":         projects,
132 125
 		"drugways":         drugways,
133 126
 		"efs":              efs,
127
+		"doctors":          doctors,
134 128
 	})
135 129
 }
136 130
 func (c *HisApiController) CreateHisPrescription() {
137 131
 	record_date := c.GetString("record_date")
138 132
 	patient_id, _ := c.GetInt64("patient_id")
133
+	//diagnose := c.GetString("diagnose")
134
+	//sick_history := c.GetString("sick_history")
139 135
 	doctor, _ := c.GetInt64("doctor")
140
-
141
-	diagnose := c.GetString("diagnose")
142
-	special_sick_history := c.GetString("special_sick_history")
136
+	//departm/**/ent, _ := c.GetInt64("department")
143 137
 
144 138
 	dataBody := make(map[string]interface{}, 0)
145 139
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
@@ -159,11 +153,9 @@ func (c *HisApiController) CreateHisPrescription() {
159 153
 	adminInfo := c.GetAdminUserInfo()
160 154
 	recordDateTime := theTime.Unix()
161 155
 
162
-	//types, _ := c.GetInt64("type")
163
-	var prescriptions []*models.HisPrescription
156
+	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
157
+		prescriptions, _ := dataBody["prescriptions"].([]interface{})
164 158
 
165
-	if dataBody["prescription"] != nil && reflect.TypeOf(dataBody["prescription"]).String() == "[]interface {}" {
166
-		prescriptions, _ := dataBody["prescription"].([]interface{})
167 159
 		if len(prescriptions) > 0 {
168 160
 			for _, item := range prescriptions {
169 161
 				items := item.(map[string]interface{})
@@ -188,21 +180,38 @@ func (c *HisApiController) CreateHisPrescription() {
188 180
 					Status:     1,
189 181
 					Doctor:     doctor,
190 182
 				}
191
-				//prescriptions = append(prescriptions, prescription)
192 183
 				service.SaveHisPrescription(prescription)
193 184
 
194 185
 				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
195 186
 					advices := items["advices"].([]interface{})
187
+					group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
188
+					groupNo := group + 1
189
+					ctime := time.Now().Unix()
190
+					mtime := ctime
196 191
 					if len(advices) > 0 {
197 192
 						for _, advice := range advices {
198 193
 							var s models.HisDoctorAdviceInfo
194
+							s.PrescriptionId = prescription.ID
195
+							s.AdviceType = 2
196
+							s.AdviceDoctor = adminInfo.AdminUser.Id
197
+							s.StopState = 2
198
+							s.ExecutionState = 2
199
+							s.AdviceDate = recordDateTime
200
+							s.Status = 1
201
+							s.UserOrgId = adminInfo.CurrentOrgId
202
+							s.RecordDate = recordDateTime
203
+							s.StartTime = recordDateTime
204
+							s.Groupno = groupNo
205
+							s.CreatedTime = ctime
206
+							s.UpdatedTime = mtime
207
+							s.PatientId = patient_id
199 208
 
200 209
 							errcode := c.setAdviceWithJSON(&s, advice.(map[string]interface{}))
201 210
 							if errcode > 0 {
202 211
 								c.ServeFailJSONWithSGJErrorCode(errcode)
203 212
 								return
204 213
 							}
205
-							advice.Children = append(advice.Children, &s)
214
+							service.CreateHisDoctorAdvice(&s)
206 215
 						}
207 216
 					}
208 217
 				}
@@ -456,91 +465,74 @@ func (c *HisApiController) GetPrintHisPatientCaseHistory() {
456 465
 }
457 466
 func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo, json map[string]interface{}) int {
458 467
 
459
-	if json["advice_name"] == nil || reflect.TypeOf(json["advice_name"]).String() != "string" {
460
-		utils.ErrorLog("advice_name")
468
+	if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
469
+		utils.ErrorLog("drug_name")
461 470
 		return enums.ErrorCodeParamWrong
462 471
 	}
463
-	adviceName, _ := json["advice_name"].(string)
472
+	adviceName, _ := json["drug_name"].(string)
464 473
 	if len(adviceName) == 0 {
465 474
 		utils.ErrorLog("len(advice_name) == 0")
466 475
 		return enums.ErrorCodeParamWrong
467 476
 	}
468 477
 	advice.AdviceName = adviceName
469
-
470 478
 	adviceDesc, _ := json["advice_desc"].(string)
471 479
 	advice.AdviceDesc = adviceDesc
472
-
473 480
 	if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
474 481
 		drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
475 482
 		advice.DrugSpec = drugSpec
476 483
 	}
477
-
478 484
 	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
479 485
 		remark, _ := json["remark"].(string)
480 486
 		advice.Remark = remark
481 487
 	}
482
-
483
-	if json["way"] == nil {
484
-		advice.Way = 0
485
-
486
-	} else {
487
-		if json["way"] != nil || reflect.TypeOf(json["way"]).String() == "float64" {
488
-			way := int64(json["way"].(float64))
489
-			advice.Way = way
490
-		}
491
-
492
-	}
493
-
494
-	if json["drug_id"] == nil {
488
+	if json["id"] == nil {
495 489
 		advice.DrugId = 0
496 490
 	} else {
497
-		if json["drug_id"] != nil || reflect.TypeOf(json["drug_id"]).String() == "float64" {
498
-			drug_id := int64(json["drug_id"].(float64))
491
+		if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
492
+			drug_id := int64(json["id"].(float64))
499 493
 			advice.DrugId = drug_id
500 494
 		}
501 495
 	}
502 496
 
503
-	if json["drug_name_id"] == nil {
504
-		advice.DrugNameId = 0
505
-	} else {
506
-		if json["drug_name_id"] != nil || reflect.TypeOf(json["drug_name_id"]).String() == "float64" {
507
-			drug_name_id := int64(json["drug_name_id"].(float64))
508
-			advice.DrugNameId = drug_name_id
509
-		}
510
-	}
511
-
512
-	if json["drug_spec_unit"] != nil && reflect.TypeOf(json["drug_spec_unit"]).String() == "string" {
513
-		drugSpecUnit, _ := json["drug_spec_unit"].(string)
497
+	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
498
+		drugSpecUnit, _ := json["min_unit"].(string)
514 499
 		advice.DrugSpecUnit = drugSpecUnit
515 500
 	}
516
-
517 501
 	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
518 502
 		singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
519 503
 		advice.SingleDose = singleDose
520 504
 	}
521
-
522
-	if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
523
-		singleDoseUnit, _ := json["single_dose_unit"].(string)
505
+	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
506
+		singleDoseUnit, _ := json["min_unit"].(string)
524 507
 		advice.SingleDoseUnit = singleDoseUnit
525 508
 	}
526
-
527 509
 	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
528 510
 		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
529 511
 		advice.PrescribingNumber = prescribingNumber
530 512
 	}
531
-
532
-	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
533
-		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
513
+	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
514
+		prescribingNumberUnit, _ := json["min_unit"].(string)
534 515
 		advice.PrescribingNumberUnit = prescribingNumberUnit
535 516
 	}
536 517
 	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
537 518
 		deliveryWay, _ := json["delivery_way"].(string)
538 519
 		advice.DeliveryWay = deliveryWay
539 520
 	}
540
-
541 521
 	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
542 522
 		executionFrequency, _ := json["execution_frequency"].(string)
543 523
 		advice.ExecutionFrequency = executionFrequency
544 524
 	}
525
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
526
+		remark, _ := json["remark"].(string)
527
+		advice.Remark = remark
528
+	}
529
+	//if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
530
+	//	advice.Price = json["retail_price"].(float64)
531
+	//}
532
+
533
+	if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
534
+		price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
535
+		advice.Price = price
536
+	}
545 537
 	return 0
546 538
 }

+ 42 - 1
controllers/his_project_api_controller.go 파일 보기

@@ -5,7 +5,6 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8
-	//"encoding/json"
9 8
 	"fmt"
10 9
 	"github.com/astaxie/beego"
11 10
 	"github.com/jinzhu/gorm"
@@ -52,6 +51,8 @@ func HisProjectRouters() {
52 51
 	beego.Router("/api/his/gettreatlist", &HisProjectApiController{}, "Get:GetTreatmentList")
53 52
 	beego.Router("/api/his/getpatientinformation", &HisProjectApiController{}, "Get:GetPatientInformation")
54 53
 	beego.Router("/api/hist/getallprojecteam", &HisProjectApiController{}, "Get:GetAllProjectTeam")
54
+	beego.Router("/api/his/getprojectlistbyid", &HisProjectApiController{}, "Get:GetProjectListById")
55
+	beego.Router("/api/his/gethispatienthistory", &HisProjectApiController{}, "Get:GetHisPatientHistory")
55 56
 }
56 57
 
57 58
 func (this *HisProjectApiController) SaveProject() {
@@ -821,6 +822,7 @@ func (this *HisProjectApiController) GetAllProjectTeam() {
821 822
 
822 823
 	adminUserInfo := this.GetAdminUserInfo()
823 824
 	orgId := adminUserInfo.CurrentOrgId
825
+	fmt.Println("aaa")
824 826
 	team, err := service.GetAllProjectTeam(orgId)
825 827
 	if err != nil {
826 828
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
@@ -830,3 +832,42 @@ func (this *HisProjectApiController) GetAllProjectTeam() {
830 832
 		"team": team,
831 833
 	})
832 834
 }
835
+
836
+func (this *HisProjectApiController) GetProjectListById() {
837
+
838
+	adminUserInfo := this.GetAdminUserInfo()
839
+	orgId := adminUserInfo.CurrentOrgId
840
+	project_id := this.GetString("project_id")
841
+	idStrs := strings.Split(project_id, ",")
842
+	project, err := service.GetProjectListById(orgId, idStrs)
843
+	if err != nil {
844
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
845
+		return
846
+	}
847
+	this.ServeSuccessJSON(map[string]interface{}{
848
+		"project": project,
849
+	})
850
+}
851
+
852
+func (this *HisProjectApiController) GetHisPatientHistory() {
853
+	timeLayout := "2006-01-02"
854
+	loc, _ := time.LoadLocation("Local")
855
+	keyword := this.GetString("keyword")
856
+	start_time := this.GetString("start_time")
857
+	end_time := this.GetString("end_time")
858
+	register_type, _ := this.GetInt64("register_type")
859
+	limit, _ := this.GetInt64("limit")
860
+	page, _ := this.GetInt64("page")
861
+	fmt.Println(keyword, start_time, end_time, register_type, limit, page)
862
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
863
+	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
864
+	history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page)
865
+	if err != nil {
866
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
867
+		return
868
+	}
869
+	this.ServeSuccessJSON(map[string]interface{}{
870
+		"history": history,
871
+		"total":   total,
872
+	})
873
+}

+ 0 - 2
models/his_models.go 파일 보기

@@ -192,8 +192,6 @@ type HisDoctorAdviceInfo struct {
192 192
 	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
193 193
 	Price                 float64 `gorm:"column:price" json:"price" form:"price"`
194 194
 	PrescriptionId        int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
195
-	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
196
-	DrugNameId            int64   `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
197 195
 }
198 196
 
199 197
 func (HisDoctorAdviceInfo) TableName() string {

+ 25 - 0
service/his_project_service.go 파일 보기

@@ -278,3 +278,28 @@ func GetAllProjectTeam(orgid int64) (project []*models.XtHisProjectTeam, err err
278 278
 	err = XTReadDB().Model(&project).Where("user_org_id = ? and status = 1", orgid).Find(&project).Error
279 279
 	return project, err
280 280
 }
281
+
282
+func GetProjectListById(orgid int64, ids []string) (project []*models.XtHisProject, err error) {
283
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and id in (?)", orgid, ids).Find(&project).Error
284
+	return project, err
285
+}
286
+
287
+func GetHisPatientHistory(keyword string, startime int64, endtime int64, registtype int64, limit int64, page int64) (hisPatient []*models.XtHisPatient, total int64, err error) {
288
+	offset := (page - 1) * limit
289
+	likeKey := "%" + keyword + "%"
290
+	db := XTReadDB().Table("his_patient as x").Where("x.status = 1")
291
+	if len(keyword) > 0 {
292
+		db = db.Where("x.name like ?", likeKey)
293
+	}
294
+	if startime > 0 {
295
+		db = db.Where("x.record_date >= ?", startime)
296
+	}
297
+	if endtime > 0 {
298
+		db = db.Where("x.record_date<=?", endtime)
299
+	}
300
+	if registtype > 0 {
301
+		db = db.Where("x.register_type = ?", registtype)
302
+	}
303
+	err = db.Select("x.id,x.balance_accounts_type,x.medical_insurance_number,x.name,x.gender,x.id_type,x.medical_treatment_type,x.birthday,x.record_date,x.age,x.phone_number,x.id_card_no,x.register_type,x.admin_user_id,x.departments,x.is_need_cost_of_production,x.register_cost,x.treatment_cost,x.cost_of_production,x.total,x.user_org_id,x.patient_id,x.number").Count(&total).Offset(offset).Limit(limit).Find(&hisPatient).Error
304
+	return hisPatient, total, err
305
+}

+ 10 - 0
service/his_service.go 파일 보기

@@ -146,3 +146,13 @@ func FindAllHisAdviceTemplate(org_id int64) (temps []*models.HisDoctorAdvicePare
146 146
 	}).Where("org_id = ? AND status=1 ", org_id).Find(&temps).Error
147 147
 	return
148 148
 }
149
+
150
+func GetHisAdminUserDoctors(org_id int64) (doctors []*models.UserAdminRole, err error) {
151
+	err = readUserDb.Model(&models.UserAdminRole{}).Where("org_id = ? AND status = 1 AND (user_type = 1 OR user_type = 2)", org_id).Find(&doctors).Error
152
+	return
153
+}
154
+
155
+func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo) (err error) {
156
+	err = writeDb.Create(s).Error
157
+	return
158
+}

+ 1 - 1
service/patient_service.go 파일 보기

@@ -547,7 +547,7 @@ func CreateDoctorAdvice(m *models.DoctorAdvice) (err error) {
547 547
 }
548 548
 func GetMaxAdviceGroupID(orgId int64) (group int64) {
549 549
 	var advice models.DoctorAdvice
550
-	err := readDb.Table("xt_doctor_advice").Where("user_org_id=?", orgId).Select("max(groupno) as groupno").First(&advice).Error
550
+	err := readDb.Table("his_doctor_advice_info").Where("user_org_id=?", orgId).Select("max(groupno) as groupno").First(&advice).Error
551 551
 	if err != nil {
552 552
 		fmt.Println(err)
553 553
 		group = 0