manager_center_api_controller.go 77KB

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