manager_center_api_controller.go 71KB

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