his_api_controller.go 70KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "bytes"
  8. "encoding/json"
  9. "fmt"
  10. "github.com/astaxie/beego"
  11. "github.com/jinzhu/gorm"
  12. "io/ioutil"
  13. "math/rand"
  14. "net/http"
  15. "reflect"
  16. "strconv"
  17. "strings"
  18. "time"
  19. )
  20. type HisApiController struct {
  21. BaseAuthAPIController
  22. }
  23. func HisManagerApiRegistRouters() {
  24. beego.Router("/api/hispatient/list", &HisApiController{}, "get:GetHisPatientList")
  25. beego.Router("/api/hispatient/get", &HisApiController{}, "get:GetHisPatientInfo")
  26. beego.Router("/api/hisprescription/config", &HisApiController{}, "get:GetHisPrescriptionConfig")
  27. beego.Router("/api/hisprescription/delete", &HisApiController{}, "post:DeletePrescription")
  28. beego.Router("/api/advice/delete", &HisApiController{}, "post:DeleteDoctorAdvice")
  29. beego.Router("/api/project/delete", &HisApiController{}, "post:DeleteProject")
  30. beego.Router("/api/addition_charge/delete", &HisApiController{}, "post:DeleteAddition")
  31. beego.Router("/api/hisprescription/list", &HisApiController{}, "get:GetHisPrescriptionList")
  32. beego.Router("/api/hisprescription/info", &HisApiController{}, "get:GetHisPrescriptionInfo")
  33. beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
  34. beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
  35. beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
  36. beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "get:CreateHisPatientCaseHistory")
  37. beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "get:CreateCaseHistoryTemplate")
  38. beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
  39. beego.Router("/api/hisorder/list", &HisApiController{}, "get:GetHisOrderList")
  40. beego.Router("/api/hisorder/get", &HisApiController{}, "get:GetHisOrder")
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  43. beego.Router("/api/refund/post", &HisApiController{}, "post:Refund")
  44. beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
  45. beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
  46. //beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
  47. //新增附加费用
  48. //beego.Router("/api/his/additionalcharge", &HisApiController{}, "Post:AdditionalCharge")
  49. //beego.Router("/api/additionalcharge/get", &HisApiController{}, "Get:GetAdditionalcharge")
  50. }
  51. func (c *HisApiController) GetHisPatientList() {
  52. types, _ := c.GetInt64("type", 0)
  53. record_date := c.GetString("record_date")
  54. timeLayout := "2006-01-02"
  55. loc, _ := time.LoadLocation("Local")
  56. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  57. if err != nil {
  58. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  59. return
  60. }
  61. recordDateTime := theTime.Unix()
  62. adminInfo := c.GetAdminUserInfo()
  63. patients, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
  64. var total_one int64
  65. var total_two int64
  66. //获取当前用户的信息
  67. adminUserInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  68. doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
  69. //获取所有科室信息
  70. department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
  71. for _, item := range patients {
  72. if item.HisPrescription == nil || len(item.HisPrescription) <= 0 {
  73. total_one = total_one + 1
  74. }
  75. if item.HisPrescription != nil && len(item.HisPrescription) > 0 {
  76. total_two = total_two + 1
  77. }
  78. }
  79. if types == 0 {
  80. c.ServeSuccessJSON(map[string]interface{}{
  81. "list": patients,
  82. "total_one": total_one,
  83. "total_two": total_two,
  84. "info": adminUserInfo,
  85. "doctors": doctors,
  86. "department": department,
  87. })
  88. } else if types == 1 { //未就诊
  89. var patientsOne []*service.Schedule
  90. for _, item := range patients {
  91. if item.HisPrescription == nil || len(item.HisPrescription) <= 0 {
  92. patientsOne = append(patientsOne, item)
  93. }
  94. }
  95. c.ServeSuccessJSON(map[string]interface{}{
  96. "list": patientsOne,
  97. "total_one": total_one,
  98. "total_two": total_two,
  99. "info": adminUserInfo,
  100. "doctors": doctors,
  101. "department": department,
  102. })
  103. } else if types == 2 { //已就诊
  104. var patientsTwo []*service.Schedule
  105. for _, item := range patients {
  106. if item.HisPrescription != nil && len(item.HisPrescription) > 0 {
  107. patientsTwo = append(patientsTwo, item)
  108. }
  109. }
  110. c.ServeSuccessJSON(map[string]interface{}{
  111. "list": patientsTwo,
  112. "total_one": total_one,
  113. "total_two": total_two,
  114. "info": adminUserInfo,
  115. "doctors": doctors,
  116. "department": department,
  117. })
  118. }
  119. }
  120. func (c *HisApiController) GetHisPatientInfo() {
  121. patient_id, _ := c.GetInt64("patient_id")
  122. record_date := c.GetString("record_date")
  123. number := c.GetString("number")
  124. timeLayout := "2006-01-02"
  125. loc, _ := time.LoadLocation("Local")
  126. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  127. if err != nil {
  128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  129. return
  130. }
  131. recordDateTime := theTime.Unix()
  132. admin := c.GetAdminUserInfo()
  133. his_patient_info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, recordDateTime)
  134. xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
  135. prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
  136. case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
  137. patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
  138. lastPatientPrescriptionInfo, _ := service.FindLastPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
  139. order, _ := service.GetHisOrder(admin.CurrentOrgId, number, patient_id)
  140. //addtions, _ := service.GetAllAdditionCharge(admin.CurrentOrgId, patient_id, recordDateTime)
  141. c.ServeSuccessJSON(map[string]interface{}{
  142. "his_info": his_patient_info,
  143. "xt_info": xt_patient_info,
  144. "prescription": prescriptions,
  145. "case_history": case_history,
  146. "info": patientPrescriptionInfo,
  147. "last_info": lastPatientPrescriptionInfo,
  148. "order": order,
  149. })
  150. return
  151. }
  152. func (c *HisApiController) GetHisPrescriptionConfig() {
  153. adminInfo := c.GetAdminUserInfo()
  154. //获取医嘱模版
  155. advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
  156. //获取所有基础药
  157. drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
  158. drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
  159. efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
  160. doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
  161. //获取所有科室信息
  162. department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
  163. //获取诊断信息
  164. sick, _ := service.FindAllSick(adminInfo.CurrentOrgId)
  165. diagnose, _ := service.FindAllDiagnose(adminInfo.CurrentOrgId)
  166. additions, _ := service.FindAllAddition(adminInfo.CurrentOrgId)
  167. c.ServeSuccessJSON(map[string]interface{}{
  168. "drugs": drugs,
  169. "advices_template": advices,
  170. "drugways": drugways,
  171. "efs": efs,
  172. "doctors": doctors,
  173. "department": department,
  174. "sick": sick,
  175. "additions": additions,
  176. "diagnose": diagnose,
  177. })
  178. }
  179. func (c *HisApiController) CreateHisPrescription() {
  180. record_date := c.GetString("record_date")
  181. patient_id, _ := c.GetInt64("patient_id")
  182. reg_type, _ := c.GetInt64("reg_type")
  183. diagnose, _ := c.GetInt64("diagnose")
  184. sick_type, _ := c.GetInt64("sick_type")
  185. sick_history := c.GetString("sick_history")
  186. doctor_id, _ := c.GetInt64("doctor", 0)
  187. department, _ := c.GetInt64("department", 0)
  188. his_patient_id, _ := c.GetInt64("his_patient_id")
  189. dataBody := make(map[string]interface{}, 0)
  190. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  191. if err != nil {
  192. utils.ErrorLog(err.Error())
  193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  194. return
  195. }
  196. timeLayout := "2006-01-02"
  197. loc, _ := time.LoadLocation("Local")
  198. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  199. if err != nil {
  200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  201. return
  202. }
  203. adminInfo := c.GetAdminUserInfo()
  204. recordDateTime := theTime.Unix()
  205. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor_id)
  206. info, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime)
  207. var hpInfo models.HisPrescriptionInfo
  208. if info.ID == 0 {
  209. var randNum int
  210. randNum = rand.Intn(10000) + 1000
  211. timestamp := time.Now().Unix()
  212. tempTime := time.Unix(timestamp, 0)
  213. timeFormat := tempTime.Format("20060102150405")
  214. p_number := timeFormat + strconv.FormatInt(int64(randNum), 10) + strconv.FormatInt(int64(adminInfo.CurrentOrgId), 10) + strconv.FormatInt(int64(patient_id), 10)
  215. hpInfo = models.HisPrescriptionInfo{
  216. UserOrgId: adminInfo.CurrentOrgId,
  217. RecordDate: theTime.Unix(),
  218. PatientId: patient_id,
  219. Status: 1,
  220. Ctime: time.Now().Unix(),
  221. Mtime: time.Now().Unix(),
  222. Creator: adminInfo.AdminUser.Id,
  223. Modifier: adminInfo.AdminUser.Id,
  224. Diagnosis: diagnose,
  225. SickHistory: sick_history,
  226. Departments: department,
  227. RegisterType: reg_type,
  228. PrescriptionNumber: p_number,
  229. PrescriptionStatus: 1,
  230. Doctor: role.UserName,
  231. DoctorId: doctor_id,
  232. SickType: sick_type,
  233. }
  234. service.SavePatientPrescriptionInfo(hpInfo)
  235. } else {
  236. hpInfo = models.HisPrescriptionInfo{
  237. ID: info.ID,
  238. UserOrgId: adminInfo.CurrentOrgId,
  239. RecordDate: info.RecordDate,
  240. PatientId: info.PatientId,
  241. Status: 1,
  242. Ctime: info.Ctime,
  243. Mtime: time.Now().Unix(),
  244. Creator: info.Creator,
  245. Modifier: adminInfo.AdminUser.Id,
  246. Diagnosis: diagnose,
  247. SickHistory: sick_history,
  248. Departments: department,
  249. RegisterType: reg_type,
  250. PrescriptionNumber: info.PrescriptionNumber,
  251. Doctor: role.UserName,
  252. PrescriptionStatus: info.PrescriptionStatus,
  253. DoctorId: doctor_id,
  254. SickType: sick_type,
  255. }
  256. service.SavePatientPrescriptionInfo(hpInfo)
  257. }
  258. if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
  259. prescriptions, _ := dataBody["prescriptions"].([]interface{})
  260. if len(prescriptions) > 0 {
  261. for _, item := range prescriptions {
  262. items := item.(map[string]interface{})
  263. if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
  264. utils.ErrorLog("id")
  265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  266. return
  267. }
  268. id := int64(items["id"].(float64))
  269. if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
  270. utils.ErrorLog("type")
  271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  272. return
  273. }
  274. types := int64(items["type"].(float64))
  275. ctime := time.Now().Unix()
  276. prescription := &models.HisPrescription{
  277. ID: id,
  278. PatientId: patient_id,
  279. UserOrgId: adminInfo.CurrentOrgId,
  280. RecordDate: recordDateTime,
  281. Ctime: ctime,
  282. Mtime: ctime,
  283. Type: types,
  284. Modifier: adminInfo.AdminUser.Id,
  285. Creator: adminInfo.AdminUser.Id,
  286. Status: 1,
  287. Doctor: role.UserName,
  288. HisPatientId: his_patient_id,
  289. OrderStatus: 1,
  290. BatchNumber: "",
  291. PrescriptionNumber: hpInfo.PrescriptionNumber,
  292. }
  293. service.SaveHisPrescription(prescription)
  294. //更改患者挂号状态
  295. _, err := service.UpdateHisPatientIsReturn(patient_id, recordDateTime, adminInfo.CurrentOrgId)
  296. fmt.Println("更改失败", err)
  297. if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
  298. advices := items["advices"].([]interface{})
  299. //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
  300. groupNo := int64(0)
  301. ctime := time.Now().Unix()
  302. mtime := ctime
  303. if len(advices) > 0 {
  304. for _, advice := range advices {
  305. var s models.HisDoctorAdviceInfo
  306. s.PrescriptionId = prescription.ID
  307. s.AdviceType = 2
  308. s.AdviceDoctor = adminInfo.AdminUser.Id
  309. s.StopState = 2
  310. s.ExecutionState = 2
  311. s.AdviceDate = recordDateTime
  312. s.Status = 1
  313. s.UserOrgId = adminInfo.CurrentOrgId
  314. s.RecordDate = recordDateTime
  315. s.StartTime = recordDateTime
  316. s.Groupno = groupNo
  317. s.CreatedTime = ctime
  318. s.UpdatedTime = mtime
  319. s.PatientId = patient_id
  320. s.HisPatientId = his_patient_id
  321. errcode := c.setAdviceWithJSON(&s, advice.(map[string]interface{}))
  322. if errcode > 0 {
  323. c.ServeFailJSONWithSGJErrorCode(errcode)
  324. return
  325. }
  326. service.CreateHisDoctorAdvice(&s)
  327. var randNum int
  328. randNum = rand.Intn(10000) + 1000
  329. timestamp := time.Now().Unix()
  330. tempTime := time.Unix(timestamp, 0)
  331. timeFormat := tempTime.Format("20060102150405")
  332. s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
  333. service.CreateHisDoctorAdvice(&s)
  334. }
  335. }
  336. }
  337. if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
  338. projects := items["project"].([]interface{})
  339. if len(projects) > 0 {
  340. for _, project := range projects {
  341. var p models.HisPrescriptionProject
  342. p.PrescriptionId = prescription.ID
  343. p.Ctime = time.Now().Unix()
  344. p.Mtime = time.Now().Unix()
  345. p.PatientId = patient_id
  346. p.RecordDate = recordDateTime
  347. p.UserOrgId = adminInfo.CurrentOrgId
  348. p.HisPatientId = his_patient_id
  349. p.Status = 1
  350. errcode := c.setProjectWithJSON(&p, project.(map[string]interface{}))
  351. if errcode > 0 {
  352. c.ServeFailJSONWithSGJErrorCode(errcode)
  353. return
  354. }
  355. service.CreateHisProjectTwo(&p)
  356. var randNum int
  357. randNum = rand.Intn(10000) + 1000
  358. timestamp := time.Now().Unix()
  359. tempTime := time.Unix(timestamp, 0)
  360. timeFormat := tempTime.Format("20060102150405")
  361. p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
  362. service.SaveHisProjectTwo(&p)
  363. }
  364. }
  365. }
  366. if items["addition"] != nil && reflect.TypeOf(items["addition"]).String() == "[]interface {}" {
  367. addition := items["addition"].([]interface{})
  368. //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
  369. ctime := time.Now().Unix()
  370. mtime := ctime
  371. if len(addition) > 0 {
  372. for _, item := range addition {
  373. var s models.HisAdditionalCharge
  374. s.PrescriptionId = prescription.ID
  375. s.Status = 1
  376. s.UserOrgId = adminInfo.CurrentOrgId
  377. s.RecordDate = recordDateTime
  378. s.CreatedTime = ctime
  379. s.UpdatedTime = mtime
  380. s.PatientId = patient_id
  381. s.HisPatientId = his_patient_id
  382. errcode := c.setAddtionWithJSON(&s, item.(map[string]interface{}))
  383. if errcode > 0 {
  384. c.ServeFailJSONWithSGJErrorCode(errcode)
  385. return
  386. }
  387. service.CreateAdditionalCharge(&s)
  388. var randNum int
  389. randNum = rand.Intn(10000) + 1000
  390. timestamp := time.Now().Unix()
  391. tempTime := time.Unix(timestamp, 0)
  392. timeFormat := tempTime.Format("20060102150405")
  393. s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "3" + "-" + strconv.FormatInt(s.ID, 10)
  394. service.CreateAdditionalCharge(&s)
  395. }
  396. }
  397. }
  398. }
  399. }
  400. }
  401. if err == nil {
  402. c.ServeSuccessJSON(map[string]interface{}{
  403. "msg": "保存成功",
  404. })
  405. return
  406. } else {
  407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  408. return
  409. }
  410. }
  411. func (c *HisApiController) DeletePrescription() {
  412. prescription_id, _ := c.GetInt64("id")
  413. //TODO 需要判断是否已经结算
  414. err := service.DelelteHisPrescription(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
  415. if err == nil {
  416. c.ServeSuccessJSON(map[string]interface{}{
  417. "msg": "删除成功",
  418. })
  419. return
  420. } else {
  421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  422. return
  423. }
  424. }
  425. func (c *HisApiController) DeleteDoctorAdvice() {
  426. id, _ := c.GetInt64("id")
  427. //TODO 需要判断是否已经结算
  428. err := service.DelelteDoctorAdvice(id, c.GetAdminUserInfo().CurrentOrgId)
  429. if err == nil {
  430. c.ServeSuccessJSON(map[string]interface{}{
  431. "msg": "删除成功",
  432. })
  433. return
  434. } else {
  435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  436. return
  437. }
  438. }
  439. func (c *HisApiController) DeleteProject() {
  440. id, _ := c.GetInt64("id")
  441. //TODO 需要判断是否已经结算
  442. err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
  443. if err == nil {
  444. c.ServeSuccessJSON(map[string]interface{}{
  445. "msg": "删除成功",
  446. })
  447. return
  448. } else {
  449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  450. return
  451. }
  452. }
  453. func (c *HisApiController) CreateHisAdditionalCharge() {
  454. his_patient_id, _ := c.GetInt64("his_patient_id")
  455. patient_id, _ := c.GetInt64("patient_id")
  456. record_date := c.GetString("record_date")
  457. timeLayout := "2006-01-02"
  458. loc, _ := time.LoadLocation("Local")
  459. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  460. if err != nil {
  461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  462. return
  463. }
  464. adminInfo := c.GetAdminUserInfo()
  465. recordDateTime := theTime.Unix()
  466. dataBody := make(map[string]interface{}, 0)
  467. err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  468. if err != nil {
  469. utils.ErrorLog(err.Error())
  470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  471. return
  472. }
  473. var additions []*models.HisAdditionalCharge
  474. if dataBody["addition"] != nil && reflect.TypeOf(dataBody["addition"]).String() == "[]interface {}" {
  475. additions, _ := dataBody["addition"].([]interface{})
  476. if len(additions) > 0 {
  477. for _, item := range additions {
  478. items := item.(map[string]interface{})
  479. if items["item_id"] == nil || reflect.TypeOf(items["item_id"]).String() != "float64" {
  480. utils.ErrorLog("item_id")
  481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  482. return
  483. }
  484. item_id := int64(items["item_id"].(float64))
  485. if items["item_name"] == nil || reflect.TypeOf(items["item_name"]).String() != "string" {
  486. utils.ErrorLog("item_name")
  487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  488. return
  489. }
  490. item_name := items["item_name"].(string)
  491. if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
  492. utils.ErrorLog("price")
  493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  494. return
  495. }
  496. price, _ := strconv.ParseFloat(items["price"].(string), 64)
  497. ctime := time.Now().Unix()
  498. additional := &models.HisAdditionalCharge{
  499. PatientId: patient_id,
  500. HisPatientId: his_patient_id,
  501. UserOrgId: adminInfo.CurrentOrgId,
  502. RecordDate: recordDateTime,
  503. CreatedTime: ctime,
  504. UpdatedTime: ctime,
  505. Modifier: adminInfo.AdminUser.Id,
  506. Creator: adminInfo.AdminUser.Id,
  507. Price: price,
  508. ItemName: item_name,
  509. ItemId: item_id,
  510. Status: 1,
  511. }
  512. additions = append(additions, additional)
  513. }
  514. }
  515. }
  516. for _, item := range additions {
  517. service.CreateAddtionalCharge(item)
  518. }
  519. c.ServeSuccessJSON(map[string]interface{}{
  520. "msg": "创建成功",
  521. })
  522. }
  523. func (c *HisApiController) CreateHisPatientCaseHistory() {
  524. blood_fat := c.GetString("blood_fat")
  525. bloodfatfloat, _ := strconv.ParseFloat(blood_fat, 64)
  526. fmt.Println("33333333", bloodfatfloat)
  527. blood_sugar := c.GetString("blood_sugar")
  528. bloodsugarfloat, _ := strconv.ParseFloat(blood_sugar, 64)
  529. fmt.Println(bloodsugarfloat)
  530. chief_conplaint := c.GetString("chief_conplaint")
  531. dbp := c.GetString("dbp")
  532. dbpfloat, _ := strconv.ParseFloat(dbp, 64)
  533. delivery_way, _ := c.GetInt64("delivery_way")
  534. diagnostic := c.GetString("diagnostic")
  535. fmt.Println("diagnostic", diagnostic)
  536. family_history := c.GetString("family_history")
  537. fmt.Println(family_history)
  538. height := c.GetString("height")
  539. history_of_present_illness := c.GetString("history_of_present_illness")
  540. is_infect, _ := c.GetInt64("is_infect")
  541. fmt.Println("is", is_infect)
  542. past_history := c.GetString("past_history")
  543. patient_id, _ := c.GetInt64("patient_id")
  544. his_patient_id, _ := c.GetInt64("his_patient_id")
  545. fmt.Println("patient_id", patient_id)
  546. personal_history := c.GetString("personal_history")
  547. pulse := c.GetString("pulse")
  548. pulsefloat, _ := strconv.ParseFloat(pulse, 64)
  549. sbp := c.GetString("sbp")
  550. sbpfloat, _ := strconv.ParseFloat(sbp, 64)
  551. heightfloat, _ := strconv.ParseFloat(height, 64)
  552. sicktype := c.GetString("sick_type")
  553. fmt.Println("sicketype", sicktype)
  554. sick_type, _ := strconv.ParseInt(sicktype, 10, 64)
  555. symptom := c.GetString("symptom")
  556. sick_date := c.GetString("sick_date")
  557. temperatures := c.GetString("temperature")
  558. fmt.Println("temperatures", temperatures)
  559. temperature, _ := strconv.ParseFloat(temperatures, 64)
  560. record_date := c.GetString("record_date")
  561. breathing := c.GetString("breathing")
  562. doctor_advice := c.GetString("doctor_advice")
  563. remark := c.GetString("remark")
  564. breathingfloat, _ := strconv.ParseFloat(breathing, 64)
  565. fmt.Println("breathingfloat", breathingfloat)
  566. timeLayout := "2006-01-02"
  567. loc, _ := time.LoadLocation("Local")
  568. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  569. if err != nil {
  570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  571. return
  572. }
  573. recordDateTime := theTime.Unix()
  574. fmt.Println("recordDataTime", recordDateTime)
  575. sickTime, err := time.ParseInLocation(timeLayout+" 15:04:05", sick_date+" 00:00:00", loc)
  576. if err != nil {
  577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  578. return
  579. }
  580. sickTimes := sickTime.Unix()
  581. ctime := time.Now().Unix()
  582. caseHistory := models.HisPatientCaseHistory{
  583. HisPatientId: his_patient_id,
  584. PatientId: patient_id,
  585. Temperature: temperature,
  586. BloodSugar: bloodsugarfloat,
  587. Pulse: pulsefloat,
  588. Sbp: sbpfloat,
  589. Dbp: dbpfloat,
  590. Height: heightfloat,
  591. BloodFat: bloodfatfloat,
  592. SickType: sick_type,
  593. Symptom: symptom,
  594. SickDate: sickTimes,
  595. IsInfect: is_infect,
  596. HistoryOfPresentIllness: history_of_present_illness,
  597. PastHistory: past_history,
  598. Doctor: c.GetAdminUserInfo().AdminUser.Id,
  599. ChiefConplaint: chief_conplaint,
  600. PersonalHistory: personal_history,
  601. FamilyHistory: family_history,
  602. Diagnostic: diagnostic,
  603. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  604. Status: 1,
  605. Ctime: ctime,
  606. Mtime: ctime,
  607. RecordDate: recordDateTime,
  608. DeliveryWay: delivery_way,
  609. Breathing: breathingfloat,
  610. DoctorAdvice: doctor_advice,
  611. Remark: remark,
  612. }
  613. err = service.SaveHisPatientCaseHistory(&caseHistory)
  614. if err != nil {
  615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  616. return
  617. }
  618. c.ServeSuccessJSON(map[string]interface{}{
  619. "caseHistory": caseHistory,
  620. })
  621. return
  622. //查询该患者是否有病历
  623. //_, errcode := service.GetHisPatientCaseHistoryById(his_patient_id)
  624. //if errcode == gorm.ErrRecordNotFound {
  625. // err = service.SaveHisPatientCaseHistory(caseHistory)
  626. // if err != nil {
  627. // c.ServeSuccessJSON(map[string]interface{}{
  628. // "msg": "保存成功",
  629. // })
  630. // }
  631. //} else if errcode == nil {
  632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  633. // return
  634. //}
  635. }
  636. func (c *HisApiController) GetHisPatientCaseHistoryList() {
  637. patient_id, _ := c.GetInt64("patient_id", 0)
  638. adminUser := c.GetAdminUserInfo()
  639. caseHistorys, _ := service.GetHisPatientCaseHistoryList(adminUser.CurrentOrgId, patient_id)
  640. c.ServeSuccessJSON(map[string]interface{}{
  641. "list": caseHistorys,
  642. })
  643. }
  644. func (c *HisApiController) GetHisPatientCaseHistory() {
  645. record_date, _ := c.GetInt64("record_date", 0)
  646. patient_id, _ := c.GetInt64("patient_id", 0)
  647. admin := c.GetAdminUserInfo()
  648. info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, record_date)
  649. case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, record_date)
  650. c.ServeSuccessJSON(map[string]interface{}{
  651. "info": info,
  652. "case_history": case_history,
  653. })
  654. }
  655. func (c *HisApiController) CreateCaseHistoryTemplate() {
  656. template_name := c.GetString("template_name")
  657. fmt.Println("template_name22222222222222", template_name)
  658. template_remark := c.GetString("template_remark")
  659. doctor := c.GetAdminUserInfo().AdminUser.Id
  660. diagnostic := c.GetString("diagnostic")
  661. chief_conplaint := c.GetString("chief_conplain")
  662. history_of_present_illness := c.GetString("history_of_present_illness")
  663. past_history := c.GetString("past_history")
  664. personal_history := c.GetString("personal_history")
  665. family_history := c.GetString("family_history")
  666. user_name := c.GetString("user_name")
  667. doctor_advice := c.GetString("doctor_advice")
  668. remark := c.GetString("remark")
  669. //record_date := c.GetString("record_date")
  670. //fmt.Println("record_date--------",record_date)
  671. //timeLayout := "2006-01-02"
  672. //loc, _ := time.LoadLocation("Local")
  673. //
  674. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  675. //if err != nil {
  676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  677. // return
  678. //}
  679. //recordDateTime := theTime.Unix()
  680. ctime := time.Now().Unix()
  681. template := models.HisCaseHistoryTemplate{
  682. HistoryOfPresentIllness: history_of_present_illness,
  683. PastHistory: past_history,
  684. ChiefConplaint: chief_conplaint,
  685. PersonalHistory: personal_history,
  686. FamilyHistory: family_history,
  687. Diagnostic: diagnostic,
  688. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  689. Status: 1,
  690. Ctime: ctime,
  691. Mtime: ctime,
  692. RecordDate: time.Now().Unix(),
  693. TemplateName: template_name,
  694. TemplateRemark: template_remark,
  695. Creator: doctor,
  696. Modifier: doctor,
  697. UserName: user_name,
  698. DoctorAdvice: doctor_advice,
  699. Remark: remark,
  700. }
  701. err := service.SaveHisPatientCaseHistoryTemplate(template)
  702. if err == nil {
  703. c.ServeSuccessJSON(map[string]interface{}{
  704. "msg": "保存成功",
  705. })
  706. } else {
  707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  708. return
  709. }
  710. }
  711. func (c *HisApiController) GetCaseHistoryTemplate() {
  712. timeLayout := "2006-01-02"
  713. loc, _ := time.LoadLocation("Local")
  714. keyword := c.GetString("keyword")
  715. start_time := c.GetString("start_time")
  716. end_time := c.GetString("end_time")
  717. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  718. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  719. admin := c.GetAdminUserInfo()
  720. template, _ := service.GetHisPatientCaseHistoryTemplate(admin.CurrentOrgId, startTime.Unix(), endTime.Unix(), keyword)
  721. //history, _ := service.GetHisPatientCaseHistory(admin.CurrentOrgId)
  722. c.ServeSuccessJSON(map[string]interface{}{
  723. "template": template,
  724. //"history": history,
  725. })
  726. }
  727. func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo, json map[string]interface{}) int {
  728. if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
  729. utils.ErrorLog("drug_name")
  730. return enums.ErrorCodeParamWrong
  731. }
  732. adviceName, _ := json["drug_name"].(string)
  733. if len(adviceName) == 0 {
  734. utils.ErrorLog("len(advice_name) == 0")
  735. return enums.ErrorCodeParamWrong
  736. }
  737. advice.AdviceName = adviceName
  738. adviceDesc, _ := json["advice_desc"].(string)
  739. advice.AdviceDesc = adviceDesc
  740. if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
  741. drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
  742. advice.DrugSpec = drugSpec
  743. }
  744. if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
  745. remark, _ := json["remark"].(string)
  746. advice.Remark = remark
  747. }
  748. if json["id"] == nil {
  749. advice.DrugId = 0
  750. } else {
  751. if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
  752. drug_id := int64(json["id"].(float64))
  753. advice.DrugId = drug_id
  754. }
  755. }
  756. if json["advice_id"] != nil && reflect.TypeOf(json["advice_id"]).String() == "float64" {
  757. advice_id := int64(json["advice_id"].(float64))
  758. advice.ID = advice_id
  759. }
  760. if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
  761. drugSpecUnit, _ := json["min_unit"].(string)
  762. advice.DrugSpecUnit = drugSpecUnit
  763. }
  764. if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
  765. singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
  766. advice.SingleDose = singleDose
  767. }
  768. if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
  769. singleDoseUnit, _ := json["single_dose_unit"].(string)
  770. advice.SingleDoseUnit = singleDoseUnit
  771. }
  772. if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
  773. prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
  774. advice.PrescribingNumber = prescribingNumber
  775. }
  776. if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
  777. prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
  778. advice.PrescribingNumberUnit = prescribingNumberUnit
  779. }
  780. if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
  781. deliveryWay, _ := json["delivery_way"].(string)
  782. advice.DeliveryWay = deliveryWay
  783. }
  784. if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
  785. executionFrequency, _ := json["execution_frequency"].(string)
  786. advice.ExecutionFrequency = executionFrequency
  787. }
  788. if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
  789. price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
  790. advice.Price = price
  791. }
  792. if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
  793. med_list_codg, _ := json["medical_insurance_number"].(string)
  794. advice.MedListCodg = med_list_codg
  795. }
  796. if json["day"] != nil || reflect.TypeOf(json["day"]).String() == "float64" {
  797. day := int64(json["day"].(float64))
  798. advice.Day = day
  799. }
  800. return 0
  801. }
  802. func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionProject, json map[string]interface{}) int {
  803. if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
  804. id := int64(json["id"].(float64))
  805. project.ID = id
  806. }
  807. if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
  808. project_id := int64(json["project_id"].(float64))
  809. project.ProjectId = project_id
  810. fmt.Println(project_id)
  811. fmt.Println(project.ProjectId)
  812. }
  813. if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
  814. price := int64(json["price"].(float64))
  815. formatInt_price := strconv.FormatInt(price, 10)
  816. float_price, _ := strconv.ParseFloat(formatInt_price, 64)
  817. project.Price = float_price
  818. }
  819. if json["total"] != nil && reflect.TypeOf(json["total"]).String() == "string" {
  820. total, _ := json["total"].(string)
  821. totals, _ := strconv.ParseInt(total, 10, 64)
  822. project.Count = totals
  823. }
  824. if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
  825. medical_code, _ := json["medical_code"].(string)
  826. project.MedListCodg = medical_code
  827. }
  828. if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
  829. single_dose, _ := json["single_dose"].(string)
  830. project.SingleDose = single_dose
  831. }
  832. if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
  833. delivery_way, _ := json["delivery_way"].(string)
  834. project.DeliveryWay = delivery_way
  835. }
  836. if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
  837. execution_frequency, _ := json["execution_frequency"].(string)
  838. project.ExecutionFrequency = execution_frequency
  839. }
  840. if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
  841. remark, _ := json["remark"].(string)
  842. project.Remark = remark
  843. }
  844. if json["number_days"] != nil && reflect.TypeOf(json["number_days"]).String() == "string" {
  845. day, _ := json["number_days"].(string)
  846. project.Day = day
  847. }
  848. if json["unit"] != nil && reflect.TypeOf(json["unit"]).String() == "string" {
  849. unit, _ := json["unit"].(string)
  850. project.Unit = unit
  851. }
  852. return 0
  853. }
  854. func (c *HisApiController) setAddtionWithJSON(additionalCharge *models.HisAdditionalCharge, json map[string]interface{}) int {
  855. if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
  856. id := int64(json["id"].(float64))
  857. additionalCharge.ID = id
  858. }
  859. if json["item_id"] != nil || reflect.TypeOf(json["item_id"]).String() == "float64" {
  860. item_id := int64(json["item_id"].(float64))
  861. additionalCharge.ItemId = item_id
  862. }
  863. if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
  864. price := int64(json["price"].(float64))
  865. formatInt_price := strconv.FormatInt(price, 10)
  866. float_price, _ := strconv.ParseFloat(formatInt_price, 64)
  867. additionalCharge.Price = float_price
  868. }
  869. if json["count"] != nil && reflect.TypeOf(json["count"]).String() == "string" {
  870. count, _ := json["count"].(string)
  871. counts, _ := strconv.ParseInt(count, 10, 64)
  872. additionalCharge.Count = counts
  873. }
  874. if json["item_name"] != nil && reflect.TypeOf(json["item_name"]).String() == "string" {
  875. item_name, _ := json["item_name"].(string)
  876. additionalCharge.ItemName = item_name
  877. }
  878. return 0
  879. }
  880. func (c *HisApiController) GetHisOrderList() {
  881. page, _ := c.GetInt64("page", -1)
  882. limit, _ := c.GetInt64("limit", -1)
  883. start_time := c.GetString("start_time")
  884. end_time := c.GetString("end_time")
  885. types, _ := c.GetInt64("type", 0)
  886. keywords := c.GetString("keywords")
  887. timeLayout := "2006-01-02"
  888. loc, _ := time.LoadLocation("Local")
  889. var startTime int64
  890. if len(start_time) > 0 {
  891. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  892. if err != nil {
  893. fmt.Println(err)
  894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  895. return
  896. }
  897. startTime = theTime.Unix()
  898. }
  899. var endTime int64
  900. if len(end_time) > 0 {
  901. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  902. if err != nil {
  903. utils.ErrorLog(err.Error())
  904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  905. return
  906. }
  907. endTime = theTime.Unix()
  908. }
  909. adminUser := c.GetAdminUserInfo()
  910. org_id := adminUser.CurrentOrgId
  911. order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords)
  912. if err == nil {
  913. c.ServeSuccessJSON(map[string]interface{}{
  914. "order": order,
  915. "total": total,
  916. })
  917. } else {
  918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  919. return
  920. }
  921. }
  922. func (c *HisApiController) GetHisOrder() {
  923. patient_id, _ := c.GetInt64("patient_id", 0)
  924. number := c.GetString("number")
  925. adminInfo := c.GetAdminUserInfo()
  926. order, err := service.GetHisOrder(adminInfo.CurrentOrgId, number, patient_id)
  927. prescriptions, _ := service.GetHisPrescriptionThree(adminInfo.CurrentOrgId, patient_id, order.SettleAccountsDate, order.Number)
  928. if err == nil {
  929. c.ServeSuccessJSON(map[string]interface{}{
  930. "order": order,
  931. "prescription": prescriptions,
  932. })
  933. } else {
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  935. return
  936. }
  937. }
  938. func (c *HisApiController) GetHisPrescriptionList() {
  939. record_date := c.GetString("record_date")
  940. keywords := c.GetString("keywords")
  941. page, _ := c.GetInt64("page")
  942. limit, _ := c.GetInt64("limit")
  943. timeLayout := "2006-01-02"
  944. loc, _ := time.LoadLocation("Local")
  945. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  946. if err != nil {
  947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  948. return
  949. }
  950. recordDateTime := theTime.Unix()
  951. adminInfo := c.GetAdminUserInfo()
  952. prescriptionOrder, err, total := service.GetHisPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
  953. //adminInfo := c.GetAdminUserInfo()
  954. //prescriptionOrder, err := service.GetHisPrescriptionOrderList(adminInfo.CurrentOrgId)
  955. //fmt.Println(prescriptionOrder)
  956. if err == nil {
  957. c.ServeSuccessJSON(map[string]interface{}{
  958. "order": prescriptionOrder,
  959. "total": total,
  960. })
  961. } else {
  962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  963. return
  964. }
  965. }
  966. func (c *HisApiController) GetHisPrescriptionInfo() {
  967. id, _ := c.GetInt64("id")
  968. adminInfo := c.GetAdminUserInfo()
  969. prescriptionOrder, err := service.GetHisPrescriptionOrderInfo(id, adminInfo.CurrentOrgId)
  970. prescription, err := service.GetHisPrescriptionFour(adminInfo.CurrentOrgId, prescriptionOrder.PatientId, prescriptionOrder.RecordDate, prescriptionOrder.PrescriptionNumber)
  971. if err == nil {
  972. c.ServeSuccessJSON(map[string]interface{}{
  973. "order": prescriptionOrder,
  974. "prescription": prescription,
  975. })
  976. } else {
  977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  978. return
  979. }
  980. }
  981. func (c *HisApiController) GetMedicalInsuranceConfig() {
  982. adminUser := c.GetAdminUserInfo()
  983. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  984. c.ServeSuccessJSON(map[string]interface{}{
  985. "config": config,
  986. })
  987. }
  988. type ResultTwo struct {
  989. ErrMsg interface{} `json:"err_msg"`
  990. InfRefmsgid string `json:"inf_refmsgid"`
  991. Infcode int64 `json:"infcode"`
  992. Output struct {
  993. Baseinfo struct {
  994. Age float64 `json:"age"`
  995. Brdy string `json:"brdy"`
  996. Certno string `json:"certno"`
  997. Gend string `json:"gend"`
  998. Naty string `json:"naty"`
  999. PsnCertType string `json:"psn_cert_type"`
  1000. PsnName string `json:"psn_name"`
  1001. PsnNo string `json:"psn_no"`
  1002. } `json:"baseinfo"`
  1003. Idetinfo []interface{} `json:"idetinfo"`
  1004. Iinfo []struct {
  1005. Balc int64 `json:"balc"`
  1006. CvlservFlag string `json:"cvlserv_flag"`
  1007. EmpName string `json:"emp_name"`
  1008. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1009. Insutype string `json:"insutype"`
  1010. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1011. PausInsuDate interface{} `json:"paus_insu_date"`
  1012. PsnInsuDate string `json:"psn_insu_date"`
  1013. PsnInsuStas string `json:"psn_insu_stas"`
  1014. PsnType string `json:"psn_type"`
  1015. } `json:"insuinfo"`
  1016. } `json:"output"`
  1017. RefmsgTime string `json:"refmsg_time"`
  1018. RespondTime string `json:"respond_time"`
  1019. Signtype interface{} `json:"signtype"`
  1020. WarnInfo interface{} `json:"warn_info"`
  1021. }
  1022. type ResultThree struct {
  1023. Cainfo interface{} `json:"cainfo"`
  1024. ErrMsg interface{} `json:"err_msg"`
  1025. InfRefmsgid string `json:"inf_refmsgid"`
  1026. Infcode int64 `json:"infcode"`
  1027. Output struct {
  1028. Data struct {
  1029. IptOtpNo string `json:"ipt_otp_no"`
  1030. MdtrtID string `json:"mdtrt_id"`
  1031. PsnNo string `json:"psn_no"`
  1032. } `json:"data"`
  1033. } `json:"output"`
  1034. RefmsgTime string `json:"refmsg_time"`
  1035. RespondTime string `json:"respond_time"`
  1036. Signtype interface{} `json:"signtype"`
  1037. WarnMsg interface{} `json:"warn_msg"`
  1038. }
  1039. type ResultFour struct {
  1040. Cainfo string `json:"cainfo"`
  1041. ErrMsg string `json:"err_msg"`
  1042. InfRefmsgid string `json:"inf_refmsgid"`
  1043. Infcode int64 `json:"infcode"`
  1044. Output struct {
  1045. Result []struct {
  1046. BasMednFlag string `json:"bas_medn_flag"`
  1047. ChldMedcFlag string `json:"chld_medc_flag"`
  1048. ChrgitmLv string `json:"chrgitm_lv"`
  1049. Cnt float64 `json:"cnt"`
  1050. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1051. DrtReimFlag string `json:"drt_reim_flag"`
  1052. FeedetlSn string `json:"feedetl_sn"`
  1053. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1054. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1055. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1056. ListSpItemFlag string `json:"list_sp_item_flag"`
  1057. LmtUsedFlag string `json:"lmt_used_flag"`
  1058. MedChrgitmType string `json:"med_chrgitm_type"`
  1059. Memo string `json:"memo"`
  1060. OverlmtAmt float64 `json:"overlmt_amt"`
  1061. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1062. Pric float64 `json:"pric"`
  1063. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1064. SelfpayProp float64 `json:"selfpay_prop"`
  1065. } `json:"result"`
  1066. } `json:"output"`
  1067. RefmsgTime string `json:"refmsg_time"`
  1068. RespondTime string `json:"respond_time"`
  1069. Signtype string `json:"signtype"`
  1070. WarnMsg string `json:"warn_msg"`
  1071. }
  1072. type ResultFive struct {
  1073. Insutype string `json:"insutype"`
  1074. }
  1075. type ResultSix struct {
  1076. Cainfo interface{} `json:"cainfo"`
  1077. ErrMsg interface{} `json:"err_msg"`
  1078. InfRefmsgid string `json:"inf_refmsgid"`
  1079. Infcode int64 `json:"infcode"`
  1080. Output struct {
  1081. } `json:"output"`
  1082. RefmsgTime string `json:"refmsg_time"`
  1083. RespondTime string `json:"respond_time"`
  1084. Signtype interface{} `json:"signtype"`
  1085. WarnMsg interface{} `json:"warn_msg"`
  1086. }
  1087. type ResultSeven struct {
  1088. Cainfo string `json:"cainfo"`
  1089. ErrMsg string `json:"err_msg"`
  1090. InfRefmsgid string `json:"inf_refmsgid"`
  1091. Infcode int64 `json:"infcode"`
  1092. Output struct {
  1093. Setldetail []interface{} `json:"setldetail"`
  1094. Setlinfo struct {
  1095. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1096. AcctPay float64 `json:"acct_pay"`
  1097. ActPayDedc float64 `json:"act_pay_dedc"`
  1098. Age float64 `json:"age"`
  1099. Balc float64 `json:"balc"`
  1100. Brdy string `json:"brdy"`
  1101. Certno string `json:"certno"`
  1102. ClrOptins string `json:"clr_optins"`
  1103. ClrType string `json:"clr_type"`
  1104. ClrWay string `json:"clr_way"`
  1105. CvlservFlag string `json:"cvlserv_flag"`
  1106. CvlservPay float64 `json:"cvlserv_pay"`
  1107. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1108. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1109. Gend string `json:"gend"`
  1110. HifesPay float64 `json:"hifes_pay"`
  1111. HifmiPay float64 `json:"hifmi_pay"`
  1112. HifobPay float64 `json:"hifob_pay"`
  1113. HifpPay float64 `json:"hifp_pay"`
  1114. HospPartAmt float64 `json:"hosp_part_amt"`
  1115. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1116. Insutype string `json:"insutype"`
  1117. MafPay float64 `json:"maf_pay"`
  1118. MdtrtCertType string `json:"mdtrt_cert_type"`
  1119. MdtrtID string `json:"mdtrt_id"`
  1120. MedType string `json:"med_type"`
  1121. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1122. MedinsSetlID string `json:"medins_setl_id"`
  1123. Naty string `json:"naty"`
  1124. OthPay float64 `json:"oth_pay"`
  1125. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1126. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1127. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1128. PsnCashPay float64 `json:"psn_cash_pay"`
  1129. PsnCertType string `json:"psn_cert_type"`
  1130. PsnName string `json:"psn_name"`
  1131. PsnNo string `json:"psn_no"`
  1132. PsnPartAmt float64 `json:"psn_part_amt"`
  1133. PsnType string `json:"psn_type"`
  1134. SetlID string `json:"setl_id"`
  1135. SetlTime string `json:"setl_time"`
  1136. } `json:"setlinfo"`
  1137. } `json:"output"`
  1138. RefmsgTime string `json:"refmsg_time"`
  1139. RespondTime string `json:"respond_time"`
  1140. Signtype interface{} `json:"signtype"`
  1141. WarnMsg interface{} `json:"warn_msg"`
  1142. }
  1143. type Custom struct {
  1144. DetItemFeeSumamt string
  1145. Cut string
  1146. FeedetlSn string
  1147. Price string
  1148. MedListCodg string
  1149. Type int64
  1150. AdviceId int64
  1151. ProjectId int64
  1152. ItemId int64
  1153. }
  1154. //获取个人信息----挂号-----上传就诊信息
  1155. func (c *HisApiController) GetRegisterInfo() {
  1156. id, _ := c.GetInt64("id")
  1157. record_time := c.GetString("record_time")
  1158. timeLayout := "2006-01-02"
  1159. loc, _ := time.LoadLocation("Local")
  1160. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1161. if err != nil {
  1162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1163. return
  1164. }
  1165. recordDateTime := theTime.Unix()
  1166. adminInfo := c.GetAdminUserInfo()
  1167. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  1168. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1169. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1170. if patient == nil {
  1171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1172. return
  1173. }
  1174. if len(patient.IdCardNo) == 0 {
  1175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  1176. return
  1177. }
  1178. //org, _ := service.GetOrgById(adminInfo.CurrentOrgId)
  1179. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1180. if config.IsOpen == 1 {
  1181. api := "http://127.0.0.1:9531/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code
  1182. resp, requestErr := http.Get(api)
  1183. if requestErr != nil {
  1184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1185. return
  1186. }
  1187. defer resp.Body.Close()
  1188. body, ioErr := ioutil.ReadAll(resp.Body)
  1189. if ioErr != nil {
  1190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1192. return
  1193. }
  1194. var respJSON map[string]interface{}
  1195. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1198. return
  1199. }
  1200. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1201. userJSONBytes, _ := json.Marshal(userJSON)
  1202. var res ResultTwo
  1203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1204. utils.ErrorLog("解析失败:%v", err)
  1205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1206. return
  1207. }
  1208. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1209. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1210. infoStr := string(Iinfos)
  1211. idetinfoStr := string(Idetinfos)
  1212. his := models.VMHisPatient{
  1213. PsnNo: res.Output.Baseinfo.PsnNo,
  1214. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1215. Certno: res.Output.Baseinfo.Certno,
  1216. PsnName: res.Output.Baseinfo.PsnName,
  1217. Gend: res.Output.Baseinfo.Gend,
  1218. Naty: res.Output.Baseinfo.Naty,
  1219. Brdy: res.Output.Baseinfo.Brdy,
  1220. Age: res.Output.Baseinfo.Age,
  1221. Iinfo: infoStr,
  1222. Idetinfo: idetinfoStr,
  1223. PatientId: patient.ID,
  1224. RecordDate: theTime.Unix(),
  1225. }
  1226. fmt.Println(his)
  1227. if res.Output.Iinfo == nil || len(res.Output.Iinfo) == 0 {
  1228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterOneException)
  1229. return
  1230. }
  1231. timestamp := time.Now().Unix()
  1232. tempTime := time.Unix(timestamp, 0)
  1233. timeFormat := tempTime.Format("20060102150405")
  1234. chrgBchno := rand.Intn(100000) + 10000
  1235. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1236. count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  1237. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1238. if count <= 0 {
  1239. api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
  1240. res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
  1241. "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
  1242. "&dept=" + department.Name + "&fixmedins_code=" + miConfig.Code
  1243. resp, requestErr := http.Get(api)
  1244. if requestErr != nil {
  1245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1246. return
  1247. }
  1248. defer resp.Body.Close()
  1249. body, ioErr := ioutil.ReadAll(resp.Body)
  1250. if ioErr != nil {
  1251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1253. return
  1254. }
  1255. var respJSON map[string]interface{}
  1256. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1259. return
  1260. }
  1261. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1262. userJSONBytes, _ := json.Marshal(respJSON)
  1263. var res ResultThree
  1264. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1265. utils.ErrorLog("解析失败:%v", err)
  1266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1267. return
  1268. }
  1269. if res.Infcode == -1 {
  1270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
  1271. return
  1272. }
  1273. fmt.Println("000!!!!!!")
  1274. fmt.Println(res)
  1275. fmt.Println(res.Output.Data.MdtrtID)
  1276. fmt.Println(res.Output.Data.PsnNo)
  1277. fmt.Println(res.Output.Data.IptOtpNo)
  1278. his.Number = res.Output.Data.MdtrtID
  1279. his.PsnNo = res.Output.Data.PsnNo
  1280. his.IptOtpNo = res.Output.Data.IptOtpNo
  1281. his.IdCardNo = patient.IdCardNo
  1282. his.PhoneNumber = patient.Phone
  1283. his.UserOrgId = adminInfo.CurrentOrgId
  1284. his.Status = 1
  1285. his.Ctime = time.Now().Unix()
  1286. his.Mtime = time.Now().Unix()
  1287. err := service.CreateHisPatientTwo(&his)
  1288. diagnosisConfig, _ := service.FindDiagnoseById(patientPrescription.Diagnosis)
  1289. if err == nil {
  1290. api := "http://127.0.0.1:9531/" + "gdyb/four?psn_no=" + his.PsnNo +
  1291. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  1292. "&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + "11" + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code
  1293. resp, requestErr := http.Get(api)
  1294. if requestErr != nil {
  1295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1296. return
  1297. }
  1298. body, ioErr := ioutil.ReadAll(resp.Body)
  1299. if ioErr != nil {
  1300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1302. return
  1303. }
  1304. var respJSON map[string]interface{}
  1305. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1308. return
  1309. }
  1310. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1311. userJSONBytes, _ := json.Marshal(respJSON)
  1312. fmt.Println(respJSON)
  1313. fmt.Println(userJSONBytes)
  1314. var res ResultSix
  1315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1316. utils.ErrorLog("解析失败:%v", err)
  1317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1318. return
  1319. }
  1320. if res.Infcode == -1 {
  1321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
  1322. return
  1323. }
  1324. c.ServeSuccessJSON(map[string]interface{}{
  1325. "his_info": his,
  1326. })
  1327. } else {
  1328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1329. return
  1330. }
  1331. }
  1332. } else {
  1333. his, err := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1334. if err == gorm.ErrRecordNotFound || his.ID == 0 {
  1335. patient := models.XtHisPatient{
  1336. Age: patient.Age,
  1337. Birthday: patient.Birthday,
  1338. AdminUserId: adminInfo.AdminUser.Id,
  1339. IdCardNo: patient.IdCardNo,
  1340. Name: patient.Name,
  1341. Gender: patient.Gender,
  1342. UserOrgId: adminInfo.CurrentOrgId,
  1343. Status: 1,
  1344. RecordDate: recordDateTime,
  1345. IsReturn: 1,
  1346. PatientId: patient.ID,
  1347. Ctime: time.Now().Unix(),
  1348. Mtime: time.Now().Unix(),
  1349. }
  1350. service.CreateHisPatient(&patient)
  1351. }
  1352. c.ServeSuccessJSON(map[string]interface{}{
  1353. "his_info": patient,
  1354. })
  1355. }
  1356. }
  1357. //上传明细----结算
  1358. func (c *HisApiController) GetUploadInfo() {
  1359. id, _ := c.GetInt64("id")
  1360. record_time := c.GetString("record_time")
  1361. timeLayout := "2006-01-02"
  1362. loc, _ := time.LoadLocation("Local")
  1363. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1364. if err != nil {
  1365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1366. return
  1367. }
  1368. recordDateTime := theTime.Unix()
  1369. adminUser := c.GetAdminUserInfo()
  1370. prescriptions, _ := service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  1371. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1372. timestamp := time.Now().Unix()
  1373. tempTime := time.Unix(timestamp, 0)
  1374. timeFormat := tempTime.Format("20060102150405")
  1375. chrgBchno := rand.Intn(100000) + 10000
  1376. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1377. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1378. //org, _ := service.GetOrgById(adminUser.CurrentOrgId)
  1379. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1380. client := &http.Client{}
  1381. data := make(map[string]interface{})
  1382. data["psn_no"] = his.PsnNo
  1383. data["mdtrt_id"] = his.Number
  1384. data["pre"] = prescriptions
  1385. data["chrg_bchno"] = chrg_bchno
  1386. data["org_name"] = miConfig.OrgName
  1387. data["doctor"] = patientPrescription.Doctor
  1388. data["dept"] = patientPrescription.Departments
  1389. data["fixmedins_code"] = miConfig.Code
  1390. var ids []int64
  1391. //var idsTwo []int64
  1392. //
  1393. for _, item := range prescriptions {
  1394. ids = append(ids, item.ID)
  1395. }
  1396. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1397. if config.IsOpen == 1 { //对接了医保,走医保流程
  1398. bytesData, _ := json.Marshal(data)
  1399. req, _ := http.NewRequest("POST", "http://127.0.0.1:9531/"+"gdyb/five", bytes.NewReader(bytesData))
  1400. resp, _ := client.Do(req)
  1401. defer resp.Body.Close()
  1402. body, ioErr := ioutil.ReadAll(resp.Body)
  1403. if ioErr != nil {
  1404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1406. return
  1407. }
  1408. var respJSON map[string]interface{}
  1409. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1412. return
  1413. }
  1414. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1415. userJSONBytes, _ := json.Marshal(respJSON)
  1416. var res ResultFour
  1417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1418. utils.ErrorLog("解析失败:%v", err)
  1419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1420. return
  1421. }
  1422. if res.Infcode == 0 {
  1423. order := &models.HisOrder{
  1424. UserOrgId: adminUser.CurrentOrgId,
  1425. HisPatientId: his.ID,
  1426. PatientId: his.PatientId,
  1427. SettleAccountsDate: recordDateTime,
  1428. Ctime: time.Now().Unix(),
  1429. Mtime: time.Now().Unix(),
  1430. Status: 1,
  1431. Number: chrg_bchno,
  1432. Infcode: res.Infcode,
  1433. WarnMsg: res.WarnMsg,
  1434. Cainfo: res.Cainfo,
  1435. ErrMsg: res.ErrMsg,
  1436. RespondTime: res.RefmsgTime,
  1437. InfRefmsgid: res.InfRefmsgid,
  1438. OrderStatus: 1,
  1439. }
  1440. err = service.CreateOrder(order)
  1441. if err != nil {
  1442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  1443. return
  1444. }
  1445. for _, item := range res.Output.Result {
  1446. temp := strings.Split(item.FeedetlSn, "-")
  1447. var advice_id int64 = 0
  1448. var project_id int64 = 0
  1449. var types int64 = 0
  1450. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1451. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1452. if temp[1] == "1" {
  1453. advice_id = id
  1454. project_id = 0
  1455. } else if temp[1] == "2" {
  1456. advice_id = 0
  1457. project_id = id
  1458. }
  1459. info := &models.HisOrderInfo{
  1460. OrderNumber: order.Number,
  1461. FeedetlSn: item.FeedetlSn,
  1462. UploadDate: time.Now().Unix(),
  1463. AdviceId: advice_id,
  1464. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1465. Cnt: item.Cnt,
  1466. Pric: float64(item.Pric),
  1467. PatientId: his.PatientId,
  1468. PricUplmtAmt: item.PricUplmtAmt,
  1469. SelfpayProp: item.SelfpayProp,
  1470. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1471. OverlmtAmt: item.OverlmtAmt,
  1472. PreselfpayAmt: item.PreselfpayAmt,
  1473. BasMednFlag: item.BasMednFlag,
  1474. MedChrgitmType: item.MedChrgitmType,
  1475. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1476. Status: 1,
  1477. Memo: item.Memo,
  1478. Mtime: time.Now().Unix(),
  1479. InscpScpAmt: item.InscpScpAmt,
  1480. DrtReimFlag: item.DrtReimFlag,
  1481. Ctime: time.Now().Unix(),
  1482. ListSpItemFlag: item.ListSpItemFlag,
  1483. ChldMedcFlag: item.ChldMedcFlag,
  1484. LmtUsedFlag: item.LmtUsedFlag,
  1485. ChrgitmLv: item.ChrgitmLv,
  1486. UserOrgId: adminUser.CurrentOrgId,
  1487. HisPatientId: his.ID,
  1488. OrderId: order.ID,
  1489. ProjectId: project_id,
  1490. Type: types,
  1491. }
  1492. service.CreateOrderInfo(info)
  1493. }
  1494. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  1495. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  1496. var total float64
  1497. for _, item := range prescriptions {
  1498. if item.Type == 1 { //药品
  1499. for _, subItem := range item.HisDoctorAdviceInfo {
  1500. total = total + (subItem.Price * subItem.PrescribingNumber)
  1501. }
  1502. }
  1503. if item.Type == 2 { //项目
  1504. for _, subItem := range item.HisPrescriptionProject {
  1505. total = total + (subItem.Price * float64(subItem.Count))
  1506. }
  1507. }
  1508. }
  1509. org, _ := service.GetOrgById(adminUser.CurrentOrgId)
  1510. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1511. allTotal := fmt.Sprintf("%.2f", total)
  1512. if res.Infcode == 0 {
  1513. var rf []*ResultFive
  1514. json.Unmarshal([]byte(his.Iinfo), &rf)
  1515. psn_no := his.PsnNo
  1516. mdtrt_id := his.Number
  1517. chrg_bchno := chrg_bchno
  1518. cert_no := his.Certno
  1519. insutype := rf[0].Insutype
  1520. api := "http://127.0.0.1:9531/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
  1521. insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  1522. "&total=" + allTotal + "&org_name=" + org.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code
  1523. resp, requestErr := http.Get(api)
  1524. if requestErr != nil {
  1525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1526. return
  1527. }
  1528. defer resp.Body.Close()
  1529. body, ioErr := ioutil.ReadAll(resp.Body)
  1530. if ioErr != nil {
  1531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. return
  1534. }
  1535. var respJSON map[string]interface{}
  1536. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. return
  1540. }
  1541. fmt.Println(respJSON)
  1542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1543. userJSONBytes, _ := json.Marshal(respJSON)
  1544. var res ResultSeven
  1545. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1546. utils.ErrorLog("解析失败:%v", err)
  1547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1548. return
  1549. }
  1550. if res.Infcode == -1 {
  1551. errlog := &models.HisOrderError{
  1552. UserOrgId: adminUser.CurrentOrgId,
  1553. Ctime: time.Now().Unix(),
  1554. Mtime: time.Now().Unix(),
  1555. Number: chrg_bchno,
  1556. ErrMsg: res.ErrMsg,
  1557. Status: 1,
  1558. PatientId: id,
  1559. RecordTime: recordDateTime,
  1560. Stage: 7,
  1561. }
  1562. service.CreateErrMsgLog(errlog)
  1563. } else {
  1564. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  1565. order.OrderStatus = 2
  1566. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  1567. order.SetlId = res.Output.Setlinfo.SetlID
  1568. order.PsnNo = res.Output.Setlinfo.PsnNo
  1569. order.PsnName = res.Output.Setlinfo.PsnName
  1570. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  1571. order.Certno = res.Output.Setlinfo.Certno
  1572. order.Gend = res.Output.Setlinfo.Gend
  1573. order.Naty = res.Output.Setlinfo.Naty
  1574. order.Age = res.Output.Setlinfo.Age
  1575. order.Insutype = res.Output.Setlinfo.Insutype
  1576. order.PsnType = res.Output.Setlinfo.PsnType
  1577. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  1578. order.SetlTime = res.Output.Setlinfo.SetlTime
  1579. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  1580. order.MedType = res.Output.Setlinfo.MedType
  1581. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  1582. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  1583. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  1584. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  1585. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  1586. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  1587. order.HifpPay = res.Output.Setlinfo.HifpPay
  1588. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  1589. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  1590. order.HifesPay = res.Output.Setlinfo.HifesPay
  1591. order.HifobPay = res.Output.Setlinfo.HifobPay
  1592. order.MafPay = res.Output.Setlinfo.MafPay
  1593. order.OthPay = res.Output.Setlinfo.OthPay
  1594. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  1595. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  1596. order.AcctPay = res.Output.Setlinfo.AcctPay
  1597. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  1598. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  1599. order.Balc = res.Output.Setlinfo.Balc
  1600. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  1601. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  1602. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  1603. order.ClrWay = res.Output.Setlinfo.ClrWay
  1604. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  1605. detailStr := string(setlDetail)
  1606. order.SetlDetail = detailStr
  1607. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  1608. err = service.UpDateOrder(order)
  1609. if err == nil {
  1610. c.ServeSuccessJSON(map[string]interface{}{
  1611. "msg": "结算成功",
  1612. })
  1613. }
  1614. }
  1615. } else {
  1616. }
  1617. } else {
  1618. }
  1619. } else {
  1620. var total float64
  1621. for _, item := range prescriptions {
  1622. if item.Type == 1 { //药品
  1623. for _, subItem := range item.HisDoctorAdviceInfo {
  1624. total = total + (subItem.Price * subItem.PrescribingNumber)
  1625. }
  1626. }
  1627. if item.Type == 2 { //项目
  1628. for _, subItem := range item.HisPrescriptionProject {
  1629. total = total + (subItem.Price * float64(subItem.Count))
  1630. }
  1631. }
  1632. for _, subItem := range item.HisAdditionalCharge {
  1633. total = total + (subItem.Price * float64(subItem.Count))
  1634. }
  1635. }
  1636. allTotal := fmt.Sprintf("%.2f", total)
  1637. totals, _ := strconv.ParseFloat(allTotal, 64)
  1638. order := &models.HisOrder{
  1639. UserOrgId: adminUser.CurrentOrgId,
  1640. HisPatientId: his.ID,
  1641. PatientId: id,
  1642. SettleAccountsDate: recordDateTime,
  1643. Ctime: time.Now().Unix(),
  1644. Mtime: time.Now().Unix(),
  1645. Status: 1,
  1646. OrderStatus: 2,
  1647. Number: chrg_bchno,
  1648. MedfeeSumamt: totals,
  1649. }
  1650. err = service.CreateOrder(order)
  1651. if err != nil {
  1652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  1653. return
  1654. }
  1655. var customs []*Custom
  1656. for _, item := range prescriptions {
  1657. if item.Type == 1 { //药品
  1658. for _, subItem := range item.HisDoctorAdviceInfo {
  1659. cus := &Custom{
  1660. AdviceId: subItem.ID,
  1661. ProjectId: 0,
  1662. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  1663. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  1664. FeedetlSn: subItem.FeedetlSn,
  1665. Price: fmt.Sprintf("%.2f", subItem.Price),
  1666. MedListCodg: subItem.MedListCodg,
  1667. Type: 1,
  1668. }
  1669. customs = append(customs, cus)
  1670. }
  1671. }
  1672. if item.Type == 2 { //项目
  1673. for _, subItem := range item.HisPrescriptionProject {
  1674. cus := &Custom{
  1675. AdviceId: 0,
  1676. ProjectId: subItem.ID,
  1677. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  1678. Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  1679. FeedetlSn: subItem.FeedetlSn,
  1680. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  1681. MedListCodg: subItem.MedListCodg,
  1682. Type: 2,
  1683. }
  1684. customs = append(customs, cus)
  1685. }
  1686. }
  1687. for _, item := range item.HisAdditionalCharge {
  1688. cus := &Custom{
  1689. ItemId: item.ID,
  1690. AdviceId: 0,
  1691. ProjectId: 0,
  1692. DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  1693. Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  1694. FeedetlSn: item.FeedetlSn,
  1695. Price: fmt.Sprintf("%.2f", float64(item.Price)),
  1696. MedListCodg: item.XtHisAddtionConfig.Code,
  1697. Type: 3,
  1698. }
  1699. customs = append(customs, cus)
  1700. }
  1701. }
  1702. for _, item := range customs {
  1703. var advice_id int64 = 0
  1704. var project_id int64 = 0
  1705. var item_id int64 = 0
  1706. var types int64 = 0
  1707. if item.Type == 1 {
  1708. advice_id = item.AdviceId
  1709. project_id = 0
  1710. item_id = 0
  1711. } else if item.Type == 2 {
  1712. advice_id = 0
  1713. item_id = 0
  1714. project_id = item.ProjectId
  1715. } else if item.Type == 3 {
  1716. advice_id = 0
  1717. item_id = item.ItemId
  1718. project_id = 0
  1719. }
  1720. detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  1721. cut, _ := strconv.ParseFloat(item.Cut, 32)
  1722. pric, _ := strconv.ParseFloat(item.Price, 32)
  1723. info := &models.HisOrderInfo{
  1724. OrderNumber: order.Number,
  1725. UploadDate: time.Now().Unix(),
  1726. AdviceId: advice_id,
  1727. DetItemFeeSumamt: detItemFeeSumamt,
  1728. Cnt: cut,
  1729. Pric: pric,
  1730. PatientId: id,
  1731. Status: 1,
  1732. Mtime: time.Now().Unix(),
  1733. Ctime: time.Now().Unix(),
  1734. UserOrgId: adminUser.CurrentOrgId,
  1735. HisPatientId: his.ID,
  1736. OrderId: order.ID,
  1737. ProjectId: project_id,
  1738. Type: types,
  1739. ItemId: item_id,
  1740. }
  1741. service.CreateOrderInfo(info)
  1742. }
  1743. //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  1744. err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  1745. err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  1746. err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  1747. if err == nil {
  1748. c.ServeSuccessJSON(map[string]interface{}{
  1749. "msg": "结算成功",
  1750. })
  1751. }
  1752. }
  1753. }
  1754. //退款
  1755. func (c *HisApiController) Refund() {
  1756. order_id, _ := c.GetInt64("order_id")
  1757. number := c.GetString("number")
  1758. adminUser := c.GetAdminUserInfo()
  1759. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1760. if config.IsOpen == 1 { //对接了医保,走医保流程
  1761. } else {
  1762. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  1763. if err == nil {
  1764. c.ServeSuccessJSON(map[string]interface{}{
  1765. "msg": "退费成功",
  1766. })
  1767. } else {
  1768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1769. return
  1770. }
  1771. }
  1772. }
  1773. func (this *HisApiController) AdditionalCharge() {
  1774. dataBody := make(map[string]interface{}, 0)
  1775. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1776. fmt.Println(err)
  1777. his_patient_id := int64(dataBody["his_patient_id"].(float64))
  1778. patient_id := int64(dataBody["patient_id"].(float64))
  1779. medicineData, _ := dataBody["medicineData"].([]interface{})
  1780. adminUserInfo := this.GetAdminUserInfo()
  1781. orgId := adminUserInfo.CurrentOrgId
  1782. admin_user_id := adminUserInfo.AdminUser.Id
  1783. timeStr := time.Now().Format("2006-01-02")
  1784. timeLayout := "2006-01-02 15:04:05"
  1785. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  1786. timenow := timeStringToTime.Unix()
  1787. var additionalCharges []*models.HisAdditionalCharge
  1788. for _, item := range medicineData {
  1789. var randNum int
  1790. randNum = rand.Intn(10000) + 1000
  1791. timestamp := time.Now().Unix()
  1792. tempTime := time.Unix(timestamp, 0)
  1793. timeFormat := tempTime.Format("20060102150405")
  1794. p_number := timeFormat + strconv.FormatInt(int64(randNum), 10) + strconv.FormatInt(int64(adminUserInfo.CurrentOrgId), 10) + strconv.FormatInt(int64(patient_id), 10)
  1795. items := item.(map[string]interface{})
  1796. money := items["price"].(string)
  1797. item_id_str := items["item_id"].(string)
  1798. name := items["name"].(string)
  1799. id_str := items["id"].(string)
  1800. moneys, _ := strconv.ParseInt(money, 10, 64)
  1801. monStr := strconv.FormatInt(moneys, 10)
  1802. monneyStr, _ := strconv.ParseFloat(monStr, 64)
  1803. item_id, _ := strconv.ParseInt(item_id_str, 10, 64)
  1804. id, _ := strconv.ParseInt(id_str, 10, 64)
  1805. additionalCharge := &models.HisAdditionalCharge{
  1806. ID: id,
  1807. HisPatientId: his_patient_id,
  1808. UserOrgId: orgId,
  1809. PatientId: patient_id,
  1810. RecordDate: timenow,
  1811. Price: monneyStr,
  1812. Status: 1,
  1813. ItemName: name,
  1814. ItemId: item_id,
  1815. AdminUserId: admin_user_id,
  1816. CreatedTime: time.Now().Unix(),
  1817. OrderStatus: 0,
  1818. PrescriptionNumber: "",
  1819. BatchNumber: "",
  1820. FeedetlSn: p_number,
  1821. }
  1822. service.CreateAdditionalCharge(additionalCharge)
  1823. additionalCharges = append(additionalCharges, additionalCharge)
  1824. }
  1825. this.ServeSuccessJSON(map[string]interface{}{
  1826. "msg": "添加成功",
  1827. "additional_charges": additionalCharges,
  1828. })
  1829. }
  1830. func (this *HisApiController) DeleteAddition() {
  1831. id, _ := this.GetInt64("id")
  1832. //TODO 需要判断是否已经结算
  1833. err := service.DelelteAddition(id, this.GetAdminUserInfo().CurrentOrgId)
  1834. if err == nil {
  1835. this.ServeSuccessJSON(map[string]interface{}{
  1836. "msg": "删除成功",
  1837. })
  1838. return
  1839. } else {
  1840. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1841. return
  1842. }
  1843. }
  1844. func (this *HisApiController) GetAdminUsers() {
  1845. adminUser := this.GetAdminUserInfo()
  1846. doctors, _ := service.GetAllHisDoctor(adminUser.CurrentOrgId)
  1847. this.ServeSuccessJSON(map[string]interface{}{
  1848. "doctors": doctors,
  1849. })
  1850. }