manager_center_api_controller.go 73KB

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