his_hospital_api_controller.go 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. package controllers
  2. import (
  3. "Xcx_New/enums"
  4. "Xcx_New/models"
  5. "Xcx_New/service"
  6. "fmt"
  7. "github.com/astaxie/beego"
  8. "time"
  9. )
  10. type HisHospitalApiController struct {
  11. BaseAuthAPIController
  12. }
  13. func HisHospitalManagerApiRegistRouters() {
  14. beego.Router("/api/hishospitalpatient/list", &HisHospitalApiController{}, "get:GetHisHospitalPatientList")
  15. //beego.Router("/api/hishospitalprescription/list", &HisHospitalApiController{}, "get:GetHisHospitalPrescriptionList")
  16. beego.Router("/api/hospitalcharge/list", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientList")
  17. beego.Router("/api/hospotalcharge/info", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientInfo")
  18. beego.Router("/api/hospitalprescription/list", &HisHospitalApiController{}, "get:GetHisHospitalPrescriptionList")
  19. //beego.Router("/api/hishospitalprescription/info", &HisApiController{}, "get:GetHisHospitalPrescriptionInfo")
  20. //beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
  21. //beego.Router("/api/hisprescription/edit", &HisApiController{}, "post:EditHisPrescription")
  22. //beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
  23. //beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
  24. //beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "get:CreateHisPatientCaseHistory")
  25. //beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "get:CreateCaseHistoryTemplate")
  26. //beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
  27. //beego.Router("/api/hisorder/list", &HisApiController{}, "get:GetHisOrderList")
  28. //beego.Router("/api/hisorder/get", &HisApiController{}, "get:GetHisOrder")
  29. //beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  30. //
  31. //beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  32. //
  33. //beego.Router("/api/refund/post", &HisApiController{}, "post:Refund")
  34. //
  35. //beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
  36. //
  37. //beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
  38. //beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
  39. //新增附加费用
  40. //beego.Router("/api/his/additionalcharge", &HisApiController{}, "Post:AdditionalCharge")
  41. //beego.Router("/api/additionalcharge/get", &HisApiController{}, "Get:GetAdditionalcharge")
  42. //beego.Router("/api/hisprescription/get", &HisApiController{}, "Get:GetLastOrNextHisPrescription")
  43. //beego.Router("/api/callhisprescription/get", &HisApiController{}, "Get:GetCallHisPrescription")
  44. //beego.Router("/api/dayprescription/get", &HisApiController{}, "get:GetHisDayPrescription")
  45. //beego.Router("/api/charge/list", &HisApiController{}, "get:GetHisChargePatientList")
  46. //beego.Router("/api/charge/info", &HisApiController{}, "get:GetHisChargePatientInfo")
  47. //beego.Router("/api/unregister/list", &HisApiController{}, "get:GetHisUnRegisterPatientList")
  48. //beego.Router("/api/orderdetail/get", &HisApiController{}, "get:GetAllOrderDetail")
  49. //beego.Router("/api/orderdetaicollect/get", &HisApiController{}, "get:GetAllOrderDetailCollect")
  50. //beego.Router("/api/cost/compare", &HisApiController{}, "get:GetMedicalInsuranceCostCompareList")
  51. //beego.Router("/api/record/list", &HisApiController{}, "get:GetPutOnRecordList")
  52. //
  53. //beego.Router("/api/comparedata/get", &HisApiController{}, "get:GetCompareData")
  54. //beego.Router("/api/fapiao/get", &HisApiController{}, "get:GetFaPiaoData")
  55. //
  56. //beego.Router("/api/incomestatistics/get", &HisApiController{}, "get:GetIncomeStatisticsData")
  57. //
  58. //beego.Router("/api/postprojectinformation", &HisApiController{}, "post:PostProjectInformation")
  59. }
  60. func (c *HisHospitalApiController) GetHisHospitalPatientList() {
  61. record_date := c.GetString("record_date")
  62. types, _ := c.GetInt64("type", 0)
  63. timeLayout := "2006-01-02"
  64. loc, _ := time.LoadLocation("Local")
  65. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  66. if err != nil {
  67. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  68. return
  69. }
  70. recordDateTime := theTime.Unix()
  71. adminInfo := c.GetAdminUserInfo()
  72. var patients []*service.HospitalPatient
  73. tempPatients, _ := service.GetHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
  74. for _, item := range tempPatients {
  75. if item.HisHospitalCheckRecord.ID > 0 && item.HisHospitalCheckRecord.InHospitalStatus == 1 && item.HisHospitalCheckRecord.OutHospitalStatus == 0 {
  76. patients = append(patients, item)
  77. }
  78. }
  79. var total_one int64
  80. var total_two int64
  81. for _, item := range patients {
  82. if item.VMHisPrescriptionInfo.ID == 0 {
  83. total_one = total_one + 1
  84. }
  85. if item.VMHisPrescriptionInfo.ID > 0 {
  86. total_two = total_two + 1
  87. }
  88. }
  89. adminUserInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  90. doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
  91. department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
  92. if types == 0 {
  93. c.ServeSuccessJSON(map[string]interface{}{
  94. "list": patients,
  95. "total_one": total_one,
  96. "total_two": total_two,
  97. "info": adminUserInfo,
  98. "doctors": doctors,
  99. "department": department,
  100. })
  101. } else if types == 1 { //未就诊
  102. var patientsOne []*service.HospitalPatient
  103. for _, item := range tempPatients {
  104. if item.VMHisPrescriptionInfo.ID == 0 {
  105. patientsOne = append(patientsOne, item)
  106. }
  107. }
  108. c.ServeSuccessJSON(map[string]interface{}{
  109. "list": patientsOne,
  110. "total_one": total_one,
  111. "total_two": total_two,
  112. "info": adminUserInfo,
  113. "doctors": doctors,
  114. "department": department,
  115. })
  116. } else if types == 2 { //已就诊
  117. var patientsTwo []*service.HospitalPatient
  118. for _, item := range tempPatients {
  119. if item.VMHisPrescriptionInfo.ID > 0 {
  120. patientsTwo = append(patientsTwo, item)
  121. }
  122. }
  123. c.ServeSuccessJSON(map[string]interface{}{
  124. "list": patientsTwo,
  125. "total_one": total_one,
  126. "total_two": total_two,
  127. "info": adminUserInfo,
  128. "doctors": doctors,
  129. "department": department,
  130. })
  131. }
  132. }
  133. func (c *HisHospitalApiController) GetHisHospitalChargePatientList() {
  134. record_date := c.GetString("record_date")
  135. timeLayout := "2006-01-02"
  136. loc, _ := time.LoadLocation("Local")
  137. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  138. if err != nil {
  139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  140. return
  141. }
  142. recordDateTime := theTime.Unix()
  143. adminInfo := c.GetAdminUserInfo()
  144. //tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
  145. tempPatients, _ := service.GetNewAllChargeHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
  146. var patients []*service.HospitalPatient
  147. for _, item := range tempPatients {
  148. fmt.Println(item.ID)
  149. if item.HisHospitalCheckRecord.ID > 0 && item.HisHospitalCheckRecord.InHospitalStatus == 1 &&
  150. item.HisHospitalCheckRecord.HisHospitalOrder.ID == 0 {
  151. patients = append(patients, item)
  152. }
  153. }
  154. c.ServeSuccessJSON(map[string]interface{}{
  155. "list": patients,
  156. "list_two": patients,
  157. })
  158. }
  159. func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
  160. patient_id, _ := c.GetInt64("patient_id")
  161. his_patient_id, _ := c.GetInt64("his_patient_id")
  162. record_date := c.GetString("record_date")
  163. start_time := c.GetString("start_time")
  164. end_time := c.GetString("end_time")
  165. order_status, _ := c.GetInt64("type", 0)
  166. p_type, _ := c.GetInt64("p_type", 0)
  167. timeLayout := "2006-01-02"
  168. loc, _ := time.LoadLocation("Local")
  169. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  170. if err != nil {
  171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  172. return
  173. }
  174. recordDateTime := theTime.Unix()
  175. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  176. if err != nil {
  177. }
  178. startRecordDateTime := startTime.Unix()
  179. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  180. if err != nil {
  181. }
  182. endRecordDateTime := endTime.Unix()
  183. admin := c.GetAdminUserInfo()
  184. his_patient_info, _ := service.GetNewHisHospitalPatientInfo(his_patient_id)
  185. xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
  186. var prescriptions []*models.HisPrescription
  187. if order_status == 1 || order_status == 0 {
  188. prescriptions, _ = service.GetUnChargeHisHospitalPrescriptionFive(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime)
  189. } else if order_status == 2 {
  190. prescriptions, _ = service.GetChargeHisHospitalPrescriptionFive(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime)
  191. }
  192. var monthPrescriptions []*models.HisPrescription
  193. if order_status == 1 || order_status == 0 {
  194. monthPrescriptions, _ = service.GetUnChargeMonthHisPrescriptionThree(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
  195. } else if order_status == 2 {
  196. monthPrescriptions, _ = service.GetChargeMonthHisPrescriptionFour(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
  197. }
  198. case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
  199. patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
  200. order, _ := service.GetNewHisOrder(admin.CurrentOrgId, his_patient_info.Number, patient_id)
  201. doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
  202. //获取所有科室信息
  203. department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
  204. c.ServeSuccessJSON(map[string]interface{}{
  205. "his_info": his_patient_info,
  206. "xt_info": xt_patient_info,
  207. "prescription": prescriptions,
  208. "case_history": case_history,
  209. "info": patientPrescriptionInfo,
  210. "month_prescriptions": monthPrescriptions,
  211. "order": order,
  212. "doctors": doctors,
  213. "department": department,
  214. })
  215. return
  216. }
  217. func (c *HisHospitalApiController) GetHisHospitalrescriptionList() {
  218. record_date := c.GetString("record_date")
  219. keywords := c.GetString("keywords")
  220. page, _ := c.GetInt64("page")
  221. limit, _ := c.GetInt64("limit")
  222. timeLayout := "2006-01-02"
  223. loc, _ := time.LoadLocation("Local")
  224. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  225. if err != nil {
  226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  227. return
  228. }
  229. recordDateTime := theTime.Unix()
  230. adminInfo := c.GetAdminUserInfo()
  231. prescriptionOrder, err, total := service.GetHisPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
  232. //adminInfo := c.GetAdminUserInfo()
  233. //prescriptionOrder, err := service.GetHisPrescriptionOrderList(adminInfo.CurrentOrgId)
  234. //fmt.Println(prescriptionOrder)
  235. if err == nil {
  236. c.ServeSuccessJSON(map[string]interface{}{
  237. "order": prescriptionOrder,
  238. "total": total,
  239. })
  240. } else {
  241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  242. return
  243. }
  244. }
  245. func (c *HisHospitalApiController) GetHisHospitalPrescriptionList() {
  246. record_date := c.GetString("record_date")
  247. keywords := c.GetString("keywords")
  248. page, _ := c.GetInt64("page")
  249. limit, _ := c.GetInt64("limit")
  250. timeLayout := "2006-01-02"
  251. loc, _ := time.LoadLocation("Local")
  252. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  253. if err != nil {
  254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  255. return
  256. }
  257. recordDateTime := theTime.Unix()
  258. adminInfo := c.GetAdminUserInfo()
  259. prescriptionOrder, err, total := service.GetHisHospitalPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
  260. if err == nil {
  261. c.ServeSuccessJSON(map[string]interface{}{
  262. "order": prescriptionOrder,
  263. "total": total,
  264. })
  265. } else {
  266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  267. return
  268. }
  269. }