manager_center_api_controller.go 68KB

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