manager_center_api_controller.go 71KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225
  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. good_unit, _ := c.GetInt64("good_unit", -1)
  1311. buy_price, _ := c.GetFloat("buy_price", 0)
  1312. sell_price, _ := c.GetFloat("sell_price", 0)
  1313. remark := c.GetString("remark")
  1314. manufacturer, _ := c.GetInt64("manufacturer", 0)
  1315. dealer, _ := c.GetInt64("dealer", 0)
  1316. expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
  1317. stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
  1318. is_reuse, _ := c.GetInt64("is_reuse", 0)
  1319. good_name := c.GetString("good_name")
  1320. pinyin := c.GetString("pinyin")
  1321. wubi := c.GetString("wubi")
  1322. good_kind, _ := c.GetInt64("good_kind", 0)
  1323. medical_insurance_level, _ := c.GetInt64("medical_insurance_level", 0)
  1324. retail_price, _ := c.GetFloat("retail_price", 0)
  1325. medical_insurance_number := c.GetString("medical_insurance_number")
  1326. is_special_diseases, _ := c.GetInt64("is_special_diseases", 0)
  1327. is_record, _ := c.GetInt64("is_record")
  1328. statistics_category, _ := c.GetInt64("statistics_category")
  1329. good_status := c.GetString("good_status")
  1330. default_count, _ := c.GetInt64("default_count")
  1331. sign, _ := c.GetInt64("sign")
  1332. is_default, _ := c.GetInt64("is_default")
  1333. is_charge_use, _ := c.GetInt64("is_charge_use")
  1334. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  1335. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  1336. sort, _ := c.GetInt64("sort")
  1337. is_doctor_use, _ := c.GetInt64("is_doctor_use")
  1338. agent := c.GetString("agent")
  1339. good_number := c.GetString("good_number")
  1340. social_security_directory_code := c.GetString("social_security_directory_code")
  1341. production_type := c.GetString("production_type")
  1342. special_medical := c.GetString("special_medical")
  1343. min_number, _ := c.GetInt64("min_number")
  1344. packing_unit := c.GetString("packing_unit")
  1345. packing_price, _ := c.GetFloat("packing_price")
  1346. min_unit := c.GetString("min_unit")
  1347. default_count_unit := c.GetString("default_count_unit")
  1348. adminUserInfo := c.GetAdminUserInfo()
  1349. totals := service.FindGoodInfoByNameTwo(specification_name, adminUserInfo.CurrentOrgId, good_id, good_name)
  1350. if totals > 0 {
  1351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
  1352. return
  1353. }
  1354. total := service.FindAllGoodInfoTotal(adminUserInfo.CurrentOrgId)
  1355. code := strconv.FormatInt(total+1, 10)
  1356. code = "24000000" + code
  1357. goodInfo := models.GoodInfo{
  1358. GoodCode: code,
  1359. SpecificationName: specification_name,
  1360. GoodTypeId: good_id,
  1361. GoodUnit: good_unit,
  1362. BuyPrice: buy_price,
  1363. SellPrice: sell_price,
  1364. Remark: remark,
  1365. Ctime: time.Now().Unix(),
  1366. Manufacturer: manufacturer,
  1367. Dealer: dealer,
  1368. ExpiryDateWarnDayCount: expiry_date_warn_day_count,
  1369. StockWarnCount: stock_warn_count,
  1370. IsReuse: is_reuse,
  1371. Status: 1,
  1372. OrgId: adminUserInfo.CurrentOrgId,
  1373. Creater: adminUserInfo.AdminUser.Id,
  1374. GoodName: good_name,
  1375. Pinyin: pinyin,
  1376. Wubi: wubi,
  1377. GoodKind: good_kind,
  1378. MedicalInsuranceNumber: medical_insurance_number,
  1379. IsSpecialDiseases: is_special_diseases,
  1380. IsRecord: is_record,
  1381. StatisticsCategory: statistics_category,
  1382. GoodStatus: good_status,
  1383. DefaultCount: default_count,
  1384. Sign: sign,
  1385. IsDefault: is_default,
  1386. IsChargeUse: is_charge_use,
  1387. IsChargePredict: is_charge_predict,
  1388. IsStatisticsWork: is_statistics_work,
  1389. Sort: sort,
  1390. IsDoctorUse: is_doctor_use,
  1391. Agent: agent,
  1392. GoodNumber: good_number,
  1393. MedicalInsuranceLevel: medical_insurance_level,
  1394. RetailPrice: retail_price,
  1395. SocialSecurityDirectoryCode: social_security_directory_code,
  1396. ProductionType: production_type,
  1397. SpecialMedical: special_medical,
  1398. MinNumber: min_number,
  1399. PackingUnit: packing_unit,
  1400. PackingPrice: packing_price,
  1401. DefaultCountUnit: default_count_unit,
  1402. MinUnit: min_unit,
  1403. }
  1404. err, goodInfos := service.AddSigleGoodInfo(&goodInfo)
  1405. if err == nil {
  1406. c.ServeSuccessJSON(map[string]interface{}{
  1407. "goodInfo": goodInfos,
  1408. })
  1409. } else {
  1410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1411. }
  1412. }
  1413. func (c *ManagerCenterApiController) ModifyGoodInfo() {
  1414. id, _ := c.GetInt64("id", 0)
  1415. good_id, _ := c.GetInt64("good_id", 0)
  1416. specification_name := c.GetString("specification_name")
  1417. good_unit, _ := c.GetInt64("good_unit", -1)
  1418. buy_price, _ := c.GetFloat("buy_price", 0)
  1419. sell_price, _ := c.GetFloat("sell_price", 0)
  1420. remark := c.GetString("remark")
  1421. manufacturer, _ := c.GetInt64("manufacturer", 0)
  1422. dealer, _ := c.GetInt64("dealer", 0)
  1423. expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
  1424. stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
  1425. is_reuse, _ := c.GetInt64("is_reuse", 0)
  1426. code := c.GetString("good_code")
  1427. good_name := c.GetString("good_name")
  1428. pinyin := c.GetString("pinyin")
  1429. wubi := c.GetString("wubi")
  1430. good_kind, _ := c.GetInt64("good_kind", 0)
  1431. medical_insurance_level, _ := c.GetInt64("medical_insurance_level", 0)
  1432. retail_price, _ := c.GetFloat("retail_price", 0)
  1433. medical_insurance_number := c.GetString("medical_insurance_number")
  1434. is_special_diseases, _ := c.GetInt64("is_special_diseases", 0)
  1435. is_record, _ := c.GetInt64("is_record")
  1436. statistics_category, _ := c.GetInt64("statistics_category")
  1437. good_status := c.GetString("good_status")
  1438. default_count, _ := c.GetInt64("default_count")
  1439. sign, _ := c.GetInt64("sign")
  1440. is_default, _ := c.GetInt64("is_default")
  1441. is_charge_use, _ := c.GetInt64("is_charge_use")
  1442. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  1443. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  1444. sort, _ := c.GetInt64("sort")
  1445. is_doctor_use, _ := c.GetInt64("is_doctor_use")
  1446. agent := c.GetString("agent")
  1447. good_number := c.GetString("good_number")
  1448. social_security_directory_code := c.GetString("social_security_directory_code")
  1449. production_type := c.GetString("production_type")
  1450. special_medical := c.GetString("special_medical")
  1451. min_number, _ := c.GetInt64("min_number")
  1452. packing_unit := c.GetString("packing_unit")
  1453. packing_price, _ := c.GetFloat("packing_price")
  1454. default_count_unit := c.GetString("default_count_unit")
  1455. min_unit := c.GetString("min_unit")
  1456. total, _ := c.GetFloat("total")
  1457. adminUserInfo := c.GetAdminUserInfo()
  1458. goodInfo := models.GoodInfo{
  1459. ID: id,
  1460. GoodCode: code,
  1461. SpecificationName: specification_name,
  1462. GoodTypeId: good_id,
  1463. GoodUnit: good_unit,
  1464. BuyPrice: buy_price,
  1465. SellPrice: sell_price,
  1466. Remark: remark,
  1467. Mtime: time.Now().Unix(),
  1468. Manufacturer: manufacturer,
  1469. Dealer: dealer,
  1470. ExpiryDateWarnDayCount: expiry_date_warn_day_count,
  1471. StockWarnCount: stock_warn_count,
  1472. IsReuse: is_reuse,
  1473. Status: 1,
  1474. OrgId: adminUserInfo.CurrentOrgId,
  1475. Modifier: adminUserInfo.AdminUser.Id,
  1476. GoodName: good_name,
  1477. Pinyin: pinyin,
  1478. Wubi: wubi,
  1479. GoodKind: good_kind,
  1480. MedicalInsuranceNumber: medical_insurance_number,
  1481. IsSpecialDiseases: is_special_diseases,
  1482. IsRecord: is_record,
  1483. StatisticsCategory: statistics_category,
  1484. GoodStatus: good_status,
  1485. DefaultCount: default_count,
  1486. Sign: sign,
  1487. IsDefault: is_default,
  1488. IsChargeUse: is_charge_use,
  1489. IsChargePredict: is_charge_predict,
  1490. IsStatisticsWork: is_statistics_work,
  1491. Sort: sort,
  1492. IsDoctorUse: is_doctor_use,
  1493. Agent: agent,
  1494. GoodNumber: good_number,
  1495. MedicalInsuranceLevel: medical_insurance_level,
  1496. RetailPrice: retail_price,
  1497. SpecialMedical: special_medical,
  1498. SocialSecurityDirectoryCode: social_security_directory_code,
  1499. ProductionType: production_type,
  1500. MinNumber: min_number,
  1501. PackingUnit: packing_unit,
  1502. PackingPrice: packing_price,
  1503. DefaultCountUnit: default_count_unit,
  1504. MinUnit: min_unit,
  1505. Total: total,
  1506. }
  1507. totals := service.FindGoodInfoByNameOne(specification_name, adminUserInfo.CurrentOrgId, good_id, id, good_name)
  1508. if totals > 0 {
  1509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
  1510. return
  1511. }
  1512. err, goodInfos := service.ModifyGoodInfo(&goodInfo)
  1513. if err == nil {
  1514. c.ServeSuccessJSON(map[string]interface{}{
  1515. "goodInfo": goodInfos,
  1516. })
  1517. } else {
  1518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1519. }
  1520. }
  1521. func (c *ManagerCenterApiController) GetGoodInfoList() {
  1522. page, _ := c.GetInt64("page", 1)
  1523. limit, _ := c.GetInt64("limit", 7)
  1524. keyword := c.GetString("keyword")
  1525. is_use, _ := c.GetInt64("is_use")
  1526. is_charge, _ := c.GetInt64("is_charge")
  1527. good_kind, _ := c.GetInt64("good_kind")
  1528. is_mark, _ := c.GetInt64("is_mark")
  1529. manufacturer, _ := c.GetInt64("manufacturer")
  1530. adminUserInfo := c.GetAdminUserInfo()
  1531. goodInfos, total, err := service.FindGoodInfoList(adminUserInfo.CurrentOrgId, page, limit, keyword, is_use, is_charge, good_kind, is_mark, manufacturer)
  1532. if err == nil {
  1533. c.ServeSuccessJSON(map[string]interface{}{
  1534. "list": goodInfos,
  1535. "total": total,
  1536. })
  1537. } else {
  1538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1539. }
  1540. }
  1541. func (c *ManagerCenterApiController) DeleteGoodInfo() {
  1542. id, _ := c.GetInt64("id", 0)
  1543. adminUserInfo := c.GetAdminUserInfo()
  1544. total, _ := service.FindWarehouseInfoTotalByGoodId(id)
  1545. total2, _ := service.FindWarehouseOutInfoTotalByGoodId(id)
  1546. if total > 0 {
  1547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
  1548. return
  1549. }
  1550. if total2 > 0 {
  1551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
  1552. return
  1553. }
  1554. err := service.DeleteGoodInfoById(id, adminUserInfo.AdminUser.Id)
  1555. if err == nil {
  1556. c.ServeSuccessJSON(map[string]interface{}{
  1557. "msg": "删除成功",
  1558. })
  1559. } else {
  1560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1561. }
  1562. }
  1563. func (c *ManagerCenterApiController) GetGoodInfoByGoodId() {
  1564. id, _ := c.GetInt64("id", 0)
  1565. goodInfo, err := service.FindGoodInfoByGoodId(id)
  1566. if err == nil {
  1567. c.ServeSuccessJSON(map[string]interface{}{
  1568. "list": goodInfo,
  1569. })
  1570. } else {
  1571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1572. }
  1573. }
  1574. func (c *ManagerCenterApiController) GetGoodInfoById() {
  1575. id, _ := c.GetInt64("id", 0)
  1576. goodInfo, err := service.FindGoodInfoById(id)
  1577. if err == nil {
  1578. c.ServeSuccessJSON(map[string]interface{}{
  1579. "goodInfo": goodInfo,
  1580. })
  1581. } else {
  1582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1583. }
  1584. }
  1585. func (c *ManagerCenterApiController) GetMedicineInsurancePercent() {
  1586. adminUser := c.GetAdminUserInfo()
  1587. type_id, _ := c.GetInt64("type_id", 0)
  1588. module, _ := c.GetInt64("module", 0)
  1589. mip, err := service.GetLastMedicineInsurance(adminUser.CurrentOrgId, type_id, module)
  1590. if err == nil {
  1591. c.ServeSuccessJSON(map[string]interface{}{
  1592. "mip": mip,
  1593. })
  1594. } else {
  1595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1596. }
  1597. }
  1598. func (c *ManagerCenterApiController) CreateMZSick() {
  1599. class_name := c.GetString("class_name")
  1600. content_code := c.GetString("content_code")
  1601. country_code := c.GetString("country_code")
  1602. country_content_name := c.GetString("country_content_name")
  1603. remark := c.GetString("remark")
  1604. pinyin := c.GetString("pinyin")
  1605. wubi := c.GetString("wubi")
  1606. if len(class_name) <= 0 {
  1607. utils.ErrorLog("len(class_name) == 0")
  1608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1609. return
  1610. }
  1611. if len(content_code) <= 0 {
  1612. utils.ErrorLog("len(content_code) == 0")
  1613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1614. return
  1615. }
  1616. adminUserInfo := c.GetAdminUserInfo()
  1617. dealer := models.OutpatientServiceSick{
  1618. ClassName: class_name,
  1619. ContentCode: content_code,
  1620. CountryCode: country_code,
  1621. CountryContentName: country_content_name,
  1622. Ctime: time.Now().Unix(),
  1623. Mtime: time.Now().Unix(),
  1624. Remark: remark,
  1625. UserOrgId: adminUserInfo.CurrentOrgId,
  1626. Status: 1,
  1627. Pinyin: pinyin,
  1628. Wubi: wubi,
  1629. }
  1630. err, dealers := service.AddSigleMZSick(&dealer)
  1631. if err == nil {
  1632. c.ServeSuccessJSON(map[string]interface{}{
  1633. "sick": dealers,
  1634. })
  1635. } else {
  1636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1637. }
  1638. }
  1639. func (c *ManagerCenterApiController) ModifyMZSick() {
  1640. id, _ := c.GetInt64("id", 0)
  1641. class_name := c.GetString("class_name")
  1642. content_code := c.GetString("content_code")
  1643. country_code := c.GetString("country_code")
  1644. country_content_name := c.GetString("country_content_name")
  1645. remark := c.GetString("remark")
  1646. pinyin := c.GetString("pinyin")
  1647. wubi := c.GetString("wubi")
  1648. if id <= 0 {
  1649. utils.ErrorLog("id == 0")
  1650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1651. return
  1652. }
  1653. if len(class_name) <= 0 {
  1654. utils.ErrorLog("len(class_name) == 0")
  1655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1656. return
  1657. }
  1658. if len(content_code) <= 0 {
  1659. utils.ErrorLog("len(content_code) == 0")
  1660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1661. return
  1662. }
  1663. adminUserInfo := c.GetAdminUserInfo()
  1664. dealer := models.OutpatientServiceSick{
  1665. ID: id,
  1666. ClassName: class_name,
  1667. ContentCode: content_code,
  1668. CountryCode: country_code,
  1669. CountryContentName: country_content_name,
  1670. Ctime: time.Now().Unix(),
  1671. Mtime: time.Now().Unix(),
  1672. Remark: remark,
  1673. UserOrgId: adminUserInfo.CurrentOrgId,
  1674. Pinyin: pinyin,
  1675. Wubi: wubi,
  1676. Status: 1,
  1677. }
  1678. err := service.ModifyMZSick(&dealer)
  1679. if err == nil {
  1680. c.ServeSuccessJSON(map[string]interface{}{
  1681. "sick": dealer,
  1682. })
  1683. } else {
  1684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1685. }
  1686. }
  1687. func (c *ManagerCenterApiController) GetMZSickList() {
  1688. page, _ := c.GetInt64("page", 1)
  1689. limit, _ := c.GetInt64("limit", 7)
  1690. adminUserInfo := c.GetAdminUserInfo()
  1691. mzSick, total, err := service.FindAllMZSickList(adminUserInfo.CurrentOrgId, page, limit)
  1692. if err == nil {
  1693. c.ServeSuccessJSON(map[string]interface{}{
  1694. "sick": mzSick,
  1695. "total": total,
  1696. })
  1697. } else {
  1698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1699. }
  1700. }
  1701. func (c *ManagerCenterApiController) DeleteMZSick() {
  1702. id, _ := c.GetInt64("id", 0)
  1703. err := service.DeleteMZSickById(id)
  1704. if err == nil {
  1705. c.ServeSuccessJSON(map[string]interface{}{
  1706. "msg": "删除成功",
  1707. })
  1708. } else {
  1709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1710. }
  1711. }
  1712. func (c *ManagerCenterApiController) GetMZSick() {
  1713. id, _ := c.GetInt64("id", 0)
  1714. mzSick, err := service.FindMZSickById(id)
  1715. if err == nil {
  1716. c.ServeSuccessJSON(map[string]interface{}{
  1717. "sick": mzSick,
  1718. })
  1719. } else {
  1720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1721. }
  1722. }
  1723. func (c *ManagerCenterApiController) DeleteBaseDrugById() {
  1724. id, _ := c.GetInt64("id")
  1725. //查询入库单
  1726. _, errcode := service.GetDrugWareoutInfo(id)
  1727. if errcode == gorm.ErrRecordNotFound {
  1728. //查询出库单
  1729. _, errcodes := service.GetDrugWareOutById(id)
  1730. if errcodes == gorm.ErrRecordNotFound {
  1731. //删除
  1732. service.DeleteBaseDrugById(id)
  1733. returnData := make(map[string]interface{}, 0)
  1734. returnData["msg"] = "ok"
  1735. c.ServeSuccessJSON(returnData)
  1736. return
  1737. } else if errcodes == nil {
  1738. c.ServeFailJsonSend(enums.ErrorCodeDataException, "已出库")
  1739. return
  1740. }
  1741. } else if errcode == nil {
  1742. c.ServeFailJsonSend(enums.ErrorCodeDataException, "已入库")
  1743. return
  1744. }
  1745. }
  1746. func (c *ManagerCenterApiController) CreateAddition() {
  1747. name := c.GetString("name")
  1748. code := c.GetString("code")
  1749. //price, _ := c.GetFloat("price")
  1750. price := c.GetString("price")
  1751. price_float, _ := strconv.ParseFloat(price, 64)
  1752. if len(name) <= 0 {
  1753. utils.ErrorLog("len(name) == 0")
  1754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1755. return
  1756. }
  1757. //if len(code) <= 0 {
  1758. // utils.ErrorLog("len(code) == 0")
  1759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1760. // return
  1761. //}
  1762. adminUserInfo := c.GetAdminUserInfo()
  1763. addition := models.XtHisAddtionConfig{
  1764. Name: name,
  1765. Code: code,
  1766. Status: 1,
  1767. Price: price_float,
  1768. Ctime: time.Now().Unix(),
  1769. Mtime: time.Now().Unix(),
  1770. UserOrgId: adminUserInfo.CurrentOrgId,
  1771. }
  1772. err, additions := service.AddSigleAddition(&addition)
  1773. if err == nil {
  1774. c.ServeSuccessJSON(map[string]interface{}{
  1775. "addition": additions,
  1776. })
  1777. } else {
  1778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1779. }
  1780. }
  1781. func (c *ManagerCenterApiController) ModifyAddition() {
  1782. id, _ := c.GetInt64("id", 0)
  1783. name := c.GetString("name")
  1784. code := c.GetString("code")
  1785. price, _ := c.GetFloat("price")
  1786. if id <= 0 {
  1787. utils.ErrorLog("id == 0")
  1788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1789. return
  1790. }
  1791. if len(name) <= 0 {
  1792. utils.ErrorLog("len(class_name) == 0")
  1793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1794. return
  1795. }
  1796. //if len(code) <= 0 {
  1797. // utils.ErrorLog("len(content_code) == 0")
  1798. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1799. // return
  1800. //}
  1801. adminUserInfo := c.GetAdminUserInfo()
  1802. addition := models.XtHisAddtionConfig{
  1803. ID: id,
  1804. Name: name,
  1805. Code: code,
  1806. Ctime: time.Now().Unix(),
  1807. Mtime: time.Now().Unix(),
  1808. UserOrgId: adminUserInfo.CurrentOrgId,
  1809. Price: price,
  1810. Status: 1,
  1811. }
  1812. err := service.ModifyAddition(&addition)
  1813. if err == nil {
  1814. c.ServeSuccessJSON(map[string]interface{}{
  1815. "addition": addition,
  1816. })
  1817. } else {
  1818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1819. }
  1820. }
  1821. func (c *ManagerCenterApiController) GetAdditionList() {
  1822. page, _ := c.GetInt64("page", 1)
  1823. limit, _ := c.GetInt64("limit", 7)
  1824. adminUserInfo := c.GetAdminUserInfo()
  1825. addition, total, err := service.FindAllAdditionList(adminUserInfo.CurrentOrgId, page, limit)
  1826. if err == nil {
  1827. c.ServeSuccessJSON(map[string]interface{}{
  1828. "addition": addition,
  1829. "total": total,
  1830. })
  1831. } else {
  1832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1833. }
  1834. }
  1835. func (c *ManagerCenterApiController) DeleteAddition() {
  1836. id, _ := c.GetInt64("id", 0)
  1837. err := service.DeleteAdditionById(id)
  1838. if err == nil {
  1839. c.ServeSuccessJSON(map[string]interface{}{
  1840. "msg": "删除成功",
  1841. })
  1842. } else {
  1843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1844. }
  1845. }
  1846. func (c *ManagerCenterApiController) GetAddition() {
  1847. id, _ := c.GetInt64("id", 0)
  1848. addition, err := service.FindAdditionById(id)
  1849. if err == nil {
  1850. c.ServeSuccessJSON(map[string]interface{}{
  1851. "addition": addition,
  1852. })
  1853. } else {
  1854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1855. }
  1856. }
  1857. func (c *ManagerCenterApiController) CreateDiagnose() {
  1858. class_name := c.GetString("class_name")
  1859. content_code := c.GetString("content_code")
  1860. country_code := c.GetString("country_code")
  1861. country_content_name := c.GetString("country_content_name")
  1862. remark := c.GetString("remark")
  1863. pinyin := c.GetString("pinyin")
  1864. wubi := c.GetString("wubi")
  1865. if len(class_name) <= 0 {
  1866. utils.ErrorLog("len(class_name) == 0")
  1867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1868. return
  1869. }
  1870. if len(content_code) <= 0 {
  1871. utils.ErrorLog("len(content_code) == 0")
  1872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1873. return
  1874. }
  1875. adminUserInfo := c.GetAdminUserInfo()
  1876. dealer := models.HisXtDiagnoseConfig{
  1877. ClassName: class_name,
  1878. ContentCode: content_code,
  1879. CountryCode: country_code,
  1880. CountryContentName: country_content_name,
  1881. Ctime: time.Now().Unix(),
  1882. Mtime: time.Now().Unix(),
  1883. Remark: remark,
  1884. UserOrgId: adminUserInfo.CurrentOrgId,
  1885. Status: 1,
  1886. Pinyin: pinyin,
  1887. Wubi: wubi,
  1888. }
  1889. err, dealers := service.AddSigleDiagnose(&dealer)
  1890. if err == nil {
  1891. c.ServeSuccessJSON(map[string]interface{}{
  1892. "sick": dealers,
  1893. })
  1894. } else {
  1895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1896. }
  1897. }
  1898. func (c *ManagerCenterApiController) ModifyDiagnose() {
  1899. id, _ := c.GetInt64("id", 0)
  1900. class_name := c.GetString("class_name")
  1901. content_code := c.GetString("content_code")
  1902. country_code := c.GetString("country_code")
  1903. country_content_name := c.GetString("country_content_name")
  1904. remark := c.GetString("remark")
  1905. pinyin := c.GetString("pinyin")
  1906. wubi := c.GetString("wubi")
  1907. if id <= 0 {
  1908. utils.ErrorLog("id == 0")
  1909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1910. return
  1911. }
  1912. if len(class_name) <= 0 {
  1913. utils.ErrorLog("len(class_name) == 0")
  1914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1915. return
  1916. }
  1917. if len(content_code) <= 0 {
  1918. utils.ErrorLog("len(content_code) == 0")
  1919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1920. return
  1921. }
  1922. adminUserInfo := c.GetAdminUserInfo()
  1923. dealer := models.HisXtDiagnoseConfig{
  1924. ID: id,
  1925. ClassName: class_name,
  1926. ContentCode: content_code,
  1927. CountryCode: country_code,
  1928. CountryContentName: country_content_name,
  1929. Ctime: time.Now().Unix(),
  1930. Mtime: time.Now().Unix(),
  1931. Remark: remark,
  1932. UserOrgId: adminUserInfo.CurrentOrgId,
  1933. Pinyin: pinyin,
  1934. Wubi: wubi,
  1935. Status: 1,
  1936. }
  1937. err := service.ModifyDiagnose(&dealer)
  1938. if err == nil {
  1939. c.ServeSuccessJSON(map[string]interface{}{
  1940. "sick": dealer,
  1941. })
  1942. } else {
  1943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1944. }
  1945. }
  1946. func (c *ManagerCenterApiController) GetDiagnoseList() {
  1947. page, _ := c.GetInt64("page", 1)
  1948. limit, _ := c.GetInt64("limit", 7)
  1949. adminUserInfo := c.GetAdminUserInfo()
  1950. mzSick, total, err := service.FindAllDiagnoseList(adminUserInfo.CurrentOrgId, page, limit)
  1951. if err == nil {
  1952. c.ServeSuccessJSON(map[string]interface{}{
  1953. "sick": mzSick,
  1954. "total": total,
  1955. })
  1956. } else {
  1957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1958. }
  1959. }
  1960. func (c *ManagerCenterApiController) DeleteDiagnose() {
  1961. id, _ := c.GetInt64("id", 0)
  1962. err := service.DeleteDiagnoseById(id)
  1963. if err == nil {
  1964. c.ServeSuccessJSON(map[string]interface{}{
  1965. "msg": "删除成功",
  1966. })
  1967. } else {
  1968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1969. }
  1970. }
  1971. func (c *ManagerCenterApiController) GetDiagnose() {
  1972. id, _ := c.GetInt64("id", 0)
  1973. mzSick, err := service.FindDiagnoseById(id)
  1974. if err == nil {
  1975. c.ServeSuccessJSON(map[string]interface{}{
  1976. "sick": mzSick,
  1977. })
  1978. } else {
  1979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1980. }
  1981. }
  1982. func (c *ManagerCenterApiController) GetAllDrugList() {
  1983. orgId := c.GetAdminUserInfo().CurrentOrgId
  1984. list, err := service.GetAllDrugList(orgId)
  1985. manufacturerList, _ := service.GetAllManufacturerList(orgId)
  1986. if err == nil {
  1987. c.ServeSuccessJSON(map[string]interface{}{
  1988. "list": list,
  1989. "manufacturerList": manufacturerList,
  1990. })
  1991. } else {
  1992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1993. }
  1994. }
  1995. func (c *ManagerCenterApiController) GetSearchDrugList() {
  1996. keyword := c.GetString("keyword")
  1997. orgId := c.GetAdminUserInfo().CurrentOrgId
  1998. list, err := service.GetSearchDrugList(keyword, orgId)
  1999. manufacturerList, _ := service.GetAllManufacturerList(orgId)
  2000. if err == nil {
  2001. c.ServeSuccessJSON(map[string]interface{}{
  2002. "list": list,
  2003. "manufacturerList": manufacturerList,
  2004. })
  2005. } else {
  2006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2007. }
  2008. }