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,7 +44,7 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
44 44
 
45 45
 
46 46
 [prod]
47
-org_id = 9919
47
+org_id = 4
48 48
 mobile_token_expiration_second = 86400
49 49
 httpdomain = https://api.xt.kuyicloud.com
50 50
 sso_domain = https://sso.kuyicloud.com

+ 80 - 67
controllers/his_api_controller.go View File

@@ -30,7 +30,6 @@ type HisApiController struct {
30 30
 }
31 31
 
32 32
 func HisManagerApiRegistRouters() {
33
-
34 33
 	beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
35 34
 	beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
36 35
 	beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
@@ -39,17 +38,10 @@ func HisManagerApiRegistRouters() {
39 38
 	beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
40 39
 	beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
41 40
 	beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
42
-
43 41
 	beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
44 42
 	beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
45
-
46
-	//beego.Router("/api/code/get", &HisApiController{}, "get:GetCode")
47
-
48 43
 	beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
49
-
50 44
 	beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
51
-	//beego.Router("/api/returnrecord/put", &HisApiController{}, "get:ReturnRecord")
52
-
53 45
 }
54 46
 
55 47
 func (c *HisApiController) Sscard() {
@@ -148,7 +140,6 @@ func GetBasBaseInfo() (jsonStr string, err error) {
148 140
 	str1 := make([]byte, 256)
149 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 143
 	fmt.Println(r)
153 144
 	return string(str), nil
154 145
 }
@@ -161,7 +152,6 @@ func GetSFZBaseInfo() (jsonStr string, err error) {
161 152
 	str1 := make([]byte, 256)
162 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 155
 	fmt.Println(r)
166 156
 	return string(str), nil
167 157
 }
@@ -599,8 +589,8 @@ func (c *HisApiController) GetRegisterInfo() {
599 589
 			count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
600 590
 			department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
601 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 595
 			IdCardNo := ""
606 596
 			if id_card_type == 1 {
@@ -669,53 +659,53 @@ func (c *HisApiController) GetRegisterInfo() {
669 659
 				his.Status = 1
670 660
 				err := service.CreateHisPatientTwo(&his)
671 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 710
 					c.ServeSuccessJSON(map[string]interface{}{
721 711
 						"his_info": his,
@@ -817,28 +807,33 @@ func (c *HisApiController) GetUploadInfo() {
817 807
 
818 808
 	var prescriptions []*models.HisPrescription
819 809
 
810
+	var start_time int64
811
+	var end_time int64
812
+
820 813
 	data := make(map[string]interface{})
821 814
 	if settle_accounts_type == 1 { //日结
822 815
 		prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
823 816
 		data["pre"] = prescriptions
824 817
 
825 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 821
 		timeLayout := "2006-01-02"
829 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 824
 		if err != nil {
832 825
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
833 826
 			return
834 827
 		}
835 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 831
 		if err != nil {
838 832
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
839 833
 			return
840 834
 		}
841 835
 		recordEndTime := theEndTime.Unix()
836
+		end_time = recordEndTime
842 837
 		prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
843 838
 		data["pre"] = prescriptions
844 839
 
@@ -926,6 +921,9 @@ func (c *HisApiController) GetUploadInfo() {
926 921
 				MedicalInsurancePrice: medical_insurance_price,
927 922
 				PrivatePrice:          private_price,
928 923
 				IsMedicineInsurance:   1,
924
+				SettleType:            settle_accounts_type,
925
+				SettleStartTime:       start_time,
926
+				SettleEndTime:         end_time,
929 927
 			}
930 928
 			err = service.CreateOrder(order)
931 929
 			if err != nil {
@@ -2253,6 +2251,11 @@ func (c *HisApiController) PutRecord() {
2253 2251
 func (c *HisApiController) GetUploadDiag() {
2254 2252
 	id, _ := c.GetInt64("id")
2255 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 2259
 	timeLayout := "2006-01-02"
2257 2260
 	loc, _ := time.LoadLocation("Local")
2258 2261
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
@@ -2260,19 +2263,25 @@ func (c *HisApiController) GetUploadDiag() {
2260 2263
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2261 2264
 		return
2262 2265
 	}
2266
+
2267
+	var patientPrescription models.HisPrescriptionInfo
2263 2268
 	recordDateTime := theTime.Unix()
2264 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 2276
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
2268
-	diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
2277
+	diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
2269 2278
 	his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
2270
-	sickConfig, _ := service.FindSickById(patientPrescription.SickType)
2279
+	sickConfig, _ := service.FindSickById(sick_type)
2271 2280
 	department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
2272 2281
 
2273 2282
 	api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
2274 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 2285
 		"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
2277 2286
 	resp2, requestErr2 := http.Get(api2)
2278 2287
 	if requestErr2 != nil {
@@ -2318,6 +2327,10 @@ func (c *HisApiController) GetUploadDiag() {
2318 2327
 		return
2319 2328
 	}
2320 2329
 
2330
+	c.ServeSuccessJSON(map[string]interface{}{
2331
+		"msg": "上传成功",
2332
+	})
2333
+
2321 2334
 }
2322 2335
 
2323 2336
 func PathExists(path string) (bool, error) {

+ 4 - 0
models/his_models.go View File

@@ -649,6 +649,10 @@ type HisOrder struct {
649 649
 	MedicalInsurancePrice float64   `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
650 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 656
 	HisOrderInfo        HisOrderInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
653 657
 	Patients            Patients            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
654 658
 	HisPatient          HisPatient          `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`