浏览代码

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

XMLWAN 4 年前
父节点
当前提交
f15b1cb8bb
共有 5 个文件被更改,包括 486 次插入74 次删除
  1. 1 1
      conf/app.conf
  2. 57 56
      controllers/his_project_api_controller.go
  3. 274 11
      models/his_models.go
  4. 6 6
      service/his_project_service.go
  5. 148 0
      service/his_service.go

+ 1 - 1
conf/app.conf 查看文件

1
 appname = 血透
1
 appname = 血透
2
-httpport = 9529
2
+httpport = 9531
3
 runmode = dev
3
 runmode = dev
4
 
4
 
5
 #
5
 #

+ 57 - 56
controllers/his_project_api_controller.go 查看文件

501
 	//统计当日挂号的患者
501
 	//统计当日挂号的患者
502
 	hisPatient, _ := service.GetHisPatient(orgId, timenow)
502
 	hisPatient, _ := service.GetHisPatient(orgId, timenow)
503
 	//统计今天开处方的患者
503
 	//统计今天开处方的患者
504
-	prescription, _ := service.HisPrescription(orgId, timenow)
504
+	prescription, _ := service.GetHisPrescriptionOther(orgId, timenow)
505
 	if err != nil {
505
 	if err != nil {
506
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
506
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
507
 		return
507
 		return
535
 
535
 
536
 func (this *HisProjectApiController) AdditionalCharge() {
536
 func (this *HisProjectApiController) AdditionalCharge() {
537
 
537
 
538
-	dataBody := make(map[string]interface{}, 0)
539
-	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
540
-	fmt.Println(err)
541
-	patient_id := int64(dataBody["patient_id"].(float64))
542
-	medicineData, _ := dataBody["medicineData"].([]interface{})
543
-	adminUserInfo := this.GetAdminUserInfo()
544
-	orgId := adminUserInfo.CurrentOrgId
545
-	admin_user_id := adminUserInfo.AdminUser.Id
546
-	timeStr := time.Now().Format("2006-01-02")
547
-	timeLayout := "2006-01-02 15:04:05"
548
-	fmt.Println("timeStr:", timeStr)
549
-	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
550
-	timenow := timeStringToTime.Unix()
551
-	for _, item := range medicineData {
552
-		items := item.(map[string]interface{})
553
-		drug_id := int64(items["id"].(float64))
554
-		money := int64(items["money"].(float64))
555
-		monStr := strconv.FormatInt(money, 10)
556
-		monneyStr, _ := strconv.ParseFloat(monStr, 64)
557
-		additionalCharge := models.HisAdditionalCharge{
558
-			DrugId:      drug_id,
559
-			UserOrgId:   orgId,
560
-			PatientId:   patient_id,
561
-			RecordDate:  timenow,
562
-			Money:       monneyStr,
563
-			Status:      1,
564
-			AdminUserId: admin_user_id,
565
-			CreatedTime: time.Now().Unix(),
566
-		}
567
-
568
-		err := service.CreateAdditionalCharge(&additionalCharge)
569
-		if err != nil {
570
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
571
-			return
572
-		}
573
-		this.ServeSuccessJSON(map[string]interface{}{
574
-			"additionalCharge": additionalCharge,
575
-		})
576
-		return
577
-	}
538
+	//dataBody := make(map[string]interface{}, 0)
539
+	//err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
540
+	//fmt.Println(err)
541
+	//patient_id := int64(dataBody["patient_id"].(float64))
542
+	//fmt.Println("patient_id2222222222", patient_id)
543
+	//medicineData, _ := dataBody["medicineData"].([]interface{})
544
+	//adminUserInfo := this.GetAdminUserInfo()
545
+	//orgId := adminUserInfo.CurrentOrgId
546
+	//admin_user_id := adminUserInfo.AdminUser.Id
547
+	//timeStr := time.Now().Format("2006-01-02")
548
+	//timeLayout := "2006-01-02 15:04:05"
549
+	//fmt.Println("timeStr:", timeStr)
550
+	//timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
551
+	//timenow := timeStringToTime.Unix()
552
+	//for _, item := range medicineData {
553
+	//	//items := item.(map[string]interface{})
554
+	//	//drug_id := int64(items["id"].(float64))
555
+	//	//money := int64(items["money"].(float64))
556
+	//	//monStr := strconv.FormatInt(money, 10)
557
+	//	//monneyStr, _ := strconv.ParseFloat(monStr, 64)
558
+	//	additionalCharge := models.HisAdditionalCharge{
559
+	//		//DrugId:      drug_id,
560
+	//		UserOrgId:   orgId,
561
+	//		PatientId:   patient_id,
562
+	//		RecordDate:  timenow,
563
+	//		//Money:       monneyStr,
564
+	//		Status:      1,
565
+	//		AdminUserId: admin_user_id,
566
+	//		CreatedTime: time.Now().Unix(),
567
+	//	}
568
+	//
569
+	//	err := service.CreateAdditionalCharge(&additionalCharge)
570
+	//	if err != nil {
571
+	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
572
+	//		return
573
+	//	}
574
+	//	this.ServeSuccessJSON(map[string]interface{}{
575
+	//		"additionalCharge": additionalCharge,
576
+	//	})
577
+	//	return
578
+	//}
578
 }
579
 }
579
 
580
 
580
 func (this *HisProjectApiController) GetTreatmentList() {
581
 func (this *HisProjectApiController) GetTreatmentList() {
767
 			IsNeedCostOfProduction: cost_checked,
768
 			IsNeedCostOfProduction: cost_checked,
768
 			TreatmentCost:          medicalExpense_float,
769
 			TreatmentCost:          medicalExpense_float,
769
 			MedicalInsuranceNumber: medicalinsurancecard,
770
 			MedicalInsuranceNumber: medicalinsurancecard,
770
-			Name:                   name,
771
-			RegisterType:           register,
772
-			RegisterCost:           registrationfees_float,
773
-			BalanceAccountsType:    settlementValue,
774
-			Gender:                 sex,
775
-			Total:                  totals_float,
776
-			UserOrgId:              orgId,
771
+			Name:                name,
772
+			RegisterType:        register,
773
+			RegisterCost:        registrationfees_float,
774
+			BalanceAccountsType: settlementValue,
775
+			Gender:              sex,
776
+			Total:               totals_float,
777
+			UserOrgId:           orgId,
777
 		}
778
 		}
778
 		err := service.CreateHisPatient(&patient)
779
 		err := service.CreateHisPatient(&patient)
779
 		if err != nil {
780
 		if err != nil {
796
 			IsNeedCostOfProduction: cost_checked,
797
 			IsNeedCostOfProduction: cost_checked,
797
 			TreatmentCost:          medicalExpense_float,
798
 			TreatmentCost:          medicalExpense_float,
798
 			MedicalInsuranceNumber: medicalinsurancecard,
799
 			MedicalInsuranceNumber: medicalinsurancecard,
799
-			Name:                   name,
800
-			RegisterType:           register,
801
-			RegisterCost:           registrationfees_float,
802
-			BalanceAccountsType:    settlementValue,
803
-			Gender:                 sex,
804
-			Total:                  totals_float,
805
-			UserOrgId:              orgId,
806
-			PatientId:              bloodPatient.ID,
800
+			Name:                name,
801
+			RegisterType:        register,
802
+			RegisterCost:        registrationfees_float,
803
+			BalanceAccountsType: settlementValue,
804
+			Gender:              sex,
805
+			Total:               totals_float,
806
+			UserOrgId:           orgId,
807
+			PatientId:           bloodPatient.ID,
807
 		}
808
 		}
808
 		err := service.CreateHisPatient(&patient)
809
 		err := service.CreateHisPatient(&patient)
809
 		if err != nil {
810
 		if err != nil {

+ 274 - 11
models/his_models.go 查看文件

121
 	Name         string
121
 	Name         string
122
 }
122
 }
123
 
123
 
124
-type HisPrescription struct {
124
+type HisCaseHistoryTemplate struct {
125
+	ID                      int64  `gorm:"column:id" json:"id" form:"id"`
126
+	HistoryOfPresentIllness string `gorm:"column:history_of_present_illness" json:"history_of_present_illness" form:"history_of_present_illness"`
127
+	PastHistory             string `gorm:"column:past_history" json:"past_history" form:"past_history"`
128
+	ChiefConplaint          string `gorm:"column:chief_conplaint" json:"chief_conplaint" form:"chief_conplaint"`
129
+	PersonalHistory         string `gorm:"column:personal_history" json:"personal_history" form:"personal_history"`
130
+	FamilyHistory           string `gorm:"column:family_history" json:"family_history" form:"family_history"`
131
+	Diagnostic              string `gorm:"column:diagnostic" json:"diagnostic" form:"diagnostic"`
132
+	UserOrgId               int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
133
+	Status                  int64  `gorm:"column:status" json:"status" form:"status"`
134
+	Ctime                   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
135
+	Mtime                   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
136
+	RecordDate              int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
137
+	TemplateName            string `gorm:"column:template_name" json:"template_name" form:"template_name"`
138
+	TemplateRemark          string `gorm:"column:template_remark" json:"template_remark" form:"template_remark"`
139
+	Creator                 int64  `gorm:"column:creator" json:"creator" form:"creator"`
140
+	Modifier                int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
141
+}
142
+
143
+func (HisCaseHistoryTemplate) TableName() string {
144
+	return "his_patient"
145
+}
146
+
147
+type HisDoctorAdviceInfo struct {
148
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
149
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
150
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
151
+	HisPatientId          int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
152
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
153
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
154
+	StartTime             int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
155
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
156
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
157
+	ReminderDate          int64   `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
158
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
159
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
160
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
161
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
162
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
163
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
164
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
165
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
166
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
167
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
168
+	AdviceAffirm          string  `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
169
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
170
+	StopTime              int64   `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
171
+	StopReason            string  `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
172
+	StopDoctor            int64   `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
173
+	StopState             int64   `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
174
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
175
+	ExecutionTime         int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
176
+	ExecutionStaff        int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
177
+	ExecutionState        int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
178
+	Checker               int64   `gorm:"column:checker" json:"checker" form:"checker"`
179
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
180
+	DialysisOrderId       int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
181
+	CheckTime             int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
182
+	CheckState            int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
183
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
184
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
185
+	Groupno               int64   `gorm:"column:groupno" json:"groupno" form:"groupno"`
186
+	RemindType            int64   `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
187
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
188
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
189
+	WeekDay               string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
190
+	TemplateId            string  `gorm:"column:template_id" json:"template_id" form:"template_id"`
191
+	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
192
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
193
+	Price                 float64 `gorm:"column:price" json:"price" form:"price"`
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
+}
198
+
199
+func (HisDoctorAdviceInfo) TableName() string {
200
+	return "his_doctor_advice_info"
201
+}
202
+
203
+type HisGroupAdvice struct {
204
+	HisDoctorAdviceInfo
205
+	Children []*HisGroupAdvice
206
+}
207
+
208
+type HisPatientCaseHistory struct {
209
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
210
+	PatientId               int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
211
+	HisPatientId            int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
212
+	Temperature             float64 `gorm:"column:temperature" json:"temperature" form:"temperature"`
213
+	BloodSugar              float64 `gorm:"column:blood_sugar" json:"blood_sugar" form:"blood_sugar"`
214
+	Pulse                   float64 `gorm:"column:pulse" json:"pulse" form:"pulse"`
215
+	Sbp                     float64 `gorm:"column:sbp" json:"sbp" form:"sbp"`
216
+	Dbp                     float64 `gorm:"column:dbp" json:"dbp" form:"dbp"`
217
+	Height                  float64 `gorm:"column:height" json:"height" form:"height"`
218
+	BloodFat                float64 `gorm:"column:blood_fat" json:"blood_fat" form:"blood_fat"`
219
+	SickType                int64   `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
220
+	Symptom                 string  `gorm:"column:symptom" json:"symptom" form:"symptom"`
221
+	SickDate                int64   `gorm:"column:sick_date" json:"sick_date" form:"sick_date"`
222
+	IsInfect                int64   `gorm:"column:is_infect" json:"is_infect" form:"is_infect"`
223
+	HistoryOfPresentIllness string  `gorm:"column:history_of_present_illness" json:"history_of_present_illness" form:"history_of_present_illness"`
224
+	PastHistory             string  `gorm:"column:past_history" json:"past_history" form:"past_history"`
225
+	Doctor                  int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
226
+	ChiefConplaint          string  `gorm:"column:chief_conplaint" json:"chief_conplaint" form:"chief_conplaint"`
227
+	PersonalHistory         string  `gorm:"column:personal_history" json:"personal_history" form:"personal_history"`
228
+	FamilyHistory           string  `gorm:"column:family_history" json:"family_history" form:"family_history"`
229
+	Diagnostic              string  `gorm:"column:diagnostic" json:"diagnostic" form:"diagnostic"`
230
+	UserOrgId               int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
231
+	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
232
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
233
+	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
234
+	RecordDate              int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
235
+}
236
+
237
+func (HisPatientCaseHistory) TableName() string {
238
+	return "his_patient_case_history"
239
+}
240
+
241
+type HisPatientInfo struct {
125
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
242
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
126
 	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
243
 	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
127
 	RecordDate   int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
244
 	RecordDate   int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
130
 	Status       int64  `gorm:"column:status" json:"status" form:"status"`
247
 	Status       int64  `gorm:"column:status" json:"status" form:"status"`
131
 	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
248
 	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
132
 	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
249
 	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
133
-	Number       string `gorm:"column:number" json:"number" form:"number"`
134
-	Type         int64  `gorm:"column:type" json:"type" form:"type"`
135
-	Doctor       int64  `gorm:"column:doctor" json:"doctor" form:"doctor"`
136
 	Creator      int64  `gorm:"column:creator" json:"creator" form:"creator"`
250
 	Creator      int64  `gorm:"column:creator" json:"creator" form:"creator"`
137
 	Modifier     int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
251
 	Modifier     int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
252
+	Diagnosis    string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
253
+	SickType     string `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
254
+	PType        string `gorm:"column:p_type" json:"p_type" form:"p_type"`
255
+}
256
+
257
+func (HisPatientInfo) TableName() string {
258
+	return "his_patient_info"
259
+}
260
+
261
+type HisPrescription struct {
262
+	ID                     int64                     `gorm:"column:id" json:"id" form:"id"`
263
+	UserOrgId              int64                     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
264
+	RecordDate             int64                     `gorm:"column:record_date" json:"record_date" form:"record_date"`
265
+	PatientId              int64                     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
266
+	HisPatientId           int64                     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
267
+	Status                 int64                     `gorm:"column:status" json:"status" form:"status"`
268
+	Ctime                  int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
269
+	Mtime                  int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
270
+	Number                 string                    `gorm:"column:number" json:"number" form:"number"`
271
+	Type                   int64                     `gorm:"column:type" json:"type" form:"type"`
272
+	Doctor                 int64                     `gorm:"column:doctor" json:"doctor" form:"doctor"`
273
+	Creator                int64                     `gorm:"column:creator" json:"creator" form:"creator"`
274
+	Modifier               int64                     `gorm:"column:modifier" json:"modifier" form:"modifier"`
275
+	HisDoctorAdviceInfo    []*HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
276
+	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
138
 }
277
 }
139
 
278
 
140
 func (HisPrescription) TableName() string {
279
 func (HisPrescription) TableName() string {
141
 	return "his_prescription"
280
 	return "his_prescription"
142
 }
281
 }
143
 
282
 
144
-type HisAdditionalCharge struct {
283
+type HisProject struct {
284
+	ID                        int64   `gorm:"column:id" json:"id" form:"id"`
285
+	ProjectName               string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
286
+	Pinyin                    string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
287
+	Wubi                      string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
288
+	Price                     float64 `gorm:"column:price" json:"price" form:"price"`
289
+	Unit                      string  `gorm:"column:unit" json:"unit" form:"unit"`
290
+	CostClassify              int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
291
+	ExecutiveSection          int64   `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
292
+	MedicalCoverage           int64   `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
293
+	StatisticalClassification int64   `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
294
+	DiseaseDirectory          int64   `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
295
+	IsRecord                  int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
296
+	MedicalCode               string  `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
297
+	TubeColor                 int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
298
+	MedicalStatus             int64   `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
299
+	Remark                    string  `gorm:"column:remark" json:"remark" form:"remark"`
300
+	Sign                      int64   `gorm:"column:sign" json:"sign" form:"sign"`
301
+	DefaultNumber             string  `gorm:"column:default_number" json:"default_number" form:"default_number"`
302
+	IsDefault                 int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
303
+	IsCharge                  int64   `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
304
+	IsEstimate                int64   `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
305
+	IsWorkload                int64   `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
306
+	Sort                      string  `gorm:"column:sort" json:"sort" form:"sort"`
307
+	DoctorAdvice              int64   `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
308
+	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
309
+	Status                    int64   `gorm:"column:status" json:"status" form:"status"`
310
+	CreatedTime               int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
311
+	UpdatedTime               int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
312
+}
313
+
314
+func (HisProject) TableName() string {
315
+	return "xt_his_project"
316
+}
317
+
318
+type HisProjectTeam struct {
145
 	ID          int64   `gorm:"column:id" json:"id" form:"id"`
319
 	ID          int64   `gorm:"column:id" json:"id" form:"id"`
146
-	DrugId      int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
147
-	PatientId   int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
148
-	Money       float64 `gorm:"column:money" json:"money" form:"money"`
149
-	AdminUserId int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
320
+	ProjectTeam string  `gorm:"column:project_team" json:"project_team" form:"project_team"`
321
+	Price       float64 `gorm:"column:price" json:"price" form:"price"`
322
+	Pinyin      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
323
+	Wubi        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
324
+	TubeColor   int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
325
+	TeamType    int64   `gorm:"column:team_type" json:"team_type" form:"team_type"`
326
+	Remark      string  `gorm:"column:remark" json:"remark" form:"remark"`
150
 	UserOrgId   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
327
 	UserOrgId   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
151
-	RecordDate  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
328
+	Status      int64   `gorm:"column:status" json:"status" form:"status"`
152
 	CreatedTime int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
329
 	CreatedTime int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
153
 	UpdatedTime int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
330
 	UpdatedTime int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
154
-	Status      int64   `gorm:"column:status" json:"status" form:"status"`
331
+	ProjectId   string  `gorm:"column:project_id" json:"project_id" form:"project_id"`
332
+}
333
+
334
+func (HisProjectTeam) TableName() string {
335
+	return "xt_his_project_team"
336
+}
337
+
338
+type HisAdditionalCharge struct {
339
+	ID           int64   `gorm:"column:id" json:"id" form:"id"`
340
+	PatientId    int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
341
+	Price        float64 `gorm:"column:price" json:"price" form:"price"`
342
+	AdminUserId  int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
343
+	UserOrgId    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
344
+	RecordDate   int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
345
+	CreatedTime  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
346
+	UpdatedTime  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
347
+	Status       int64   `gorm:"column:status" json:"status" form:"status"`
348
+	ItemName     string  `gorm:"column:item_name" json:"item_name" form:"item_name"`
349
+	HisPatientId int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
350
+	ItemId       int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
351
+	Creator      int64   `gorm:"column:creator" json:"creator" form:"creator"`
352
+	Modifier     int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
155
 }
353
 }
156
 
354
 
157
 func (HisAdditionalCharge) TableName() string {
355
 func (HisAdditionalCharge) TableName() string {
158
 	return "his_additional_charge"
356
 	return "his_additional_charge"
159
 }
357
 }
160
 
358
 
359
+type HisDoctorAdviceParentTemplate struct {
360
+	ID                      int64                      `gorm:"column:id" json:"id" form:"id"`
361
+	OrgId                   int64                      `gorm:"column:org_id" json:"org_id" form:"org_id"`
362
+	Name                    string                     `gorm:"column:name" json:"name" form:"name"`
363
+	Status                  int64                      `gorm:"column:status" json:"status" form:"status"`
364
+	CreatedTime             int64                      `gorm:"column:created_time" json:"created_time" form:"created_time"`
365
+	UpdatedTime             int64                      `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
366
+	AdviceType              int64                      `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
367
+	HisDoctorAdviceTemplate []*HisDoctorAdviceTemplate `gorm:"ForeignKey:TemplateId;AssociationForeignKey:ID" json:"advices"`
368
+}
369
+
370
+func (HisDoctorAdviceParentTemplate) TableName() string {
371
+	return "his_doctor_advice_parent_template"
372
+}
373
+
374
+type HisDoctorAdviceTemplate struct {
375
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
376
+	OrgId                 int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
377
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
378
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
379
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
380
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
381
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
382
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
383
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
384
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
385
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
386
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
387
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
388
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
389
+	TemplateId            int64   `gorm:"column:template_id" json:"template_id" form:"template_id"`
390
+	DrugSpec              string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
391
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
392
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
393
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
394
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
395
+	WeekDays              string  `gorm:"column:week_days" json:"week_days" form:"week_days"`
396
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
397
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
398
+	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
399
+	DrugNameId            int64   `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
400
+}
401
+
402
+func (HisDoctorAdviceTemplate) TableName() string {
403
+	return "his_doctor_advice_template"
404
+}
405
+
406
+type HisPrescriptionProject struct {
407
+	ID             int64   `gorm:"column:id" json:"id" form:"id"`
408
+	ProjectId      int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
409
+	Price          float64 `gorm:"column:price" json:"price" form:"price"`
410
+	UserOrgId      int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
411
+	Status         int64   `gorm:"column:status" json:"status" form:"status"`
412
+	Ctime          int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
413
+	Mtime          int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
414
+	PatientId      int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
415
+	HisPatientId   int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
416
+	RecordDate     int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
417
+	PrescriptionId int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
418
+}
419
+
420
+func (HisPrescriptionProject) TableName() string {
421
+	return "his_prescription_project"
422
+}
423
+
161
 type SchedulesVm struct {
424
 type SchedulesVm struct {
162
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
425
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
163
 	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
426
 	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`

+ 6 - 6
service/his_project_service.go 查看文件

169
 	return paitent, err
169
 	return paitent, err
170
 }
170
 }
171
 
171
 
172
-func HisPrescription(orgid int64, recorddate int64) (prescription []*models.HisPrescriptionVm, err error) {
172
+func GetHisPrescriptionOther(orgid int64, recorddate int64) (prescription []*models.HisPrescriptionVm, err error) {
173
 
173
 
174
 	db := XTReadDB().Table("his_prescription as x").Where("x.status = 1")
174
 	db := XTReadDB().Table("his_prescription as x").Where("x.status = 1")
175
 	if orgid > 0 {
175
 	if orgid > 0 {
200
 	return prescription, err
200
 	return prescription, err
201
 }
201
 }
202
 
202
 
203
-func GetAllProjectList(orgid int64) (project []*models.XtHisProject, err error) {
204
-
205
-	err = XTReadDB().Model(&project).Where("user_org_id = ? and status = 1", orgid).Find(&project).Error
206
-	return project, err
207
-}
203
+//func GetAllProjectList(orgid int64) (project []*models.XtHisProject, err error) {
204
+//
205
+//	err = XTReadDB().Model(&project).Where("user_org_id = ? and status = 1", orgid).Find(&project).Error
206
+//	return project, err
207
+//}
208
 
208
 
209
 func CreateProjectList(list *models.XtHisProjectList) error {
209
 func CreateProjectList(list *models.XtHisProjectList) error {
210
 
210
 

+ 148 - 0
service/his_service.go 查看文件

1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
6
+)
7
+
8
+type HisPatient struct {
9
+	ID              int64              `gorm:"column:id" json:"id" form:"id"`
10
+	Name            string             `gorm:"column:name" json:"name" form:"name"`
11
+	Gender          int64              `gorm:"column:gender" json:"gender" form:"gender"`
12
+	Total           float64            `gorm:"column:total" json:"total" form:"total"`
13
+	UserOrgId       int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
14
+	Status          int64              `gorm:"column:status" json:"status" form:"status"`
15
+	RecordDate      int64              `gorm:"column:record_date" json:"record_date" form:"record_date"`
16
+	HisPrescription []*HisPrescription `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:ID,RecordDate" json:"prescription"`
17
+	PatientId       int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
18
+	Number          string             `gorm:"column:name" json:"name" form:"name"`
19
+}
20
+
21
+func (HisPatient) TableName() string {
22
+	return "his_patient"
23
+}
24
+
25
+type Schedule struct {
26
+	ID              int64              `gorm:"column:id" json:"id" form:"id"`
27
+	UserOrgId       int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
28
+	PatientId       int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
29
+	Status          int64              `gorm:"column:status" json:"status" form:"status"`
30
+	ScheduleDate    int64              `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
31
+	Patients        Patients           `gorm:"ForeignKey:ID;AssociationForeignKey:PatientId" json:"patients"`
32
+	HisPatient      HisPatient         `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"his_patient"`
33
+	HisPrescription []*HisPrescription `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"prescription"`
34
+}
35
+
36
+func (Schedule) TableName() string {
37
+	return "xt_schedule"
38
+}
39
+
40
+type Patients struct {
41
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
42
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
43
+	Name      string `gorm:"column:name" json:"name" form:"name"`
44
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
45
+}
46
+
47
+func (Patients) TableName() string {
48
+	return "xt_patients"
49
+}
50
+
51
+type HisPrescription struct {
52
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
53
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
54
+	RecordDate   int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
55
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
56
+	HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
57
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
58
+}
59
+
60
+func (HisPrescription) TableName() string {
61
+	return "his_prescription"
62
+}
63
+
64
+func GetHisPatientList(org_id int64, keywords string, record_date int64) (patients []*Schedule, err error) {
65
+	db := readDb.Model(&Schedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date = ?", org_id, record_date)
66
+	db = db.Preload("Patients", "user_org_id = ? AND status = 1", org_id)
67
+	db = db.Preload("HisPatient", "user_org_id = ? AND status = 1", org_id)
68
+	err = db.Preload("HisPrescription", "user_org_id = ? AND status = 1", org_id).Find(&patients).Error
69
+	return
70
+}
71
+
72
+func GetAllBaseDrugStockList(org_id int64) (drugs []*models.BaseDrugLib, err error) {
73
+	err = readDb.Model(&models.BaseDrugLib{}).Where("user_org_id = ? AND status = 1", org_id).Find(&drugs).Error
74
+	return
75
+}
76
+
77
+func GetHisPatientInfo(org_id int64, patient_id int64, record_date int64) (info HisPatient, err error) {
78
+	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND id = ?", org_id, record_date, patient_id).First(&info).Error
79
+	return
80
+}
81
+
82
+func GetXTPatientInfo(org_id int64, patient_id int64) (info models.Patients, err error) {
83
+	err = readDb.Model(&models.Patients{}).Where("user_org_id = ? AND status = 1  AND id = ?", org_id, patient_id).First(&info).Error
84
+	return
85
+}
86
+
87
+func GetHisPatientCaseHistoryInfo(org_id int64, patient_id int64, record_date int64) (info models.HisPatientCaseHistory, err error) {
88
+	err = readDb.Model(&models.HisPatientCaseHistory{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).First(&info).Error
89
+	return
90
+}
91
+
92
+func GetHisPatientCaseHistoryList(org_id int64, patient_id int64) (caseHistorys []*models.HisPatientCaseHistory, err error) {
93
+	db := readDb.Model(&models.HisPatientCaseHistory{}).Where("user_org_id = ? AND status = 1  AND his_patient_id = ?", org_id, patient_id)
94
+	err = db.Find(&caseHistorys).Error
95
+	return
96
+}
97
+
98
+func GetHisPatientCaseHistoryTemplate(org_id int64) (caseHistorys []*models.HisCaseHistoryTemplate, err error) {
99
+	db := readDb.Model(&models.HisCaseHistoryTemplate{}).Where("user_org_id = ? AND status = 1", org_id)
100
+	err = db.Find(&caseHistorys).Error
101
+	return
102
+}
103
+
104
+func SaveHisPatientCaseHistoryTemplate(template models.HisCaseHistoryTemplate) (err error) {
105
+	err = writeDb.Create(&template).Error
106
+	return
107
+}
108
+
109
+func SaveHisPatientCaseHistory(caseHistory models.HisPatientCaseHistory) (err error) {
110
+	err = writeDb.Create(&caseHistory).Error
111
+	return
112
+}
113
+
114
+func SaveHisPrescription(prescription *models.HisPrescription) (err error) {
115
+	err = writeDb.Create(&prescription).Error
116
+	return
117
+}
118
+
119
+func GetHisPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
120
+	err = readDb.Model(&models.HisPrescription{}).
121
+		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
122
+		Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ?", org_id).
123
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).
124
+		First(&prescription).Error
125
+	return
126
+}
127
+
128
+func GetAllDrugLibList(org_id int64) (list []*models.BaseDrugLib, err error) {
129
+	err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ?  AND status = 1", org_id).Find(&list).Error
130
+	return
131
+}
132
+
133
+func GetAllProjectList(org_id int64) (list []*models.HisProject, err error) {
134
+	err = readDb.Model(&models.HisProject{}).Where("user_org_id = ?  AND status = 1", org_id).Find(&list).Error
135
+	return
136
+}
137
+
138
+func CreateAddtionalCharge(charge *models.HisAdditionalCharge) (err error) {
139
+	err = writeDb.Create(&charge).Error
140
+	return
141
+}
142
+
143
+func FindAllHisAdviceTemplate(org_id int64) (temps []*models.HisDoctorAdviceParentTemplate, err error) {
144
+	err = readDb.Model(&models.HisDoctorAdviceParentTemplate{}).Preload("HisDoctorAdviceTemplate", func(db *gorm.DB) *gorm.DB {
145
+		return db.Select("id,advice_name,advice_desc,single_dose,single_dose_unit,prescribing_number,prescribing_number_unit,delivery_way,execution_frequency,status,created_time,updated_time,parent_id,template_id,drug_spec,drug_spec_unit,advice_type,day_count,week_days,frequency_type,way,drug_id,drug_name_id, IF(parent_id>0, parent_id, id) as advice_order").Where("status = 1").Order("advice_order desc, id")
146
+	}).Where("org_id = ? AND status=1 ", org_id).Find(&temps).Error
147
+	return
148
+}