public_api_controller.go 42KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "encoding/json"
  7. "fmt"
  8. "os"
  9. "path"
  10. "runtime"
  11. "strconv"
  12. "strings"
  13. "time"
  14. "github.com/astaxie/beego"
  15. )
  16. type PublicApiController struct {
  17. BaseAPIController
  18. }
  19. func PublicApiRegistRouters() {
  20. beego.Router("/api/public/getadviceconfig", &PublicApiController{}, "Get:GetDoctorAdviceConfig")
  21. beego.Router("/api/public/servertime", &PublicApiController{}, "Get:GetServerTime")
  22. beego.Router("/api/app/release", &PublicApiController{}, "Get:AppRelease")
  23. beego.Router("/api/get", &PublicApiController{}, "Get:GetJson")
  24. beego.Router("/api/public/handledata", &PublicApiController{}, "get:HandleData")
  25. beego.Router("/api/public/handlestockdata", &PublicApiController{}, "get:HandleStockData")
  26. beego.Router("/api/public/handlecomdata", &PublicApiController{}, "get:HandleComData")
  27. beego.Router("/hello", &PublicApiController{}, "get:HandleComData")
  28. beego.Router("/handel", &PublicApiController{}, "get:HandleHIS")
  29. }
  30. func (c *PublicApiController) GetDoctorAdviceConfig() {
  31. drugs, _, _ := service.GetPublicDrugDics()
  32. drugways, _, _ := service.GetPublicDrugWayDics()
  33. efs, _, _ := service.GetPublicExecutionFrequencyDics()
  34. c.ServeSuccessJSON(map[string]interface{}{
  35. "drugs": drugs,
  36. "drugways": drugways,
  37. "efs": efs,
  38. })
  39. }
  40. func (c *PublicApiController) GetServerTime() {
  41. timeNow := time.Now()
  42. timeNowStamp := timeNow.Unix()
  43. timeNowStr := timeNow.Format("2006-01-02 15:04:05")
  44. c.ServeSuccessJSON(map[string]interface{}{
  45. "time": timeNowStr,
  46. "timestamp": timeNowStamp,
  47. })
  48. }
  49. func (c *PublicApiController) AppRelease() {
  50. // appId := c.GetString("appid")
  51. version := c.GetString("version")
  52. appType, _ := c.GetInt64("app_type", 0)
  53. appVersion, err := service.GetAppVersionByAppType(appType)
  54. if err != nil {
  55. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  56. return
  57. }
  58. if appVersion == nil {
  59. c.ServeSuccessJSON(map[string]interface{}{
  60. "version": nil,
  61. "state": 2,
  62. })
  63. return
  64. }
  65. state := strings.Compare(version, appVersion.Version)
  66. // state := 1
  67. if state < 0 {
  68. c.ServeSuccessJSON(map[string]interface{}{
  69. "version": appVersion,
  70. "state": appVersion.Status,
  71. })
  72. return
  73. }
  74. c.ServeSuccessJSON(map[string]interface{}{
  75. "version": nil,
  76. "state": 2,
  77. })
  78. return
  79. }
  80. func (this *PublicApiController) GetJson() {
  81. type Global struct {
  82. DeviceSN string
  83. Version string
  84. Timestamp string
  85. InterfaceSource string
  86. }
  87. type RBPResultModel struct {
  88. Sys string
  89. Dia string
  90. HR string
  91. MeasureTime string
  92. }
  93. type ScannerResultModel struct {
  94. Code string
  95. }
  96. type IDCardResultModel struct {
  97. IDCardNo string
  98. UserName string
  99. Age string
  100. Female string
  101. Male string
  102. SocialSecurityNo string
  103. }
  104. type JsonTemp struct {
  105. Global Global
  106. RBPResultModel RBPResultModel
  107. ScannerResultModel ScannerResultModel
  108. IDCardResultModel IDCardResultModel
  109. }
  110. var person JsonTemp
  111. err3 := json.Unmarshal([]byte(this.GetString("params")), &person)
  112. fmt.Println(err3)
  113. fmt.Println(person.Global)
  114. //temp := JsonTemp{
  115. // Global:Global{
  116. // DeviceSN:"1122",
  117. // Version:"1122",
  118. // Timestamp:"1222",
  119. // InterfaceSource:"1233",
  120. // },
  121. // RBPResultModel: RBPResultModel{
  122. // Sys:"12",
  123. // Dia:"22",
  124. // HR:"23",
  125. // MeasureTime:"123",
  126. // },
  127. // ScannerResultModel:ScannerResultModel{
  128. // Code:"1233",
  129. // },
  130. // IDCardResultModel:IDCardResultModel{
  131. // IDCardNo:"123",
  132. // UserName:"123",
  133. // Age:"123",
  134. // Female:"123",
  135. // Male:"123",
  136. // SocialSecurityNo:"123",
  137. // },
  138. //}
  139. //
  140. //jsonBytes, err := json.Marshal(temp)
  141. //if err != nil {
  142. // fmt.Println(err)
  143. //}
  144. //fmt.Println(string(jsonBytes))
  145. }
  146. func (c *PublicApiController) HandleData() {
  147. //service.HandleData()
  148. org_app, _ := service.GetAllAppOrg()
  149. //org_role, _ := service.GetAllRole()
  150. //
  151. //var org_ids []int64
  152. for _, apps := range org_app {
  153. xt_org_app, _ := service.GetAppByType(int64(apps.OrgId), 3)
  154. //org_app_6, _ := service.GetAppByType(int64(apps.OrgId), 6)
  155. //org_app_7, _ := service.GetAppByType(int64(apps.OrgId), 7)
  156. //org_app_8, _ := service.GetAppByType(int64(apps.OrgId), 8)
  157. //org_app_9, _ := service.GetAppByType(int64(apps.OrgId), 9)
  158. //org_app_10, _ := service.GetAppByType(int64(apps.OrgId), 10)
  159. //org_app_11, _ := service.GetAppByType(int64(apps.OrgId), 11)
  160. //org_app_12, _ := service.GetAppByType(int64(apps.OrgId), 12)
  161. //org_app_13, _ := service.GetAppByType(int64(apps.OrgId), 13)
  162. //org_app_14, _ := service.GetAppByType(int64(apps.OrgId), 14)
  163. //org_app_15, _ := service.GetAppByType(int64(apps.OrgId), 15)
  164. //org_app_16, _ := service.GetAppByType(int64(apps.OrgId), 16)
  165. //org_app_17, _ := service.GetAppByType(int64(apps.OrgId), 17)
  166. org_app_18, _ := service.GetAppByType(int64(apps.OrgId), 18)
  167. var xt_temp_org_app *models.OrgApp
  168. //var mall_temp_org_app *models.OrgApp
  169. if xt_org_app == nil || xt_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  170. app, _ := service.GetOrgAppA(0, 3)
  171. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  172. if org == nil || org.Id == 0 {
  173. continue
  174. }
  175. app.Id = 0
  176. app.OrgId = apps.OrgId
  177. app.Creator = int(org.Creator)
  178. app.Number = 0
  179. app.Status = 1
  180. app.ModifyTime = time.Now().Unix()
  181. app.CreateTime = time.Now().Unix()
  182. service.CreateOrgApp(app)
  183. xt_temp_org_app = app
  184. } else {
  185. xt_temp_org_app = xt_org_app
  186. }
  187. //if scrm_org_app == nil || scrm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  188. //
  189. // app, _ := service.GetOrgAppA(0, 1)
  190. // //org, _ := service.GetOrgById(int64(12))
  191. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  192. // if org == nil || org.Id == 0 {
  193. // continue
  194. // }
  195. //
  196. //
  197. // app.OrgId = apps.OrgId
  198. // app.Id = 0
  199. //
  200. // app.Creator = int(org.Creator)
  201. // app.Number = 0
  202. // app.Status = 1
  203. // app.ModifyTime = time.Now().Unix()
  204. // app.CreateTime = time.Now().Unix()
  205. // service.CreateOrgApp(app)
  206. //
  207. //}
  208. //
  209. //if cdm_org_app == nil || cdm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  210. // app, _ := service.GetOrgAppA(0, 4)
  211. // //org, _ := service.GetOrgById(int64(12))
  212. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  213. // if org == nil || org.Id == 0 {
  214. // continue
  215. // }
  216. //
  217. //
  218. // app.OrgId = apps.OrgId
  219. // app.Creator = int(org.Creator)
  220. // app.Number = 0
  221. // app.Id = 0
  222. //
  223. // app.Status = 1
  224. // app.ModifyTime = time.Now().Unix()
  225. // app.CreateTime = time.Now().Unix()
  226. // service.CreateOrgApp(app)
  227. //}
  228. //
  229. //if mall_org_app == nil || mall_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  230. // app, _ := service.GetOrgAppA(0, 5)
  231. // //org, _ := service.GetOrgById(int64(12))
  232. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  233. //
  234. // if org == nil || org.Id == 0 {
  235. // continue
  236. // }
  237. //
  238. // app.OrgId = apps.OrgId
  239. // app.Creator = int(org.Creator)
  240. // app.Number = 0
  241. // app.Id = 0
  242. //
  243. // app.Status = 1
  244. // app.ModifyTime = time.Now().Unix()
  245. // app.CreateTime = time.Now().Unix()
  246. // service.CreateOrgApp(app)
  247. // mall_temp_org_app = app
  248. //} else {
  249. // mall_temp_org_app = mall_org_app
  250. //}
  251. //
  252. //if org_app_16 == nil || org_app_16.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  253. // app, _ := service.GetOrgAppA(0, 16)
  254. // //org, _ := service.GetOrgById(int64(12))
  255. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  256. // if org == nil || org.Id == 0 {
  257. // continue
  258. // }
  259. //
  260. // app.OrgId = apps.OrgId
  261. // app.Creator = int(org.Creator)
  262. // app.Number = 11
  263. // app.Id = 0
  264. // app.Status = 1
  265. // app.ModifyTime = time.Now().Unix()
  266. // app.CreateTime = time.Now().Unix()
  267. // app.Pid = xt_temp_org_app.Id
  268. // service.CreateOrgApp(app)
  269. //
  270. //}
  271. //
  272. //if org_app_17 == nil || org_app_17.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  273. // app, _ := service.GetOrgAppA(0, 17)
  274. // //org, _ := service.GetOrgById(int64(12))
  275. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  276. // if org == nil || org.Id == 0 {
  277. // continue
  278. // }
  279. //
  280. // app.OrgId = apps.OrgId
  281. // app.Creator = int(org.Creator)
  282. // app.Number = 12
  283. // app.Id = 0
  284. // app.Status = 1
  285. // app.ModifyTime = time.Now().Unix()
  286. // app.CreateTime = time.Now().Unix()
  287. // app.Pid = xt_temp_org_app.Id
  288. // service.CreateOrgApp(app)
  289. //
  290. //}
  291. if org_app_18 == nil || org_app_18.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  292. app, _ := service.GetOrgAppA(0, 18)
  293. //org, _ := service.GetOrgById(int64(12))
  294. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  295. if org == nil || org.Id == 0 {
  296. continue
  297. }
  298. app.OrgId = apps.OrgId
  299. app.Creator = int(org.Creator)
  300. app.Number = 5
  301. app.Id = 0
  302. app.Status = 1
  303. app.ModifyTime = time.Now().Unix()
  304. app.CreateTime = time.Now().Unix()
  305. app.Pid = xt_temp_org_app.Id
  306. service.CreateOrgApp(app)
  307. }
  308. //if org_app_7 == nil || org_app_7.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  309. // app, _ := service.GetOrgAppA(0, 7)
  310. // //org, _ := service.GetOrgById(int64(12))
  311. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  312. // if org == nil || org.Id == 0 {
  313. // continue
  314. // }
  315. //
  316. //
  317. // app.OrgId = apps.OrgId
  318. // app.Creator = int(org.Creator)
  319. // app.Number = 2
  320. // app.Status = 2
  321. // app.Id = 0
  322. //
  323. // app.ModifyTime = time.Now().Unix()
  324. // app.CreateTime = time.Now().Unix()
  325. // app.Pid = xt_temp_org_app.Id
  326. //
  327. // service.CreateOrgApp(app)
  328. //}
  329. //if org_app_8 == nil || org_app_8.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  330. // app, _ := service.GetOrgAppA(0, 8)
  331. // //org, _ := service.GetOrgById(int64(12))
  332. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  333. // if org == nil || org.Id == 0 {
  334. // continue
  335. // }
  336. //
  337. //
  338. // app.OrgId = apps.OrgId
  339. // app.Creator = int(org.Creator)
  340. // app.Number = 3
  341. // app.Id = 0
  342. //
  343. // app.Pid = mall_temp_org_app.Id
  344. //
  345. // app.Status = 1
  346. // app.ModifyTime = time.Now().Unix()
  347. // app.CreateTime = time.Now().Unix()
  348. // service.CreateOrgApp(app)
  349. //}
  350. //if org_app_9 == nil || org_app_9.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  351. // app, _ := service.GetOrgAppA(0, 9)
  352. // //org, _ := service.GetOrgById(int64(12))
  353. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  354. // if org == nil || org.Id == 0 {
  355. // continue
  356. // }
  357. //
  358. //
  359. // app.OrgId = apps.OrgId
  360. // app.Pid = xt_temp_org_app.Id
  361. //
  362. // app.Creator = int(org.Creator)
  363. // app.Number = 4
  364. // app.Id = 0
  365. //
  366. // app.Status = 1
  367. // app.ModifyTime = time.Now().Unix()
  368. // app.CreateTime = time.Now().Unix()
  369. // service.CreateOrgApp(app)
  370. //
  371. //}
  372. //if org_app_10 == nil || org_app_10.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  373. // app, _ := service.GetOrgAppA(0, 10)
  374. // //org, _ := service.GetOrgById(int64(12))
  375. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  376. // if org == nil || org.Id == 0 {
  377. // continue
  378. // }
  379. //
  380. //
  381. // app.OrgId = apps.OrgId
  382. // app.Creator = int(org.Creator)
  383. // app.Pid = xt_temp_org_app.Id
  384. //
  385. // app.Number = 5
  386. // app.Id = 0
  387. //
  388. // app.Status = 1
  389. // app.ModifyTime = time.Now().Unix()
  390. // app.CreateTime = time.Now().Unix()
  391. // service.CreateOrgApp(app)
  392. //}
  393. //if org_app_11 == nil || org_app_11.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  394. // app, _ := service.GetOrgAppA(0, 11)
  395. // //org, _ := service.GetOrgById(int64(12))
  396. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  397. // if org == nil || org.Id == 0 {
  398. // continue
  399. // }
  400. //
  401. //
  402. // app.OrgId = apps.OrgId
  403. // app.Creator = int(org.Creator)
  404. // app.Pid = xt_temp_org_app.Id
  405. // app.Id = 0
  406. //
  407. // app.Number = 6
  408. // app.Status = 1
  409. // app.ModifyTime = time.Now().Unix()
  410. // app.CreateTime = time.Now().Unix()
  411. // service.CreateOrgApp(app)
  412. //}
  413. //if org_app_12 == nil || org_app_12.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  414. // app, _ := service.GetOrgAppA(0, 12)
  415. // //org, _ := service.GetOrgById(int64(12))
  416. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  417. // if org == nil || org.Id == 0 {
  418. // continue
  419. // }
  420. //
  421. //
  422. // app.OrgId = apps.OrgId
  423. // app.Creator = int(org.Creator)
  424. // app.Pid = xt_temp_org_app.Id
  425. // app.Number = 7
  426. // app.Status = 1
  427. // app.Id = 0
  428. //
  429. // app.ModifyTime = time.Now().Unix()
  430. // app.CreateTime = time.Now().Unix()
  431. // service.CreateOrgApp(app)
  432. //}
  433. //if org_app_13 == nil || org_app_13.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  434. // app, _ := service.GetOrgAppA(0, 13)
  435. // //org, _ := service.GetOrgById(int64(12))
  436. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  437. // if org == nil || org.Id == 0 {
  438. // continue
  439. // }
  440. //
  441. //
  442. // app.OrgId = apps.OrgId
  443. // app.Creator = int(org.Creator)
  444. // app.Pid = xt_temp_org_app.Id
  445. // app.Number = 8
  446. // app.Id = 0
  447. // app.Status = 1
  448. // app.ModifyTime = time.Now().Unix()
  449. // app.CreateTime = time.Now().Unix()
  450. // service.CreateOrgApp(app)
  451. //}
  452. //if org_app_14 == nil || org_app_14.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  453. // app, _ := service.GetOrgAppA(0, 14)
  454. // //org, _ := service.GetOrgById(int64(12))
  455. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  456. // if org == nil || org.Id == 0 {
  457. // continue
  458. // }
  459. //
  460. //
  461. // app.OrgId = apps.OrgId
  462. // app.Creator = int(org.Creator)
  463. // app.Pid = xt_temp_org_app.Id
  464. // app.Id = 0
  465. // app.Number = 9
  466. // app.Status = 1
  467. // app.ModifyTime = time.Now().Unix()
  468. // app.CreateTime = time.Now().Unix()
  469. // service.CreateOrgApp(app)
  470. //}
  471. //if org_app_15 == nil || org_app_15.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  472. // app, _ := service.GetOrgAppA(0, 15)
  473. // //org, _ := service.GetOrgById(int64(12))
  474. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  475. // if org == nil || org.Id == 0 {
  476. // continue
  477. // }
  478. //
  479. // app.OrgId = apps.OrgId
  480. // app.Creator = int(org.Creator)
  481. // app.Pid = xt_temp_org_app.Id
  482. // app.Number = 10
  483. // app.Status = 1
  484. // app.Id = 0
  485. // app.ModifyTime = time.Now().Unix()
  486. // app.CreateTime = time.Now().Unix()
  487. // service.CreateOrgApp(app)
  488. //}
  489. }
  490. //for _, role := range org_role {
  491. // org_ids = append(org_ids, role.OrgId)
  492. //}
  493. //
  494. //
  495. ////创建内置角色
  496. //InitRoleAndPurviews(org_ids)
  497. //var org_id int = 0
  498. //管理员
  499. //app_roles := service.GetAllUserRoleByUserTypeOne(org_id)
  500. //for _, item := range app_roles{
  501. // var ids string
  502. // if len(item.RoleIds) == 0{
  503. // ids = strconv.FormatInt( item.RoleId,10)
  504. // }else{
  505. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  506. // }
  507. // service.UpdateRoleIds(item.Id, ids)
  508. //}
  509. //护士医生
  510. //app_roles2 := service.GetAllUserRoleByUserTypeOther()
  511. // for _, item := range app_roles2{
  512. // var ids string
  513. // if len(item.RoleIds) == 0{
  514. // ids = strconv.FormatInt( item.RoleId,10)
  515. // }else{
  516. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  517. // }
  518. // if item.UserType == 2{
  519. // role := service.FindRoleByUserTypeOne(item.OrgId)
  520. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  521. //
  522. // } else if item.UserType == 3{
  523. // role := service.FindRoleByUserTypeTwo(item.OrgId)
  524. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  525. // }
  526. // service.UpdateRoleIds(item.Id, ids)
  527. // }
  528. //c.ServeSuccessJSON(map[string]interface{}{
  529. // "msg": "ok",
  530. //})
  531. }
  532. func InitRoleAndPurviews(org_ids []int64) {
  533. roles := LoadRoleConfig("./role.json").Roles
  534. for _, org_id := range org_ids {
  535. app, _ := service.GetOrgAppB(org_id, 3)
  536. role, _ := service.GetSystemRole(org_id)
  537. if app == nil || app.Id == 0 {
  538. continue
  539. }
  540. if len(role) == 0 {
  541. for _, item := range roles {
  542. role := &models.Role{
  543. RoleName: item.RoleName,
  544. RoleIntro: item.RoleIntroduction,
  545. Creator: 0,
  546. OrgId: org_id,
  547. AppId: app.Id,
  548. IsSuperAdmin: false,
  549. Status: 1,
  550. CreateTime: time.Now().Unix(),
  551. ModifyTime: time.Now().Unix(),
  552. Number: item.Number,
  553. IsSystem: item.IsSystem,
  554. }
  555. err := service.CreateOrgRoleB(role)
  556. if err == nil {
  557. purview := &models.RolePurview{
  558. RoleId: role.Id,
  559. OrgId: org_id,
  560. AppId: role.AppId,
  561. PurviewIds: item.PurviewIds,
  562. Status: 1,
  563. CreateTime: time.Now().Unix(),
  564. ModifyTime: time.Now().Unix(),
  565. }
  566. func_purview := &models.SgjUserRoleFuncPurview{
  567. RoleId: role.Id,
  568. OrgId: org_id,
  569. AppId: role.AppId,
  570. PurviewIds: item.FuncIds,
  571. Status: 1,
  572. Ctime: time.Now().Unix(),
  573. Mtime: time.Now().Unix(),
  574. }
  575. service.CreateRolePurviewB(purview)
  576. service.CreateFuncRolePurviewB(func_purview)
  577. }
  578. }
  579. }
  580. }
  581. }
  582. type RoleConfig struct {
  583. Roles []*models.VMUserRoleAndPurview "json:roles"
  584. }
  585. func LoadRoleConfig(dataFile string) *RoleConfig {
  586. var config RoleConfig
  587. _, filename, _, _ := runtime.Caller(1)
  588. datapath := path.Join(path.Dir(filename), dataFile)
  589. config_file, err := os.Open(datapath)
  590. if err != nil {
  591. emit("Failed to open config file '%s': %s\n", datapath, err)
  592. return &config
  593. }
  594. fi, _ := config_file.Stat()
  595. buffer := make([]byte, fi.Size())
  596. _, err = config_file.Read(buffer)
  597. buffer, err = StripComments(buffer) //去掉注释
  598. if err != nil {
  599. emit("Failed to strip comments from json: %s\n", err)
  600. return &config
  601. }
  602. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  603. err = json.Unmarshal(buffer, &config) //解析json格式数据
  604. if err != nil {
  605. emit("Failed unmarshalling json: %s\n", err)
  606. return &config
  607. }
  608. return &config
  609. }
  610. type GoodTypesConfig struct {
  611. GoodTypes []*models.VMGoodsType "json:list"
  612. }
  613. func LoadGoodTypeConfig(dataFile string) *GoodTypesConfig {
  614. var config GoodTypesConfig
  615. _, filename, _, _ := runtime.Caller(1)
  616. datapath := path.Join(path.Dir(filename), dataFile)
  617. config_file, err := os.Open(datapath)
  618. if err != nil {
  619. emit("Failed to open config file '%s': %s\n", datapath, err)
  620. return &config
  621. }
  622. fi, _ := config_file.Stat()
  623. buffer := make([]byte, fi.Size())
  624. _, err = config_file.Read(buffer)
  625. buffer, err = StripComments(buffer) //去掉注释
  626. if err != nil {
  627. emit("Failed to strip comments from json: %s\n", err)
  628. return &config
  629. }
  630. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  631. err = json.Unmarshal(buffer, &config) //解析json格式数据
  632. if err != nil {
  633. emit("Failed unmarshalling json: %s\n", err)
  634. return &config
  635. }
  636. return &config
  637. }
  638. func (c *PublicApiController) HandleStockData() {
  639. org, _ := service.FindAllOrgByImportType()
  640. for _, item := range org {
  641. if item.Id != 3907 || item.Id != 9779 || item.Id != 9883 {
  642. goodTypes := &models.GoodsType{
  643. TypeCode: "14000000",
  644. TypeName: "穿刺针",
  645. Remark: "",
  646. Ctime: time.Now().Unix(),
  647. Mtime: time.Now().Unix(),
  648. Creater: 0,
  649. Modifier: 0,
  650. OrgId: item.Id,
  651. Status: 1,
  652. Type: 1,
  653. Number: 1,
  654. }
  655. service.AddSigleGoodType(goodTypes)
  656. goodTypes1 := &models.GoodsType{
  657. TypeCode: "14000001",
  658. TypeName: "透析器",
  659. Remark: "",
  660. Ctime: time.Now().Unix(),
  661. Mtime: time.Now().Unix(),
  662. Creater: 0,
  663. Modifier: 0,
  664. OrgId: item.Id,
  665. Status: 1,
  666. Type: 1,
  667. Number: 2,
  668. }
  669. service.AddSigleGoodType(goodTypes1)
  670. goodTypes2 := &models.GoodsType{
  671. TypeCode: "14000002",
  672. TypeName: "灌流器",
  673. Remark: "",
  674. Ctime: time.Now().Unix(),
  675. Mtime: time.Now().Unix(),
  676. Creater: 0,
  677. Modifier: 0,
  678. OrgId: item.Id,
  679. Status: 1,
  680. Type: 1,
  681. Number: 3,
  682. }
  683. service.AddSigleGoodType(goodTypes2)
  684. goodTypes3 := &models.GoodsType{
  685. TypeCode: "14000003",
  686. TypeName: "血路管",
  687. Remark: "",
  688. Ctime: time.Now().Unix(),
  689. Mtime: time.Now().Unix(),
  690. Creater: 0,
  691. Modifier: 0,
  692. OrgId: item.Id,
  693. Status: 1,
  694. Type: 1,
  695. Number: 4,
  696. }
  697. service.AddSigleGoodType(goodTypes3)
  698. goodTypes4 := &models.GoodsType{
  699. TypeCode: "14000004",
  700. TypeName: "血滤补液管",
  701. Remark: "",
  702. Ctime: time.Now().Unix(),
  703. Mtime: time.Now().Unix(),
  704. Creater: 0,
  705. Modifier: 0,
  706. OrgId: item.Id,
  707. Status: 1,
  708. Type: 1,
  709. Number: 5,
  710. }
  711. service.AddSigleGoodType(goodTypes4)
  712. goodTypes5 := &models.GoodsType{
  713. TypeCode: "14000005",
  714. TypeName: "注射器",
  715. Remark: "",
  716. Ctime: time.Now().Unix(),
  717. Mtime: time.Now().Unix(),
  718. Creater: 0,
  719. Modifier: 0,
  720. OrgId: item.Id,
  721. Status: 1,
  722. Type: 1,
  723. Number: 6,
  724. }
  725. service.AddSigleGoodType(goodTypes5)
  726. goodTypes6 := &models.GoodsType{
  727. TypeCode: "14000006",
  728. TypeName: "护理包(内瘘穿刺包)",
  729. Remark: "",
  730. Ctime: time.Now().Unix(),
  731. Mtime: time.Now().Unix(),
  732. Creater: 0,
  733. Modifier: 0,
  734. OrgId: item.Id,
  735. Status: 1,
  736. Type: 1,
  737. Number: 7,
  738. }
  739. service.AddSigleGoodType(goodTypes6)
  740. goodTypes7 := &models.GoodsType{
  741. TypeCode: "14000007",
  742. TypeName: "细菌过滤器",
  743. Remark: "",
  744. Ctime: time.Now().Unix(),
  745. Mtime: time.Now().Unix(),
  746. Creater: 0,
  747. Modifier: 0,
  748. OrgId: item.Id,
  749. Status: 1,
  750. Type: 1,
  751. Number: 8,
  752. }
  753. service.AddSigleGoodType(goodTypes7)
  754. goodTypes8 := &models.GoodsType{
  755. TypeCode: "14000008",
  756. TypeName: "血液透析干粉",
  757. Remark: "",
  758. Ctime: time.Now().Unix(),
  759. Mtime: time.Now().Unix(),
  760. Creater: 0,
  761. Modifier: 0,
  762. OrgId: item.Id,
  763. Status: 1,
  764. Type: 1,
  765. Number: 9,
  766. }
  767. service.AddSigleGoodType(goodTypes8)
  768. goodTypes9 := &models.GoodsType{
  769. TypeCode: "14000009",
  770. TypeName: "A液",
  771. Remark: "",
  772. Ctime: time.Now().Unix(),
  773. Mtime: time.Now().Unix(),
  774. Creater: 0,
  775. Modifier: 0,
  776. OrgId: item.Id,
  777. Status: 1,
  778. Type: 1,
  779. Number: 10,
  780. }
  781. service.AddSigleGoodType(goodTypes9)
  782. goodTypes10 := &models.GoodsType{
  783. TypeCode: "14000010",
  784. TypeName: "B液",
  785. Remark: "",
  786. Ctime: time.Now().Unix(),
  787. Mtime: time.Now().Unix(),
  788. Creater: 0,
  789. Modifier: 0,
  790. OrgId: item.Id,
  791. Status: 1,
  792. Type: 1,
  793. Number: 11,
  794. }
  795. service.AddSigleGoodType(goodTypes10)
  796. goodTypes11 := &models.GoodsType{
  797. TypeCode: "14000011",
  798. TypeName: "导管包",
  799. Remark: "",
  800. Ctime: time.Now().Unix(),
  801. Mtime: time.Now().Unix(),
  802. Creater: 0,
  803. Modifier: 0,
  804. OrgId: item.Id,
  805. Status: 1,
  806. Type: 1,
  807. Number: 12,
  808. }
  809. service.AddSigleGoodType(goodTypes11)
  810. goodTypes12 := &models.GoodsType{
  811. TypeCode: "14000012",
  812. TypeName: "血液透析导管",
  813. Remark: "",
  814. Ctime: time.Now().Unix(),
  815. Mtime: time.Now().Unix(),
  816. Creater: 0,
  817. Modifier: 0,
  818. OrgId: item.Id,
  819. Status: 1,
  820. Type: 1,
  821. Number: 13,
  822. }
  823. service.AddSigleGoodType(goodTypes12)
  824. }
  825. }
  826. }
  827. func (c *PublicApiController) HandleComData() {
  828. org_ids := []int64{3907, 9779, 9883}
  829. for _, id := range org_ids {
  830. //查处所有处方记录
  831. prescriptions, _ := service.FindAllPrescription(id)
  832. if id == 3907 {
  833. for _, item := range prescriptions {
  834. if item.Niprocart > 0 {
  835. before := &models.DialysisBeforePrepare{
  836. UserOrgId: id,
  837. PatientId: item.PatientId,
  838. RecordDate: item.RecordDate,
  839. Count: 1,
  840. Ctime: item.RecordDate,
  841. Mtime: item.RecordDate,
  842. Creater: item.Creater,
  843. Modifier: item.Creater,
  844. Status: 1,
  845. }
  846. before.GoodId = item.Niprocart
  847. before.GoodTypeId = 241
  848. service.AddSigleDialysisBeforePre(before)
  849. }
  850. if item.Jms > 0 {
  851. before := &models.DialysisBeforePrepare{
  852. UserOrgId: id,
  853. PatientId: item.PatientId,
  854. RecordDate: item.RecordDate,
  855. Count: 1,
  856. Ctime: item.RecordDate,
  857. Mtime: item.RecordDate,
  858. Creater: item.Creater,
  859. Modifier: item.Creater,
  860. Status: 1,
  861. }
  862. before.GoodId = item.Jms
  863. before.GoodTypeId = 233
  864. service.AddSigleDialysisBeforePre(before)
  865. }
  866. if item.FistulaNeedleSet > 0 {
  867. before := &models.DialysisBeforePrepare{
  868. UserOrgId: id,
  869. PatientId: item.PatientId,
  870. RecordDate: item.RecordDate,
  871. Count: 1,
  872. Ctime: item.RecordDate,
  873. Mtime: item.RecordDate,
  874. Creater: item.Creater,
  875. Modifier: item.Creater,
  876. Status: 1,
  877. }
  878. before.GoodId = item.FistulaNeedleSet
  879. before.GoodTypeId = 233
  880. service.AddSigleDialysisBeforePre(before)
  881. }
  882. if item.FistulaNeedleSet16 > 0 {
  883. before := &models.DialysisBeforePrepare{
  884. UserOrgId: id,
  885. PatientId: item.PatientId,
  886. RecordDate: item.RecordDate,
  887. Count: 1,
  888. Ctime: item.RecordDate,
  889. Mtime: item.RecordDate,
  890. Creater: item.Creater,
  891. Modifier: item.Creater,
  892. Status: 1,
  893. }
  894. before.GoodId = item.FistulaNeedleSet16
  895. before.GoodTypeId = 233
  896. service.AddSigleDialysisBeforePre(before)
  897. }
  898. if item.Hemoperfusion > 0 {
  899. before := &models.DialysisBeforePrepare{
  900. UserOrgId: id,
  901. PatientId: item.PatientId,
  902. RecordDate: item.RecordDate,
  903. Count: 1,
  904. Ctime: item.RecordDate,
  905. Mtime: item.RecordDate,
  906. Creater: item.Creater,
  907. Modifier: item.Creater,
  908. Status: 1,
  909. }
  910. before.GoodId = item.Hemoperfusion
  911. before.GoodTypeId = 235
  912. service.AddSigleDialysisBeforePre(before)
  913. }
  914. if item.DialyserSterilised > 0 {
  915. before := &models.DialysisBeforePrepare{
  916. UserOrgId: id,
  917. PatientId: item.PatientId,
  918. RecordDate: item.RecordDate,
  919. Count: 1,
  920. Ctime: item.RecordDate,
  921. Mtime: item.RecordDate,
  922. Creater: item.Creater,
  923. Modifier: item.Creater,
  924. Status: 1,
  925. }
  926. before.GoodId = item.DialyserSterilised
  927. before.GoodTypeId = 234
  928. service.AddSigleDialysisBeforePre(before)
  929. }
  930. if item.Filtryzer > 0 {
  931. before := &models.DialysisBeforePrepare{
  932. UserOrgId: id,
  933. PatientId: item.PatientId,
  934. RecordDate: item.RecordDate,
  935. Count: 1,
  936. Ctime: item.RecordDate,
  937. Mtime: item.RecordDate,
  938. Creater: item.Creater,
  939. Modifier: item.Creater,
  940. Status: 1,
  941. }
  942. before.GoodId = item.Filtryzer
  943. before.GoodTypeId = 234
  944. service.AddSigleDialysisBeforePre(before)
  945. }
  946. if item.Dialyzers > 0 {
  947. before := &models.DialysisBeforePrepare{
  948. UserOrgId: id,
  949. PatientId: item.PatientId,
  950. RecordDate: item.RecordDate,
  951. Count: 1,
  952. Ctime: item.RecordDate,
  953. Mtime: item.RecordDate,
  954. Creater: item.Creater,
  955. Modifier: item.Creater,
  956. Status: 1,
  957. }
  958. before.GoodId = item.Dialyzers
  959. before.GoodTypeId = 234
  960. service.AddSigleDialysisBeforePre(before)
  961. }
  962. if item.Injector > 0 {
  963. before := &models.DialysisBeforePrepare{
  964. UserOrgId: id,
  965. PatientId: item.PatientId,
  966. RecordDate: item.RecordDate,
  967. Count: 1,
  968. Ctime: item.RecordDate,
  969. Mtime: item.RecordDate,
  970. Creater: item.Creater,
  971. Modifier: item.Creater,
  972. Status: 1,
  973. }
  974. before.GoodId = item.Injector
  975. before.GoodTypeId = 238
  976. service.AddSigleDialysisBeforePre(before)
  977. }
  978. if item.Bloodlines > 0 {
  979. before := &models.DialysisBeforePrepare{
  980. UserOrgId: id,
  981. PatientId: item.PatientId,
  982. RecordDate: item.RecordDate,
  983. Count: 1,
  984. Ctime: item.RecordDate,
  985. Mtime: item.RecordDate,
  986. Creater: item.Creater,
  987. Modifier: item.Creater,
  988. Status: 1,
  989. }
  990. before.GoodId = item.Bloodlines
  991. before.GoodTypeId = 236
  992. service.AddSigleDialysisBeforePre(before)
  993. }
  994. if item.TubingHemodialysis > 0 {
  995. before := &models.DialysisBeforePrepare{
  996. UserOrgId: id,
  997. PatientId: item.PatientId,
  998. RecordDate: item.RecordDate,
  999. Count: 1,
  1000. Ctime: item.RecordDate,
  1001. Mtime: item.RecordDate,
  1002. Creater: item.Creater,
  1003. Modifier: item.Creater,
  1004. Status: 1,
  1005. }
  1006. before.GoodId = item.TubingHemodialysis
  1007. before.GoodTypeId = 237
  1008. service.AddSigleDialysisBeforePre(before)
  1009. }
  1010. if item.Package > 0 {
  1011. before := &models.DialysisBeforePrepare{
  1012. UserOrgId: id,
  1013. PatientId: item.PatientId,
  1014. RecordDate: item.RecordDate,
  1015. Count: 1,
  1016. Ctime: item.RecordDate,
  1017. Mtime: item.RecordDate,
  1018. Creater: item.Creater,
  1019. Modifier: item.Creater,
  1020. Status: 1,
  1021. }
  1022. before.GoodId = item.Package
  1023. before.GoodTypeId = 239
  1024. service.AddSigleDialysisBeforePre(before)
  1025. }
  1026. if item.ALiquid > 0 {
  1027. before := &models.DialysisBeforePrepare{
  1028. UserOrgId: id,
  1029. PatientId: item.PatientId,
  1030. RecordDate: item.RecordDate,
  1031. Count: 1,
  1032. Ctime: item.RecordDate,
  1033. Mtime: item.RecordDate,
  1034. Creater: item.Creater,
  1035. Modifier: item.Creater,
  1036. Status: 1,
  1037. }
  1038. before.GoodId = item.ALiquid
  1039. before.GoodTypeId = 242
  1040. service.AddSigleDialysisBeforePre(before)
  1041. }
  1042. }
  1043. } else if id == 9779 {
  1044. for _, item := range prescriptions {
  1045. if item.Niprocart > 0 {
  1046. before := &models.DialysisBeforePrepare{
  1047. UserOrgId: id,
  1048. PatientId: item.PatientId,
  1049. RecordDate: item.RecordDate,
  1050. Count: 1,
  1051. Ctime: item.RecordDate,
  1052. Mtime: item.RecordDate,
  1053. Creater: item.Creater,
  1054. Modifier: item.Creater,
  1055. Status: 1,
  1056. }
  1057. before.GoodId = item.Niprocart
  1058. before.GoodTypeId = 254
  1059. service.AddSigleDialysisBeforePre(before)
  1060. }
  1061. if item.Jms > 0 {
  1062. before := &models.DialysisBeforePrepare{
  1063. UserOrgId: id,
  1064. PatientId: item.PatientId,
  1065. RecordDate: item.RecordDate,
  1066. Count: 1,
  1067. Ctime: item.RecordDate,
  1068. Mtime: item.RecordDate,
  1069. Creater: item.Creater,
  1070. Modifier: item.Creater,
  1071. Status: 1,
  1072. }
  1073. before.GoodId = item.Jms
  1074. before.GoodTypeId = 246
  1075. service.AddSigleDialysisBeforePre(before)
  1076. }
  1077. if item.FistulaNeedleSet > 0 {
  1078. before := &models.DialysisBeforePrepare{
  1079. UserOrgId: id,
  1080. PatientId: item.PatientId,
  1081. RecordDate: item.RecordDate,
  1082. Count: 1,
  1083. Ctime: item.RecordDate,
  1084. Mtime: item.RecordDate,
  1085. Creater: item.Creater,
  1086. Modifier: item.Creater,
  1087. Status: 1,
  1088. }
  1089. before.GoodId = item.FistulaNeedleSet
  1090. before.GoodTypeId = 246
  1091. service.AddSigleDialysisBeforePre(before)
  1092. }
  1093. if item.FistulaNeedleSet16 > 0 {
  1094. before := &models.DialysisBeforePrepare{
  1095. UserOrgId: id,
  1096. PatientId: item.PatientId,
  1097. RecordDate: item.RecordDate,
  1098. Count: 1,
  1099. Ctime: item.RecordDate,
  1100. Mtime: item.RecordDate,
  1101. Creater: item.Creater,
  1102. Modifier: item.Creater,
  1103. Status: 1,
  1104. }
  1105. before.GoodId = item.FistulaNeedleSet16
  1106. before.GoodTypeId = 246
  1107. service.AddSigleDialysisBeforePre(before)
  1108. }
  1109. if item.Hemoperfusion > 0 {
  1110. before := &models.DialysisBeforePrepare{
  1111. UserOrgId: id,
  1112. PatientId: item.PatientId,
  1113. RecordDate: item.RecordDate,
  1114. Count: 1,
  1115. Ctime: item.RecordDate,
  1116. Mtime: item.RecordDate,
  1117. Creater: item.Creater,
  1118. Modifier: item.Creater,
  1119. Status: 1,
  1120. }
  1121. before.GoodId = item.Hemoperfusion
  1122. before.GoodTypeId = 248
  1123. service.AddSigleDialysisBeforePre(before)
  1124. }
  1125. if item.DialyserSterilised > 0 {
  1126. before := &models.DialysisBeforePrepare{
  1127. UserOrgId: id,
  1128. PatientId: item.PatientId,
  1129. RecordDate: item.RecordDate,
  1130. Count: 1,
  1131. Ctime: item.RecordDate,
  1132. Mtime: item.RecordDate,
  1133. Creater: item.Creater,
  1134. Modifier: item.Creater,
  1135. Status: 1,
  1136. }
  1137. before.GoodId = item.DialyserSterilised
  1138. before.GoodTypeId = 247
  1139. service.AddSigleDialysisBeforePre(before)
  1140. }
  1141. if item.Filtryzer > 0 {
  1142. before := &models.DialysisBeforePrepare{
  1143. UserOrgId: id,
  1144. PatientId: item.PatientId,
  1145. RecordDate: item.RecordDate,
  1146. Count: 1,
  1147. Ctime: item.RecordDate,
  1148. Mtime: item.RecordDate,
  1149. Creater: item.Creater,
  1150. Modifier: item.Creater,
  1151. Status: 1,
  1152. }
  1153. before.GoodId = item.Filtryzer
  1154. before.GoodTypeId = 247
  1155. service.AddSigleDialysisBeforePre(before)
  1156. }
  1157. if item.Dialyzers > 0 {
  1158. before := &models.DialysisBeforePrepare{
  1159. UserOrgId: id,
  1160. PatientId: item.PatientId,
  1161. RecordDate: item.RecordDate,
  1162. Count: 1,
  1163. Ctime: item.RecordDate,
  1164. Mtime: item.RecordDate,
  1165. Creater: item.Creater,
  1166. Modifier: item.Creater,
  1167. Status: 1,
  1168. }
  1169. before.GoodId = item.Dialyzers
  1170. before.GoodTypeId = 247
  1171. service.AddSigleDialysisBeforePre(before)
  1172. }
  1173. if item.Injector > 0 {
  1174. before := &models.DialysisBeforePrepare{
  1175. UserOrgId: id,
  1176. PatientId: item.PatientId,
  1177. RecordDate: item.RecordDate,
  1178. Count: 1,
  1179. Ctime: item.RecordDate,
  1180. Mtime: item.RecordDate,
  1181. Creater: item.Creater,
  1182. Modifier: item.Creater,
  1183. Status: 1,
  1184. }
  1185. before.GoodId = item.Injector
  1186. before.GoodTypeId = 251
  1187. service.AddSigleDialysisBeforePre(before)
  1188. }
  1189. if item.Bloodlines > 0 {
  1190. before := &models.DialysisBeforePrepare{
  1191. UserOrgId: id,
  1192. PatientId: item.PatientId,
  1193. RecordDate: item.RecordDate,
  1194. Count: 1,
  1195. Ctime: item.RecordDate,
  1196. Mtime: item.RecordDate,
  1197. Creater: item.Creater,
  1198. Modifier: item.Creater,
  1199. Status: 1,
  1200. }
  1201. before.GoodId = item.Bloodlines
  1202. before.GoodTypeId = 249
  1203. service.AddSigleDialysisBeforePre(before)
  1204. }
  1205. if item.TubingHemodialysis > 0 {
  1206. before := &models.DialysisBeforePrepare{
  1207. UserOrgId: id,
  1208. PatientId: item.PatientId,
  1209. RecordDate: item.RecordDate,
  1210. Count: 1,
  1211. Ctime: item.RecordDate,
  1212. Mtime: item.RecordDate,
  1213. Creater: item.Creater,
  1214. Modifier: item.Creater,
  1215. Status: 1,
  1216. }
  1217. before.GoodId = item.TubingHemodialysis
  1218. before.GoodTypeId = 250
  1219. service.AddSigleDialysisBeforePre(before)
  1220. }
  1221. if item.Package > 0 {
  1222. before := &models.DialysisBeforePrepare{
  1223. UserOrgId: id,
  1224. PatientId: item.PatientId,
  1225. RecordDate: item.RecordDate,
  1226. Count: 1,
  1227. Ctime: item.RecordDate,
  1228. Mtime: item.RecordDate,
  1229. Creater: item.Creater,
  1230. Modifier: item.Creater,
  1231. Status: 1,
  1232. }
  1233. before.GoodId = item.Package
  1234. before.GoodTypeId = 252
  1235. service.AddSigleDialysisBeforePre(before)
  1236. }
  1237. if item.ALiquid > 0 {
  1238. before := &models.DialysisBeforePrepare{
  1239. UserOrgId: id,
  1240. PatientId: item.PatientId,
  1241. RecordDate: item.RecordDate,
  1242. Count: 1,
  1243. Ctime: item.RecordDate,
  1244. Mtime: item.RecordDate,
  1245. Creater: item.Creater,
  1246. Modifier: item.Creater,
  1247. Status: 1,
  1248. }
  1249. before.GoodId = item.ALiquid
  1250. before.GoodTypeId = 255
  1251. service.AddSigleDialysisBeforePre(before)
  1252. }
  1253. }
  1254. } else if id == 9883 {
  1255. for _, item := range prescriptions {
  1256. if item.Niprocart > 0 {
  1257. before := &models.DialysisBeforePrepare{
  1258. UserOrgId: id,
  1259. PatientId: item.PatientId,
  1260. RecordDate: item.RecordDate,
  1261. Count: 1,
  1262. Ctime: item.RecordDate,
  1263. Mtime: item.RecordDate,
  1264. Creater: item.Creater,
  1265. Modifier: item.Creater,
  1266. Status: 1,
  1267. }
  1268. before.GoodId = item.Niprocart
  1269. before.GoodTypeId = 267
  1270. service.AddSigleDialysisBeforePre(before)
  1271. }
  1272. if item.Jms > 0 {
  1273. before := &models.DialysisBeforePrepare{
  1274. UserOrgId: id,
  1275. PatientId: item.PatientId,
  1276. RecordDate: item.RecordDate,
  1277. Count: 1,
  1278. Ctime: item.RecordDate,
  1279. Mtime: item.RecordDate,
  1280. Creater: item.Creater,
  1281. Modifier: item.Creater,
  1282. Status: 1,
  1283. }
  1284. before.GoodId = item.Jms
  1285. before.GoodTypeId = 259
  1286. service.AddSigleDialysisBeforePre(before)
  1287. }
  1288. if item.FistulaNeedleSet > 0 {
  1289. before := &models.DialysisBeforePrepare{
  1290. UserOrgId: id,
  1291. PatientId: item.PatientId,
  1292. RecordDate: item.RecordDate,
  1293. Count: 1,
  1294. Ctime: item.RecordDate,
  1295. Mtime: item.RecordDate,
  1296. Creater: item.Creater,
  1297. Modifier: item.Creater,
  1298. Status: 1,
  1299. }
  1300. before.GoodId = item.FistulaNeedleSet
  1301. before.GoodTypeId = 259
  1302. service.AddSigleDialysisBeforePre(before)
  1303. }
  1304. if item.FistulaNeedleSet16 > 0 {
  1305. before := &models.DialysisBeforePrepare{
  1306. UserOrgId: id,
  1307. PatientId: item.PatientId,
  1308. RecordDate: item.RecordDate,
  1309. Count: 1,
  1310. Ctime: item.RecordDate,
  1311. Mtime: item.RecordDate,
  1312. Creater: item.Creater,
  1313. Modifier: item.Creater,
  1314. Status: 1,
  1315. }
  1316. before.GoodId = item.FistulaNeedleSet16
  1317. before.GoodTypeId = 259
  1318. service.AddSigleDialysisBeforePre(before)
  1319. }
  1320. if item.Hemoperfusion > 0 {
  1321. before := &models.DialysisBeforePrepare{
  1322. UserOrgId: id,
  1323. PatientId: item.PatientId,
  1324. RecordDate: item.RecordDate,
  1325. Count: 1,
  1326. Ctime: item.RecordDate,
  1327. Mtime: item.RecordDate,
  1328. Creater: item.Creater,
  1329. Modifier: item.Creater,
  1330. Status: 1,
  1331. }
  1332. before.GoodId = item.Hemoperfusion
  1333. before.GoodTypeId = 261
  1334. service.AddSigleDialysisBeforePre(before)
  1335. }
  1336. if item.DialyserSterilised > 0 {
  1337. before := &models.DialysisBeforePrepare{
  1338. UserOrgId: id,
  1339. PatientId: item.PatientId,
  1340. RecordDate: item.RecordDate,
  1341. Count: 1,
  1342. Ctime: item.RecordDate,
  1343. Mtime: item.RecordDate,
  1344. Creater: item.Creater,
  1345. Modifier: item.Creater,
  1346. Status: 1,
  1347. }
  1348. before.GoodId = item.DialyserSterilised
  1349. before.GoodTypeId = 260
  1350. service.AddSigleDialysisBeforePre(before)
  1351. }
  1352. if item.Filtryzer > 0 {
  1353. before := &models.DialysisBeforePrepare{
  1354. UserOrgId: id,
  1355. PatientId: item.PatientId,
  1356. RecordDate: item.RecordDate,
  1357. Count: 1,
  1358. Ctime: item.RecordDate,
  1359. Mtime: item.RecordDate,
  1360. Creater: item.Creater,
  1361. Modifier: item.Creater,
  1362. Status: 1,
  1363. }
  1364. before.GoodId = item.Filtryzer
  1365. before.GoodTypeId = 260
  1366. service.AddSigleDialysisBeforePre(before)
  1367. }
  1368. if item.Dialyzers > 0 {
  1369. before := &models.DialysisBeforePrepare{
  1370. UserOrgId: id,
  1371. PatientId: item.PatientId,
  1372. RecordDate: item.RecordDate,
  1373. Count: 1,
  1374. Ctime: item.RecordDate,
  1375. Mtime: item.RecordDate,
  1376. Creater: item.Creater,
  1377. Modifier: item.Creater,
  1378. Status: 1,
  1379. }
  1380. before.GoodId = item.Dialyzers
  1381. before.GoodTypeId = 260
  1382. service.AddSigleDialysisBeforePre(before)
  1383. }
  1384. if item.Injector > 0 {
  1385. before := &models.DialysisBeforePrepare{
  1386. UserOrgId: id,
  1387. PatientId: item.PatientId,
  1388. RecordDate: item.RecordDate,
  1389. Count: 1,
  1390. Ctime: item.RecordDate,
  1391. Mtime: item.RecordDate,
  1392. Creater: item.Creater,
  1393. Modifier: item.Creater,
  1394. Status: 1,
  1395. }
  1396. before.GoodId = item.Injector
  1397. before.GoodTypeId = 264
  1398. service.AddSigleDialysisBeforePre(before)
  1399. }
  1400. if item.Bloodlines > 0 {
  1401. before := &models.DialysisBeforePrepare{
  1402. UserOrgId: id,
  1403. PatientId: item.PatientId,
  1404. RecordDate: item.RecordDate,
  1405. Count: 1,
  1406. Ctime: item.RecordDate,
  1407. Mtime: item.RecordDate,
  1408. Creater: item.Creater,
  1409. Modifier: item.Creater,
  1410. Status: 1,
  1411. }
  1412. before.GoodId = item.Bloodlines
  1413. before.GoodTypeId = 262
  1414. service.AddSigleDialysisBeforePre(before)
  1415. }
  1416. if item.TubingHemodialysis > 0 {
  1417. before := &models.DialysisBeforePrepare{
  1418. UserOrgId: id,
  1419. PatientId: item.PatientId,
  1420. RecordDate: item.RecordDate,
  1421. Count: 1,
  1422. Ctime: item.RecordDate,
  1423. Mtime: item.RecordDate,
  1424. Creater: item.Creater,
  1425. Modifier: item.Creater,
  1426. Status: 1,
  1427. }
  1428. before.GoodId = item.TubingHemodialysis
  1429. before.GoodTypeId = 263
  1430. service.AddSigleDialysisBeforePre(before)
  1431. }
  1432. if item.Package > 0 {
  1433. before := &models.DialysisBeforePrepare{
  1434. UserOrgId: id,
  1435. PatientId: item.PatientId,
  1436. RecordDate: item.RecordDate,
  1437. Count: 1,
  1438. Ctime: item.RecordDate,
  1439. Mtime: item.RecordDate,
  1440. Creater: item.Creater,
  1441. Modifier: item.Creater,
  1442. Status: 1,
  1443. }
  1444. before.GoodId = item.Package
  1445. before.GoodTypeId = 265
  1446. service.AddSigleDialysisBeforePre(before)
  1447. }
  1448. if item.ALiquid > 0 {
  1449. before := &models.DialysisBeforePrepare{
  1450. UserOrgId: id,
  1451. PatientId: item.PatientId,
  1452. RecordDate: item.RecordDate,
  1453. Count: 1,
  1454. Ctime: item.RecordDate,
  1455. Mtime: item.RecordDate,
  1456. Creater: item.Creater,
  1457. Modifier: item.Creater,
  1458. Status: 1,
  1459. }
  1460. before.GoodId = item.ALiquid
  1461. before.GoodTypeId = 268
  1462. service.AddSigleDialysisBeforePre(before)
  1463. }
  1464. }
  1465. }
  1466. }
  1467. }
  1468. func (c *PublicApiController) HandleHIS() {
  1469. his, _ := service.GetAllHisInfo(9919)
  1470. for _, item := range his {
  1471. fsn := strings.Split(item.FeedetlSn, "-")
  1472. item.FeedetlSn = fsn[0] + "-" + fsn[1] + "-" + strconv.FormatInt(item.ID, 10)
  1473. fmt.Println(item.FeedetlSn)
  1474. service.UpDateHis2(item)
  1475. }
  1476. }