csx 4 years ago
parent
commit
c08df5f889
3 changed files with 85 additions and 68 deletions
  1. 1 1
      conf/app.conf
  2. 80 67
      controllers/his_api_controller.go
  3. 4 0
      models/his_models.go

+ 1 - 1
conf/app.conf View File

44
 
44
 
45
 
45
 
46
 [prod]
46
 [prod]
47
-org_id = 9919
47
+org_id = 4
48
 mobile_token_expiration_second = 86400
48
 mobile_token_expiration_second = 86400
49
 httpdomain = https://api.xt.kuyicloud.com
49
 httpdomain = https://api.xt.kuyicloud.com
50
 sso_domain = https://sso.kuyicloud.com
50
 sso_domain = https://sso.kuyicloud.com

+ 80 - 67
controllers/his_api_controller.go View File

30
 }
30
 }
31
 
31
 
32
 func HisManagerApiRegistRouters() {
32
 func HisManagerApiRegistRouters() {
33
-
34
 	beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
33
 	beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
35
 	beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
34
 	beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
36
 	beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
35
 	beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
39
 	beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
38
 	beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
40
 	beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
39
 	beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
41
 	beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
40
 	beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
42
-
43
 	beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
41
 	beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
44
 	beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
42
 	beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
45
-
46
-	//beego.Router("/api/code/get", &HisApiController{}, "get:GetCode")
47
-
48
 	beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
43
 	beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
49
-
50
 	beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
44
 	beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
51
-	//beego.Router("/api/returnrecord/put", &HisApiController{}, "get:ReturnRecord")
52
-
53
 }
45
 }
54
 
46
 
55
 func (c *HisApiController) Sscard() {
47
 func (c *HisApiController) Sscard() {
148
 	str1 := make([]byte, 256)
140
 	str1 := make([]byte, 256)
149
 	r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
141
 	r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
150
 
142
 
151
-	fmt.Println(string(str))
152
 	fmt.Println(r)
143
 	fmt.Println(r)
153
 	return string(str), nil
144
 	return string(str), nil
154
 }
145
 }
161
 	str1 := make([]byte, 256)
152
 	str1 := make([]byte, 256)
162
 	r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
153
 	r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
163
 
154
 
164
-	fmt.Println(string(str))
165
 	fmt.Println(r)
155
 	fmt.Println(r)
166
 	return string(str), nil
156
 	return string(str), nil
167
 }
157
 }
599
 			count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
589
 			count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
600
 			department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
590
 			department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
601
 			doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
591
 			doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
602
-			diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
603
-			sickConfig, _ := service.FindSickById(patientPrescription.SickType)
592
+			//diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
593
+			//sickConfig, _ := service.FindSickById(patientPrescription.SickType)
604
 
594
 
605
 			IdCardNo := ""
595
 			IdCardNo := ""
606
 			if id_card_type == 1 {
596
 			if id_card_type == 1 {
669
 				his.Status = 1
659
 				his.Status = 1
670
 				err := service.CreateHisPatientTwo(&his)
660
 				err := service.CreateHisPatientTwo(&his)
671
 				if err == nil {
661
 				if err == nil {
672
-					api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
673
-						"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
674
-						"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
675
-						"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
676
-					resp2, requestErr2 := http.Get(api2)
677
-					if requestErr2 != nil {
678
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
679
-						return
680
-					}
681
-					body2, ioErr2 := ioutil.ReadAll(resp2.Body)
682
-					if ioErr2 != nil {
683
-						utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
684
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
685
-						return
686
-					}
687
-					var respJSON2 map[string]interface{}
688
-					if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
689
-						utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
690
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
691
-						return
692
-					}
693
-					respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
694
-					userJSONBytes2, _ := json.Marshal(respJSON2)
695
-
696
-					var res2 ResultSix
697
-					if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
698
-						utils.ErrorLog("解析失败:%v", err)
699
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
700
-						return
701
-					}
702
-					if res2.Infcode == -1 {
703
-						adminUser := c.GetAdminUserInfo()
704
-						errlog := &models.HisOrderError{
705
-							UserOrgId:  adminUser.CurrentOrgId,
706
-							Ctime:      time.Now().Unix(),
707
-							Mtime:      time.Now().Unix(),
708
-							ErrMsg:     res2.ErrMsg,
709
-							Status:     1,
710
-							PatientId:  id,
711
-							RecordTime: recordDateTime,
712
-							Stage:      3,
713
-						}
714
-						service.CreateErrMsgLog(errlog)
715
-
716
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
717
-						return
718
-					}
662
+					//api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
663
+					//	"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
664
+					//	"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
665
+					//	"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
666
+					//resp2, requestErr2 := http.Get(api2)
667
+					//if requestErr2 != nil {
668
+					//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
669
+					//	return
670
+					//}
671
+					//body2, ioErr2 := ioutil.ReadAll(resp2.Body)
672
+					//if ioErr2 != nil {
673
+					//	utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
674
+					//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
675
+					//	return
676
+					//}
677
+					//var respJSON2 map[string]interface{}
678
+					//if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
679
+					//	utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
680
+					//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
681
+					//	return
682
+					//}
683
+					//respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
684
+					//userJSONBytes2, _ := json.Marshal(respJSON2)
685
+					//
686
+					//var res2 ResultSix
687
+					//if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
688
+					//	utils.ErrorLog("解析失败:%v", err)
689
+					//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
690
+					//	return
691
+					//}
692
+					//if res2.Infcode == -1 {
693
+					//	adminUser := c.GetAdminUserInfo()
694
+					//	errlog := &models.HisOrderError{
695
+					//		UserOrgId:  adminUser.CurrentOrgId,
696
+					//		Ctime:      time.Now().Unix(),
697
+					//		Mtime:      time.Now().Unix(),
698
+					//		ErrMsg:     res2.ErrMsg,
699
+					//		Status:     1,
700
+					//		PatientId:  id,
701
+					//		RecordTime: recordDateTime,
702
+					//		Stage:      3,
703
+					//	}
704
+					//	service.CreateErrMsgLog(errlog)
705
+					//
706
+					//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
707
+					//	return
708
+					//}
719
 
709
 
720
 					c.ServeSuccessJSON(map[string]interface{}{
710
 					c.ServeSuccessJSON(map[string]interface{}{
721
 						"his_info": his,
711
 						"his_info": his,
817
 
807
 
818
 	var prescriptions []*models.HisPrescription
808
 	var prescriptions []*models.HisPrescription
819
 
809
 
810
+	var start_time int64
811
+	var end_time int64
812
+
820
 	data := make(map[string]interface{})
813
 	data := make(map[string]interface{})
821
 	if settle_accounts_type == 1 { //日结
814
 	if settle_accounts_type == 1 { //日结
822
 		prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
815
 		prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
823
 		data["pre"] = prescriptions
816
 		data["pre"] = prescriptions
824
 
817
 
825
 	} else { //月结
818
 	} else { //月结
826
-		start_time := c.GetString("start_time")
827
-		end_time := c.GetString("end_time")
819
+		start_time_str := c.GetString("start_time")
820
+		end_time_str := c.GetString("end_time")
828
 		timeLayout := "2006-01-02"
821
 		timeLayout := "2006-01-02"
829
 		loc, _ := time.LoadLocation("Local")
822
 		loc, _ := time.LoadLocation("Local")
830
-		theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
823
+		theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
831
 		if err != nil {
824
 		if err != nil {
832
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
825
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
833
 			return
826
 			return
834
 		}
827
 		}
835
 		recordStartTime := theStartTime.Unix()
828
 		recordStartTime := theStartTime.Unix()
836
-		theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
829
+		start_time = recordStartTime
830
+		theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
837
 		if err != nil {
831
 		if err != nil {
838
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
832
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
839
 			return
833
 			return
840
 		}
834
 		}
841
 		recordEndTime := theEndTime.Unix()
835
 		recordEndTime := theEndTime.Unix()
836
+		end_time = recordEndTime
842
 		prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
837
 		prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
843
 		data["pre"] = prescriptions
838
 		data["pre"] = prescriptions
844
 
839
 
926
 				MedicalInsurancePrice: medical_insurance_price,
921
 				MedicalInsurancePrice: medical_insurance_price,
927
 				PrivatePrice:          private_price,
922
 				PrivatePrice:          private_price,
928
 				IsMedicineInsurance:   1,
923
 				IsMedicineInsurance:   1,
924
+				SettleType:            settle_accounts_type,
925
+				SettleStartTime:       start_time,
926
+				SettleEndTime:         end_time,
929
 			}
927
 			}
930
 			err = service.CreateOrder(order)
928
 			err = service.CreateOrder(order)
931
 			if err != nil {
929
 			if err != nil {
2253
 func (c *HisApiController) GetUploadDiag() {
2251
 func (c *HisApiController) GetUploadDiag() {
2254
 	id, _ := c.GetInt64("id")
2252
 	id, _ := c.GetInt64("id")
2255
 	record_time := c.GetString("record_time")
2253
 	record_time := c.GetString("record_time")
2254
+
2255
+	diagnosis_id, _ := c.GetInt64("diagnosis")
2256
+	sick_type, _ := c.GetInt64("sick_type")
2257
+	reg_type, _ := c.GetInt64("reg_type")
2258
+
2256
 	timeLayout := "2006-01-02"
2259
 	timeLayout := "2006-01-02"
2257
 	loc, _ := time.LoadLocation("Local")
2260
 	loc, _ := time.LoadLocation("Local")
2258
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
2261
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
2260
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2263
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2261
 		return
2264
 		return
2262
 	}
2265
 	}
2266
+
2267
+	var patientPrescription models.HisPrescriptionInfo
2263
 	recordDateTime := theTime.Unix()
2268
 	recordDateTime := theTime.Unix()
2264
 	adminInfo := c.GetAdminUserInfo()
2269
 	adminInfo := c.GetAdminUserInfo()
2265
-	patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
2270
+	patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
2271
+
2272
+	if patientPrescription.ID == 0 {
2273
+		patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
2274
+	}
2266
 
2275
 
2267
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
2276
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
2268
-	diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
2277
+	diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
2269
 	his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
2278
 	his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
2270
-	sickConfig, _ := service.FindSickById(patientPrescription.SickType)
2279
+	sickConfig, _ := service.FindSickById(sick_type)
2271
 	department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
2280
 	department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
2272
 
2281
 
2273
 	api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
2282
 	api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
2274
 		"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
2283
 		"&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
2275
-		"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
2284
+		"&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
2276
 		"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
2285
 		"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
2277
 	resp2, requestErr2 := http.Get(api2)
2286
 	resp2, requestErr2 := http.Get(api2)
2278
 	if requestErr2 != nil {
2287
 	if requestErr2 != nil {
2318
 		return
2327
 		return
2319
 	}
2328
 	}
2320
 
2329
 
2330
+	c.ServeSuccessJSON(map[string]interface{}{
2331
+		"msg": "上传成功",
2332
+	})
2333
+
2321
 }
2334
 }
2322
 
2335
 
2323
 func PathExists(path string) (bool, error) {
2336
 func PathExists(path string) (bool, error) {

+ 4 - 0
models/his_models.go View File

649
 	MedicalInsurancePrice float64   `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
649
 	MedicalInsurancePrice float64   `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
650
 	PrivatePrice          float64   `gorm:"column:private_price" json:"private_price" form:"private_price"`
650
 	PrivatePrice          float64   `gorm:"column:private_price" json:"private_price" form:"private_price"`
651
 
651
 
652
+	SettleType      int64 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
653
+	SettleStartTime int64 `gorm:"column:settle_start_time" json:"settle_start_time" form:"settle_start_time"`
654
+	SettleEndTime   int64 `gorm:"column:settle_end_time" json:"settle_end_time" form:"settle_end_time"`
655
+
652
 	HisOrderInfo        HisOrderInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
656
 	HisOrderInfo        HisOrderInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
653
 	Patients            Patients            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
657
 	Patients            Patients            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
654
 	HisPatient          HisPatient          `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`
658
 	HisPatient          HisPatient          `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`