|
@@ -142,6 +142,7 @@ func (c *HisApiController) GetHisPatientList() {
|
142
|
142
|
patients, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
|
143
|
143
|
patients_two, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
|
144
|
144
|
patients = append(patients, patients_two...)
|
|
145
|
+ patients = RemoveRepeatedPatient(patients)
|
145
|
146
|
|
146
|
147
|
var total_one int64
|
147
|
148
|
var total_two int64
|
|
@@ -244,6 +245,11 @@ func (c *HisApiController) GetHisPatientInfo() {
|
244
|
245
|
case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
|
245
|
246
|
patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
|
246
|
247
|
order, _ := service.GetHisOrder(admin.CurrentOrgId, number, patient_id)
|
|
248
|
+
|
|
249
|
+ doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
|
|
250
|
+ //获取所有科室信息
|
|
251
|
+ department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
|
|
252
|
+
|
247
|
253
|
c.ServeSuccessJSON(map[string]interface{}{
|
248
|
254
|
"his_info": his_patient_info,
|
249
|
255
|
"xt_info": xt_patient_info,
|
|
@@ -252,6 +258,8 @@ func (c *HisApiController) GetHisPatientInfo() {
|
252
|
258
|
"info": patientPrescriptionInfo,
|
253
|
259
|
"month_prescriptions": monthPrescriptions,
|
254
|
260
|
"order": order,
|
|
261
|
+ "doctors": doctors,
|
|
262
|
+ "department": department,
|
255
|
263
|
})
|
256
|
264
|
return
|
257
|
265
|
|
|
@@ -2007,22 +2015,23 @@ type Custom struct {
|
2007
|
2015
|
func (c *HisApiController) GetRegisterInfo() {
|
2008
|
2016
|
id, _ := c.GetInt64("id")
|
2009
|
2017
|
record_time := c.GetString("record_time")
|
2010
|
|
-
|
|
2018
|
+ settlementValue, _ := c.GetInt64("settlement_value")
|
|
2019
|
+ medical_insurance_card := c.GetString("medical_insurance_card")
|
2011
|
2020
|
name := c.GetString("name")
|
2012
|
|
- gender, _ := c.GetInt64("gender")
|
2013
|
|
- age, _ := c.GetInt64("age")
|
|
2021
|
+ id_card_type, _ := c.GetInt64("id_card_type")
|
|
2022
|
+ certificates, _ := c.GetInt64("certificates")
|
|
2023
|
+ medical_care, _ := c.GetInt64("medical_care")
|
2014
|
2024
|
birthday := c.GetString("birthday")
|
|
2025
|
+ age, _ := c.GetInt64("age")
|
|
2026
|
+ id_card := c.GetString("idCard")
|
|
2027
|
+ register_type, _ := c.GetInt64("register")
|
|
2028
|
+ doctor, _ := c.GetInt64("doctor")
|
|
2029
|
+ department, _ := c.GetInt64("department")
|
|
2030
|
+ gender, _ := c.GetInt64("sex")
|
2015
|
2031
|
phone := c.GetString("phone")
|
2016
|
|
- medical_care, _ := c.GetInt64("medical_care")
|
2017
|
|
- id_card := c.GetString("id_card")
|
2018
|
|
- register_type, _ := c.GetInt64("register_type")
|
2019
|
2032
|
registration_fee, _ := c.GetFloat("registration_fee")
|
2020
|
2033
|
medical_expenses, _ := c.GetFloat("medical_expenses")
|
2021
|
|
- certificates, _ := c.GetInt64("certificates")
|
2022
|
|
- settlementValue, _ := c.GetInt64("settlement_value")
|
2023
|
2034
|
social_type, _ := c.GetInt64("social_type")
|
2024
|
|
- medical_insurance_card := c.GetString("medical_insurance_card")
|
2025
|
|
- id_card_type, _ := c.GetInt64("id_card_type")
|
2026
|
2035
|
|
2027
|
2036
|
timeLayout := "2006-01-02"
|
2028
|
2037
|
loc, _ := time.LoadLocation("Local")
|
|
@@ -2037,12 +2046,18 @@ func (c *HisApiController) GetRegisterInfo() {
|
2037
|
2046
|
recordDateTime := theTime.Unix()
|
2038
|
2047
|
|
2039
|
2048
|
adminInfo := c.GetAdminUserInfo()
|
2040
|
|
- patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
|
2041
|
|
- patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
|
2042
|
2049
|
|
2043
|
|
- miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
|
|
2050
|
+ var patient service.Patients
|
2044
|
2051
|
|
2045
|
|
- if patient == nil {
|
|
2052
|
+ if id == 0 {
|
|
2053
|
+ patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
|
|
2054
|
+
|
|
2055
|
+ } else {
|
|
2056
|
+ patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
|
|
2057
|
+
|
|
2058
|
+ }
|
|
2059
|
+
|
|
2060
|
+ if patient.ID == 0 {
|
2046
|
2061
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
|
2047
|
2062
|
return
|
2048
|
2063
|
}
|
|
@@ -2051,197 +2066,10 @@ func (c *HisApiController) GetRegisterInfo() {
|
2051
|
2066
|
return
|
2052
|
2067
|
}
|
2053
|
2068
|
|
2054
|
|
- //org, _ := service.GetOrgById(adminInfo.CurrentOrgId)
|
2055
|
2069
|
config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
|
2056
|
2070
|
|
2057
|
2071
|
if config.IsOpen == 1 {
|
2058
|
2072
|
|
2059
|
|
- api := "http://127.0.0.1:9531/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
|
2060
|
|
- resp, requestErr := http.Get(api)
|
2061
|
|
-
|
2062
|
|
- if requestErr != nil {
|
2063
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2064
|
|
- return
|
2065
|
|
- }
|
2066
|
|
- defer resp.Body.Close()
|
2067
|
|
- body, ioErr := ioutil.ReadAll(resp.Body)
|
2068
|
|
- if ioErr != nil {
|
2069
|
|
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
2070
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2071
|
|
- return
|
2072
|
|
- }
|
2073
|
|
- var respJSON map[string]interface{}
|
2074
|
|
-
|
2075
|
|
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
2076
|
|
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
2077
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2078
|
|
- return
|
2079
|
|
- }
|
2080
|
|
-
|
2081
|
|
- userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
2082
|
|
- userJSONBytes, _ := json.Marshal(userJSON)
|
2083
|
|
- var res ResultTwo
|
2084
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
2085
|
|
- utils.ErrorLog("解析失败:%v", err)
|
2086
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2087
|
|
- return
|
2088
|
|
- }
|
2089
|
|
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
2090
|
|
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
2091
|
|
- infoStr := string(Iinfos)
|
2092
|
|
- idetinfoStr := string(Idetinfos)
|
2093
|
|
-
|
2094
|
|
- his := models.VMHisPatient{
|
2095
|
|
- PsnNo: res.Output.Baseinfo.PsnNo,
|
2096
|
|
- PsnCertType: res.Output.Baseinfo.PsnCertType,
|
2097
|
|
- Certno: res.Output.Baseinfo.Certno,
|
2098
|
|
- PsnName: res.Output.Baseinfo.PsnName,
|
2099
|
|
- Gend: res.Output.Baseinfo.Gend,
|
2100
|
|
- Naty: res.Output.Baseinfo.Naty,
|
2101
|
|
- Brdy: res.Output.Baseinfo.Brdy,
|
2102
|
|
- Age: res.Output.Baseinfo.Age,
|
2103
|
|
- Iinfo: infoStr,
|
2104
|
|
- Idetinfo: idetinfoStr,
|
2105
|
|
- PatientId: patient.ID,
|
2106
|
|
- RecordDate: theTime.Unix(),
|
2107
|
|
- UserOrgId: adminInfo.CurrentOrgId,
|
2108
|
|
- AdminUserId: adminInfo.AdminUser.Id,
|
2109
|
|
- IsReturn: 1,
|
2110
|
|
- }
|
2111
|
|
- fmt.Println(his)
|
2112
|
|
-
|
2113
|
|
- lastPatient, _ := service.GetLastPatient(adminInfo.CurrentOrgId)
|
2114
|
|
- timeStr := time.Now().Format("2006-01-02")
|
2115
|
|
- timeArr := strings.Split(timeStr, "-")
|
2116
|
|
- var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(lastPatient.ID, 10)
|
2117
|
|
-
|
2118
|
|
- hisPatient := models.HisPatient{
|
2119
|
|
- Number: str,
|
2120
|
|
- }
|
2121
|
|
- err = service.UpdateHisPatient(lastPatient.ID, hisPatient)
|
2122
|
|
-
|
2123
|
|
- if res.Output.Iinfo == nil || len(res.Output.Iinfo) == 0 {
|
2124
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterOneException)
|
2125
|
|
- return
|
2126
|
|
- }
|
2127
|
|
-
|
2128
|
|
- timestamp := time.Now().Unix()
|
2129
|
|
- tempTime := time.Unix(timestamp, 0)
|
2130
|
|
- timeFormat := tempTime.Format("20060102150405")
|
2131
|
|
- chrgBchno := rand.Intn(100000) + 10000
|
2132
|
|
- ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
|
2133
|
|
-
|
2134
|
|
- count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
|
2135
|
|
-
|
2136
|
|
- department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
|
2137
|
|
-
|
2138
|
|
- //department_id := strconv.FormatInt(department.ID, 10)
|
2139
|
|
- doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
|
2140
|
|
-
|
2141
|
|
- if count <= 0 {
|
2142
|
|
- api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
|
2143
|
|
- res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
|
2144
|
|
- "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
|
2145
|
|
- "&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
|
2146
|
|
- resp, requestErr := http.Get(api)
|
2147
|
|
- if requestErr != nil {
|
2148
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2149
|
|
- return
|
2150
|
|
- }
|
2151
|
|
- defer resp.Body.Close()
|
2152
|
|
- body, ioErr := ioutil.ReadAll(resp.Body)
|
2153
|
|
- if ioErr != nil {
|
2154
|
|
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
2155
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2156
|
|
- return
|
2157
|
|
- }
|
2158
|
|
- var respJSON map[string]interface{}
|
2159
|
|
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
2160
|
|
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
2161
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2162
|
|
- return
|
2163
|
|
- }
|
2164
|
|
-
|
2165
|
|
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
2166
|
|
- userJSONBytes, _ := json.Marshal(respJSON)
|
2167
|
|
- var res ResultThree
|
2168
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
2169
|
|
- utils.ErrorLog("解析失败:%v", err)
|
2170
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2171
|
|
- return
|
2172
|
|
- }
|
2173
|
|
- if res.Infcode == -1 {
|
2174
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
|
2175
|
|
- return
|
2176
|
|
- }
|
2177
|
|
- fmt.Println("000!!!!!!")
|
2178
|
|
- fmt.Println(res)
|
2179
|
|
- fmt.Println(res.Output.Data.MdtrtID)
|
2180
|
|
- fmt.Println(res.Output.Data.PsnNo)
|
2181
|
|
- fmt.Println(res.Output.Data.IptOtpNo)
|
2182
|
|
-
|
2183
|
|
- his.Number = res.Output.Data.MdtrtID
|
2184
|
|
- his.PsnNo = res.Output.Data.PsnNo
|
2185
|
|
- his.IptOtpNo = res.Output.Data.IptOtpNo
|
2186
|
|
- his.IdCardNo = patient.IdCardNo
|
2187
|
|
- his.PhoneNumber = patient.Phone
|
2188
|
|
- his.UserOrgId = adminInfo.CurrentOrgId
|
2189
|
|
- his.Status = 1
|
2190
|
|
- his.Ctime = time.Now().Unix()
|
2191
|
|
- his.Mtime = time.Now().Unix()
|
2192
|
|
- err := service.CreateHisPatientTwo(&his)
|
2193
|
|
-
|
2194
|
|
- diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
|
2195
|
|
-
|
2196
|
|
- if err == nil {
|
2197
|
|
- api := "http://127.0.0.1:9531/" + "gdyb/four?psn_no=" + his.PsnNo +
|
2198
|
|
- "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
|
2199
|
|
- "&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + "11" + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
|
2200
|
|
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
|
2201
|
|
- resp, requestErr := http.Get(api)
|
2202
|
|
- if requestErr != nil {
|
2203
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2204
|
|
- return
|
2205
|
|
- }
|
2206
|
|
-
|
2207
|
|
- body, ioErr := ioutil.ReadAll(resp.Body)
|
2208
|
|
- if ioErr != nil {
|
2209
|
|
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
2210
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2211
|
|
- return
|
2212
|
|
- }
|
2213
|
|
- var respJSON map[string]interface{}
|
2214
|
|
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
2215
|
|
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
2216
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2217
|
|
- return
|
2218
|
|
- }
|
2219
|
|
-
|
2220
|
|
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
2221
|
|
- userJSONBytes, _ := json.Marshal(respJSON)
|
2222
|
|
- fmt.Println(respJSON)
|
2223
|
|
- fmt.Println(userJSONBytes)
|
2224
|
|
-
|
2225
|
|
- var res ResultSix
|
2226
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
2227
|
|
- utils.ErrorLog("解析失败:%v", err)
|
2228
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2229
|
|
- return
|
2230
|
|
- }
|
2231
|
|
- if res.Infcode == -1 {
|
2232
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
|
2233
|
|
- return
|
2234
|
|
- }
|
2235
|
|
-
|
2236
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
2237
|
|
- "his_info": his,
|
2238
|
|
- })
|
2239
|
|
- } else {
|
2240
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
2241
|
|
- return
|
2242
|
|
- }
|
2243
|
|
- }
|
2244
|
|
-
|
2245
|
2073
|
} else {
|
2246
|
2074
|
timeStr := time.Now().Format("2006-01-02")
|
2247
|
2075
|
timeArr := strings.Split(timeStr, "-")
|
|
@@ -2275,6 +2103,8 @@ func (c *HisApiController) GetRegisterInfo() {
|
2275
|
2103
|
Mtime: time.Now().Unix(),
|
2276
|
2104
|
Number: str,
|
2277
|
2105
|
IdCardType: id_card_type,
|
|
2106
|
+ Departments: department,
|
|
2107
|
+ Doctor: doctor,
|
2278
|
2108
|
}
|
2279
|
2109
|
service.CreateHisPatient(&hisPatient)
|
2280
|
2110
|
|
|
@@ -2949,13 +2779,14 @@ func (c *HisApiController) GetHisChargePatientList() {
|
2949
|
2779
|
}
|
2950
|
2780
|
recordDateTime := theTime.Unix()
|
2951
|
2781
|
adminInfo := c.GetAdminUserInfo()
|
2952
|
|
- patients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
|
2953
|
|
- //var patients []*service.Patients
|
2954
|
|
- //for _, item := range tempPatients{
|
2955
|
|
- // if len(item.HisPrescription) > 0 {
|
2956
|
|
- // patients = append(patients, item)
|
2957
|
|
- // }
|
2958
|
|
- //}
|
|
2782
|
+ tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
|
|
2783
|
+ var patients []*service.Patients
|
|
2784
|
+ for _, item := range tempPatients {
|
|
2785
|
+ //过滤掉没挂号的和没开处方的
|
|
2786
|
+ if item.HisPatient.ID > 0 || len(item.HisPrescription) > 0 {
|
|
2787
|
+ patients = append(patients, item)
|
|
2788
|
+ }
|
|
2789
|
+ }
|
2959
|
2790
|
//patients_two, _ := service.GetChargeHisPatientListTwo(adminInfo.CurrentOrgId, "", recordDateTime)
|
2960
|
2791
|
c.ServeSuccessJSON(map[string]interface{}{
|
2961
|
2792
|
"list": patients,
|
|
@@ -2990,3 +2821,20 @@ func (c *HisApiController) GetHisUnRegisterPatientList() {
|
2990
|
2821
|
})
|
2991
|
2822
|
|
2992
|
2823
|
}
|
|
2824
|
+
|
|
2825
|
+func RemoveRepeatedPatient(patient []*service.Patients) (newArr []*service.Patients) {
|
|
2826
|
+ newArr = make([]*service.Patients, 0)
|
|
2827
|
+ for i := 0; i < len(patient); i++ {
|
|
2828
|
+ repeat := false
|
|
2829
|
+ for j := i + 1; j < len(patient); j++ {
|
|
2830
|
+ if patient[i].ID == patient[j].ID {
|
|
2831
|
+ repeat = true
|
|
2832
|
+ break
|
|
2833
|
+ }
|
|
2834
|
+ }
|
|
2835
|
+ if !repeat {
|
|
2836
|
+ newArr = append(newArr, patient[i])
|
|
2837
|
+ }
|
|
2838
|
+ }
|
|
2839
|
+ return
|
|
2840
|
+}
|