manager_center_api_controller.go 69KB

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