소스 검색

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

csx 4 년 전
부모
커밋
ac2aafd55e
4개의 변경된 파일82개의 추가작업 그리고 32개의 파일을 삭제
  1. 32 11
      controllers/his_project_api_controller.go
  2. 1 1
      controllers/mobile_api_controllers/dialysis_api_controller.go
  3. 46 18
      models/his_models.go
  4. 3 2
      service/his_project_service.go

+ 32 - 11
controllers/his_project_api_controller.go 파일 보기

732
 	recordDateStr := time.Now().Format("2006-01-02")
732
 	recordDateStr := time.Now().Format("2006-01-02")
733
 	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
733
 	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
734
 	nowtime := recordDate.Unix()
734
 	nowtime := recordDate.Unix()
735
+	fmt.Println("nowtime0000000000", nowtime)
735
 	phone := this.GetString("phone")
736
 	phone := this.GetString("phone")
736
 	social_type, _ := this.GetInt64("social_type")
737
 	social_type, _ := this.GetInt64("social_type")
737
 	bloodPatient, errcode := service.GetBloodPatientByIdCard(idcard, orgId)
738
 	bloodPatient, errcode := service.GetBloodPatientByIdCard(idcard, orgId)
805
 			Ctime:               time.Now().Unix(),
806
 			Ctime:               time.Now().Unix(),
806
 			Phone:               phone,
807
 			Phone:               phone,
807
 			SocialType:          social_type,
808
 			SocialType:          social_type,
809
+			RecordDate:          nowtime,
808
 		}
810
 		}
809
 		err := service.CreateHisPatient(&patient)
811
 		err := service.CreateHisPatient(&patient)
812
+		lastPatient, err := service.GetLastPatient(orgId)
813
+		timeStr := time.Now().Format("2006-01-02")
814
+		timeArr := strings.Split(timeStr, "-")
815
+		var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(lastPatient.ID, 10)
816
+
817
+		hisPatient := models.HisPatient{
818
+			Number: str,
819
+		}
820
+		err = service.UpdateHisPatient(lastPatient.ID, hisPatient)
821
+		//fmt.Println("er", err)
810
 		if err != nil {
822
 		if err != nil {
811
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
823
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
812
 			return
824
 			return
993
 
1005
 
994
 	patient_id, _ := this.GetInt64("patient_id")
1006
 	patient_id, _ := this.GetInt64("patient_id")
995
 	record_date := this.GetString("record_date")
1007
 	record_date := this.GetString("record_date")
1008
+	schIDStr := this.GetString("ids")
1009
+	if len(schIDStr) == 0 {
1010
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1011
+		return
1012
+	}
1013
+	idStrs := strings.Split(schIDStr, ",")
1014
+
996
 	timeLayout := "2006-01-02"
1015
 	timeLayout := "2006-01-02"
997
 	loc, _ := time.LoadLocation("Local")
1016
 	loc, _ := time.LoadLocation("Local")
998
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1017
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
999
 	recordDateTime := theTime.Unix()
1018
 	recordDateTime := theTime.Unix()
1000
-	prescription_id, _ := this.GetInt64("prescription_id")
1001
-	advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, prescription_id)
1002
-
1003
-	doctorPorject, err := service.GetDoctorProjectItem(patient_id, recordDateTime)
1004
-	patient, err := service.GetBloodPatientByPatient(patient_id)
1005
-	prescriptionInfo, err := service.GetPrscriptionInfo(patient_id, recordDateTime)
1019
+	//prescription_id, _ := this.GetInt64("prescription_id")
1020
+	adminUserInfo := this.GetAdminUserInfo()
1021
+	advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, idStrs)
1022
+	projectlist, err := service.GetAllProjectList(adminUserInfo.CurrentOrgId)
1023
+	//doctorPorject, err := service.GetDoctorProjectItem(patient_id, recordDateTime)
1024
+	//patient, err := service.GetBloodPatientByPatient(patient_id)
1025
+	//prescriptionInfo, err := service.GetPrscriptionInfo(patient_id, recordDateTime)
1006
 	if err != nil {
1026
 	if err != nil {
1007
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1027
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1008
 		return
1028
 		return
1009
 	}
1029
 	}
1010
 	this.ServeSuccessJSON(map[string]interface{}{
1030
 	this.ServeSuccessJSON(map[string]interface{}{
1011
-		"advicePrint":      advicePrint,
1012
-		"patient":          patient,
1013
-		"doctorPorject":    doctorPorject,
1014
-		"prescriptionInfo": prescriptionInfo,
1031
+		"advicePrint": advicePrint,
1032
+		"projectlist": projectlist,
1033
+		//"patient":          patient,
1034
+		//"doctorPorject":    doctorPorject,
1035
+		//"prescriptionInfo": prescriptionInfo,
1015
 	})
1036
 	})
1016
 }
1037
 }
1017
 
1038
 
1036
 	adminUserInfo := this.GetAdminUserInfo()
1057
 	adminUserInfo := this.GetAdminUserInfo()
1037
 	orgId := adminUserInfo.CurrentOrgId
1058
 	orgId := adminUserInfo.CurrentOrgId
1038
 	_, errcode := service.GetHisTemplateId(template_id, orgId)
1059
 	_, errcode := service.GetHisTemplateId(template_id, orgId)
1039
-	fmt.Println("errcode0-------", errcode)
1060
+	fmt.Println("errcode", errcode)
1040
 	if errcode == gorm.ErrRecordNotFound {
1061
 	if errcode == gorm.ErrRecordNotFound {
1041
 		template := models.XtHisTemplate{
1062
 		template := models.XtHisTemplate{
1042
 			TemplateId: template_id,
1063
 			TemplateId: template_id,

+ 1 - 1
controllers/mobile_api_controllers/dialysis_api_controller.go 파일 보기

1698
 	}
1698
 	}
1699
 
1699
 
1700
 	//只针对广慈医院
1700
 	//只针对广慈医院
1701
-	if template.TemplateId == 26 || template.TemplateId == 25 || template.TemplateId == 28 {
1701
+	if template.TemplateId == 26 || template.TemplateId == 25 || template.TemplateId == 28 || adminUserInfo.Org.Id == 9987 {
1702
 		// 查询病人是否有透前评估数据
1702
 		// 查询病人是否有透前评估数据
1703
 		befor, errcode := service.GetAssessmentBefor(adminUserInfo.Org.Id, patientID, recordDate.Unix())
1703
 		befor, errcode := service.GetAssessmentBefor(adminUserInfo.Org.Id, patientID, recordDate.Unix())
1704
 		//如果有数据就插入
1704
 		//如果有数据就插入

+ 46 - 18
models/his_models.go 파일 보기

274
 }
274
 }
275
 
275
 
276
 type HisPrescription struct {
276
 type HisPrescription struct {
277
-	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
278
-	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
279
-	RecordDate         int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
280
-	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
281
-	HisPatientId       int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
282
-	Status             int64  `gorm:"column:status" json:"status" form:"status"`
283
-	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
284
-	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
285
-	Number             string `gorm:"column:number" json:"number" form:"number"`
286
-	Type               int64  `gorm:"column:type" json:"type" form:"type"`
287
-	Doctor             string `gorm:"column:doctor" json:"doctor" form:"doctor"`
288
-	Creator            int64  `gorm:"column:creator" json:"creator" form:"creator"`
289
-	Modifier           int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
290
-	OrderStatus        int64  `gorm:"column:order_status" json:"order_status" form:"order_status"`
291
-	BatchNumber        string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
292
-	PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
293
-
277
+	ID                     int64                     `gorm:"column:id" json:"id" form:"id"`
278
+	UserOrgId              int64                     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
279
+	RecordDate             int64                     `gorm:"column:record_date" json:"record_date" form:"record_date"`
280
+	PatientId              int64                     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
281
+	HisPatientId           int64                     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
282
+	Status                 int64                     `gorm:"column:status" json:"status" form:"status"`
283
+	Ctime                  int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
284
+	Mtime                  int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
285
+	Number                 string                    `gorm:"column:number" json:"number" form:"number"`
286
+	Type                   int64                     `gorm:"column:type" json:"type" form:"type"`
287
+	Doctor                 string                    `gorm:"column:doctor" json:"doctor" form:"doctor"`
288
+	Creator                int64                     `gorm:"column:creator" json:"creator" form:"creator"`
289
+	Modifier               int64                     `gorm:"column:modifier" json:"modifier" form:"modifier"`
290
+	OrderStatus            int64                     `gorm:"column:order_status" json:"order_status" form:"order_status"`
291
+	BatchNumber            string                    `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
292
+	PrescriptionNumber     string                    `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
293
+	Patients               Patients                  `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
294
+	HisPatient             VMHisPatient              `gorm:"ForeignKey:PatientId;AssociationForeignKey:patient_id" json:"hisPatient"`
294
 	HisDoctorAdviceInfo    []*HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
295
 	HisDoctorAdviceInfo    []*HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
295
 	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
296
 	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
296
 	HisAdditionalCharge    []*HisAdditionalCharge    `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"addition"`
297
 	HisAdditionalCharge    []*HisAdditionalCharge    `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"addition"`
449
 	DeliveryWay        string     `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
450
 	DeliveryWay        string     `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
450
 	ExecutionFrequency string     `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
451
 	ExecutionFrequency string     `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
451
 	Day                string     `gorm:"column:day" json:"day" form:"day"`
452
 	Day                string     `gorm:"column:day" json:"day" form:"day"`
452
-	HisProject         HisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
453
+	HisProject         HisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
453
 	Remark             string     `gorm:"column:remark" json:"remark" form:"remark"`
454
 	Remark             string     `gorm:"column:remark" json:"remark" form:"remark"`
454
 }
455
 }
455
 
456
 
804
 func (XtHisTreatmentTemplate) TableName() string {
805
 func (XtHisTreatmentTemplate) TableName() string {
805
 	return "xt_his_treatment_template"
806
 	return "xt_his_treatment_template"
806
 }
807
 }
808
+
809
+type XtHisAdditionalCharge struct {
810
+	ID                 int64   `gorm:"column:id" json:"id" form:"id"`
811
+	PatientId          int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
812
+	Price              float64 `gorm:"column:price" json:"price" form:"price"`
813
+	AdminUserId        int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
814
+	UserOrgId          int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
815
+	RecordDate         int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
816
+	CreatedTime        int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
817
+	UpdatedTime        int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
818
+	Status             int64   `gorm:"column:status" json:"status" form:"status"`
819
+	ItemName           string  `gorm:"column:item_name" json:"item_name" form:"item_name"`
820
+	HisPatientId       int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
821
+	ItemId             int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
822
+	Creator            int64   `gorm:"column:creator" json:"creator" form:"creator"`
823
+	Modifier           int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
824
+	BatchNumber        string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
825
+	OrderStatus        int64   `gorm:"column:order_status" json:"order_status" form:"order_status"`
826
+	PrescriptionNumber string  `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
827
+	FeedetlSn          string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
828
+	PrescriptionId     int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
829
+	Count              int64   `gorm:"column:count" json:"count" form:"count"`
830
+}
831
+
832
+func (XtHisAdditionalCharge) TableName() string {
833
+	return "his_additional_charge"
834
+}

+ 3 - 2
service/his_project_service.go 파일 보기

387
 	return hisPatient, err
387
 	return hisPatient, err
388
 }
388
 }
389
 
389
 
390
-func GetDoctorAdvicePrint(his_patient_id int64, recorddate int64, prescription_id int64) (prescription []*models.HisDoctorAdviceInfo, err error) {
390
+func GetDoctorAdvicePrint(his_patient_id int64, recorddate int64, schIDs []string) (prescription []*models.HisPrescription, err error) {
391
 
391
 
392
-	err = XTReadDB().Model(&prescription).Where("patient_id = ? and status = 1 and advice_date = ? and prescription_id = ?", his_patient_id, recorddate, prescription_id).Find(&prescription).Error
392
+	err = XTReadDB().Model(&prescription).Where("patient_id = ? and record_date = ? and id in(?) and  status = 1 ", his_patient_id, recorddate, schIDs).Preload("Patients", "status = 1").Preload("HisDoctorAdviceInfo", "status = 1").Preload("HisPrescriptionProject", "status = 1").Preload("XtHisAdditionalCharge", "status = 1").Find(&prescription).Error
393
+	//err = XTReadDB().Model(&prescription).Where("patient_id = ? and status = 1 and advice_date = ? and prescription_id = ?", his_patient_id, recorddate, prescription_id).Find(&prescription).Error
393
 	return prescription, err
394
 	return prescription, err
394
 }
395
 }
395
 
396