manager_center_api_controller.go 73KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269
  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. "github.com/jinzhu/gorm"
  11. "reflect"
  12. "strconv"
  13. "time"
  14. )
  15. type ManagerCenterApiController struct {
  16. BaseAuthAPIController
  17. }
  18. func ManagerCenterRegistRouters() {
  19. //药品基础库
  20. beego.Router("/api/basedruglib/create", &ManagerCenterApiController{}, "post:CreateBaseDrugLib")
  21. beego.Router("/api/basedruglib/edit", &ManagerCenterApiController{}, "post:EditBaseDrugLib")
  22. beego.Router("/api/basedruglib/get", &ManagerCenterApiController{}, "get:GetBaseDrugLib")
  23. beego.Router("/api/basedruglib/list", &ManagerCenterApiController{}, "get:GetBaseDrugLibList")
  24. beego.Router("/api/medicineinsurancepercent/create", &ManagerCenterApiController{}, "post:CreateMedicineInsurancePercent")
  25. beego.Router("/api/drugunitsafeguard/create", &ManagerCenterApiController{}, "post:CreateDrugUnitSafeguard")
  26. beego.Router("/api/medicineinsurancepercent/get", &ManagerCenterApiController{}, "get:GetMedicineInsurancePercent")
  27. //beego.Router("/api/drugunitsafeguard/get", &ManagerCenterApiController{}, "get:GetDrugUnitSafeguard")
  28. beego.Router("/api/drug/basedruglib", &ManagerCenterApiController{}, "get:DeleteBaseDrugById")
  29. //专项字典
  30. beego.Router("/api/dictionary/getconfiglist", &ManagerCenterApiController{}, "get,post:GetConfigList")
  31. beego.Router("/api/dictionary/createconfig", &ManagerCenterApiController{}, "Post:CreateConfig")
  32. beego.Router("/api/dictionary/createchildconfig", &ManagerCenterApiController{}, "Post:CreateChildConfig")
  33. beego.Router("/api/dictionary/updatechildconfig", &ManagerCenterApiController{}, "Post:UpdateChildConfig")
  34. beego.Router("/api/dictionary/deletechildconfig", &ManagerCenterApiController{}, "Post:DeleteChildConfig")
  35. beego.Router("/api/dictionary/updatetemplate", &ManagerCenterApiController{}, "Post:UpdateTemplate")
  36. //经销商
  37. beego.Router("/api/stock/dealer/create", &ManagerCenterApiController{}, "post:CreateDealer")
  38. beego.Router("/api/stock/dealer/modify", &ManagerCenterApiController{}, "post:ModifyDealer")
  39. beego.Router("/api/stock/dealer/list", &ManagerCenterApiController{}, "get:GetDealersList")
  40. beego.Router("/api/stock/dealer/delete", &ManagerCenterApiController{}, "post:DeleteDealer")
  41. beego.Router("/api/stock/dealer/get", &ManagerCenterApiController{}, "get:GetDealer")
  42. //厂商
  43. beego.Router("/api/stock/manufacturer/create", &ManagerCenterApiController{}, "post:CreateManufacturer")
  44. beego.Router("/api/stock/manufacturer/modify", &ManagerCenterApiController{}, "post:ModifyManufacturer")
  45. beego.Router("/api/stock/manufacturer/list", &ManagerCenterApiController{}, "get:GetManufacturerList")
  46. beego.Router("/api/stock/manufacturer/delete", &ManagerCenterApiController{}, "post:DeleteManufacturer")
  47. beego.Router("/api/stock/manufacturer/get", &ManagerCenterApiController{}, "get:GetManufacturer")
  48. beego.Router("/api/stock/good/info/create", &ManagerCenterApiController{}, "post:CreateGoodInfo")
  49. beego.Router("/api/stock/good/info/modify", &ManagerCenterApiController{}, "post:ModifyGoodInfo")
  50. beego.Router("/api/stock/good/info/list", &ManagerCenterApiController{}, "get:GetGoodInfoList")
  51. beego.Router("/api/info/delete", &ManagerCenterApiController{}, "post:DeleteGoodInfo")
  52. beego.Router("/api/stock/good/info/get", &ManagerCenterApiController{}, "get:GetGoodInfoByGoodId")
  53. beego.Router("/api/stock/good/info", &ManagerCenterApiController{}, "get:GetGoodInfoById")
  54. //门诊大病
  55. beego.Router("/api/mz/sick/create", &ManagerCenterApiController{}, "post:CreateMZSick")
  56. beego.Router("/api/mz/sick/modify", &ManagerCenterApiController{}, "post:ModifyMZSick")
  57. beego.Router("/api/mz/sick/list", &ManagerCenterApiController{}, "get:GetMZSickList")
  58. beego.Router("/api/mz/sick/delete", &ManagerCenterApiController{}, "post:DeleteMZSick")
  59. beego.Router("/api/mz/sick/get", &ManagerCenterApiController{}, "get:GetMZSick")
  60. beego.Router("/api/addition/create", &ManagerCenterApiController{}, "post:CreateAddition")
  61. beego.Router("/api/addition/modify", &ManagerCenterApiController{}, "post:ModifyAddition")
  62. beego.Router("/api/addition/list", &ManagerCenterApiController{}, "get:GetAdditionList")
  63. beego.Router("/api/addition/delete", &ManagerCenterApiController{}, "post:DeleteAddition")
  64. beego.Router("/api/addition/get", &ManagerCenterApiController{}, "get:GetAddition")
  65. //门诊诊断
  66. beego.Router("/api/diagnose/create", &ManagerCenterApiController{}, "post:CreateDiagnose")
  67. beego.Router("/api/diagnose/modify", &ManagerCenterApiController{}, "post:ModifyDiagnose")
  68. beego.Router("/api/diagnose/list", &ManagerCenterApiController{}, "get:GetDiagnoseList")
  69. beego.Router("/api/diagnose/delete", &ManagerCenterApiController{}, "post:DeleteDiagnose")
  70. beego.Router("/api/diagnose/get", &ManagerCenterApiController{}, "get:GetDiagnose")
  71. beego.Router("/api/drug/getalldruglist", &ManagerCenterApiController{}, "get:GetAllDrugList")
  72. beego.Router("/api/drug/postsearchdruglist", &ManagerCenterApiController{}, "get:GetSearchDrugList")
  73. }
  74. func (c *ManagerCenterApiController) CreateBaseDrugLib() {
  75. drug_name := c.GetString("drug_name")
  76. pinyin := c.GetString("pinyin")
  77. wubi := c.GetString("wubi")
  78. drug_alias := c.GetString("drug_alias")
  79. drug_alias_pinyin := c.GetString("drug_alias_pinyin")
  80. drug_alias_wubi := c.GetString("drug_alias_wubi")
  81. drug_category, _ := c.GetInt64("drug_category")
  82. drug_spec := c.GetString("drug_spec")
  83. drug_type, _ := c.GetInt64("drug_type")
  84. drug_stock_limit := c.GetString("drug_stock_limit")
  85. drug_origin_place := c.GetString("drug_origin_place")
  86. drug_dosage_form, _ := c.GetInt64("drug_dosage_form")
  87. medical_insurance_level, _ := c.GetInt64("medical_insurance_level")
  88. max_unit := c.GetString("max_unit")
  89. min_unit := c.GetString("min_unit")
  90. unit_matrixing := c.GetString("unit_matrixing")
  91. retail_price, _ := c.GetFloat("retail_price")
  92. last_price, _ := c.GetFloat("last_price")
  93. drug_control, _ := c.GetInt64("drug_control")
  94. number := c.GetString("number")
  95. drug_classify := c.GetString("drug_classify")
  96. drug_dose, _ := c.GetFloat("drug_dose")
  97. drug_dose_unit, _ := c.GetInt64("drug_dose_unit")
  98. medical_insurance_number := c.GetString("medical_insurance_number")
  99. manufacturer, _ := c.GetInt64("manufacturer")
  100. pharmacology_category, _ := c.GetInt64("pharmacology_category")
  101. statistics_category, _ := c.GetInt64("statistics_category")
  102. code := c.GetString("code")
  103. is_special_diseases, _ := c.GetInt64("is_special_diseases")
  104. is_record, _ := c.GetInt64("is_record")
  105. agent := c.GetString("agent")
  106. drug_status := c.GetString("drug_status")
  107. limit_remark := c.GetString("limit_remark")
  108. delivery_way := c.GetString("delivery_way")
  109. execution_frequency := c.GetString("execution_frequency")
  110. single_dose, _ := c.GetFloat("single_dose")
  111. fmt.Println(single_dose)
  112. prescribing_number, _ := c.GetFloat("prescribing_number")
  113. label, _ := c.GetInt64("label")
  114. sort, _ := c.GetInt64("sort")
  115. is_use_doctor_advice, _ := c.GetInt64("is_use_doctor_advice")
  116. is_default, _ := c.GetInt64("is_default")
  117. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  118. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  119. is_charge_use, _ := c.GetInt64("is_charge_use")
  120. dealer, _ := c.GetInt64("dealer")
  121. prescription_mark, _ := c.GetInt64("prescription_mark")
  122. social_security_directory_code := c.GetString("social_security_directory_code")
  123. record_date := c.GetString("record_date")
  124. timeLayout := "2006-01-02"
  125. loc, _ := time.LoadLocation("Local")
  126. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  127. drug_remark := c.GetString("drug_remark")
  128. dose, _ := c.GetFloat("dose")
  129. dose_unit := c.GetString("dose_unit")
  130. min_price, _ := c.GetFloat("min_price")
  131. min_number, _ := c.GetInt64("min_number")
  132. drug_day := c.GetString("drug_day")
  133. hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
  134. lmt_used_flag, _ := c.GetInt64("lmt_used_flag")
  135. prescribing_number_unit := c.GetString("prescribing_number_unit")
  136. adminInfo := c.GetAdminUserInfo()
  137. drugLib := &models.BaseDrugLib{
  138. DrugName: drug_name,
  139. Pinyin: pinyin,
  140. Wubi: wubi,
  141. DrugAlias: drug_alias,
  142. DrugAliasPinyin: drug_alias_pinyin,
  143. DrugAliasWubi: drug_alias_wubi,
  144. DrugCategory: drug_category,
  145. DrugSpec: drug_spec,
  146. DrugType: drug_type,
  147. DrugStockLimit: drug_stock_limit,
  148. DrugOriginPlace: drug_origin_place,
  149. MedicalInsuranceLevel: medical_insurance_level,
  150. DrugDosageForm: drug_dosage_form,
  151. MaxUnit: max_unit,
  152. MinUnit: min_unit,
  153. UnitMatrixing: unit_matrixing,
  154. RetailPrice: retail_price,
  155. LastPrice: last_price,
  156. DrugControl: drug_control,
  157. Number: number,
  158. DrugClassify: drug_classify,
  159. DrugDose: drug_dose,
  160. DrugDoseUnit: drug_dose_unit,
  161. MedicalInsuranceNumber: medical_insurance_number,
  162. Manufacturer: manufacturer,
  163. PharmacologyCategory: pharmacology_category,
  164. StatisticsCategory: statistics_category,
  165. Code: code,
  166. IsSpecialDiseases: is_special_diseases,
  167. IsRecord: is_record,
  168. Agent: agent,
  169. DrugStatus: drug_status,
  170. LimitRemark: limit_remark,
  171. DeliveryWay: delivery_way,
  172. ExecutionFrequency: execution_frequency,
  173. SingleDose: drug_dose,
  174. PrescribingNumber: prescribing_number,
  175. Label: label,
  176. Sort: sort,
  177. IsUseDoctorAdvice: is_use_doctor_advice,
  178. IsDefault: is_default,
  179. IsChargePredict: is_charge_predict,
  180. IsStatisticsWork: is_statistics_work,
  181. IsChargeUse: is_charge_use,
  182. OrgId: adminInfo.CurrentOrgId,
  183. Status: 1,
  184. Ctime: time.Now().Unix(),
  185. Mtime: time.Now().Unix(),
  186. Dealer: dealer,
  187. PrescriptionMark: prescription_mark,
  188. SocialSecurityDirectoryCode: social_security_directory_code,
  189. RecordDate: theTime.Unix(),
  190. DrugRemark: drug_remark,
  191. DrugDay: drug_day,
  192. MinNumber: min_number,
  193. Dose: dose,
  194. MinPrice: min_price,
  195. DoseUnit: dose_unit,
  196. HospApprFlag: hosp_appr_flag,
  197. LmtUsedFlag: lmt_used_flag,
  198. PrescribingNumberUnit: prescribing_number_unit,
  199. }
  200. total := service.FindAllDrugLibRecordTotal(adminInfo.CurrentOrgId)
  201. drug_code := strconv.FormatInt(total+1, 10)
  202. drug_code = "54000000" + drug_code
  203. drugLib.DrugCode = drug_code
  204. count := service.FindBaseDrugLibRecordCountOne(drugLib)
  205. if count == 0 {
  206. err := service.CreateBaseDrugLib(drugLib)
  207. if err == nil {
  208. c.ServeSuccessJSON(map[string]interface{}{
  209. "msg": "创建成功",
  210. })
  211. } else {
  212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  213. return
  214. }
  215. return
  216. } else {
  217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDrugRepeatDataException)
  218. return
  219. }
  220. }
  221. func (c *ManagerCenterApiController) EditBaseDrugLib() {
  222. id, _ := c.GetInt64("id")
  223. drug_name := c.GetString("drug_name")
  224. pinyin := c.GetString("pinyin")
  225. wubi := c.GetString("wubi")
  226. drug_alias := c.GetString("drug_alias")
  227. drug_alias_pinyin := c.GetString("drug_alias_pinyin")
  228. drug_alias_wubi := c.GetString("drug_alias_wubi")
  229. drug_category, _ := c.GetInt64("drug_category")
  230. drug_spec := c.GetString("drug_spec")
  231. drug_type, _ := c.GetInt64("drug_type")
  232. drug_stock_limit := c.GetString("drug_stock_limit")
  233. drug_origin_place := c.GetString("drug_origin_place")
  234. drug_dosage_form, _ := c.GetInt64("drug_dosage_form")
  235. medical_insurance_level, _ := c.GetInt64("medical_insurance_level")
  236. max_unit := c.GetString("max_unit")
  237. min_unit := c.GetString("min_unit")
  238. unit_matrixing := c.GetString("unit_matrixing")
  239. retail_price, _ := c.GetFloat("retail_price")
  240. last_price, _ := c.GetFloat("last_price")
  241. drug_control, _ := c.GetInt64("drug_control")
  242. number := c.GetString("number")
  243. drug_classify := c.GetString("drug_classify")
  244. drug_dose, _ := c.GetFloat("drug_dose")
  245. drug_dose_unit, _ := c.GetInt64("drug_dose_unit")
  246. medical_insurance_number := c.GetString("medical_insurance_number")
  247. manufacturer, _ := c.GetInt64("manufacturer")
  248. pharmacology_category, _ := c.GetInt64("pharmacology_category")
  249. statistics_category, _ := c.GetInt64("statistics_category")
  250. code := c.GetString("code")
  251. is_special_diseases, _ := c.GetInt64("is_special_diseases")
  252. is_record, _ := c.GetInt64("is_record")
  253. agent := c.GetString("agent")
  254. drug_status := c.GetString("drug_status")
  255. limit_remark := c.GetString("limit_remark")
  256. delivery_way := c.GetString("delivery_way")
  257. execution_frequency := c.GetString("execution_frequency")
  258. single_dose, _ := c.GetFloat("single_dose")
  259. fmt.Println("sigle_dose", single_dose)
  260. prescribing_number, _ := c.GetFloat("prescribing_number")
  261. label, _ := c.GetInt64("label")
  262. sort, _ := c.GetInt64("sort")
  263. is_use_doctor_advice, _ := c.GetInt64("is_use_doctor_advice")
  264. is_default, _ := c.GetInt64("is_default")
  265. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  266. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  267. is_charge_use, _ := c.GetInt64("is_charge_use")
  268. drug_code := c.GetString("drug_code")
  269. //unit := c.GetString("unit")
  270. dealer, _ := c.GetInt64("dealer")
  271. prescription_mark, _ := c.GetInt64("prescription_mark")
  272. social_security_directory_code := c.GetString("social_security_directory_code")
  273. record_date := c.GetString("record_date")
  274. timeLayout := "2006-01-02"
  275. loc, _ := time.LoadLocation("Local")
  276. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  277. drug_remark := c.GetString("drug_remark")
  278. min_number, _ := c.GetInt64("min_number")
  279. drug_day := c.GetString("drug_day")
  280. dose, _ := c.GetFloat("dose")
  281. dose_unit := c.GetString("dose_unit")
  282. total, _ := c.GetFloat("total")
  283. min_price, _ := c.GetFloat("min_price")
  284. hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
  285. lmt_used_flag, _ := c.GetInt64("lmt_used_flag")
  286. prescribing_number_unit := c.GetString("prescribing_number_unit")
  287. adminInfo := c.GetAdminUserInfo()
  288. drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
  289. drugLib := &models.BaseDrugLib{
  290. ID: id,
  291. DrugName: drug_name,
  292. Pinyin: pinyin,
  293. Wubi: wubi,
  294. DrugAlias: drug_alias,
  295. DrugAliasPinyin: drug_alias_pinyin,
  296. DrugAliasWubi: drug_alias_wubi,
  297. DrugCategory: drug_category,
  298. DrugSpec: drug_spec,
  299. DrugType: drug_type,
  300. DrugStockLimit: drug_stock_limit,
  301. DrugOriginPlace: drug_origin_place,
  302. MedicalInsuranceLevel: medical_insurance_level,
  303. DrugDosageForm: drug_dosage_form,
  304. MaxUnit: max_unit,
  305. MinUnit: min_unit,
  306. UnitMatrixing: unit_matrixing,
  307. RetailPrice: retail_price,
  308. LastPrice: last_price,
  309. DrugControl: drug_control,
  310. Number: number,
  311. DrugClassify: drug_classify,
  312. DrugDose: drug_dose,
  313. DrugDoseUnit: drug_dose_unit,
  314. MedicalInsuranceNumber: medical_insurance_number,
  315. Manufacturer: manufacturer,
  316. PharmacologyCategory: pharmacology_category,
  317. StatisticsCategory: statistics_category,
  318. Code: code,
  319. IsSpecialDiseases: is_special_diseases,
  320. IsRecord: is_record,
  321. Agent: agent,
  322. DrugStatus: drug_status,
  323. LimitRemark: limit_remark,
  324. DeliveryWay: delivery_way,
  325. ExecutionFrequency: execution_frequency,
  326. PrescribingNumber: prescribing_number,
  327. Label: label,
  328. Sort: sort,
  329. IsUseDoctorAdvice: is_use_doctor_advice,
  330. IsDefault: is_default,
  331. IsChargePredict: is_charge_predict,
  332. IsStatisticsWork: is_statistics_work,
  333. IsChargeUse: is_charge_use,
  334. OrgId: adminInfo.CurrentOrgId,
  335. Status: 1,
  336. Ctime: drug.Ctime,
  337. Mtime: time.Now().Unix(),
  338. DrugCode: drug_code,
  339. Dealer: dealer,
  340. PrescriptionMark: prescription_mark,
  341. SocialSecurityDirectoryCode: social_security_directory_code,
  342. RecordDate: theTime.Unix(),
  343. DrugRemark: drug_remark,
  344. DrugDay: drug_day,
  345. HospApprFlag: hosp_appr_flag,
  346. LmtUsedFlag: lmt_used_flag,
  347. MinNumber: min_number,
  348. Dose: dose,
  349. MinPrice: min_price,
  350. DoseUnit: dose_unit,
  351. PrescribingNumberUnit: prescribing_number_unit,
  352. Total: total,
  353. SingleDose: drug_dose,
  354. }
  355. err := service.UpdateBaseDrugLib(drugLib)
  356. //查询是否存在
  357. _, errOne := service.GetDrugNameIsExist(id, adminInfo.CurrentOrgId)
  358. if errOne == gorm.ErrRecordNotFound {
  359. c.ServeSuccessJSON(map[string]interface{}{
  360. "msg": "修改成功",
  361. })
  362. return
  363. } else if errOne == nil {
  364. //修改xt_drug_name 表
  365. drugName := models.XtDrugName{
  366. DrugName: drug_name,
  367. }
  368. service.UpdatedDrugName(id, adminInfo.CurrentOrgId, &drugName)
  369. }
  370. //查询是否存在
  371. _, errTwo := service.GetStandNameIsExist(id, adminInfo.CurrentOrgId)
  372. if errTwo == gorm.ErrRecordNotFound {
  373. c.ServeSuccessJSON(map[string]interface{}{
  374. "msg": "修改成功",
  375. })
  376. return
  377. } else if errTwo == nil {
  378. //修改规格xt_stand_name表
  379. standName := models.XtStandName{
  380. DrugName: drug_name,
  381. DrugSpec: drug_spec,
  382. DrugStockLimit: drug_stock_limit,
  383. MinUnit: min_unit,
  384. }
  385. service.UpdateStandName(id, adminInfo.CurrentOrgId, &standName)
  386. }
  387. _, errThree := service.GetSelfMedicalIsExist(id, adminInfo.CurrentOrgId)
  388. if errThree == gorm.ErrRecordNotFound {
  389. c.ServeSuccessJSON(map[string]interface{}{
  390. "msg": "修改成功",
  391. })
  392. return
  393. } else if errThree == nil {
  394. //修改药品表
  395. medical := models.XtSelfMedical{
  396. DrugName: drug_name,
  397. DrugSpec: drug_spec,
  398. ExecutionFrequency: execution_frequency,
  399. PrescribingNumber: prescribing_number,
  400. DeliveryWay: delivery_way,
  401. SingleDose: single_dose,
  402. MinUnit: min_unit,
  403. }
  404. service.UpdateSelfMedical(id, adminInfo.CurrentOrgId, &medical)
  405. }
  406. _, errFour := service.GetSelfStosckIsExist(id, adminInfo.CurrentOrgId)
  407. if errFour == gorm.ErrRecordNotFound {
  408. c.ServeSuccessJSON(map[string]interface{}{
  409. "msg": "修改成功",
  410. })
  411. return
  412. } else if errFour == nil {
  413. stock := models.XtSelfStock{
  414. DrugSpec: drug_spec,
  415. DrugName: drug_name,
  416. MinUnit: min_unit,
  417. }
  418. service.UpdatedSelfStock(&stock, id, adminInfo.CurrentOrgId)
  419. }
  420. _, errFive := service.GetOutSelfOutStockIsExist(id, adminInfo.CurrentOrgId)
  421. if errFive == gorm.ErrRecordNotFound {
  422. c.ServeSuccessJSON(map[string]interface{}{
  423. "msg": "修改成功",
  424. })
  425. return
  426. } else if errFive == nil {
  427. outStock := models.XtSelfOutStock{
  428. DrugName: drug_name,
  429. DrugSpec: drug_spec,
  430. }
  431. //修改出库表
  432. service.UpdatedOutSelfStock(&outStock, id, adminInfo.CurrentOrgId)
  433. }
  434. _, errSix := service.GetDoctorAdviceIsExist(id, adminInfo.CurrentOrgId)
  435. if errSix == gorm.ErrRecordNotFound {
  436. fmt.Println("进来了吗5")
  437. c.ServeSuccessJSON(map[string]interface{}{
  438. "msg": "修改成功",
  439. })
  440. return
  441. } else if errSix == nil {
  442. //查询未执行的医嘱
  443. advice := models.DoctorAdvice{
  444. AdviceName: drug_name,
  445. AdviceDesc: drug_spec,
  446. DeliveryWay: delivery_way,
  447. ExecutionFrequency: execution_frequency,
  448. SingleDose: single_dose,
  449. SingleDoseUnit: min_unit,
  450. }
  451. service.UpdateNoExcuteDoctorAdvice(id, adminInfo.CurrentOrgId, &advice)
  452. }
  453. _, errSeven := service.GetDoctorAdviceTemplateIsExist(id, adminInfo.CurrentOrgId)
  454. if errSeven == gorm.ErrRecordNotFound {
  455. fmt.Println("进来了吗6")
  456. c.ServeSuccessJSON(map[string]interface{}{
  457. "msg": "修改成功",
  458. })
  459. return
  460. } else if errSeven == nil {
  461. //修改医嘱模板
  462. template := models.DoctorAdviceTemplate{
  463. AdviceName: drug_name,
  464. AdviceDesc: drug_spec,
  465. DeliveryWay: delivery_way,
  466. ExecutionFrequency: execution_frequency,
  467. SingleDose: single_dose,
  468. SingleDoseUnit: min_unit,
  469. }
  470. service.UpdatedDoctorAdviceTemplate(id, adminInfo.CurrentOrgId, &template)
  471. }
  472. if err == nil {
  473. c.ServeSuccessJSON(map[string]interface{}{
  474. "msg": "修改成功",
  475. })
  476. return
  477. } else {
  478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  479. return
  480. }
  481. }
  482. func (c *ManagerCenterApiController) GetBaseDrugLib() {
  483. id, _ := c.GetInt64("id")
  484. adminInfo := c.GetAdminUserInfo()
  485. drug, err := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
  486. if err == nil {
  487. c.ServeSuccessJSON(map[string]interface{}{
  488. "drug": drug,
  489. })
  490. return
  491. } else {
  492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  493. return
  494. }
  495. }
  496. func (c *ManagerCenterApiController) GetBaseDrugLibList() {
  497. page, _ := c.GetInt64("page", 1)
  498. limit, _ := c.GetInt64("limit", 10)
  499. is_use, _ := c.GetInt64("is_use", 0)
  500. is_charge, _ := c.GetInt64("is_charge", 0)
  501. is_inject, _ := c.GetInt64("is_inject", 0)
  502. manufacturer, _ := c.GetInt64("manufacturer")
  503. is_record, _ := c.GetInt64("is_record")
  504. keyword := c.GetString("keyword")
  505. adminInfo := c.GetAdminUserInfo()
  506. if page <= 0 {
  507. page = 1
  508. }
  509. if limit <= 0 {
  510. limit = 10
  511. }
  512. list, total, _ := service.GetBaseDrugLibList(adminInfo.CurrentOrgId, keyword, page, limit, is_use, is_charge, is_inject, manufacturer, is_record)
  513. c.ServeSuccessJSON(map[string]interface{}{
  514. "list": list,
  515. "total": total,
  516. })
  517. return
  518. }
  519. func (c *ManagerCenterApiController) CreateMedicineInsurancePercent() {
  520. module, _ := c.GetInt64("module", 0)
  521. adminInfo := c.GetAdminUserInfo()
  522. dataBody := make(map[string]interface{}, 0)
  523. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  524. if err != nil {
  525. utils.ErrorLog(err.Error())
  526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  527. return
  528. }
  529. var mips []*models.MedicineInsurancePercentage
  530. var errs error
  531. record_time := time.Now().Unix()
  532. if dataBody["mip"] != nil && reflect.TypeOf(dataBody["mip"]).String() == "[]interface {}" {
  533. mip_map, _ := dataBody["mip"].([]interface{})
  534. if len(mip_map) > 0 {
  535. for _, item := range mip_map {
  536. items := item.(map[string]interface{})
  537. if items["type_id"] == nil || reflect.TypeOf(items["type_id"]).String() != "float64" {
  538. utils.ErrorLog("type_id")
  539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  540. return
  541. }
  542. type_id := int64(items["type_id"].(float64))
  543. if items["medicine_insurance_type"] == nil || reflect.TypeOf(items["medicine_insurance_type"]).String() != "float64" {
  544. utils.ErrorLog("medicine_insurance_type")
  545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  546. return
  547. }
  548. types := int64(items["medicine_insurance_type"].(float64))
  549. if items["percent"] == nil || reflect.TypeOf(items["percent"]).String() != "string" {
  550. utils.ErrorLog("percent")
  551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  552. return
  553. }
  554. percent, _ := strconv.ParseFloat(items["percent"].(string), 64)
  555. //percent := items["percent"].(float64)
  556. mip_temp := &models.MedicineInsurancePercentage{
  557. TypeId: type_id,
  558. Status: 1,
  559. Ctime: time.Now().Unix(),
  560. Mtime: time.Now().Unix(),
  561. RecordTime: record_time,
  562. MedicineInsuranceType: types,
  563. UserOrgId: adminInfo.CurrentOrgId,
  564. Percent: percent,
  565. Module: module,
  566. GoodId: 0,
  567. }
  568. mips = append(mips, mip_temp)
  569. }
  570. }
  571. for _, item := range mips {
  572. errs = service.CreateMedicineInsurancePercentage(item)
  573. }
  574. }
  575. if errs == nil {
  576. c.ServeSuccessJSON(map[string]interface{}{
  577. "msg": "添加成功",
  578. })
  579. return
  580. } else {
  581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  582. return
  583. }
  584. }
  585. func (c *ManagerCenterApiController) CreateDrugUnitSafeguard() {
  586. }
  587. //GetPatientsList 取配置信息列表
  588. func (c *ManagerCenterApiController) GetConfigList() {
  589. adminUserInfo := c.GetAdminUserInfo()
  590. configList, _ := service.GetDictionaryConfigList(adminUserInfo.CurrentOrgId)
  591. c.ServeSuccessJSON(map[string]interface{}{
  592. "configlist": configList,
  593. })
  594. return
  595. }
  596. //CreateConfig 创建配置信息
  597. func (c *ManagerCenterApiController) CreateConfig() {
  598. adminUserInfo := c.GetAdminUserInfo()
  599. var dataconfig models.DictionaryDataconfig
  600. var resultConfig models.DictionaryConfigViewModel
  601. code := dictionaryConfigFormData(&dataconfig, c.Ctx.Input.RequestBody)
  602. if code > 0 {
  603. c.ServeFailJSONWithSGJErrorCode(code)
  604. return
  605. }
  606. // 验证关键字段的值是否重复
  607. thisConfig, _ := service.FindDictionaryConfigByTitle(dataconfig.Module, dataconfig.FieldName, adminUserInfo.CurrentOrgId)
  608. if thisConfig.ID > 0 {
  609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
  610. return
  611. }
  612. fieldValue := service.GetDictionaryChildValue(dataconfig.Module, dataconfig.ParentId, adminUserInfo.CurrentOrgId)
  613. dataconfig.Value = fieldValue + 1
  614. dataBody := make(map[string]interface{}, 0)
  615. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  616. if err != nil {
  617. utils.ErrorLog(err.Error())
  618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  619. return
  620. }
  621. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  622. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  623. dataconfig.Status = 1
  624. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  625. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  626. dataconfig.Remark = string(dataBody["remark"].(string))
  627. if dataBody["order"] != nil {
  628. dataconfig.Order = int64(dataBody["order"].(float64))
  629. } else {
  630. dataconfig.Order = 0
  631. }
  632. err = service.CreateDictionaryConfig(&dataconfig)
  633. if err != nil {
  634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  635. return
  636. } else {
  637. resultConfig.ID = dataconfig.ID
  638. resultConfig.Module = dataconfig.Module
  639. resultConfig.Name = dataconfig.Name
  640. resultConfig.OrgId = dataconfig.OrgId
  641. resultConfig.ParentId = dataconfig.ParentId
  642. resultConfig.FieldName = dataconfig.FieldName
  643. resultConfig.CreateUserId = dataconfig.CreateUserId
  644. resultConfig.Title = dataconfig.Title
  645. resultConfig.Content = dataconfig.Content
  646. }
  647. c.ServeSuccessJSON(map[string]interface{}{
  648. "dataconfig": resultConfig,
  649. "msg": "ok",
  650. })
  651. return
  652. }
  653. func (c *ManagerCenterApiController) UpdateTemplate() {
  654. adminUserInfo := c.GetAdminUserInfo()
  655. var dataconfig models.DictionaryDataconfig
  656. code := dictionaryConfigFormData(&dataconfig, c.Ctx.Input.RequestBody)
  657. if code > 0 {
  658. c.ServeFailJSONWithSGJErrorCode(code)
  659. return
  660. }
  661. dataBody := make(map[string]interface{}, 0)
  662. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  663. if err != nil {
  664. utils.ErrorLog(err.Error())
  665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  666. return
  667. }
  668. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  669. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  670. dataconfig.Status = 1
  671. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  672. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  673. dataconfig.Remark = string(dataBody["remark"].(string))
  674. if dataBody["order"] != nil {
  675. dataconfig.Order = int64(dataBody["order"].(float64))
  676. } else {
  677. dataconfig.Order = 0
  678. }
  679. // 验证关键字段的值是否重复
  680. // cur_id := int64(dataBody["id"].(float64))
  681. // thisConfig,_:=service.FindConfigByTitleForUpdate(dataconfig.Module, dataconfig.Title,dataconfig.OrgId,cur_id)
  682. // if thisConfig.ID >0 {
  683. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
  684. // return
  685. // }
  686. configOrgId := int64(dataBody["org_id"].(float64))
  687. if configOrgId == 0 {
  688. dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
  689. err := service.CreateDictionaryConfig(&dataconfig)
  690. if err != nil {
  691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  692. return
  693. }
  694. } else {
  695. dataconfig.ID = int64(dataBody["id"].(float64))
  696. err = service.UpdateDictionaryTemplate(&dataconfig)
  697. if err != nil {
  698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  699. return
  700. }
  701. }
  702. c.ServeSuccessJSON(map[string]interface{}{
  703. "dataconfig": dataconfig,
  704. "msg": "ok",
  705. })
  706. return
  707. }
  708. func (c *ManagerCenterApiController) UpdateChildConfig() {
  709. adminUserInfo := c.GetAdminUserInfo()
  710. var dataconfig models.DictionaryDataconfig
  711. code := dictionaryConfigChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
  712. if code > 0 {
  713. c.ServeFailJSONWithSGJErrorCode(code)
  714. return
  715. }
  716. dataBody := make(map[string]interface{}, 0)
  717. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  718. if err != nil {
  719. utils.ErrorLog(err.Error())
  720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  721. return
  722. }
  723. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  724. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  725. dataconfig.Status = 1
  726. dataconfig.Value = int(int64(dataBody["value"].(float64)))
  727. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  728. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  729. dataconfig.Remark = string(dataBody["remark"].(string))
  730. dataconfig.Order = int64(dataBody["orders"].(float64))
  731. dataconfig.Code = string(dataBody["code"].(string))
  732. fmt.Println("dataconfitg------", dataconfig.Order)
  733. //if dataBody["orders"] != nil {
  734. // dataconfig.Order = int64(dataBody["orders"].(float64))
  735. // fmt.Println("dataconfig",dataconfig.Order)
  736. //} else {
  737. // dataconfig.Order = 0
  738. //}
  739. configOrgId := int64(dataBody["org_id"].(float64))
  740. // 验证关键字段的值是否重复
  741. // configId := int64(dataBody["id"].(float64))
  742. // thisConfig,_:=service.FindConfigByNameForUpdate(dataconfig.Module, dataconfig.Name,dataconfig.ParentId,dataconfig.OrgId,configId)
  743. // if thisConfig.ID >0 {
  744. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
  745. // return
  746. // }
  747. if configOrgId == 0 {
  748. dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
  749. err := service.CreateDictionaryConfig(&dataconfig)
  750. if err != nil {
  751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  752. return
  753. }
  754. } else {
  755. dataconfig.ID = int64(dataBody["id"].(float64))
  756. err = service.UpdateDictionaryChildConfig(&dataconfig)
  757. if err != nil {
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  759. return
  760. }
  761. }
  762. c.ServeSuccessJSON(map[string]interface{}{
  763. "dataconfig": dataconfig,
  764. "msg": "ok",
  765. })
  766. return
  767. }
  768. func (c *ManagerCenterApiController) DeleteChildConfig() {
  769. adminUserInfo := c.GetAdminUserInfo()
  770. var dataconfig models.DictionaryDataconfig
  771. code := dictionaryConfigChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
  772. if code > 0 {
  773. c.ServeFailJSONWithSGJErrorCode(code)
  774. return
  775. }
  776. dataBody := make(map[string]interface{}, 0)
  777. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  778. if err != nil {
  779. utils.ErrorLog(err.Error())
  780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  781. return
  782. }
  783. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  784. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  785. dataconfig.Status = 0
  786. dataconfig.Value = int(int64(dataBody["value"].(float64)))
  787. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  788. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  789. dataconfig.Remark = string(dataBody["remark"].(string))
  790. if dataBody["order"] != nil {
  791. dataconfig.Order = int64(dataBody["order"].(float64))
  792. } else {
  793. dataconfig.Order = 0
  794. }
  795. configOrgId := int64(dataBody["org_id"].(float64))
  796. if configOrgId == 0 {
  797. dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
  798. err := service.CreateDictionaryConfig(&dataconfig)
  799. if err != nil {
  800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  801. return
  802. }
  803. } else {
  804. dataconfig.ID = int64(dataBody["id"].(float64))
  805. err := service.DeleteDictionaryChildConfig(&dataconfig)
  806. if err != nil {
  807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  808. return
  809. }
  810. }
  811. c.ServeSuccessJSON(map[string]interface{}{
  812. "dataconfig": dataconfig,
  813. "msg": "ok",
  814. })
  815. return
  816. }
  817. //CreateChildConfig 创建子配置信息
  818. func (c *ManagerCenterApiController) CreateChildConfig() {
  819. adminUserInfo := c.GetAdminUserInfo()
  820. var dataconfig models.DictionaryDataconfig
  821. code := dictionaryConfigChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
  822. if code > 0 {
  823. c.ServeFailJSONWithSGJErrorCode(code)
  824. return
  825. }
  826. dataBody := make(map[string]interface{}, 0)
  827. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  828. if err != nil {
  829. utils.ErrorLog(err.Error())
  830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  831. return
  832. }
  833. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  834. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  835. dataconfig.Status = 1
  836. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  837. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  838. dataconfig.Remark = string(dataBody["remark"].(string))
  839. dataconfig.Code = string(dataBody["code"].(string))
  840. fmt.Println("3444444444", dataconfig.Code)
  841. if dataBody["order"] != nil {
  842. dataconfig.Order = int64(dataBody["order"].(float64))
  843. } else {
  844. dataconfig.Order = 0
  845. }
  846. // 验证关键字段的值是否重复
  847. // thisConfig,_:=service.FindConfigByName(dataconfig.Module, dataconfig.Name,dataconfig.ParentId,dataconfig.OrgId)
  848. // if thisConfig.ID >0 {
  849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
  850. // return
  851. // }
  852. fieldValue := service.GetDictionaryChildValue(dataconfig.Module, dataconfig.ParentId, dataconfig.OrgId)
  853. dataconfig.Value = fieldValue + 1
  854. err = service.CreateDictionaryConfig(&dataconfig)
  855. if err != nil {
  856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  857. return
  858. }
  859. c.ServeSuccessJSON(map[string]interface{}{
  860. "dataconfig": dataconfig,
  861. "msg": "ok",
  862. })
  863. return
  864. }
  865. func dictionaryConfigFormData(dataconfig *models.DictionaryDataconfig, data []byte) (code int) {
  866. configBody := make(map[string]interface{}, 0)
  867. err := json.Unmarshal(data, &configBody)
  868. utils.InfoLog(string(data))
  869. if err != nil {
  870. utils.ErrorLog(err.Error())
  871. code = enums.ErrorCodeParamWrong
  872. return
  873. }
  874. if configBody["module"] == nil || reflect.TypeOf(configBody["module"]).String() != "string" {
  875. utils.ErrorLog("module")
  876. code = enums.ErrorCodeParamWrong
  877. return
  878. }
  879. module, _ := configBody["module"].(string)
  880. if len(module) == 0 {
  881. utils.ErrorLog("len(module) == 0")
  882. code = enums.ErrorCodeParamWrong
  883. return
  884. }
  885. dataconfig.Module = module
  886. if module == "education" || module == "summary" || module == "course_disease" || module == "rescue_record" || module == "nursing_record" || module == "special_record" {
  887. if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
  888. utils.ErrorLog("title")
  889. code = enums.ErrorCodeParamWrong
  890. return
  891. }
  892. title, _ := configBody["title"].(string)
  893. if len(title) == 0 {
  894. utils.ErrorLog("len(title) == 0")
  895. code = enums.ErrorCodeParamWrong
  896. return
  897. }
  898. dataconfig.Title = title
  899. if configBody["content"] == nil || reflect.TypeOf(configBody["content"]).String() != "string" {
  900. utils.ErrorLog("content")
  901. code = enums.ErrorCodeParamWrong
  902. return
  903. }
  904. content, _ := configBody["content"].(string)
  905. if len(content) == 0 {
  906. utils.ErrorLog("len(content) == 0")
  907. code = enums.ErrorCodeParamWrong
  908. return
  909. }
  910. dataconfig.Content = content
  911. } else {
  912. if configBody["name"] == nil || reflect.TypeOf(configBody["name"]).String() != "string" {
  913. utils.ErrorLog("name")
  914. code = enums.ErrorCodeParamWrong
  915. return
  916. }
  917. name, _ := configBody["name"].(string)
  918. if len(name) == 0 {
  919. utils.ErrorLog("len(name) == 0")
  920. code = enums.ErrorCodeParamWrong
  921. return
  922. }
  923. dataconfig.Name = name
  924. if configBody["field_name"] == nil || reflect.TypeOf(configBody["field_name"]).String() != "string" {
  925. utils.ErrorLog("field_name")
  926. code = enums.ErrorCodeParamWrong
  927. return
  928. }
  929. field_name, _ := configBody["field_name"].(string)
  930. if len(field_name) == 0 {
  931. utils.ErrorLog("len(field_name) == 0")
  932. code = enums.ErrorCodeParamWrong
  933. return
  934. }
  935. dataconfig.FieldName = field_name
  936. }
  937. return
  938. }
  939. func dictionaryConfigChildFormData(dataconfig *models.DictionaryDataconfig, data []byte) (code int) {
  940. configBody := make(map[string]interface{}, 0)
  941. err := json.Unmarshal(data, &configBody)
  942. utils.InfoLog(string(data))
  943. if err != nil {
  944. utils.ErrorLog(err.Error())
  945. code = enums.ErrorCodeParamWrong
  946. return
  947. }
  948. if configBody["module"] == nil || reflect.TypeOf(configBody["module"]).String() != "string" {
  949. utils.ErrorLog("module")
  950. code = enums.ErrorCodeParamWrong
  951. return
  952. }
  953. module, _ := configBody["module"].(string)
  954. if len(module) == 0 {
  955. utils.ErrorLog("len(module) == 0")
  956. code = enums.ErrorCodeParamWrong
  957. return
  958. }
  959. dataconfig.Module = module
  960. if module == "education" || module == "summary" {
  961. if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
  962. utils.ErrorLog("title")
  963. code = enums.ErrorCodeParamWrong
  964. return
  965. }
  966. title, _ := configBody["title"].(string)
  967. if len(title) == 0 {
  968. utils.ErrorLog("len(title) == 0")
  969. code = enums.ErrorCodeParamWrong
  970. return
  971. }
  972. dataconfig.Title = title
  973. if configBody["content"] == nil || reflect.TypeOf(configBody["content"]).String() != "string" {
  974. utils.ErrorLog("content")
  975. code = enums.ErrorCodeParamWrong
  976. return
  977. }
  978. content, _ := configBody["content"].(string)
  979. if len(content) == 0 {
  980. utils.ErrorLog("len(content) == 0")
  981. code = enums.ErrorCodeParamWrong
  982. return
  983. }
  984. dataconfig.Content = content
  985. } else {
  986. if configBody["parent_id"] == nil || reflect.TypeOf(configBody["parent_id"]).String() != "float64" {
  987. utils.ErrorLog("module")
  988. code = enums.ErrorCodeParamWrong
  989. return
  990. }
  991. parent_id := int64(configBody["parent_id"].(float64))
  992. if parent_id <= 0 {
  993. utils.ErrorLog("parent_id <= 0")
  994. code = enums.ErrorCodeParamWrong
  995. return
  996. }
  997. dataconfig.ParentId = parent_id
  998. if configBody["name"] == nil || reflect.TypeOf(configBody["name"]).String() != "string" {
  999. utils.ErrorLog("name")
  1000. code = enums.ErrorCodeParamWrong
  1001. return
  1002. }
  1003. name, _ := configBody["name"].(string)
  1004. if len(name) == 0 {
  1005. utils.ErrorLog("len(name) == 0")
  1006. code = enums.ErrorCodeParamWrong
  1007. return
  1008. }
  1009. dataconfig.Name = name
  1010. }
  1011. return
  1012. }
  1013. func (c *ManagerCenterApiController) CreateDealer() {
  1014. dealer_name := c.GetString("dealer_name")
  1015. contact := c.GetString("contact")
  1016. contact_phone := c.GetString("contact_phone")
  1017. platform_number := c.GetString("platform_number")
  1018. email := c.GetString("email")
  1019. contact_address := c.GetString("contact_address")
  1020. remark := c.GetString("remark")
  1021. pinyin := c.GetString("pinyin")
  1022. wubi := c.GetString("wubi")
  1023. if len(dealer_name) <= 0 {
  1024. utils.ErrorLog("len(dealer_name) == 0")
  1025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1026. return
  1027. }
  1028. adminUserInfo := c.GetAdminUserInfo()
  1029. total := service.FindAllDealerTotal(adminUserInfo.CurrentOrgId)
  1030. totalStr := strconv.FormatInt(total+1, 10)
  1031. code := "1000" + totalStr
  1032. dealer := models.Dealer{
  1033. DealerName: dealer_name,
  1034. Contact: contact,
  1035. ContactPhone: contact_phone,
  1036. ContactAddress: contact_address,
  1037. DealerCode: code,
  1038. Ctime: time.Now().Unix(),
  1039. Mtime: time.Now().Unix(),
  1040. Remark: remark,
  1041. Creater: adminUserInfo.AdminUser.Id,
  1042. Email: email,
  1043. PlatformNumber: platform_number,
  1044. OrgId: adminUserInfo.CurrentOrgId,
  1045. Status: 1,
  1046. PinYin: pinyin,
  1047. WuBi: wubi,
  1048. }
  1049. err, dealers := service.AddSigleDealer(&dealer)
  1050. if err == nil {
  1051. c.ServeSuccessJSON(map[string]interface{}{
  1052. "dealer": dealers,
  1053. })
  1054. } else {
  1055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1056. }
  1057. }
  1058. func (c *ManagerCenterApiController) ModifyDealer() {
  1059. id, _ := c.GetInt64("id", 0)
  1060. dealer_name := c.GetString("dealer_name")
  1061. contact := c.GetString("contact")
  1062. contact_phone := c.GetString("contact_phone")
  1063. platform_number := c.GetString("platform_number")
  1064. dealer_code := c.GetString("dealer_code")
  1065. email := c.GetString("email")
  1066. contact_address := c.GetString("contact_address")
  1067. remark := c.GetString("remark")
  1068. pinyin := c.GetString("pinyin")
  1069. wubi := c.GetString("wubi")
  1070. if id <= 0 {
  1071. utils.ErrorLog("id == 0")
  1072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1073. return
  1074. }
  1075. if len(dealer_name) <= 0 {
  1076. utils.ErrorLog("len(dealer_name) == 0")
  1077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1078. return
  1079. }
  1080. adminUserInfo := c.GetAdminUserInfo()
  1081. dealer := models.Dealer{
  1082. ID: id,
  1083. DealerName: dealer_name,
  1084. Contact: contact,
  1085. ContactPhone: contact_phone,
  1086. ContactAddress: contact_address,
  1087. Mtime: time.Now().Unix(),
  1088. DealerCode: dealer_code,
  1089. Remark: remark,
  1090. Creater: adminUserInfo.AdminUser.Id,
  1091. Email: email,
  1092. PlatformNumber: platform_number,
  1093. Modifier: adminUserInfo.AdminUser.Id,
  1094. OrgId: adminUserInfo.CurrentOrgId,
  1095. Status: 1,
  1096. PinYin: pinyin,
  1097. WuBi: wubi,
  1098. }
  1099. err := service.ModifyDealer(&dealer)
  1100. if err == nil {
  1101. c.ServeSuccessJSON(map[string]interface{}{
  1102. "dealer": dealer,
  1103. })
  1104. } else {
  1105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1106. }
  1107. }
  1108. func (c *ManagerCenterApiController) GetDealersList() {
  1109. page, _ := c.GetInt64("page", 1)
  1110. limit, _ := c.GetInt64("limit", 7)
  1111. adminUserInfo := c.GetAdminUserInfo()
  1112. deales, total, err := service.FindAllDealerList(adminUserInfo.CurrentOrgId, page, limit)
  1113. if err == nil {
  1114. c.ServeSuccessJSON(map[string]interface{}{
  1115. "dealer": deales,
  1116. "total": total,
  1117. })
  1118. } else {
  1119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1120. }
  1121. }
  1122. func (c *ManagerCenterApiController) DeleteDealer() {
  1123. id, _ := c.GetInt64("id", 0)
  1124. total, _ := service.FindStockInByDealerId(id)
  1125. if total > 0 {
  1126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteDealerWrong)
  1127. return
  1128. }
  1129. err := service.DeleteDealerById(id)
  1130. if err == nil {
  1131. c.ServeSuccessJSON(map[string]interface{}{
  1132. "msg": "删除成功",
  1133. })
  1134. } else {
  1135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1136. }
  1137. }
  1138. func (c *ManagerCenterApiController) GetDealer() {
  1139. id, _ := c.GetInt64("id", 0)
  1140. dealer, err := service.FindDealerById(id)
  1141. if err == nil {
  1142. c.ServeSuccessJSON(map[string]interface{}{
  1143. "dealer": dealer,
  1144. })
  1145. } else {
  1146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1147. }
  1148. }
  1149. func (c *ManagerCenterApiController) CreateManufacturer() {
  1150. manufacturer_name := c.GetString("manufacturer_name")
  1151. contact := c.GetString("contact")
  1152. contact_phone := c.GetString("contact_phone")
  1153. platform_number := c.GetString("platform_number")
  1154. email := c.GetString("email")
  1155. contact_address := c.GetString("contact_address")
  1156. remark := c.GetString("remark")
  1157. pinyin := c.GetString("pinyin")
  1158. wubi := c.GetString("wubi")
  1159. if len(manufacturer_name) <= 0 {
  1160. utils.ErrorLog("len(manufacturer_name) == 0")
  1161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1162. return
  1163. }
  1164. adminUserInfo := c.GetAdminUserInfo()
  1165. total := service.FindManufacturerTotal(adminUserInfo.CurrentOrgId)
  1166. totalStr := strconv.FormatInt(total+1, 10)
  1167. code := "2000" + totalStr
  1168. manufacturer := models.Manufacturer{
  1169. ManufacturerName: manufacturer_name,
  1170. Contact: contact,
  1171. ContactPhone: contact_phone,
  1172. ContactAddress: contact_address,
  1173. Ctime: time.Now().Unix(),
  1174. Mtime: time.Now().Unix(),
  1175. Remark: remark,
  1176. Creater: adminUserInfo.AdminUser.Id,
  1177. Email: email,
  1178. PlatformNumber: platform_number,
  1179. OrgId: adminUserInfo.CurrentOrgId,
  1180. Status: 1,
  1181. ManufacturerCode: code,
  1182. PinYin: pinyin,
  1183. WuBi: wubi,
  1184. }
  1185. err, manufacturers := service.AddSigleManufacturer(&manufacturer)
  1186. if err == nil {
  1187. c.ServeSuccessJSON(map[string]interface{}{
  1188. "manufacturer": manufacturers,
  1189. })
  1190. } else {
  1191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1192. }
  1193. }
  1194. func (c *ManagerCenterApiController) ModifyManufacturer() {
  1195. id, _ := c.GetInt64("id", 0)
  1196. manufacturer_name := c.GetString("manufacturer_name")
  1197. contact := c.GetString("contact")
  1198. contact_phone := c.GetString("contact_phone")
  1199. platform_number := c.GetString("platform_number")
  1200. email := c.GetString("email")
  1201. contact_address := c.GetString("contact_address")
  1202. remark := c.GetString("remark")
  1203. manufacturer_code := c.GetString("manufacturer_code")
  1204. pinyin := c.GetString("pinyin")
  1205. wubi := c.GetString("wubi")
  1206. if id <= 0 {
  1207. utils.ErrorLog("id == 0")
  1208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1209. return
  1210. }
  1211. if len(manufacturer_name) <= 0 {
  1212. utils.ErrorLog("len(manufacturer_name) == 0")
  1213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1214. return
  1215. }
  1216. adminUserInfo := c.GetAdminUserInfo()
  1217. manufacturer := models.Manufacturer{
  1218. ID: id,
  1219. ManufacturerName: manufacturer_name,
  1220. Contact: contact,
  1221. ContactPhone: contact_phone,
  1222. ContactAddress: contact_address,
  1223. Mtime: time.Now().Unix(),
  1224. Remark: remark,
  1225. Creater: adminUserInfo.AdminUser.Id,
  1226. Email: email,
  1227. PlatformNumber: platform_number,
  1228. Modifier: adminUserInfo.AdminUser.Id,
  1229. OrgId: adminUserInfo.CurrentOrgId,
  1230. ManufacturerCode: manufacturer_code,
  1231. Status: 1,
  1232. PinYin: pinyin,
  1233. WuBi: wubi,
  1234. }
  1235. err := service.ModifyManufacturer(&manufacturer)
  1236. if err == nil {
  1237. c.ServeSuccessJSON(map[string]interface{}{
  1238. "manufacturer": manufacturer,
  1239. })
  1240. } else {
  1241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1242. }
  1243. }
  1244. func (c *ManagerCenterApiController) GetManufacturerList() {
  1245. page, _ := c.GetInt64("page", 1)
  1246. limit, _ := c.GetInt64("limit", 10)
  1247. adminUserInfo := c.GetAdminUserInfo()
  1248. manufacturer, total, err := service.FindAllManufacturerList(adminUserInfo.CurrentOrgId, page, limit)
  1249. if err == nil {
  1250. c.ServeSuccessJSON(map[string]interface{}{
  1251. "manufacturer": manufacturer,
  1252. "total": total,
  1253. })
  1254. } else {
  1255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1256. }
  1257. }
  1258. func (c *ManagerCenterApiController) DeleteManufacturer() {
  1259. id, _ := c.GetInt64("id", 0)
  1260. total, _ := service.FindStockInByManufacturerId(id)
  1261. if total > 0 {
  1262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteManufacturerWrong)
  1263. return
  1264. }
  1265. err := service.DeleteManufacturerById(id)
  1266. if err == nil {
  1267. c.ServeSuccessJSON(map[string]interface{}{
  1268. "msg": "删除成功",
  1269. })
  1270. } else {
  1271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1272. }
  1273. }
  1274. func (c *ManagerCenterApiController) GetManufacturer() {
  1275. id, _ := c.GetInt64("id", 0)
  1276. manufacturer, err := service.FindManufacturerById(id)
  1277. if err == nil {
  1278. c.ServeSuccessJSON(map[string]interface{}{
  1279. "manufacturer": manufacturer,
  1280. })
  1281. } else {
  1282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1283. }
  1284. }
  1285. func (c *ManagerCenterApiController) GetAllDealer() {
  1286. adminUserInfo := c.GetAdminUserInfo()
  1287. dealer, err := service.FindAllDealer(adminUserInfo.CurrentOrgId)
  1288. if err == nil {
  1289. c.ServeSuccessJSON(map[string]interface{}{
  1290. "dealer": dealer,
  1291. })
  1292. } else {
  1293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1294. }
  1295. }
  1296. func (c *ManagerCenterApiController) GetAllManufacturer() {
  1297. adminUserInfo := c.GetAdminUserInfo()
  1298. manufacturer, err := service.FindAllManufacturer(adminUserInfo.CurrentOrgId)
  1299. if err == nil {
  1300. c.ServeSuccessJSON(map[string]interface{}{
  1301. "manufacturer": manufacturer,
  1302. })
  1303. } else {
  1304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1305. }
  1306. }
  1307. func (c *ManagerCenterApiController) CreateGoodInfo() {
  1308. good_id, _ := c.GetInt64("good_id", 0)
  1309. specification_name := c.GetString("specification_name")
  1310. register_number := c.GetString("register_number")
  1311. good_unit, _ := c.GetInt64("good_unit", -1)
  1312. buy_price, _ := c.GetFloat("buy_price", 0)
  1313. sell_price, _ := c.GetFloat("sell_price", 0)
  1314. remark := c.GetString("remark")
  1315. manufacturer, _ := c.GetInt64("manufacturer", 0)
  1316. dealer, _ := c.GetInt64("dealer", 0)
  1317. expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
  1318. stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
  1319. is_reuse, _ := c.GetInt64("is_reuse", 0)
  1320. good_name := c.GetString("good_name")
  1321. pinyin := c.GetString("pinyin")
  1322. wubi := c.GetString("wubi")
  1323. good_kind, _ := c.GetInt64("good_kind", 0)
  1324. medical_insurance_level, _ := c.GetInt64("medical_insurance_level", 0)
  1325. retail_price, _ := c.GetFloat("retail_price", 0)
  1326. fmt.Println(retail_price)
  1327. medical_insurance_number := c.GetString("medical_insurance_number")
  1328. is_special_diseases, _ := c.GetInt64("is_special_diseases", 0)
  1329. is_record, _ := c.GetInt64("is_record")
  1330. statistics_category, _ := c.GetInt64("statistics_category")
  1331. good_status := c.GetString("good_status")
  1332. default_count, _ := c.GetInt64("default_count")
  1333. sign, _ := c.GetInt64("sign")
  1334. is_default, _ := c.GetInt64("is_default")
  1335. is_charge_use, _ := c.GetInt64("is_charge_use")
  1336. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  1337. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  1338. sort, _ := c.GetInt64("sort")
  1339. is_doctor_use, _ := c.GetInt64("is_doctor_use")
  1340. agent := c.GetString("agent")
  1341. good_number := c.GetString("good_number")
  1342. social_security_directory_code := c.GetString("social_security_directory_code")
  1343. production_type := c.GetString("production_type")
  1344. special_medical := c.GetString("special_medical")
  1345. min_number, _ := c.GetInt64("min_number")
  1346. packing_unit := c.GetString("packing_unit")
  1347. packing_price, _ := c.GetFloat("packing_price")
  1348. min_unit := c.GetString("min_unit")
  1349. default_count_unit := c.GetString("default_count_unit")
  1350. adminUserInfo := c.GetAdminUserInfo()
  1351. totals := service.FindGoodInfoByNameTwo(specification_name, adminUserInfo.CurrentOrgId, good_id, good_name)
  1352. if totals > 0 {
  1353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
  1354. return
  1355. }
  1356. total := service.FindAllGoodInfoTotal(adminUserInfo.CurrentOrgId)
  1357. code := strconv.FormatInt(total+1, 10)
  1358. code = "24000000" + code
  1359. goodInfo := models.GoodInfo{
  1360. GoodCode: code,
  1361. SpecificationName: specification_name,
  1362. GoodTypeId: good_id,
  1363. GoodUnit: good_unit,
  1364. BuyPrice: buy_price,
  1365. SellPrice: sell_price,
  1366. Remark: remark,
  1367. Ctime: time.Now().Unix(),
  1368. Manufacturer: manufacturer,
  1369. Dealer: dealer,
  1370. ExpiryDateWarnDayCount: expiry_date_warn_day_count,
  1371. StockWarnCount: stock_warn_count,
  1372. IsReuse: is_reuse,
  1373. Status: 1,
  1374. OrgId: adminUserInfo.CurrentOrgId,
  1375. Creater: adminUserInfo.AdminUser.Id,
  1376. GoodName: good_name,
  1377. Pinyin: pinyin,
  1378. Wubi: wubi,
  1379. GoodKind: good_kind,
  1380. MedicalInsuranceNumber: medical_insurance_number,
  1381. IsSpecialDiseases: is_special_diseases,
  1382. IsRecord: is_record,
  1383. StatisticsCategory: statistics_category,
  1384. GoodStatus: good_status,
  1385. DefaultCount: default_count,
  1386. Sign: sign,
  1387. IsDefault: is_default,
  1388. IsChargeUse: is_charge_use,
  1389. IsChargePredict: is_charge_predict,
  1390. IsStatisticsWork: is_statistics_work,
  1391. Sort: sort,
  1392. IsDoctorUse: is_doctor_use,
  1393. Agent: agent,
  1394. GoodNumber: good_number,
  1395. MedicalInsuranceLevel: medical_insurance_level,
  1396. RetailPrice: packing_price,
  1397. SocialSecurityDirectoryCode: social_security_directory_code,
  1398. ProductionType: production_type,
  1399. SpecialMedical: special_medical,
  1400. MinNumber: min_number,
  1401. PackingUnit: packing_unit,
  1402. PackingPrice: packing_price,
  1403. DefaultCountUnit: default_count_unit,
  1404. MinUnit: min_unit,
  1405. RegisterNumber: register_number,
  1406. }
  1407. err, goodInfos := service.AddSigleGoodInfo(&goodInfo)
  1408. if err == nil {
  1409. c.ServeSuccessJSON(map[string]interface{}{
  1410. "goodInfo": goodInfos,
  1411. })
  1412. } else {
  1413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1414. }
  1415. }
  1416. func (c *ManagerCenterApiController) ModifyGoodInfo() {
  1417. id, _ := c.GetInt64("id", 0)
  1418. good_id, _ := c.GetInt64("good_id", 0)
  1419. specification_name := c.GetString("specification_name")
  1420. good_unit, _ := c.GetInt64("good_unit", -1)
  1421. buy_price, _ := c.GetFloat("buy_price", 0)
  1422. sell_price, _ := c.GetFloat("sell_price", 0)
  1423. remark := c.GetString("remark")
  1424. manufacturer, _ := c.GetInt64("manufacturer", 0)
  1425. dealer, _ := c.GetInt64("dealer", 0)
  1426. expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
  1427. stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
  1428. is_reuse, _ := c.GetInt64("is_reuse", 0)
  1429. code := c.GetString("good_code")
  1430. good_name := c.GetString("good_name")
  1431. pinyin := c.GetString("pinyin")
  1432. wubi := c.GetString("wubi")
  1433. good_kind, _ := c.GetInt64("good_kind", 0)
  1434. medical_insurance_level, _ := c.GetInt64("medical_insurance_level", 0)
  1435. retail_price, _ := c.GetFloat("retail_price", 0)
  1436. fmt.Println(retail_price)
  1437. medical_insurance_number := c.GetString("medical_insurance_number")
  1438. is_special_diseases, _ := c.GetInt64("is_special_diseases", 0)
  1439. is_record, _ := c.GetInt64("is_record")
  1440. statistics_category, _ := c.GetInt64("statistics_category")
  1441. good_status := c.GetString("good_status")
  1442. default_count, _ := c.GetInt64("default_count")
  1443. sign, _ := c.GetInt64("sign")
  1444. is_default, _ := c.GetInt64("is_default")
  1445. is_charge_use, _ := c.GetInt64("is_charge_use")
  1446. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  1447. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  1448. sort, _ := c.GetInt64("sort")
  1449. is_doctor_use, _ := c.GetInt64("is_doctor_use")
  1450. agent := c.GetString("agent")
  1451. good_number := c.GetString("good_number")
  1452. social_security_directory_code := c.GetString("social_security_directory_code")
  1453. production_type := c.GetString("production_type")
  1454. special_medical := c.GetString("special_medical")
  1455. min_number, _ := c.GetInt64("min_number")
  1456. packing_unit := c.GetString("packing_unit")
  1457. packing_price, _ := c.GetFloat("packing_price")
  1458. default_count_unit := c.GetString("default_count_unit")
  1459. min_unit := c.GetString("min_unit")
  1460. total, _ := c.GetFloat("total")
  1461. register_number := c.GetString("register_number")
  1462. adminUserInfo := c.GetAdminUserInfo()
  1463. goodInfo := models.GoodInfo{
  1464. ID: id,
  1465. GoodCode: code,
  1466. SpecificationName: specification_name,
  1467. GoodTypeId: good_id,
  1468. GoodUnit: good_unit,
  1469. BuyPrice: buy_price,
  1470. SellPrice: sell_price,
  1471. Remark: remark,
  1472. Mtime: time.Now().Unix(),
  1473. Manufacturer: manufacturer,
  1474. Dealer: dealer,
  1475. ExpiryDateWarnDayCount: expiry_date_warn_day_count,
  1476. StockWarnCount: stock_warn_count,
  1477. IsReuse: is_reuse,
  1478. Status: 1,
  1479. OrgId: adminUserInfo.CurrentOrgId,
  1480. Modifier: adminUserInfo.AdminUser.Id,
  1481. GoodName: good_name,
  1482. Pinyin: pinyin,
  1483. Wubi: wubi,
  1484. GoodKind: good_kind,
  1485. MedicalInsuranceNumber: medical_insurance_number,
  1486. IsSpecialDiseases: is_special_diseases,
  1487. IsRecord: is_record,
  1488. StatisticsCategory: statistics_category,
  1489. GoodStatus: good_status,
  1490. DefaultCount: default_count,
  1491. Sign: sign,
  1492. IsDefault: is_default,
  1493. IsChargeUse: is_charge_use,
  1494. IsChargePredict: is_charge_predict,
  1495. IsStatisticsWork: is_statistics_work,
  1496. Sort: sort,
  1497. IsDoctorUse: is_doctor_use,
  1498. Agent: agent,
  1499. GoodNumber: good_number,
  1500. MedicalInsuranceLevel: medical_insurance_level,
  1501. RetailPrice: packing_price,
  1502. SpecialMedical: special_medical,
  1503. SocialSecurityDirectoryCode: social_security_directory_code,
  1504. ProductionType: production_type,
  1505. MinNumber: min_number,
  1506. PackingUnit: packing_unit,
  1507. PackingPrice: packing_price,
  1508. DefaultCountUnit: default_count_unit,
  1509. MinUnit: min_unit,
  1510. Total: total,
  1511. RegisterNumber: register_number,
  1512. }
  1513. totals := service.FindGoodInfoByNameOne(specification_name, adminUserInfo.CurrentOrgId, good_id, id, good_name)
  1514. if totals > 0 {
  1515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
  1516. return
  1517. }
  1518. err, goodInfos := service.ModifyGoodInfo(&goodInfo)
  1519. if err == nil {
  1520. c.ServeSuccessJSON(map[string]interface{}{
  1521. "goodInfo": goodInfos,
  1522. })
  1523. } else {
  1524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1525. }
  1526. }
  1527. func (c *ManagerCenterApiController) GetGoodInfoList() {
  1528. page, _ := c.GetInt64("page", 1)
  1529. limit, _ := c.GetInt64("limit", 7)
  1530. keyword := c.GetString("keyword")
  1531. is_use, _ := c.GetInt64("is_use")
  1532. is_charge, _ := c.GetInt64("is_charge")
  1533. good_kind, _ := c.GetInt64("good_kind")
  1534. is_mark, _ := c.GetInt64("is_mark")
  1535. manufacturer, _ := c.GetInt64("manufacturer")
  1536. is_type, _ := c.GetInt64("is_type")
  1537. adminUserInfo := c.GetAdminUserInfo()
  1538. goodInfos, total, err := service.FindGoodInfoList(adminUserInfo.CurrentOrgId, page, limit, keyword, is_use, is_charge, good_kind, is_mark, manufacturer, is_type)
  1539. if err == nil {
  1540. c.ServeSuccessJSON(map[string]interface{}{
  1541. "list": goodInfos,
  1542. "total": total,
  1543. })
  1544. } else {
  1545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1546. }
  1547. }
  1548. func (c *ManagerCenterApiController) DeleteGoodInfo() {
  1549. id, _ := c.GetInt64("id", 0)
  1550. adminUserInfo := c.GetAdminUserInfo()
  1551. total, _ := service.FindWarehouseInfoTotalByGoodId(id)
  1552. total2, _ := service.FindWarehouseOutInfoTotalByGoodId(id)
  1553. if total > 0 {
  1554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
  1555. return
  1556. }
  1557. if total2 > 0 {
  1558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
  1559. return
  1560. }
  1561. err := service.DeleteGoodInfoById(id, adminUserInfo.AdminUser.Id)
  1562. if err == nil {
  1563. c.ServeSuccessJSON(map[string]interface{}{
  1564. "msg": "删除成功",
  1565. })
  1566. } else {
  1567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1568. }
  1569. }
  1570. func (c *ManagerCenterApiController) GetGoodInfoByGoodId() {
  1571. id, _ := c.GetInt64("id", 0)
  1572. goodInfo, err := service.FindGoodInfoByGoodId(id)
  1573. if err == nil {
  1574. c.ServeSuccessJSON(map[string]interface{}{
  1575. "list": goodInfo,
  1576. })
  1577. } else {
  1578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1579. }
  1580. }
  1581. func (c *ManagerCenterApiController) GetGoodInfoById() {
  1582. id, _ := c.GetInt64("id", 0)
  1583. goodInfo, err := service.FindGoodInfoById(id)
  1584. if err == nil {
  1585. c.ServeSuccessJSON(map[string]interface{}{
  1586. "goodInfo": goodInfo,
  1587. })
  1588. } else {
  1589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1590. }
  1591. }
  1592. func (c *ManagerCenterApiController) GetMedicineInsurancePercent() {
  1593. adminUser := c.GetAdminUserInfo()
  1594. type_id, _ := c.GetInt64("type_id", 0)
  1595. module, _ := c.GetInt64("module", 0)
  1596. mip, err := service.GetLastMedicineInsurance(adminUser.CurrentOrgId, type_id, module)
  1597. if err == nil {
  1598. c.ServeSuccessJSON(map[string]interface{}{
  1599. "mip": mip,
  1600. })
  1601. } else {
  1602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1603. }
  1604. }
  1605. func (c *ManagerCenterApiController) CreateMZSick() {
  1606. class_name := c.GetString("class_name")
  1607. content_code := c.GetString("content_code")
  1608. country_code := c.GetString("country_code")
  1609. country_content_name := c.GetString("country_content_name")
  1610. remark := c.GetString("remark")
  1611. pinyin := c.GetString("pinyin")
  1612. wubi := c.GetString("wubi")
  1613. if len(class_name) <= 0 {
  1614. utils.ErrorLog("len(class_name) == 0")
  1615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1616. return
  1617. }
  1618. if len(content_code) <= 0 {
  1619. utils.ErrorLog("len(content_code) == 0")
  1620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1621. return
  1622. }
  1623. adminUserInfo := c.GetAdminUserInfo()
  1624. dealer := models.OutpatientServiceSick{
  1625. ClassName: class_name,
  1626. ContentCode: content_code,
  1627. CountryCode: country_code,
  1628. CountryContentName: country_content_name,
  1629. Ctime: time.Now().Unix(),
  1630. Mtime: time.Now().Unix(),
  1631. Remark: remark,
  1632. UserOrgId: adminUserInfo.CurrentOrgId,
  1633. Status: 1,
  1634. Pinyin: pinyin,
  1635. Wubi: wubi,
  1636. }
  1637. err, dealers := service.AddSigleMZSick(&dealer)
  1638. if err == nil {
  1639. redis := service.RedisClient()
  1640. defer redis.Close()
  1641. sick_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_sick"
  1642. redis.Set(sick_keys, "", time.Second*60*60*18)
  1643. c.ServeSuccessJSON(map[string]interface{}{
  1644. "sick": dealers,
  1645. })
  1646. } else {
  1647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1648. }
  1649. }
  1650. func (c *ManagerCenterApiController) ModifyMZSick() {
  1651. id, _ := c.GetInt64("id", 0)
  1652. class_name := c.GetString("class_name")
  1653. content_code := c.GetString("content_code")
  1654. country_code := c.GetString("country_code")
  1655. country_content_name := c.GetString("country_content_name")
  1656. remark := c.GetString("remark")
  1657. pinyin := c.GetString("pinyin")
  1658. wubi := c.GetString("wubi")
  1659. if id <= 0 {
  1660. utils.ErrorLog("id == 0")
  1661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1662. return
  1663. }
  1664. if len(class_name) <= 0 {
  1665. utils.ErrorLog("len(class_name) == 0")
  1666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1667. return
  1668. }
  1669. if len(content_code) <= 0 {
  1670. utils.ErrorLog("len(content_code) == 0")
  1671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1672. return
  1673. }
  1674. adminUserInfo := c.GetAdminUserInfo()
  1675. dealer := models.OutpatientServiceSick{
  1676. ID: id,
  1677. ClassName: class_name,
  1678. ContentCode: content_code,
  1679. CountryCode: country_code,
  1680. CountryContentName: country_content_name,
  1681. Ctime: time.Now().Unix(),
  1682. Mtime: time.Now().Unix(),
  1683. Remark: remark,
  1684. UserOrgId: adminUserInfo.CurrentOrgId,
  1685. Pinyin: pinyin,
  1686. Wubi: wubi,
  1687. Status: 1,
  1688. }
  1689. err := service.ModifyMZSick(&dealer)
  1690. if err == nil {
  1691. redis := service.RedisClient()
  1692. defer redis.Close()
  1693. sick_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_sick"
  1694. redis.Set(sick_keys, "", time.Second*60*60*18)
  1695. c.ServeSuccessJSON(map[string]interface{}{
  1696. "sick": dealer,
  1697. })
  1698. } else {
  1699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1700. }
  1701. }
  1702. func (c *ManagerCenterApiController) GetMZSickList() {
  1703. page, _ := c.GetInt64("page", 1)
  1704. limit, _ := c.GetInt64("limit", 7)
  1705. adminUserInfo := c.GetAdminUserInfo()
  1706. mzSick, total, err := service.FindAllMZSickList(adminUserInfo.CurrentOrgId, page, limit)
  1707. if err == nil {
  1708. c.ServeSuccessJSON(map[string]interface{}{
  1709. "sick": mzSick,
  1710. "total": total,
  1711. })
  1712. } else {
  1713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1714. }
  1715. }
  1716. func (c *ManagerCenterApiController) DeleteMZSick() {
  1717. id, _ := c.GetInt64("id", 0)
  1718. err := service.DeleteMZSickById(id)
  1719. if err == nil {
  1720. redis := service.RedisClient()
  1721. defer redis.Close()
  1722. sick_keys := strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + "_sick"
  1723. redis.Set(sick_keys, "", time.Second*60*60*18)
  1724. c.ServeSuccessJSON(map[string]interface{}{
  1725. "msg": "删除成功",
  1726. })
  1727. } else {
  1728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1729. }
  1730. }
  1731. func (c *ManagerCenterApiController) GetMZSick() {
  1732. id, _ := c.GetInt64("id", 0)
  1733. mzSick, err := service.FindMZSickById(id)
  1734. if err == nil {
  1735. c.ServeSuccessJSON(map[string]interface{}{
  1736. "sick": mzSick,
  1737. })
  1738. } else {
  1739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1740. }
  1741. }
  1742. func (c *ManagerCenterApiController) DeleteBaseDrugById() {
  1743. id, _ := c.GetInt64("id")
  1744. //查询入库单
  1745. _, errcode := service.GetDrugWareoutInfo(id)
  1746. if errcode == gorm.ErrRecordNotFound {
  1747. //查询出库单
  1748. _, errcodes := service.GetDrugWareOutById(id)
  1749. if errcodes == gorm.ErrRecordNotFound {
  1750. //删除
  1751. service.DeleteBaseDrugById(id)
  1752. returnData := make(map[string]interface{}, 0)
  1753. returnData["msg"] = "ok"
  1754. c.ServeSuccessJSON(returnData)
  1755. return
  1756. } else if errcodes == nil {
  1757. c.ServeFailJsonSend(enums.ErrorCodeDataException, "已出库")
  1758. return
  1759. }
  1760. } else if errcode == nil {
  1761. c.ServeFailJsonSend(enums.ErrorCodeDataException, "已入库")
  1762. return
  1763. }
  1764. }
  1765. func (c *ManagerCenterApiController) CreateAddition() {
  1766. name := c.GetString("name")
  1767. code := c.GetString("code")
  1768. //price, _ := c.GetFloat("price")
  1769. price := c.GetString("price")
  1770. price_float, _ := strconv.ParseFloat(price, 64)
  1771. if len(name) <= 0 {
  1772. utils.ErrorLog("len(name) == 0")
  1773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1774. return
  1775. }
  1776. //if len(code) <= 0 {
  1777. // utils.ErrorLog("len(code) == 0")
  1778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1779. // return
  1780. //}
  1781. adminUserInfo := c.GetAdminUserInfo()
  1782. addition := models.XtHisAddtionConfig{
  1783. Name: name,
  1784. Code: code,
  1785. Status: 1,
  1786. Price: price_float,
  1787. Ctime: time.Now().Unix(),
  1788. Mtime: time.Now().Unix(),
  1789. UserOrgId: adminUserInfo.CurrentOrgId,
  1790. }
  1791. err, additions := service.AddSigleAddition(&addition)
  1792. if err == nil {
  1793. c.ServeSuccessJSON(map[string]interface{}{
  1794. "addition": additions,
  1795. })
  1796. } else {
  1797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1798. }
  1799. }
  1800. func (c *ManagerCenterApiController) ModifyAddition() {
  1801. id, _ := c.GetInt64("id", 0)
  1802. name := c.GetString("name")
  1803. code := c.GetString("code")
  1804. price, _ := c.GetFloat("price")
  1805. if id <= 0 {
  1806. utils.ErrorLog("id == 0")
  1807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1808. return
  1809. }
  1810. if len(name) <= 0 {
  1811. utils.ErrorLog("len(class_name) == 0")
  1812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1813. return
  1814. }
  1815. //if len(code) <= 0 {
  1816. // utils.ErrorLog("len(content_code) == 0")
  1817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1818. // return
  1819. //}
  1820. adminUserInfo := c.GetAdminUserInfo()
  1821. addition := models.XtHisAddtionConfig{
  1822. ID: id,
  1823. Name: name,
  1824. Code: code,
  1825. Ctime: time.Now().Unix(),
  1826. Mtime: time.Now().Unix(),
  1827. UserOrgId: adminUserInfo.CurrentOrgId,
  1828. Price: price,
  1829. Status: 1,
  1830. }
  1831. err := service.ModifyAddition(&addition)
  1832. if err == nil {
  1833. c.ServeSuccessJSON(map[string]interface{}{
  1834. "addition": addition,
  1835. })
  1836. } else {
  1837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1838. }
  1839. }
  1840. func (c *ManagerCenterApiController) GetAdditionList() {
  1841. page, _ := c.GetInt64("page", 1)
  1842. limit, _ := c.GetInt64("limit", 7)
  1843. adminUserInfo := c.GetAdminUserInfo()
  1844. addition, total, err := service.FindAllAdditionList(adminUserInfo.CurrentOrgId, page, limit)
  1845. if err == nil {
  1846. c.ServeSuccessJSON(map[string]interface{}{
  1847. "addition": addition,
  1848. "total": total,
  1849. })
  1850. } else {
  1851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1852. }
  1853. }
  1854. func (c *ManagerCenterApiController) DeleteAddition() {
  1855. id, _ := c.GetInt64("id", 0)
  1856. err := service.DeleteAdditionById(id)
  1857. if err == nil {
  1858. c.ServeSuccessJSON(map[string]interface{}{
  1859. "msg": "删除成功",
  1860. })
  1861. } else {
  1862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1863. }
  1864. }
  1865. func (c *ManagerCenterApiController) GetAddition() {
  1866. id, _ := c.GetInt64("id", 0)
  1867. addition, err := service.FindAdditionById(id)
  1868. if err == nil {
  1869. c.ServeSuccessJSON(map[string]interface{}{
  1870. "addition": addition,
  1871. })
  1872. } else {
  1873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1874. }
  1875. }
  1876. func (c *ManagerCenterApiController) CreateDiagnose() {
  1877. class_name := c.GetString("class_name")
  1878. content_code := c.GetString("content_code")
  1879. country_code := c.GetString("country_code")
  1880. country_content_name := c.GetString("country_content_name")
  1881. remark := c.GetString("remark")
  1882. pinyin := c.GetString("pinyin")
  1883. wubi := c.GetString("wubi")
  1884. if len(class_name) <= 0 {
  1885. utils.ErrorLog("len(class_name) == 0")
  1886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1887. return
  1888. }
  1889. if len(content_code) <= 0 {
  1890. utils.ErrorLog("len(content_code) == 0")
  1891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1892. return
  1893. }
  1894. adminUserInfo := c.GetAdminUserInfo()
  1895. dealer := models.HisXtDiagnoseConfig{
  1896. ClassName: class_name,
  1897. ContentCode: content_code,
  1898. CountryCode: country_code,
  1899. CountryContentName: country_content_name,
  1900. Ctime: time.Now().Unix(),
  1901. Mtime: time.Now().Unix(),
  1902. Remark: remark,
  1903. UserOrgId: adminUserInfo.CurrentOrgId,
  1904. Status: 1,
  1905. Pinyin: pinyin,
  1906. Wubi: wubi,
  1907. }
  1908. err, dealers := service.AddSigleDiagnose(&dealer)
  1909. if err == nil {
  1910. redis := service.RedisClient()
  1911. defer redis.Close()
  1912. diagnose_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_diagnose"
  1913. redis.Set(diagnose_keys, "", time.Second*60*60*18)
  1914. c.ServeSuccessJSON(map[string]interface{}{
  1915. "sick": dealers,
  1916. })
  1917. } else {
  1918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1919. }
  1920. }
  1921. func (c *ManagerCenterApiController) ModifyDiagnose() {
  1922. id, _ := c.GetInt64("id", 0)
  1923. class_name := c.GetString("class_name")
  1924. content_code := c.GetString("content_code")
  1925. country_code := c.GetString("country_code")
  1926. country_content_name := c.GetString("country_content_name")
  1927. remark := c.GetString("remark")
  1928. pinyin := c.GetString("pinyin")
  1929. wubi := c.GetString("wubi")
  1930. if id <= 0 {
  1931. utils.ErrorLog("id == 0")
  1932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1933. return
  1934. }
  1935. if len(class_name) <= 0 {
  1936. utils.ErrorLog("len(class_name) == 0")
  1937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1938. return
  1939. }
  1940. if len(content_code) <= 0 {
  1941. utils.ErrorLog("len(content_code) == 0")
  1942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1943. return
  1944. }
  1945. adminUserInfo := c.GetAdminUserInfo()
  1946. dealer := models.HisXtDiagnoseConfig{
  1947. ID: id,
  1948. ClassName: class_name,
  1949. ContentCode: content_code,
  1950. CountryCode: country_code,
  1951. CountryContentName: country_content_name,
  1952. Ctime: time.Now().Unix(),
  1953. Mtime: time.Now().Unix(),
  1954. Remark: remark,
  1955. UserOrgId: adminUserInfo.CurrentOrgId,
  1956. Pinyin: pinyin,
  1957. Wubi: wubi,
  1958. Status: 1,
  1959. }
  1960. err := service.ModifyDiagnose(&dealer)
  1961. if err == nil {
  1962. redis := service.RedisClient()
  1963. defer redis.Close()
  1964. diagnose_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_diagnose"
  1965. redis.Set(diagnose_keys, "", time.Second*60*60*18)
  1966. c.ServeSuccessJSON(map[string]interface{}{
  1967. "sick": dealer,
  1968. })
  1969. } else {
  1970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1971. }
  1972. }
  1973. func (c *ManagerCenterApiController) GetDiagnoseList() {
  1974. page, _ := c.GetInt64("page", 1)
  1975. limit, _ := c.GetInt64("limit", 7)
  1976. adminUserInfo := c.GetAdminUserInfo()
  1977. mzSick, total, err := service.FindAllDiagnoseList(adminUserInfo.CurrentOrgId, page, limit)
  1978. if err == nil {
  1979. c.ServeSuccessJSON(map[string]interface{}{
  1980. "sick": mzSick,
  1981. "total": total,
  1982. })
  1983. } else {
  1984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1985. }
  1986. }
  1987. func (c *ManagerCenterApiController) DeleteDiagnose() {
  1988. id, _ := c.GetInt64("id", 0)
  1989. err := service.DeleteDiagnoseById(id)
  1990. if err == nil {
  1991. redis := service.RedisClient()
  1992. defer redis.Close()
  1993. diagnose_keys := strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + "_diagnose"
  1994. redis.Set(diagnose_keys, "", time.Second*60*60*18)
  1995. c.ServeSuccessJSON(map[string]interface{}{
  1996. "msg": "删除成功",
  1997. })
  1998. } else {
  1999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2000. }
  2001. }
  2002. func (c *ManagerCenterApiController) GetDiagnose() {
  2003. id, _ := c.GetInt64("id", 0)
  2004. mzSick, err := service.FindDiagnoseById(id)
  2005. if err == nil {
  2006. c.ServeSuccessJSON(map[string]interface{}{
  2007. "sick": mzSick,
  2008. })
  2009. } else {
  2010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2011. }
  2012. }
  2013. func (c *ManagerCenterApiController) GetAllDrugList() {
  2014. orgId := c.GetAdminUserInfo().CurrentOrgId
  2015. list, err := service.GetAllDrugList(orgId)
  2016. manufacturerList, _ := service.GetAllManufacturerList(orgId)
  2017. dealerList, _ := service.GetAllDealerList(orgId)
  2018. if err == nil {
  2019. c.ServeSuccessJSON(map[string]interface{}{
  2020. "list": list,
  2021. "manufacturerList": manufacturerList,
  2022. "dealerList": dealerList,
  2023. })
  2024. } else {
  2025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2026. }
  2027. }
  2028. func (c *ManagerCenterApiController) GetSearchDrugList() {
  2029. keyword := c.GetString("keyword")
  2030. orgId := c.GetAdminUserInfo().CurrentOrgId
  2031. list, err := service.GetSearchDrugList(keyword, orgId)
  2032. manufacturerList, _ := service.GetAllManufacturerList(orgId)
  2033. dealerList, _ := service.GetAllDealerList(orgId)
  2034. if err == nil {
  2035. c.ServeSuccessJSON(map[string]interface{}{
  2036. "list": list,
  2037. "manufacturerList": manufacturerList,
  2038. "dealerList": dealerList,
  2039. })
  2040. } else {
  2041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2042. }
  2043. }