manager_center_api_controller.go 73KB

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