manager_center_api_controller.go 68KB

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