manager_center_api_controller.go 71KB

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