his_api_controller.go 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "encoding/json"
  8. "fmt"
  9. "github.com/astaxie/beego"
  10. "reflect"
  11. "strconv"
  12. "time"
  13. )
  14. type HisApiController struct {
  15. BaseAuthAPIController
  16. }
  17. func HisManagerApiRegistRouters() {
  18. beego.Router("/api/hispatient/list", &HisApiController{}, "get:GetHisPatientList")
  19. beego.Router("/api/hispatient/get", &HisApiController{}, "get:GetHisPatientInfo")
  20. beego.Router("/api/hisprescription/config", &HisApiController{}, "get:GetHisPrescriptionConfig")
  21. beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
  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{}, "post:CreateHisPatientCaseHistory")
  25. beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "post:CreateCaseHistoryTemplate")
  26. beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
  27. beego.Router("/api/doctorworkstation/printcasehistory/get", &HisApiController{}, "get:GetPrintHisPatientCaseHistory")
  28. }
  29. func (c *HisApiController) GetHisPatientList() {
  30. types, _ := c.GetInt64("type", 0)
  31. record_date := c.GetString("record_date")
  32. timeLayout := "2006-01-02"
  33. loc, _ := time.LoadLocation("Local")
  34. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  35. if err != nil {
  36. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37. return
  38. }
  39. recordDateTime := theTime.Unix()
  40. adminInfo := c.GetAdminUserInfo()
  41. patients, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
  42. if types == 0 {
  43. c.ServeSuccessJSON(map[string]interface{}{
  44. "list": patients,
  45. })
  46. } else if types == 1 { //未就诊
  47. var patientsOne []*service.Schedule
  48. for _, item := range patients {
  49. if item.HisPrescription == nil || len(item.HisPrescription) <= 0 {
  50. patientsOne = append(patientsOne, item)
  51. }
  52. }
  53. c.ServeSuccessJSON(map[string]interface{}{
  54. "list": patientsOne,
  55. })
  56. } else if types == 2 { //已就诊
  57. var patientsTwo []*service.Schedule
  58. for _, item := range patients {
  59. if item.HisPrescription != nil && len(item.HisPrescription) > 0 {
  60. patientsTwo = append(patientsTwo, item)
  61. }
  62. }
  63. c.ServeSuccessJSON(map[string]interface{}{
  64. "list": patientsTwo,
  65. })
  66. }
  67. }
  68. func (c *HisApiController) GetHisPatientInfo() {
  69. patient_id, _ := c.GetInt64("patient_id")
  70. record_date := c.GetString("record_date")
  71. timeLayout := "2006-01-02"
  72. loc, _ := time.LoadLocation("Local")
  73. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  74. if err != nil {
  75. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  76. return
  77. }
  78. recordDateTime := theTime.Unix()
  79. admin := c.GetAdminUserInfo()
  80. his_patient_info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, recordDateTime)
  81. xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
  82. prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
  83. //prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
  84. case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
  85. c.ServeSuccessJSON(map[string]interface{}{
  86. "his_info": his_patient_info,
  87. "xt_info": xt_patient_info,
  88. "prescription": prescriptions,
  89. "case_history": case_history,
  90. })
  91. return
  92. }
  93. func (c *HisApiController) GetHisPrescriptionConfig() {
  94. adminInfo := c.GetAdminUserInfo()
  95. //获取医嘱模版
  96. advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
  97. //获取所有基础药
  98. drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
  99. //drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
  100. //drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
  101. drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
  102. efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
  103. doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
  104. //获取所有科室信息
  105. department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
  106. c.ServeSuccessJSON(map[string]interface{}{
  107. "drugs": drugs,
  108. "advices_template": advices,
  109. "drugways": drugways,
  110. "efs": efs,
  111. "doctors": doctors,
  112. "department": department,
  113. })
  114. }
  115. func (c *HisApiController) CreateHisPrescription() {
  116. record_date := c.GetString("record_date")
  117. fmt.Println("record_date", record_date)
  118. patient_id, _ := c.GetInt64("patient_id")
  119. //diagnose := c.GetString("diagnose")
  120. //sick_history := c.GetString("sick_history")
  121. doctor, _ := c.GetInt64("doctor")
  122. //departm/**/ent, _ := c.GetInt64("department")
  123. his_patient_id, _ := c.GetInt64("his_patient_id")
  124. dataBody := make(map[string]interface{}, 0)
  125. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  126. if err != nil {
  127. utils.ErrorLog(err.Error())
  128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  129. return
  130. }
  131. timeLayout := "2006-01-02"
  132. loc, _ := time.LoadLocation("Local")
  133. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  134. if err != nil {
  135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  136. return
  137. }
  138. adminInfo := c.GetAdminUserInfo()
  139. recordDateTime := theTime.Unix()
  140. if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
  141. prescriptions, _ := dataBody["prescriptions"].([]interface{})
  142. if len(prescriptions) > 0 {
  143. for _, item := range prescriptions {
  144. items := item.(map[string]interface{})
  145. if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
  146. utils.ErrorLog("type")
  147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  148. return
  149. }
  150. types := int64(items["type"].(float64))
  151. ctime := time.Now().Unix()
  152. prescription := &models.HisPrescription{
  153. PatientId: patient_id,
  154. UserOrgId: adminInfo.CurrentOrgId,
  155. RecordDate: recordDateTime,
  156. Ctime: ctime,
  157. Mtime: ctime,
  158. Type: types,
  159. Modifier: adminInfo.AdminUser.Id,
  160. Creator: adminInfo.AdminUser.Id,
  161. Status: 1,
  162. Doctor: doctor,
  163. HisPatientId: his_patient_id,
  164. }
  165. service.SaveHisPrescription(prescription)
  166. if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
  167. advices := items["advices"].([]interface{})
  168. group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
  169. groupNo := group + 1
  170. ctime := time.Now().Unix()
  171. mtime := ctime
  172. if len(advices) > 0 {
  173. for _, advice := range advices {
  174. var s models.HisDoctorAdviceInfo
  175. s.PrescriptionId = prescription.ID
  176. s.AdviceType = 2
  177. s.AdviceDoctor = adminInfo.AdminUser.Id
  178. s.StopState = 2
  179. s.ExecutionState = 2
  180. s.AdviceDate = recordDateTime
  181. s.Status = 1
  182. s.UserOrgId = adminInfo.CurrentOrgId
  183. s.RecordDate = recordDateTime
  184. s.StartTime = recordDateTime
  185. s.Groupno = groupNo
  186. s.CreatedTime = ctime
  187. s.UpdatedTime = mtime
  188. s.PatientId = patient_id
  189. s.HisPatientId = his_patient_id
  190. errcode := c.setAdviceWithJSON(&s, advice.(map[string]interface{}))
  191. if errcode > 0 {
  192. c.ServeFailJSONWithSGJErrorCode(errcode)
  193. return
  194. }
  195. service.CreateHisDoctorAdvice(&s)
  196. }
  197. }
  198. }
  199. if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
  200. projects := items["project"].([]interface{})
  201. if len(projects) > 0 {
  202. for _, project := range projects {
  203. var p models.HisPrescriptionProject
  204. p.PrescriptionId = prescription.ID
  205. p.Ctime = time.Now().Unix()
  206. p.Mtime = time.Now().Unix()
  207. p.PatientId = patient_id
  208. p.RecordDate = recordDateTime
  209. p.UserOrgId = adminInfo.CurrentOrgId
  210. p.HisPatientId = his_patient_id
  211. errcode := c.setProjectWithJSON(&p, project.(map[string]interface{}))
  212. if errcode > 0 {
  213. c.ServeFailJSONWithSGJErrorCode(errcode)
  214. return
  215. }
  216. service.CreateHisProjectTwo(&p)
  217. }
  218. }
  219. }
  220. }
  221. }
  222. //查询患者今日处方信息
  223. //_, errcode := service.GetHisPrescriptionTwo(his_patient_id, adminInfo.CurrentOrgId, recordDateTime)
  224. //if errcode == nil{
  225. // //改变患者信息状态
  226. // service.UpdatedHisPatient(his_patient_id, adminInfo.CurrentOrgId, recordDateTime)
  227. //
  228. //}
  229. }
  230. if err == nil {
  231. c.ServeSuccessJSON(map[string]interface{}{
  232. "msg": "保存成功",
  233. })
  234. return
  235. } else {
  236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  237. return
  238. }
  239. }
  240. func (c *HisApiController) CreateHisAdditionalCharge() {
  241. his_patient_id, _ := c.GetInt64("his_patient_id")
  242. patient_id, _ := c.GetInt64("patient_id")
  243. record_date := c.GetString("record_date")
  244. timeLayout := "2006-01-02"
  245. loc, _ := time.LoadLocation("Local")
  246. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  247. if err != nil {
  248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  249. return
  250. }
  251. adminInfo := c.GetAdminUserInfo()
  252. recordDateTime := theTime.Unix()
  253. dataBody := make(map[string]interface{}, 0)
  254. err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  255. if err != nil {
  256. utils.ErrorLog(err.Error())
  257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  258. return
  259. }
  260. var additions []*models.HisAdditionalCharge
  261. if dataBody["addition"] != nil && reflect.TypeOf(dataBody["addition"]).String() == "[]interface {}" {
  262. additions, _ := dataBody["addition"].([]interface{})
  263. if len(additions) > 0 {
  264. for _, item := range additions {
  265. items := item.(map[string]interface{})
  266. if items["item_id"] == nil || reflect.TypeOf(items["item_id"]).String() != "float64" {
  267. utils.ErrorLog("item_id")
  268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  269. return
  270. }
  271. item_id := int64(items["item_id"].(float64))
  272. if items["item_name"] == nil || reflect.TypeOf(items["item_name"]).String() != "string" {
  273. utils.ErrorLog("item_name")
  274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  275. return
  276. }
  277. item_name := items["item_name"].(string)
  278. if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
  279. utils.ErrorLog("price")
  280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  281. return
  282. }
  283. price, _ := strconv.ParseFloat(items["price"].(string), 64)
  284. ctime := time.Now().Unix()
  285. additional := &models.HisAdditionalCharge{
  286. PatientId: patient_id,
  287. HisPatientId: his_patient_id,
  288. UserOrgId: adminInfo.CurrentOrgId,
  289. RecordDate: recordDateTime,
  290. CreatedTime: ctime,
  291. UpdatedTime: ctime,
  292. Modifier: adminInfo.AdminUser.Id,
  293. Creator: adminInfo.AdminUser.Id,
  294. Price: price,
  295. ItemName: item_name,
  296. ItemId: item_id,
  297. Status: 1,
  298. }
  299. additions = append(additions, additional)
  300. }
  301. }
  302. }
  303. for _, item := range additions {
  304. service.CreateAddtionalCharge(item)
  305. }
  306. c.ServeSuccessJSON(map[string]interface{}{
  307. "msg": "创建成功",
  308. })
  309. }
  310. func (c *HisApiController) CreateHisPatientCaseHistory() {
  311. diagnostic := c.GetString("diagnostic")
  312. temperature, _ := c.GetFloat("temperature")
  313. blood_sugar, _ := c.GetFloat("blood_sugar")
  314. pulse, _ := c.GetFloat("pulse")
  315. sbp, _ := c.GetFloat("sbp")
  316. dbp, _ := c.GetFloat("dbp")
  317. blood_fat, _ := c.GetFloat("blood_fat")
  318. height, _ := c.GetFloat("height")
  319. sick_type, _ := c.GetInt64("sick_type")
  320. symptom := c.GetString("symptom")
  321. sick_date := c.GetString("sick_date")
  322. is_infect, _ := c.GetInt64("is_infect")
  323. chief_conplaint := c.GetString("chief_conplaint")
  324. history_of_present_illness := c.GetString("history_of_present_illness")
  325. past_history := c.GetString("past_history")
  326. personal_history := c.GetString("personal_history")
  327. family_history := c.GetString("family_history")
  328. record_date := c.GetString("record_date")
  329. patient_id, _ := c.GetInt64("patient_id")
  330. timeLayout := "2006-01-02"
  331. loc, _ := time.LoadLocation("Local")
  332. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  333. if err != nil {
  334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  335. return
  336. }
  337. recordDateTime := theTime.Unix()
  338. sickTime, err := time.ParseInLocation(timeLayout+" 15:04:05", sick_date+" 00:00:00", loc)
  339. if err != nil {
  340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  341. return
  342. }
  343. sickTimes := sickTime.Unix()
  344. ctime := time.Now().Unix()
  345. caseHistory := models.HisPatientCaseHistory{
  346. HisPatientId: patient_id,
  347. Temperature: temperature,
  348. BloodSugar: blood_sugar,
  349. Pulse: pulse,
  350. Sbp: sbp,
  351. Dbp: dbp,
  352. Height: height,
  353. BloodFat: blood_fat,
  354. SickType: sick_type,
  355. Symptom: symptom,
  356. SickDate: sickTimes,
  357. IsInfect: is_infect,
  358. HistoryOfPresentIllness: history_of_present_illness,
  359. PastHistory: past_history,
  360. Doctor: c.GetAdminUserInfo().AdminUser.Id,
  361. ChiefConplaint: chief_conplaint,
  362. PersonalHistory: personal_history,
  363. FamilyHistory: family_history,
  364. Diagnostic: diagnostic,
  365. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  366. Status: 1,
  367. Ctime: ctime,
  368. Mtime: ctime,
  369. RecordDate: recordDateTime,
  370. }
  371. err = service.SaveHisPatientCaseHistory(caseHistory)
  372. if err != nil {
  373. c.ServeSuccessJSON(map[string]interface{}{
  374. "msg": "保存成功",
  375. })
  376. }
  377. }
  378. func (c *HisApiController) GetHisPatientCaseHistoryList() {
  379. patient_id, _ := c.GetInt64("patient_id", 0)
  380. adminUser := c.GetAdminUserInfo()
  381. caseHistorys, _ := service.GetHisPatientCaseHistoryList(adminUser.CurrentOrgId, patient_id)
  382. c.ServeSuccessJSON(map[string]interface{}{
  383. "list": caseHistorys,
  384. })
  385. }
  386. func (c *HisApiController) GetHisPatientCaseHistory() {
  387. record_date, _ := c.GetInt64("record_date", 0)
  388. patient_id, _ := c.GetInt64("patient_id", 0)
  389. admin := c.GetAdminUserInfo()
  390. info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, record_date)
  391. case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, record_date)
  392. c.ServeSuccessJSON(map[string]interface{}{
  393. "info": info,
  394. "case_history": case_history,
  395. })
  396. }
  397. func (c *HisApiController) CreateCaseHistoryTemplate() {
  398. template_name := c.GetString("template_name")
  399. template_remark := c.GetString("template_remark")
  400. doctor := c.GetAdminUserInfo().AdminUser.Id
  401. diagnostic := c.GetString("diagnostic")
  402. chief_conplaint := c.GetString("chief_conplaint")
  403. history_of_present_illness := c.GetString("history_of_present_illness")
  404. past_history := c.GetString("past_history")
  405. personal_history := c.GetString("personal_history")
  406. family_history := c.GetString("family_history")
  407. record_date := c.GetString("record_date")
  408. timeLayout := "2006-01-02"
  409. loc, _ := time.LoadLocation("Local")
  410. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  411. if err != nil {
  412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  413. return
  414. }
  415. recordDateTime := theTime.Unix()
  416. ctime := time.Now().Unix()
  417. template := models.HisCaseHistoryTemplate{
  418. HistoryOfPresentIllness: history_of_present_illness,
  419. PastHistory: past_history,
  420. ChiefConplaint: chief_conplaint,
  421. PersonalHistory: personal_history,
  422. FamilyHistory: family_history,
  423. Diagnostic: diagnostic,
  424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  425. Status: 1,
  426. Ctime: ctime,
  427. Mtime: ctime,
  428. RecordDate: recordDateTime,
  429. TemplateName: template_name,
  430. TemplateRemark: template_remark,
  431. Creator: doctor,
  432. Modifier: doctor,
  433. }
  434. err = service.SaveHisPatientCaseHistoryTemplate(template)
  435. if err == nil {
  436. c.ServeSuccessJSON(map[string]interface{}{
  437. "msg": "保存成功",
  438. })
  439. } else {
  440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  441. return
  442. }
  443. }
  444. func (c *HisApiController) GetCaseHistoryTemplate() {
  445. admin := c.GetAdminUserInfo()
  446. template, _ := service.GetHisPatientCaseHistoryTemplate(admin.CurrentOrgId)
  447. c.ServeSuccessJSON(map[string]interface{}{
  448. "template": template,
  449. })
  450. }
  451. func (c *HisApiController) GetPrintHisPatientCaseHistory() {
  452. }
  453. func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo, json map[string]interface{}) int {
  454. if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
  455. utils.ErrorLog("drug_name")
  456. return enums.ErrorCodeParamWrong
  457. }
  458. adviceName, _ := json["drug_name"].(string)
  459. if len(adviceName) == 0 {
  460. utils.ErrorLog("len(advice_name) == 0")
  461. return enums.ErrorCodeParamWrong
  462. }
  463. advice.AdviceName = adviceName
  464. adviceDesc, _ := json["advice_desc"].(string)
  465. advice.AdviceDesc = adviceDesc
  466. if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
  467. drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
  468. advice.DrugSpec = drugSpec
  469. }
  470. if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
  471. remark, _ := json["remark"].(string)
  472. advice.Remark = remark
  473. }
  474. if json["id"] == nil {
  475. advice.DrugId = 0
  476. } else {
  477. if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
  478. drug_id := int64(json["id"].(float64))
  479. advice.DrugId = drug_id
  480. }
  481. }
  482. if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
  483. drugSpecUnit, _ := json["min_unit"].(string)
  484. advice.DrugSpecUnit = drugSpecUnit
  485. }
  486. if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
  487. singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
  488. advice.SingleDose = singleDose
  489. }
  490. if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
  491. singleDoseUnit, _ := json["min_unit"].(string)
  492. advice.SingleDoseUnit = singleDoseUnit
  493. }
  494. if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
  495. prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
  496. advice.PrescribingNumber = prescribingNumber
  497. }
  498. if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
  499. prescribingNumberUnit, _ := json["min_unit"].(string)
  500. advice.PrescribingNumberUnit = prescribingNumberUnit
  501. }
  502. if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
  503. deliveryWay, _ := json["delivery_way"].(string)
  504. advice.DeliveryWay = deliveryWay
  505. }
  506. if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
  507. executionFrequency, _ := json["execution_frequency"].(string)
  508. advice.ExecutionFrequency = executionFrequency
  509. }
  510. if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
  511. remark, _ := json["remark"].(string)
  512. advice.Remark = remark
  513. }
  514. //if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
  515. // advice.Price = json["retail_price"].(float64)
  516. //}
  517. if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
  518. price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
  519. advice.Price = price
  520. }
  521. return 0
  522. }
  523. func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionProject, json map[string]interface{}) int {
  524. if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
  525. project_id := int64(json["id"].(float64))
  526. project.ProjectId = project_id
  527. }
  528. if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
  529. price := int64(json["price"].(float64))
  530. formatInt_price := strconv.FormatInt(price, 10)
  531. float_price, _ := strconv.ParseFloat(formatInt_price, 64)
  532. project.Price = float_price
  533. }
  534. return 0
  535. }