public_api_controller.go 65KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415
  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. //var f_a *os.File
  20. //
  21. //
  22. // func init() {
  23. // org_id, _ := beego.AppConfig.Int64("org_id")
  24. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  25. // Mkdir(miConfig.OrgName+"日志")
  26. // month := time.Unix(1557042972, 0).Format("1")
  27. // year := time.Now().Format("2006")
  28. // month = time.Now().Format("01")
  29. // day := time.Now().Format("02")
  30. // file := strconv.FormatInt( org_id, 10) + "_"+ year + month + day + "_log"
  31. // file_name := file + ".txt"
  32. // file_path := miConfig.OrgName+"日志" + "/" + file_name
  33. // exist, _ := PathExists(file_path)
  34. // if exist {//存在
  35. // f_a, _ := os.OpenFile(file_path,os.O_WRONLY,0644)
  36. // content := "新的日志内容吧"
  37. // n, _ := f_a.Seek(0,2)
  38. // f_a.WriteAt([]byte(content),n)
  39. //
  40. // } else { //不存在
  41. // fmt.Println("文件不存在,创建文件")
  42. // f, err := os.Create(miConfig.OrgName+"日志" + "/" + file_name)
  43. // defer f.Close()
  44. // if err !=nil {
  45. // } else {
  46. // _,err=f.Write([]byte("记录日志"))
  47. // }
  48. // }
  49. //
  50. // }
  51. func PublicApiRegistRouters() {
  52. beego.Router("/api/public/getadviceconfig", &PublicApiController{}, "Get:GetDoctorAdviceConfig")
  53. beego.Router("/api/public/servertime", &PublicApiController{}, "Get:GetServerTime")
  54. beego.Router("/api/app/release", &PublicApiController{}, "Get:AppRelease")
  55. beego.Router("/api/get", &PublicApiController{}, "Get:GetJson")
  56. beego.Router("/api/public/handledata", &PublicApiController{}, "get:HandleData")
  57. beego.Router("/api/public/handlestockdata", &PublicApiController{}, "get:HandleStockData")
  58. beego.Router("/api/public/handlecomdata", &PublicApiController{}, "get:HandleComData")
  59. beego.Router("/hello", &PublicApiController{}, "get:HandleComData")
  60. beego.Router("/handel", &PublicApiController{}, "get:HandleHIS")
  61. beego.Router("/groupno", &PublicApiController{}, "get:HandleGroupNo")
  62. beego.Router("/handle10215", &PublicApiController{}, "get:Handle10215")
  63. beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
  64. beego.Router("/handelHis", &PublicApiController{}, "get:HandleHisTwo")
  65. beego.Router("/handelProject", &PublicApiController{}, "get:HandleProject")
  66. beego.Router("/handelsettledata", &PublicApiController{}, "get:HandleSettleData")
  67. beego.Router("/handelhispatient", &PublicApiController{}, "get:HandleHisPatient")
  68. //beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
  69. beego.Router("/handleExportData", &PublicApiController{}, "get:HandleExportAllData")
  70. beego.Router("/handleExportData10138", &PublicApiController{}, "get:HandleExportData10138")
  71. beego.Router("/handleData10265", &PublicApiController{}, "get:HandleData10265")
  72. beego.Router("/handleData10106", &PublicApiController{}, "get:HandleData10106")
  73. beego.Router("/handleData10318", &PublicApiController{}, "get:HandleData10318")
  74. beego.Router("/handleOne", &PublicApiController{}, "get:HandleOne")
  75. beego.Router("/handelschedule", &PublicApiController{}, "get:HandleSchedule")
  76. //beego.Router("/handelscheduleTwo", &PublicApiController{}, "get:HandleScheduleTwo")
  77. //
  78. //
  79. //
  80. //beego.Router("/handelhispatienttwo", &PublicApiController{}, "get:HandleHisPatientTwo")
  81. //beego.Router("/handleorderinfo", &PublicApiController{}, "get:HandleOrderInfoData")
  82. //
  83. //beego.Router("/hande10138", &PublicApiController{}, "get:HandleOrderInfoData10138")
  84. }
  85. type ResultFiveT struct {
  86. Balc float64 `json:"balc"`
  87. CvlservFlag string `json:"cvlserv_flag"`
  88. EmpName string `json:"emp_name"`
  89. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  90. Insutype string `json:"insutype"`
  91. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  92. PausInsuDate string `json:"paus_insu_date"`
  93. PsnInsuDate string `json:"psn_insu_date"`
  94. PsnInsuStas string `json:"psn_insu_stas"`
  95. PsnType string `json:"psn_type"`
  96. }
  97. func (c *PublicApiController) HandleSchedule() {
  98. //fmt.Println("~~~~~~")
  99. service.GetLongSolution()
  100. }
  101. func (c *PublicApiController) HandleOne() {
  102. //fmt.Println("~~~~~~")
  103. start_time := c.GetString("start_time")
  104. end_time := c.GetString("end_time")
  105. timeLayout := "2006-01-02"
  106. loc, _ := time.LoadLocation("Local")
  107. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  108. if err != nil {
  109. }
  110. startRecordDateTime := startTime.Unix()
  111. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  112. if err != nil {
  113. }
  114. endRecordDateTime := endTime.Unix()
  115. orders, _ := service.GetHisOrderDetailOne(startRecordDateTime, endRecordDateTime)
  116. c.ServeSuccessJSON(map[string]interface{}{
  117. "order": orders,
  118. })
  119. }
  120. //func (c *PublicApiController) HandleScheduleTwo() {
  121. // models, _ := service.GetAllSchMode()
  122. // for _, item := range models {
  123. // if item.Mode == 1 {
  124. // templates, _ := service.GetOrgPatientScheduleTemplateIDs(item.OrgID)
  125. // thisTime := time.Now()
  126. // _, theWeek := thisTime.ISOWeek()
  127. // templates[0].Week = theWeek
  128. // service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
  129. // } else if item.Mode == 2 {
  130. // templates, _ := service.GetOrgPatientScheduleTemplateIDs(item.OrgID)
  131. // now := time.Now()
  132. // nextSecWeek := now.AddDate(0, 0, 14)
  133. // nextWeek := now.AddDate(0, 0, 7)
  134. // if item.ExecuteTimes%2 == 0 { //下第二周生成的是
  135. // templates[0].Week = service.GetWeeks(nextWeek.Format("2006-01-02 15:04:05"))
  136. // templates[1].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
  137. // service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
  138. // service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, int8(templates[1].Week))
  139. //
  140. // } else if item.ExecuteTimes%2 == 1 {
  141. // templates[0].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
  142. // templates[1].Week = service.GetWeeks(nextWeek.Format("2006-01-02 15:04:05"))
  143. // service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
  144. // service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, int8(templates[1].Week))
  145. //
  146. // }
  147. //
  148. // }
  149. // }
  150. //
  151. //}
  152. func (c *PublicApiController) HandleHisPatient() {
  153. ps, _ := service.GetHisPatient11111(10215)
  154. for _, item := range ps {
  155. var rf []*ResultFiveT
  156. json.Unmarshal([]byte(item.Iinfo), &rf)
  157. var insuplc_admdvs string
  158. var insutype string
  159. var is390 int = 0
  160. var is310 int = 0
  161. var insutypes []*ResultFiveT
  162. for _, item := range rf {
  163. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  164. insutypes = append(insutypes, item)
  165. }
  166. }
  167. fmt.Println(insutypes)
  168. if len(insutypes) == 1 {
  169. insutype = insutypes[0].Insutype
  170. is390 = 1
  171. fmt.Println("111111")
  172. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  173. } else {
  174. fmt.Println("222222")
  175. for _, i := range insutypes {
  176. if i.Insutype == "390" {
  177. is390 = 1
  178. }
  179. if i.Insutype == "310" {
  180. is310 = 1
  181. }
  182. }
  183. }
  184. if is390 == 1 {
  185. insutype = "390"
  186. }
  187. if is310 == 1 {
  188. insutype = "310"
  189. }
  190. if len(insutypes) == 0 {
  191. insutype = "390"
  192. }
  193. for _, item := range rf {
  194. if item.Insutype == insutype {
  195. insuplc_admdvs = item.InsuplcAdmdvs
  196. }
  197. }
  198. item.InsuplcAdmdvs = insuplc_admdvs
  199. service.SaveHP(item)
  200. }
  201. }
  202. //func (c *PublicApiController) HandleHisPatientTwo() {
  203. //
  204. // ps, _ := service.GetHisPatient2222(10188)
  205. // for _, item := range ps {
  206. // var rf []*ResultFiveT
  207. // json.Unmarshal([]byte(item.Iinfo), &rf)
  208. // var insuplc_admdvs string
  209. //
  210. // for _, subItem := range rf {
  211. // if subItem.Insutype == item.Insutype {
  212. // insuplc_admdvs = subItem.InsuplcAdmdvs
  213. // }
  214. // }
  215. // item.InsuplcAdmdvs = insuplc_admdvs
  216. // service.SaveHPtWO(item)
  217. // }
  218. //}
  219. func (c *PublicApiController) HandleSettleData() {
  220. orders, _ := service.GetHisOrderDetailThree()
  221. c.ServeSuccessJSON(map[string]interface{}{
  222. "order": orders,
  223. })
  224. }
  225. //func (c *PublicApiController) HandleData10106() {
  226. // start_time := c.GetString("start_time")
  227. // end_time := c.GetString("end_time")
  228. //
  229. // timeLayout := "2006-01-02"
  230. // loc, _ := time.LoadLocation("Local")
  231. // startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  232. // if err != nil {
  233. //
  234. // }
  235. // startRecordDateTime := startTime.Unix()
  236. //
  237. // endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  238. // if err != nil {
  239. //
  240. // }
  241. // endRecordDateTime := endTime.Unix()
  242. // fmt.Println(startRecordDateTime)
  243. // fmt.Println(endRecordDateTime)
  244. //
  245. // orders, _ := service.GetHisOrderDetail10106(startRecordDateTime, endRecordDateTime)
  246. // c.ServeSuccessJSON(map[string]interface{}{
  247. // "order": orders,
  248. // })
  249. //}
  250. func (c *PublicApiController) HandleData10106() {
  251. start_time := c.GetString("start_time")
  252. end_time := c.GetString("end_time")
  253. timeLayout := "2006-01-02"
  254. loc, _ := time.LoadLocation("Local")
  255. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  256. if err != nil {
  257. }
  258. startRecordDateTime := startTime.Unix()
  259. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  260. if err != nil {
  261. }
  262. endRecordDateTime := endTime.Unix()
  263. fmt.Println(startRecordDateTime)
  264. fmt.Println(endRecordDateTime)
  265. orders, _ := service.GetHisOrderDetail10106(startRecordDateTime, endRecordDateTime)
  266. c.ServeSuccessJSON(map[string]interface{}{
  267. "order": orders,
  268. })
  269. }
  270. func (c *PublicApiController) HandleData10318() {
  271. start_time := c.GetString("start_time")
  272. end_time := c.GetString("end_time")
  273. timeLayout := "2006-01-02"
  274. loc, _ := time.LoadLocation("Local")
  275. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  276. if err != nil {
  277. }
  278. startRecordDateTime := startTime.Unix()
  279. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  280. if err != nil {
  281. }
  282. endRecordDateTime := endTime.Unix()
  283. fmt.Println(startRecordDateTime)
  284. fmt.Println(endRecordDateTime)
  285. orders, _ := service.GetHisOrderDetail10318(startRecordDateTime, endRecordDateTime)
  286. c.ServeSuccessJSON(map[string]interface{}{
  287. "order": orders,
  288. })
  289. }
  290. func (c *PublicApiController) HandleProject() {
  291. prescriptions := service.GetAllProjectPrescription()
  292. for _, item := range prescriptions {
  293. ps := service.GetAllProject(item.ID)
  294. for _, subItem := range ps {
  295. subItem.Status = 0
  296. service.SaveHisProject(subItem)
  297. }
  298. }
  299. }
  300. func (c *PublicApiController) HandleHisTwo() {
  301. hiss := service.GetAllPrivateHis(10215)
  302. for _, item := range hiss {
  303. patient, _ := service.GetPatientByID(10215, item.PatientId)
  304. item.Gender = patient.Gender
  305. service.SaveHis(item)
  306. }
  307. }
  308. func (c *PublicApiController) GetDoctorAdviceConfig() {
  309. drugs, _, _ := service.GetPublicDrugDics()
  310. drugways, _, _ := service.GetPublicDrugWayDics()
  311. efs, _, _ := service.GetPublicExecutionFrequencyDics()
  312. c.ServeSuccessJSON(map[string]interface{}{
  313. "drugs": drugs,
  314. "drugways": drugways,
  315. "efs": efs,
  316. })
  317. }
  318. func (c *PublicApiController) GetServerTime() {
  319. timeNow := time.Now()
  320. timeNowStamp := timeNow.Unix()
  321. timeNowStr := timeNow.Format("2006-01-02 15:04:05")
  322. c.ServeSuccessJSON(map[string]interface{}{
  323. "time": timeNowStr,
  324. "timestamp": timeNowStamp,
  325. })
  326. }
  327. func (c *PublicApiController) AppRelease() {
  328. // appId := c.GetString("appid")
  329. version := c.GetString("version")
  330. appType, _ := c.GetInt64("app_type", 0)
  331. appVersion, err := service.GetAppVersionByAppType(appType)
  332. if err != nil {
  333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  334. return
  335. }
  336. if appVersion == nil {
  337. c.ServeSuccessJSON(map[string]interface{}{
  338. "version": nil,
  339. "state": 2,
  340. })
  341. return
  342. }
  343. state := strings.Compare(version, appVersion.Version)
  344. // state := 1
  345. if state < 0 {
  346. c.ServeSuccessJSON(map[string]interface{}{
  347. "version": appVersion,
  348. "state": appVersion.Status,
  349. })
  350. return
  351. }
  352. c.ServeSuccessJSON(map[string]interface{}{
  353. "version": nil,
  354. "state": 2,
  355. })
  356. return
  357. }
  358. func (this *PublicApiController) GetJson() {
  359. type Global struct {
  360. DeviceSN string
  361. Version string
  362. Timestamp string
  363. InterfaceSource string
  364. }
  365. type RBPResultModel struct {
  366. Sys string
  367. Dia string
  368. HR string
  369. MeasureTime string
  370. }
  371. type ScannerResultModel struct {
  372. Code string
  373. }
  374. type IDCardResultModel struct {
  375. IDCardNo string
  376. UserName string
  377. Age string
  378. Female string
  379. Male string
  380. SocialSecurityNo string
  381. }
  382. type JsonTemp struct {
  383. Global Global
  384. RBPResultModel RBPResultModel
  385. ScannerResultModel ScannerResultModel
  386. IDCardResultModel IDCardResultModel
  387. }
  388. var person JsonTemp
  389. err3 := json.Unmarshal([]byte(this.GetString("params")), &person)
  390. fmt.Println(err3)
  391. fmt.Println(person.Global)
  392. //temp := JsonTemp{
  393. // Global:Global{
  394. // DeviceSN:"1122",
  395. // Version:"1122",
  396. // Timestamp:"1222",
  397. // InterfaceSource:"1233",
  398. // },
  399. // RBPResultModel: RBPResultModel{
  400. // Sys:"12",
  401. // Dia:"22",
  402. // HR:"23",
  403. // MeasureTime:"123",
  404. // },
  405. // ScannerResultModel:ScannerResultModel{
  406. // Code:"1233",
  407. // },
  408. // IDCardResultModel:IDCardResultModel{
  409. // IDCardNo:"123",
  410. // UserName:"123",
  411. // Age:"123",
  412. // Female:"123",
  413. // Male:"123",
  414. // SocialSecurityNo:"123",
  415. // },
  416. //}
  417. //
  418. //jsonBytes, err := json.Marshal(temp)
  419. //if err != nil {
  420. // fmt.Println(err)
  421. //}
  422. //fmt.Println(string(jsonBytes))
  423. }
  424. func (c *PublicApiController) HandleData() {
  425. //service.HandleData()
  426. org_app, _ := service.GetAllAppOrg()
  427. //org_role, _ := service.GetAllRole()
  428. //
  429. //var org_ids []int64
  430. for _, apps := range org_app {
  431. xt_org_app, _ := service.GetAppByType(int64(apps.OrgId), 3)
  432. //org_app_6, _ := service.GetAppByType(int64(apps.OrgId), 6)
  433. //org_app_7, _ := service.GetAppByType(int64(apps.OrgId), 7)
  434. //org_app_8, _ := service.GetAppByType(int64(apps.OrgId), 8)
  435. //org_app_9, _ := service.GetAppByType(int64(apps.OrgId), 9)
  436. //org_app_10, _ := service.GetAppByType(int64(apps.OrgId), 10)
  437. //org_app_11, _ := service.GetAppByType(int64(apps.OrgId), 11)
  438. //org_app_12, _ := service.GetAppByType(int64(apps.OrgId), 12)
  439. //org_app_13, _ := service.GetAppByType(int64(apps.OrgId), 13)
  440. //org_app_14, _ := service.GetAppByType(int64(apps.OrgId), 14)
  441. //org_app_15, _ := service.GetAppByType(int64(apps.OrgId), 15)
  442. //org_app_16, _ := service.GetAppByType(int64(apps.OrgId), 16)
  443. //org_app_17, _ := service.GetAppByType(int64(apps.OrgId), 17)
  444. org_app_18, _ := service.GetAppByType(int64(apps.OrgId), 18)
  445. var xt_temp_org_app *models.OrgApp
  446. //var mall_temp_org_app *models.OrgApp
  447. if xt_org_app == nil || xt_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  448. app, _ := service.GetOrgAppA(0, 3)
  449. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  450. if org == nil || org.Id == 0 {
  451. continue
  452. }
  453. app.Id = 0
  454. app.OrgId = apps.OrgId
  455. app.Creator = int(org.Creator)
  456. app.Number = 0
  457. app.Status = 1
  458. app.ModifyTime = time.Now().Unix()
  459. app.CreateTime = time.Now().Unix()
  460. service.CreateOrgApp(app)
  461. xt_temp_org_app = app
  462. } else {
  463. xt_temp_org_app = xt_org_app
  464. }
  465. //if scrm_org_app == nil || scrm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  466. //
  467. // app, _ := service.GetOrgAppA(0, 1)
  468. // //org, _ := service.GetOrgById(int64(12))
  469. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  470. // if org == nil || org.Id == 0 {
  471. // continue
  472. // }
  473. //
  474. //
  475. // app.OrgId = apps.OrgId
  476. // app.Id = 0
  477. //
  478. // app.Creator = int(org.Creator)
  479. // app.Number = 0
  480. // app.Status = 1
  481. // app.ModifyTime = time.Now().Unix()
  482. // app.CreateTime = time.Now().Unix()
  483. // service.CreateOrgApp(app)
  484. //
  485. //}
  486. //
  487. //if cdm_org_app == nil || cdm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  488. // app, _ := service.GetOrgAppA(0, 4)
  489. // //org, _ := service.GetOrgById(int64(12))
  490. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  491. // if org == nil || org.Id == 0 {
  492. // continue
  493. // }
  494. //
  495. //
  496. // app.OrgId = apps.OrgId
  497. // app.Creator = int(org.Creator)
  498. // app.Number = 0
  499. // app.Id = 0
  500. //
  501. // app.Status = 1
  502. // app.ModifyTime = time.Now().Unix()
  503. // app.CreateTime = time.Now().Unix()
  504. // service.CreateOrgApp(app)
  505. //}
  506. //
  507. //if mall_org_app == nil || mall_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  508. // app, _ := service.GetOrgAppA(0, 5)
  509. // //org, _ := service.GetOrgById(int64(12))
  510. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  511. //
  512. // if org == nil || org.Id == 0 {
  513. // continue
  514. // }
  515. //
  516. // app.OrgId = apps.OrgId
  517. // app.Creator = int(org.Creator)
  518. // app.Number = 0
  519. // app.Id = 0
  520. //
  521. // app.Status = 1
  522. // app.ModifyTime = time.Now().Unix()
  523. // app.CreateTime = time.Now().Unix()
  524. // service.CreateOrgApp(app)
  525. // mall_temp_org_app = app
  526. //} else {
  527. // mall_temp_org_app = mall_org_app
  528. //}
  529. //
  530. //if org_app_16 == nil || org_app_16.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  531. // app, _ := service.GetOrgAppA(0, 16)
  532. // //org, _ := service.GetOrgById(int64(12))
  533. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  534. // if org == nil || org.Id == 0 {
  535. // continue
  536. // }
  537. //
  538. // app.OrgId = apps.OrgId
  539. // app.Creator = int(org.Creator)
  540. // app.Number = 11
  541. // app.Id = 0
  542. // app.Status = 1
  543. // app.ModifyTime = time.Now().Unix()
  544. // app.CreateTime = time.Now().Unix()
  545. // app.Pid = xt_temp_org_app.Id
  546. // service.CreateOrgApp(app)
  547. //
  548. //}
  549. //
  550. //if org_app_17 == nil || org_app_17.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  551. // app, _ := service.GetOrgAppA(0, 17)
  552. // //org, _ := service.GetOrgById(int64(12))
  553. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  554. // if org == nil || org.Id == 0 {
  555. // continue
  556. // }
  557. //
  558. // app.OrgId = apps.OrgId
  559. // app.Creator = int(org.Creator)
  560. // app.Number = 12
  561. // app.Id = 0
  562. // app.Status = 1
  563. // app.ModifyTime = time.Now().Unix()
  564. // app.CreateTime = time.Now().Unix()
  565. // app.Pid = xt_temp_org_app.Id
  566. // service.CreateOrgApp(app)
  567. //
  568. //}
  569. if org_app_18 == nil || org_app_18.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  570. app, _ := service.GetOrgAppA(0, 18)
  571. //org, _ := service.GetOrgById(int64(12))
  572. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  573. if org == nil || org.Id == 0 {
  574. continue
  575. }
  576. app.OrgId = apps.OrgId
  577. app.Creator = int(org.Creator)
  578. app.Number = 5
  579. app.Id = 0
  580. app.Status = 1
  581. app.ModifyTime = time.Now().Unix()
  582. app.CreateTime = time.Now().Unix()
  583. app.Pid = xt_temp_org_app.Id
  584. service.CreateOrgApp(app)
  585. }
  586. //if org_app_7 == nil || org_app_7.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  587. // app, _ := service.GetOrgAppA(0, 7)
  588. // //org, _ := service.GetOrgById(int64(12))
  589. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  590. // if org == nil || org.Id == 0 {
  591. // continue
  592. // }
  593. //
  594. //
  595. // app.OrgId = apps.OrgId
  596. // app.Creator = int(org.Creator)
  597. // app.Number = 2
  598. // app.Status = 2
  599. // app.Id = 0
  600. //
  601. // app.ModifyTime = time.Now().Unix()
  602. // app.CreateTime = time.Now().Unix()
  603. // app.Pid = xt_temp_org_app.Id
  604. //
  605. // service.CreateOrgApp(app)
  606. //}
  607. //if org_app_8 == nil || org_app_8.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  608. // app, _ := service.GetOrgAppA(0, 8)
  609. // //org, _ := service.GetOrgById(int64(12))
  610. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  611. // if org == nil || org.Id == 0 {
  612. // continue
  613. // }
  614. //
  615. //
  616. // app.OrgId = apps.OrgId
  617. // app.Creator = int(org.Creator)
  618. // app.Number = 3
  619. // app.Id = 0
  620. //
  621. // app.Pid = mall_temp_org_app.Id
  622. //
  623. // app.Status = 1
  624. // app.ModifyTime = time.Now().Unix()
  625. // app.CreateTime = time.Now().Unix()
  626. // service.CreateOrgApp(app)
  627. //}
  628. //if org_app_9 == nil || org_app_9.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  629. // app, _ := service.GetOrgAppA(0, 9)
  630. // //org, _ := service.GetOrgById(int64(12))
  631. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  632. // if org == nil || org.Id == 0 {
  633. // continue
  634. // }
  635. //
  636. //
  637. // app.OrgId = apps.OrgId
  638. // app.Pid = xt_temp_org_app.Id
  639. //
  640. // app.Creator = int(org.Creator)
  641. // app.Number = 4
  642. // app.Id = 0
  643. //
  644. // app.Status = 1
  645. // app.ModifyTime = time.Now().Unix()
  646. // app.CreateTime = time.Now().Unix()
  647. // service.CreateOrgApp(app)
  648. //
  649. //}
  650. //if org_app_10 == nil || org_app_10.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  651. // app, _ := service.GetOrgAppA(0, 10)
  652. // //org, _ := service.GetOrgById(int64(12))
  653. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  654. // if org == nil || org.Id == 0 {
  655. // continue
  656. // }
  657. //
  658. //
  659. // app.OrgId = apps.OrgId
  660. // app.Creator = int(org.Creator)
  661. // app.Pid = xt_temp_org_app.Id
  662. //
  663. // app.Number = 5
  664. // app.Id = 0
  665. //
  666. // app.Status = 1
  667. // app.ModifyTime = time.Now().Unix()
  668. // app.CreateTime = time.Now().Unix()
  669. // service.CreateOrgApp(app)
  670. //}
  671. //if org_app_11 == nil || org_app_11.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  672. // app, _ := service.GetOrgAppA(0, 11)
  673. // //org, _ := service.GetOrgById(int64(12))
  674. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  675. // if org == nil || org.Id == 0 {
  676. // continue
  677. // }
  678. //
  679. //
  680. // app.OrgId = apps.OrgId
  681. // app.Creator = int(org.Creator)
  682. // app.Pid = xt_temp_org_app.Id
  683. // app.Id = 0
  684. //
  685. // app.Number = 6
  686. // app.Status = 1
  687. // app.ModifyTime = time.Now().Unix()
  688. // app.CreateTime = time.Now().Unix()
  689. // service.CreateOrgApp(app)
  690. //}
  691. //if org_app_12 == nil || org_app_12.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  692. // app, _ := service.GetOrgAppA(0, 12)
  693. // //org, _ := service.GetOrgById(int64(12))
  694. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  695. // if org == nil || org.Id == 0 {
  696. // continue
  697. // }
  698. //
  699. //
  700. // app.OrgId = apps.OrgId
  701. // app.Creator = int(org.Creator)
  702. // app.Pid = xt_temp_org_app.Id
  703. // app.Number = 7
  704. // app.Status = 1
  705. // app.Id = 0
  706. //
  707. // app.ModifyTime = time.Now().Unix()
  708. // app.CreateTime = time.Now().Unix()
  709. // service.CreateOrgApp(app)
  710. //}
  711. //if org_app_13 == nil || org_app_13.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  712. // app, _ := service.GetOrgAppA(0, 13)
  713. // //org, _ := service.GetOrgById(int64(12))
  714. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  715. // if org == nil || org.Id == 0 {
  716. // continue
  717. // }
  718. //
  719. //
  720. // app.OrgId = apps.OrgId
  721. // app.Creator = int(org.Creator)
  722. // app.Pid = xt_temp_org_app.Id
  723. // app.Number = 8
  724. // app.Id = 0
  725. // app.Status = 1
  726. // app.ModifyTime = time.Now().Unix()
  727. // app.CreateTime = time.Now().Unix()
  728. // service.CreateOrgApp(app)
  729. //}
  730. //if org_app_14 == nil || org_app_14.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  731. // app, _ := service.GetOrgAppA(0, 14)
  732. // //org, _ := service.GetOrgById(int64(12))
  733. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  734. // if org == nil || org.Id == 0 {
  735. // continue
  736. // }
  737. //
  738. //
  739. // app.OrgId = apps.OrgId
  740. // app.Creator = int(org.Creator)
  741. // app.Pid = xt_temp_org_app.Id
  742. // app.Id = 0
  743. // app.Number = 9
  744. // app.Status = 1
  745. // app.ModifyTime = time.Now().Unix()
  746. // app.CreateTime = time.Now().Unix()
  747. // service.CreateOrgApp(app)
  748. //}
  749. //if org_app_15 == nil || org_app_15.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  750. // app, _ := service.GetOrgAppA(0, 15)
  751. // //org, _ := service.GetOrgById(int64(12))
  752. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  753. // if org == nil || org.Id == 0 {
  754. // continue
  755. // }
  756. //
  757. // app.OrgId = apps.OrgId
  758. // app.Creator = int(org.Creator)
  759. // app.Pid = xt_temp_org_app.Id
  760. // app.Number = 10
  761. // app.Status = 1
  762. // app.Id = 0
  763. // app.ModifyTime = time.Now().Unix()
  764. // app.CreateTime = time.Now().Unix()
  765. // service.CreateOrgApp(app)
  766. //}
  767. }
  768. //for _, role := range org_role {
  769. // org_ids = append(org_ids, role.OrgId)
  770. //}
  771. //
  772. //
  773. ////创建内置角色
  774. //InitRoleAndPurviews(org_ids)
  775. //var org_id int = 0
  776. //管理员
  777. //app_roles := service.GetAllUserRoleByUserTypeOne(org_id)
  778. //for _, item := range app_roles{
  779. // var ids string
  780. // if len(item.RoleIds) == 0{
  781. // ids = strconv.FormatInt( item.RoleId,10)
  782. // }else{
  783. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  784. // }
  785. // service.UpdateRoleIds(item.Id, ids)
  786. //}
  787. //护士医生
  788. //app_roles2 := service.GetAllUserRoleByUserTypeOther()
  789. // for _, item := range app_roles2{
  790. // var ids string
  791. // if len(item.RoleIds) == 0{
  792. // ids = strconv.FormatInt( item.RoleId,10)
  793. // }else{
  794. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  795. // }
  796. // if item.UserType == 2{
  797. // role := service.FindRoleByUserTypeOne(item.OrgId)
  798. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  799. //
  800. // } else if item.UserType == 3{
  801. // role := service.FindRoleByUserTypeTwo(item.OrgId)
  802. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  803. // }
  804. // service.UpdateRoleIds(item.Id, ids)
  805. // }
  806. //c.ServeSuccessJSON(map[string]interface{}{
  807. // "msg": "ok",
  808. //})
  809. }
  810. func (c *PublicApiController) HandleGroupNo() {
  811. //service.GetAllPatientChargeDetails(10138, 1634054400)
  812. //pts, _ := service.GetHisPrescriptionTemplateTwo()
  813. //for _, item := range pts {
  814. // if len(item.HisPrescriptionAdviceTemplate) > 0 {
  815. // for index, subItem := range item.HisPrescriptionAdviceTemplate {
  816. // subItem.Groupno = int64(index + 1)
  817. // service.SaveAdviceTemplate(subItem)
  818. // }
  819. // }
  820. //}
  821. }
  822. func InitRoleAndPurviews(org_ids []int64) {
  823. roles := LoadRoleConfig("./role.json").Roles
  824. for _, org_id := range org_ids {
  825. app, _ := service.GetOrgAppB(org_id, 3)
  826. role, _ := service.GetSystemRole(org_id)
  827. if app == nil || app.Id == 0 {
  828. continue
  829. }
  830. if len(role) == 0 {
  831. for _, item := range roles {
  832. role := &models.Role{
  833. RoleName: item.RoleName,
  834. RoleIntro: item.RoleIntroduction,
  835. Creator: 0,
  836. OrgId: org_id,
  837. AppId: app.Id,
  838. IsSuperAdmin: false,
  839. Status: 1,
  840. CreateTime: time.Now().Unix(),
  841. ModifyTime: time.Now().Unix(),
  842. Number: item.Number,
  843. IsSystem: item.IsSystem,
  844. }
  845. err := service.CreateOrgRoleB(role)
  846. if err == nil {
  847. purview := &models.RolePurview{
  848. RoleId: role.Id,
  849. OrgId: org_id,
  850. AppId: role.AppId,
  851. PurviewIds: item.PurviewIds,
  852. Status: 1,
  853. CreateTime: time.Now().Unix(),
  854. ModifyTime: time.Now().Unix(),
  855. }
  856. func_purview := &models.SgjUserRoleFuncPurview{
  857. RoleId: role.Id,
  858. OrgId: org_id,
  859. AppId: role.AppId,
  860. PurviewIds: item.FuncIds,
  861. Status: 1,
  862. Ctime: time.Now().Unix(),
  863. Mtime: time.Now().Unix(),
  864. }
  865. service.CreateRolePurviewB(purview)
  866. service.CreateFuncRolePurviewB(func_purview)
  867. }
  868. }
  869. }
  870. }
  871. }
  872. type RoleConfig struct {
  873. Roles []*models.VMUserRoleAndPurview "json:roles"
  874. }
  875. func LoadRoleConfig(dataFile string) *RoleConfig {
  876. var config RoleConfig
  877. _, filename, _, _ := runtime.Caller(1)
  878. datapath := path.Join(path.Dir(filename), dataFile)
  879. config_file, err := os.Open(datapath)
  880. if err != nil {
  881. emit("Failed to open config file '%s': %s\n", datapath, err)
  882. return &config
  883. }
  884. fi, _ := config_file.Stat()
  885. buffer := make([]byte, fi.Size())
  886. _, err = config_file.Read(buffer)
  887. buffer, err = StripComments(buffer) //去掉注释
  888. if err != nil {
  889. emit("Failed to strip comments from json: %s\n", err)
  890. return &config
  891. }
  892. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  893. err = json.Unmarshal(buffer, &config) //解析json格式数据
  894. if err != nil {
  895. emit("Failed unmarshalling json: %s\n", err)
  896. return &config
  897. }
  898. return &config
  899. }
  900. type GoodTypesConfig struct {
  901. GoodTypes []*models.VMGoodsType "json:list"
  902. }
  903. func LoadGoodTypeConfig(dataFile string) *GoodTypesConfig {
  904. var config GoodTypesConfig
  905. _, filename, _, _ := runtime.Caller(1)
  906. datapath := path.Join(path.Dir(filename), dataFile)
  907. config_file, err := os.Open(datapath)
  908. if err != nil {
  909. emit("Failed to open config file '%s': %s\n", datapath, err)
  910. return &config
  911. }
  912. fi, _ := config_file.Stat()
  913. buffer := make([]byte, fi.Size())
  914. _, err = config_file.Read(buffer)
  915. buffer, err = StripComments(buffer) //去掉注释
  916. if err != nil {
  917. emit("Failed to strip comments from json: %s\n", err)
  918. return &config
  919. }
  920. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  921. err = json.Unmarshal(buffer, &config) //解析json格式数据
  922. if err != nil {
  923. emit("Failed unmarshalling json: %s\n", err)
  924. return &config
  925. }
  926. return &config
  927. }
  928. func (c *PublicApiController) HandleStockData() {
  929. org, _ := service.FindAllOrgByImportType()
  930. for _, item := range org {
  931. if item.Id != 3907 || item.Id != 9779 || item.Id != 9883 {
  932. goodTypes := &models.GoodsType{
  933. TypeCode: "14000000",
  934. TypeName: "穿刺针",
  935. Remark: "",
  936. Ctime: time.Now().Unix(),
  937. Mtime: time.Now().Unix(),
  938. Creater: 0,
  939. Modifier: 0,
  940. OrgId: item.Id,
  941. Status: 1,
  942. Type: 1,
  943. Number: 1,
  944. }
  945. service.AddSigleGoodType(goodTypes)
  946. goodTypes1 := &models.GoodsType{
  947. TypeCode: "14000001",
  948. TypeName: "透析器",
  949. Remark: "",
  950. Ctime: time.Now().Unix(),
  951. Mtime: time.Now().Unix(),
  952. Creater: 0,
  953. Modifier: 0,
  954. OrgId: item.Id,
  955. Status: 1,
  956. Type: 1,
  957. Number: 2,
  958. }
  959. service.AddSigleGoodType(goodTypes1)
  960. goodTypes2 := &models.GoodsType{
  961. TypeCode: "14000002",
  962. TypeName: "灌流器",
  963. Remark: "",
  964. Ctime: time.Now().Unix(),
  965. Mtime: time.Now().Unix(),
  966. Creater: 0,
  967. Modifier: 0,
  968. OrgId: item.Id,
  969. Status: 1,
  970. Type: 1,
  971. Number: 3,
  972. }
  973. service.AddSigleGoodType(goodTypes2)
  974. goodTypes3 := &models.GoodsType{
  975. TypeCode: "14000003",
  976. TypeName: "血路管",
  977. Remark: "",
  978. Ctime: time.Now().Unix(),
  979. Mtime: time.Now().Unix(),
  980. Creater: 0,
  981. Modifier: 0,
  982. OrgId: item.Id,
  983. Status: 1,
  984. Type: 1,
  985. Number: 4,
  986. }
  987. service.AddSigleGoodType(goodTypes3)
  988. goodTypes4 := &models.GoodsType{
  989. TypeCode: "14000004",
  990. TypeName: "血滤补液管",
  991. Remark: "",
  992. Ctime: time.Now().Unix(),
  993. Mtime: time.Now().Unix(),
  994. Creater: 0,
  995. Modifier: 0,
  996. OrgId: item.Id,
  997. Status: 1,
  998. Type: 1,
  999. Number: 5,
  1000. }
  1001. service.AddSigleGoodType(goodTypes4)
  1002. goodTypes5 := &models.GoodsType{
  1003. TypeCode: "14000005",
  1004. TypeName: "注射器",
  1005. Remark: "",
  1006. Ctime: time.Now().Unix(),
  1007. Mtime: time.Now().Unix(),
  1008. Creater: 0,
  1009. Modifier: 0,
  1010. OrgId: item.Id,
  1011. Status: 1,
  1012. Type: 1,
  1013. Number: 6,
  1014. }
  1015. service.AddSigleGoodType(goodTypes5)
  1016. goodTypes6 := &models.GoodsType{
  1017. TypeCode: "14000006",
  1018. TypeName: "护理包(内瘘穿刺包)",
  1019. Remark: "",
  1020. Ctime: time.Now().Unix(),
  1021. Mtime: time.Now().Unix(),
  1022. Creater: 0,
  1023. Modifier: 0,
  1024. OrgId: item.Id,
  1025. Status: 1,
  1026. Type: 1,
  1027. Number: 7,
  1028. }
  1029. service.AddSigleGoodType(goodTypes6)
  1030. goodTypes7 := &models.GoodsType{
  1031. TypeCode: "14000007",
  1032. TypeName: "细菌过滤器",
  1033. Remark: "",
  1034. Ctime: time.Now().Unix(),
  1035. Mtime: time.Now().Unix(),
  1036. Creater: 0,
  1037. Modifier: 0,
  1038. OrgId: item.Id,
  1039. Status: 1,
  1040. Type: 1,
  1041. Number: 8,
  1042. }
  1043. service.AddSigleGoodType(goodTypes7)
  1044. goodTypes8 := &models.GoodsType{
  1045. TypeCode: "14000008",
  1046. TypeName: "血液透析干粉",
  1047. Remark: "",
  1048. Ctime: time.Now().Unix(),
  1049. Mtime: time.Now().Unix(),
  1050. Creater: 0,
  1051. Modifier: 0,
  1052. OrgId: item.Id,
  1053. Status: 1,
  1054. Type: 1,
  1055. Number: 9,
  1056. }
  1057. service.AddSigleGoodType(goodTypes8)
  1058. goodTypes9 := &models.GoodsType{
  1059. TypeCode: "14000009",
  1060. TypeName: "A液",
  1061. Remark: "",
  1062. Ctime: time.Now().Unix(),
  1063. Mtime: time.Now().Unix(),
  1064. Creater: 0,
  1065. Modifier: 0,
  1066. OrgId: item.Id,
  1067. Status: 1,
  1068. Type: 1,
  1069. Number: 10,
  1070. }
  1071. service.AddSigleGoodType(goodTypes9)
  1072. goodTypes10 := &models.GoodsType{
  1073. TypeCode: "14000010",
  1074. TypeName: "B液",
  1075. Remark: "",
  1076. Ctime: time.Now().Unix(),
  1077. Mtime: time.Now().Unix(),
  1078. Creater: 0,
  1079. Modifier: 0,
  1080. OrgId: item.Id,
  1081. Status: 1,
  1082. Type: 1,
  1083. Number: 11,
  1084. }
  1085. service.AddSigleGoodType(goodTypes10)
  1086. goodTypes11 := &models.GoodsType{
  1087. TypeCode: "14000011",
  1088. TypeName: "导管包",
  1089. Remark: "",
  1090. Ctime: time.Now().Unix(),
  1091. Mtime: time.Now().Unix(),
  1092. Creater: 0,
  1093. Modifier: 0,
  1094. OrgId: item.Id,
  1095. Status: 1,
  1096. Type: 1,
  1097. Number: 12,
  1098. }
  1099. service.AddSigleGoodType(goodTypes11)
  1100. goodTypes12 := &models.GoodsType{
  1101. TypeCode: "14000012",
  1102. TypeName: "血液透析导管",
  1103. Remark: "",
  1104. Ctime: time.Now().Unix(),
  1105. Mtime: time.Now().Unix(),
  1106. Creater: 0,
  1107. Modifier: 0,
  1108. OrgId: item.Id,
  1109. Status: 1,
  1110. Type: 1,
  1111. Number: 13,
  1112. }
  1113. service.AddSigleGoodType(goodTypes12)
  1114. }
  1115. }
  1116. }
  1117. func (c *PublicApiController) HandleComData() {
  1118. org_ids := []int64{3907, 9779, 9883}
  1119. for _, id := range org_ids {
  1120. //查处所有处方记录
  1121. prescriptions, _ := service.FindAllPrescription(id)
  1122. if id == 3907 {
  1123. for _, item := range prescriptions {
  1124. if item.Niprocart > 0 {
  1125. before := &models.DialysisBeforePrepare{
  1126. UserOrgId: id,
  1127. PatientId: item.PatientId,
  1128. RecordDate: item.RecordDate,
  1129. Count: 1,
  1130. Ctime: item.RecordDate,
  1131. Mtime: item.RecordDate,
  1132. Creater: item.Creater,
  1133. Modifier: item.Creater,
  1134. Status: 1,
  1135. }
  1136. before.GoodId = item.Niprocart
  1137. before.GoodTypeId = 241
  1138. service.AddSigleDialysisBeforePre(before)
  1139. }
  1140. if item.Jms > 0 {
  1141. before := &models.DialysisBeforePrepare{
  1142. UserOrgId: id,
  1143. PatientId: item.PatientId,
  1144. RecordDate: item.RecordDate,
  1145. Count: 1,
  1146. Ctime: item.RecordDate,
  1147. Mtime: item.RecordDate,
  1148. Creater: item.Creater,
  1149. Modifier: item.Creater,
  1150. Status: 1,
  1151. }
  1152. before.GoodId = item.Jms
  1153. before.GoodTypeId = 233
  1154. service.AddSigleDialysisBeforePre(before)
  1155. }
  1156. if item.FistulaNeedleSet > 0 {
  1157. before := &models.DialysisBeforePrepare{
  1158. UserOrgId: id,
  1159. PatientId: item.PatientId,
  1160. RecordDate: item.RecordDate,
  1161. Count: 1,
  1162. Ctime: item.RecordDate,
  1163. Mtime: item.RecordDate,
  1164. Creater: item.Creater,
  1165. Modifier: item.Creater,
  1166. Status: 1,
  1167. }
  1168. before.GoodId = item.FistulaNeedleSet
  1169. before.GoodTypeId = 233
  1170. service.AddSigleDialysisBeforePre(before)
  1171. }
  1172. if item.FistulaNeedleSet16 > 0 {
  1173. before := &models.DialysisBeforePrepare{
  1174. UserOrgId: id,
  1175. PatientId: item.PatientId,
  1176. RecordDate: item.RecordDate,
  1177. Count: 1,
  1178. Ctime: item.RecordDate,
  1179. Mtime: item.RecordDate,
  1180. Creater: item.Creater,
  1181. Modifier: item.Creater,
  1182. Status: 1,
  1183. }
  1184. before.GoodId = item.FistulaNeedleSet16
  1185. before.GoodTypeId = 233
  1186. service.AddSigleDialysisBeforePre(before)
  1187. }
  1188. if item.Hemoperfusion > 0 {
  1189. before := &models.DialysisBeforePrepare{
  1190. UserOrgId: id,
  1191. PatientId: item.PatientId,
  1192. RecordDate: item.RecordDate,
  1193. Count: 1,
  1194. Ctime: item.RecordDate,
  1195. Mtime: item.RecordDate,
  1196. Creater: item.Creater,
  1197. Modifier: item.Creater,
  1198. Status: 1,
  1199. }
  1200. before.GoodId = item.Hemoperfusion
  1201. before.GoodTypeId = 235
  1202. service.AddSigleDialysisBeforePre(before)
  1203. }
  1204. if item.DialyserSterilised > 0 {
  1205. before := &models.DialysisBeforePrepare{
  1206. UserOrgId: id,
  1207. PatientId: item.PatientId,
  1208. RecordDate: item.RecordDate,
  1209. Count: 1,
  1210. Ctime: item.RecordDate,
  1211. Mtime: item.RecordDate,
  1212. Creater: item.Creater,
  1213. Modifier: item.Creater,
  1214. Status: 1,
  1215. }
  1216. before.GoodId = item.DialyserSterilised
  1217. before.GoodTypeId = 234
  1218. service.AddSigleDialysisBeforePre(before)
  1219. }
  1220. if item.Filtryzer > 0 {
  1221. before := &models.DialysisBeforePrepare{
  1222. UserOrgId: id,
  1223. PatientId: item.PatientId,
  1224. RecordDate: item.RecordDate,
  1225. Count: 1,
  1226. Ctime: item.RecordDate,
  1227. Mtime: item.RecordDate,
  1228. Creater: item.Creater,
  1229. Modifier: item.Creater,
  1230. Status: 1,
  1231. }
  1232. before.GoodId = item.Filtryzer
  1233. before.GoodTypeId = 234
  1234. service.AddSigleDialysisBeforePre(before)
  1235. }
  1236. if item.Dialyzers > 0 {
  1237. before := &models.DialysisBeforePrepare{
  1238. UserOrgId: id,
  1239. PatientId: item.PatientId,
  1240. RecordDate: item.RecordDate,
  1241. Count: 1,
  1242. Ctime: item.RecordDate,
  1243. Mtime: item.RecordDate,
  1244. Creater: item.Creater,
  1245. Modifier: item.Creater,
  1246. Status: 1,
  1247. }
  1248. before.GoodId = item.Dialyzers
  1249. before.GoodTypeId = 234
  1250. service.AddSigleDialysisBeforePre(before)
  1251. }
  1252. if item.Injector > 0 {
  1253. before := &models.DialysisBeforePrepare{
  1254. UserOrgId: id,
  1255. PatientId: item.PatientId,
  1256. RecordDate: item.RecordDate,
  1257. Count: 1,
  1258. Ctime: item.RecordDate,
  1259. Mtime: item.RecordDate,
  1260. Creater: item.Creater,
  1261. Modifier: item.Creater,
  1262. Status: 1,
  1263. }
  1264. before.GoodId = item.Injector
  1265. before.GoodTypeId = 238
  1266. service.AddSigleDialysisBeforePre(before)
  1267. }
  1268. if item.Bloodlines > 0 {
  1269. before := &models.DialysisBeforePrepare{
  1270. UserOrgId: id,
  1271. PatientId: item.PatientId,
  1272. RecordDate: item.RecordDate,
  1273. Count: 1,
  1274. Ctime: item.RecordDate,
  1275. Mtime: item.RecordDate,
  1276. Creater: item.Creater,
  1277. Modifier: item.Creater,
  1278. Status: 1,
  1279. }
  1280. before.GoodId = item.Bloodlines
  1281. before.GoodTypeId = 236
  1282. service.AddSigleDialysisBeforePre(before)
  1283. }
  1284. if item.TubingHemodialysis > 0 {
  1285. before := &models.DialysisBeforePrepare{
  1286. UserOrgId: id,
  1287. PatientId: item.PatientId,
  1288. RecordDate: item.RecordDate,
  1289. Count: 1,
  1290. Ctime: item.RecordDate,
  1291. Mtime: item.RecordDate,
  1292. Creater: item.Creater,
  1293. Modifier: item.Creater,
  1294. Status: 1,
  1295. }
  1296. before.GoodId = item.TubingHemodialysis
  1297. before.GoodTypeId = 237
  1298. service.AddSigleDialysisBeforePre(before)
  1299. }
  1300. if item.Package > 0 {
  1301. before := &models.DialysisBeforePrepare{
  1302. UserOrgId: id,
  1303. PatientId: item.PatientId,
  1304. RecordDate: item.RecordDate,
  1305. Count: 1,
  1306. Ctime: item.RecordDate,
  1307. Mtime: item.RecordDate,
  1308. Creater: item.Creater,
  1309. Modifier: item.Creater,
  1310. Status: 1,
  1311. }
  1312. before.GoodId = item.Package
  1313. before.GoodTypeId = 239
  1314. service.AddSigleDialysisBeforePre(before)
  1315. }
  1316. if item.ALiquid > 0 {
  1317. before := &models.DialysisBeforePrepare{
  1318. UserOrgId: id,
  1319. PatientId: item.PatientId,
  1320. RecordDate: item.RecordDate,
  1321. Count: 1,
  1322. Ctime: item.RecordDate,
  1323. Mtime: item.RecordDate,
  1324. Creater: item.Creater,
  1325. Modifier: item.Creater,
  1326. Status: 1,
  1327. }
  1328. before.GoodId = item.ALiquid
  1329. before.GoodTypeId = 242
  1330. service.AddSigleDialysisBeforePre(before)
  1331. }
  1332. }
  1333. } else if id == 9779 {
  1334. for _, item := range prescriptions {
  1335. if item.Niprocart > 0 {
  1336. before := &models.DialysisBeforePrepare{
  1337. UserOrgId: id,
  1338. PatientId: item.PatientId,
  1339. RecordDate: item.RecordDate,
  1340. Count: 1,
  1341. Ctime: item.RecordDate,
  1342. Mtime: item.RecordDate,
  1343. Creater: item.Creater,
  1344. Modifier: item.Creater,
  1345. Status: 1,
  1346. }
  1347. before.GoodId = item.Niprocart
  1348. before.GoodTypeId = 254
  1349. service.AddSigleDialysisBeforePre(before)
  1350. }
  1351. if item.Jms > 0 {
  1352. before := &models.DialysisBeforePrepare{
  1353. UserOrgId: id,
  1354. PatientId: item.PatientId,
  1355. RecordDate: item.RecordDate,
  1356. Count: 1,
  1357. Ctime: item.RecordDate,
  1358. Mtime: item.RecordDate,
  1359. Creater: item.Creater,
  1360. Modifier: item.Creater,
  1361. Status: 1,
  1362. }
  1363. before.GoodId = item.Jms
  1364. before.GoodTypeId = 246
  1365. service.AddSigleDialysisBeforePre(before)
  1366. }
  1367. if item.FistulaNeedleSet > 0 {
  1368. before := &models.DialysisBeforePrepare{
  1369. UserOrgId: id,
  1370. PatientId: item.PatientId,
  1371. RecordDate: item.RecordDate,
  1372. Count: 1,
  1373. Ctime: item.RecordDate,
  1374. Mtime: item.RecordDate,
  1375. Creater: item.Creater,
  1376. Modifier: item.Creater,
  1377. Status: 1,
  1378. }
  1379. before.GoodId = item.FistulaNeedleSet
  1380. before.GoodTypeId = 246
  1381. service.AddSigleDialysisBeforePre(before)
  1382. }
  1383. if item.FistulaNeedleSet16 > 0 {
  1384. before := &models.DialysisBeforePrepare{
  1385. UserOrgId: id,
  1386. PatientId: item.PatientId,
  1387. RecordDate: item.RecordDate,
  1388. Count: 1,
  1389. Ctime: item.RecordDate,
  1390. Mtime: item.RecordDate,
  1391. Creater: item.Creater,
  1392. Modifier: item.Creater,
  1393. Status: 1,
  1394. }
  1395. before.GoodId = item.FistulaNeedleSet16
  1396. before.GoodTypeId = 246
  1397. service.AddSigleDialysisBeforePre(before)
  1398. }
  1399. if item.Hemoperfusion > 0 {
  1400. before := &models.DialysisBeforePrepare{
  1401. UserOrgId: id,
  1402. PatientId: item.PatientId,
  1403. RecordDate: item.RecordDate,
  1404. Count: 1,
  1405. Ctime: item.RecordDate,
  1406. Mtime: item.RecordDate,
  1407. Creater: item.Creater,
  1408. Modifier: item.Creater,
  1409. Status: 1,
  1410. }
  1411. before.GoodId = item.Hemoperfusion
  1412. before.GoodTypeId = 248
  1413. service.AddSigleDialysisBeforePre(before)
  1414. }
  1415. if item.DialyserSterilised > 0 {
  1416. before := &models.DialysisBeforePrepare{
  1417. UserOrgId: id,
  1418. PatientId: item.PatientId,
  1419. RecordDate: item.RecordDate,
  1420. Count: 1,
  1421. Ctime: item.RecordDate,
  1422. Mtime: item.RecordDate,
  1423. Creater: item.Creater,
  1424. Modifier: item.Creater,
  1425. Status: 1,
  1426. }
  1427. before.GoodId = item.DialyserSterilised
  1428. before.GoodTypeId = 247
  1429. service.AddSigleDialysisBeforePre(before)
  1430. }
  1431. if item.Filtryzer > 0 {
  1432. before := &models.DialysisBeforePrepare{
  1433. UserOrgId: id,
  1434. PatientId: item.PatientId,
  1435. RecordDate: item.RecordDate,
  1436. Count: 1,
  1437. Ctime: item.RecordDate,
  1438. Mtime: item.RecordDate,
  1439. Creater: item.Creater,
  1440. Modifier: item.Creater,
  1441. Status: 1,
  1442. }
  1443. before.GoodId = item.Filtryzer
  1444. before.GoodTypeId = 247
  1445. service.AddSigleDialysisBeforePre(before)
  1446. }
  1447. if item.Dialyzers > 0 {
  1448. before := &models.DialysisBeforePrepare{
  1449. UserOrgId: id,
  1450. PatientId: item.PatientId,
  1451. RecordDate: item.RecordDate,
  1452. Count: 1,
  1453. Ctime: item.RecordDate,
  1454. Mtime: item.RecordDate,
  1455. Creater: item.Creater,
  1456. Modifier: item.Creater,
  1457. Status: 1,
  1458. }
  1459. before.GoodId = item.Dialyzers
  1460. before.GoodTypeId = 247
  1461. service.AddSigleDialysisBeforePre(before)
  1462. }
  1463. if item.Injector > 0 {
  1464. before := &models.DialysisBeforePrepare{
  1465. UserOrgId: id,
  1466. PatientId: item.PatientId,
  1467. RecordDate: item.RecordDate,
  1468. Count: 1,
  1469. Ctime: item.RecordDate,
  1470. Mtime: item.RecordDate,
  1471. Creater: item.Creater,
  1472. Modifier: item.Creater,
  1473. Status: 1,
  1474. }
  1475. before.GoodId = item.Injector
  1476. before.GoodTypeId = 251
  1477. service.AddSigleDialysisBeforePre(before)
  1478. }
  1479. if item.Bloodlines > 0 {
  1480. before := &models.DialysisBeforePrepare{
  1481. UserOrgId: id,
  1482. PatientId: item.PatientId,
  1483. RecordDate: item.RecordDate,
  1484. Count: 1,
  1485. Ctime: item.RecordDate,
  1486. Mtime: item.RecordDate,
  1487. Creater: item.Creater,
  1488. Modifier: item.Creater,
  1489. Status: 1,
  1490. }
  1491. before.GoodId = item.Bloodlines
  1492. before.GoodTypeId = 249
  1493. service.AddSigleDialysisBeforePre(before)
  1494. }
  1495. if item.TubingHemodialysis > 0 {
  1496. before := &models.DialysisBeforePrepare{
  1497. UserOrgId: id,
  1498. PatientId: item.PatientId,
  1499. RecordDate: item.RecordDate,
  1500. Count: 1,
  1501. Ctime: item.RecordDate,
  1502. Mtime: item.RecordDate,
  1503. Creater: item.Creater,
  1504. Modifier: item.Creater,
  1505. Status: 1,
  1506. }
  1507. before.GoodId = item.TubingHemodialysis
  1508. before.GoodTypeId = 250
  1509. service.AddSigleDialysisBeforePre(before)
  1510. }
  1511. if item.Package > 0 {
  1512. before := &models.DialysisBeforePrepare{
  1513. UserOrgId: id,
  1514. PatientId: item.PatientId,
  1515. RecordDate: item.RecordDate,
  1516. Count: 1,
  1517. Ctime: item.RecordDate,
  1518. Mtime: item.RecordDate,
  1519. Creater: item.Creater,
  1520. Modifier: item.Creater,
  1521. Status: 1,
  1522. }
  1523. before.GoodId = item.Package
  1524. before.GoodTypeId = 252
  1525. service.AddSigleDialysisBeforePre(before)
  1526. }
  1527. if item.ALiquid > 0 {
  1528. before := &models.DialysisBeforePrepare{
  1529. UserOrgId: id,
  1530. PatientId: item.PatientId,
  1531. RecordDate: item.RecordDate,
  1532. Count: 1,
  1533. Ctime: item.RecordDate,
  1534. Mtime: item.RecordDate,
  1535. Creater: item.Creater,
  1536. Modifier: item.Creater,
  1537. Status: 1,
  1538. }
  1539. before.GoodId = item.ALiquid
  1540. before.GoodTypeId = 255
  1541. service.AddSigleDialysisBeforePre(before)
  1542. }
  1543. }
  1544. } else if id == 9883 {
  1545. for _, item := range prescriptions {
  1546. if item.Niprocart > 0 {
  1547. before := &models.DialysisBeforePrepare{
  1548. UserOrgId: id,
  1549. PatientId: item.PatientId,
  1550. RecordDate: item.RecordDate,
  1551. Count: 1,
  1552. Ctime: item.RecordDate,
  1553. Mtime: item.RecordDate,
  1554. Creater: item.Creater,
  1555. Modifier: item.Creater,
  1556. Status: 1,
  1557. }
  1558. before.GoodId = item.Niprocart
  1559. before.GoodTypeId = 267
  1560. service.AddSigleDialysisBeforePre(before)
  1561. }
  1562. if item.Jms > 0 {
  1563. before := &models.DialysisBeforePrepare{
  1564. UserOrgId: id,
  1565. PatientId: item.PatientId,
  1566. RecordDate: item.RecordDate,
  1567. Count: 1,
  1568. Ctime: item.RecordDate,
  1569. Mtime: item.RecordDate,
  1570. Creater: item.Creater,
  1571. Modifier: item.Creater,
  1572. Status: 1,
  1573. }
  1574. before.GoodId = item.Jms
  1575. before.GoodTypeId = 259
  1576. service.AddSigleDialysisBeforePre(before)
  1577. }
  1578. if item.FistulaNeedleSet > 0 {
  1579. before := &models.DialysisBeforePrepare{
  1580. UserOrgId: id,
  1581. PatientId: item.PatientId,
  1582. RecordDate: item.RecordDate,
  1583. Count: 1,
  1584. Ctime: item.RecordDate,
  1585. Mtime: item.RecordDate,
  1586. Creater: item.Creater,
  1587. Modifier: item.Creater,
  1588. Status: 1,
  1589. }
  1590. before.GoodId = item.FistulaNeedleSet
  1591. before.GoodTypeId = 259
  1592. service.AddSigleDialysisBeforePre(before)
  1593. }
  1594. if item.FistulaNeedleSet16 > 0 {
  1595. before := &models.DialysisBeforePrepare{
  1596. UserOrgId: id,
  1597. PatientId: item.PatientId,
  1598. RecordDate: item.RecordDate,
  1599. Count: 1,
  1600. Ctime: item.RecordDate,
  1601. Mtime: item.RecordDate,
  1602. Creater: item.Creater,
  1603. Modifier: item.Creater,
  1604. Status: 1,
  1605. }
  1606. before.GoodId = item.FistulaNeedleSet16
  1607. before.GoodTypeId = 259
  1608. service.AddSigleDialysisBeforePre(before)
  1609. }
  1610. if item.Hemoperfusion > 0 {
  1611. before := &models.DialysisBeforePrepare{
  1612. UserOrgId: id,
  1613. PatientId: item.PatientId,
  1614. RecordDate: item.RecordDate,
  1615. Count: 1,
  1616. Ctime: item.RecordDate,
  1617. Mtime: item.RecordDate,
  1618. Creater: item.Creater,
  1619. Modifier: item.Creater,
  1620. Status: 1,
  1621. }
  1622. before.GoodId = item.Hemoperfusion
  1623. before.GoodTypeId = 261
  1624. service.AddSigleDialysisBeforePre(before)
  1625. }
  1626. if item.DialyserSterilised > 0 {
  1627. before := &models.DialysisBeforePrepare{
  1628. UserOrgId: id,
  1629. PatientId: item.PatientId,
  1630. RecordDate: item.RecordDate,
  1631. Count: 1,
  1632. Ctime: item.RecordDate,
  1633. Mtime: item.RecordDate,
  1634. Creater: item.Creater,
  1635. Modifier: item.Creater,
  1636. Status: 1,
  1637. }
  1638. before.GoodId = item.DialyserSterilised
  1639. before.GoodTypeId = 260
  1640. service.AddSigleDialysisBeforePre(before)
  1641. }
  1642. if item.Filtryzer > 0 {
  1643. before := &models.DialysisBeforePrepare{
  1644. UserOrgId: id,
  1645. PatientId: item.PatientId,
  1646. RecordDate: item.RecordDate,
  1647. Count: 1,
  1648. Ctime: item.RecordDate,
  1649. Mtime: item.RecordDate,
  1650. Creater: item.Creater,
  1651. Modifier: item.Creater,
  1652. Status: 1,
  1653. }
  1654. before.GoodId = item.Filtryzer
  1655. before.GoodTypeId = 260
  1656. service.AddSigleDialysisBeforePre(before)
  1657. }
  1658. if item.Dialyzers > 0 {
  1659. before := &models.DialysisBeforePrepare{
  1660. UserOrgId: id,
  1661. PatientId: item.PatientId,
  1662. RecordDate: item.RecordDate,
  1663. Count: 1,
  1664. Ctime: item.RecordDate,
  1665. Mtime: item.RecordDate,
  1666. Creater: item.Creater,
  1667. Modifier: item.Creater,
  1668. Status: 1,
  1669. }
  1670. before.GoodId = item.Dialyzers
  1671. before.GoodTypeId = 260
  1672. service.AddSigleDialysisBeforePre(before)
  1673. }
  1674. if item.Injector > 0 {
  1675. before := &models.DialysisBeforePrepare{
  1676. UserOrgId: id,
  1677. PatientId: item.PatientId,
  1678. RecordDate: item.RecordDate,
  1679. Count: 1,
  1680. Ctime: item.RecordDate,
  1681. Mtime: item.RecordDate,
  1682. Creater: item.Creater,
  1683. Modifier: item.Creater,
  1684. Status: 1,
  1685. }
  1686. before.GoodId = item.Injector
  1687. before.GoodTypeId = 264
  1688. service.AddSigleDialysisBeforePre(before)
  1689. }
  1690. if item.Bloodlines > 0 {
  1691. before := &models.DialysisBeforePrepare{
  1692. UserOrgId: id,
  1693. PatientId: item.PatientId,
  1694. RecordDate: item.RecordDate,
  1695. Count: 1,
  1696. Ctime: item.RecordDate,
  1697. Mtime: item.RecordDate,
  1698. Creater: item.Creater,
  1699. Modifier: item.Creater,
  1700. Status: 1,
  1701. }
  1702. before.GoodId = item.Bloodlines
  1703. before.GoodTypeId = 262
  1704. service.AddSigleDialysisBeforePre(before)
  1705. }
  1706. if item.TubingHemodialysis > 0 {
  1707. before := &models.DialysisBeforePrepare{
  1708. UserOrgId: id,
  1709. PatientId: item.PatientId,
  1710. RecordDate: item.RecordDate,
  1711. Count: 1,
  1712. Ctime: item.RecordDate,
  1713. Mtime: item.RecordDate,
  1714. Creater: item.Creater,
  1715. Modifier: item.Creater,
  1716. Status: 1,
  1717. }
  1718. before.GoodId = item.TubingHemodialysis
  1719. before.GoodTypeId = 263
  1720. service.AddSigleDialysisBeforePre(before)
  1721. }
  1722. if item.Package > 0 {
  1723. before := &models.DialysisBeforePrepare{
  1724. UserOrgId: id,
  1725. PatientId: item.PatientId,
  1726. RecordDate: item.RecordDate,
  1727. Count: 1,
  1728. Ctime: item.RecordDate,
  1729. Mtime: item.RecordDate,
  1730. Creater: item.Creater,
  1731. Modifier: item.Creater,
  1732. Status: 1,
  1733. }
  1734. before.GoodId = item.Package
  1735. before.GoodTypeId = 265
  1736. service.AddSigleDialysisBeforePre(before)
  1737. }
  1738. if item.ALiquid > 0 {
  1739. before := &models.DialysisBeforePrepare{
  1740. UserOrgId: id,
  1741. PatientId: item.PatientId,
  1742. RecordDate: item.RecordDate,
  1743. Count: 1,
  1744. Ctime: item.RecordDate,
  1745. Mtime: item.RecordDate,
  1746. Creater: item.Creater,
  1747. Modifier: item.Creater,
  1748. Status: 1,
  1749. }
  1750. before.GoodId = item.ALiquid
  1751. before.GoodTypeId = 268
  1752. service.AddSigleDialysisBeforePre(before)
  1753. }
  1754. }
  1755. }
  1756. }
  1757. }
  1758. func (c *PublicApiController) HandleHIS() {
  1759. his, _ := service.GetAllHisInfo(9919)
  1760. for _, item := range his {
  1761. fsn := strings.Split(item.FeedetlSn, "-")
  1762. item.FeedetlSn = fsn[0] + "-" + fsn[1] + "-" + strconv.FormatInt(item.ID, 10)
  1763. fmt.Println(item.FeedetlSn)
  1764. service.UpDateHis2(item)
  1765. }
  1766. }
  1767. func (c *PublicApiController) HandleOrder() {
  1768. orders, _ := service.GetAllHisOrder(10106)
  1769. record, _ := service.FindFapiaoByIsUse(10106)
  1770. last_order, _ := service.GetAllHisOrderTwo(10106)
  1771. if record.ID > 0 {
  1772. for index, item := range orders {
  1773. item.FaPiaoCode = record.FapiaoCode
  1774. var zero string
  1775. max_number, _ := strconv.ParseInt(last_order.FaPiaoNumber, 10, 64)
  1776. number, _ := strconv.ParseInt(record.FapiaoNumber, 10, 64)
  1777. number = number + max_number
  1778. if number+int64(index) >= 1000 {
  1779. zero = "0000" + strconv.FormatInt(number+int64(index), 10)
  1780. } else if number+int64(index) >= 10000 {
  1781. zero = "000" + strconv.FormatInt(number+int64(index), 10)
  1782. } else if number+int64(index) >= 100000 {
  1783. zero = "00" + strconv.FormatInt(number+int64(index), 10)
  1784. } else if number+int64(index) >= 1000000 {
  1785. zero = "0" + strconv.FormatInt(number+int64(index), 10)
  1786. } else {
  1787. zero = strconv.FormatInt(number+int64(index), 10)
  1788. }
  1789. item.FaPiaoNumber = zero
  1790. item.FaPiaoBatchnumberId = record.ID
  1791. service.SaveOrder(item)
  1792. }
  1793. }
  1794. }
  1795. func Mkdir(dir string) {
  1796. // 创建文件夹
  1797. exist, err := PathExists(dir)
  1798. if err != nil {
  1799. fmt.Println(err.Error())
  1800. } else {
  1801. if exist {
  1802. fmt.Println(dir + "文件夹已存在!")
  1803. } else {
  1804. // 文件夹名称,权限
  1805. err := os.Mkdir(dir, os.ModePerm)
  1806. if err != nil {
  1807. fmt.Println(dir+"文件夹创建失败:", err.Error())
  1808. } else {
  1809. fmt.Println(dir + "文件夹创建成功!")
  1810. }
  1811. }
  1812. }
  1813. }
  1814. func PathExists(path string) (bool, error) {
  1815. _, err := os.Stat(path)
  1816. if err == nil {
  1817. return true, nil
  1818. }
  1819. if os.IsNotExist(err) {
  1820. return false, nil
  1821. }
  1822. return false, err
  1823. }
  1824. func (c *PublicApiController) Handle10215() {
  1825. //projects,_ := service.GetAllInfo(10215,2284)
  1826. //
  1827. //for _, item := range projects{
  1828. // service.UpdateStatus(item.ID, item.PrescriptionId)
  1829. //}
  1830. //projects_two,_ := service.GetAllInfo(10215,2277)
  1831. //
  1832. //for _, item := range projects_two{
  1833. // service.UpdateStatus(item.ID, item.PrescriptionId)
  1834. //}
  1835. //service.GetAllInfo(10215,2284)
  1836. //service.GetAllInfo(10215,2277)
  1837. his, _ := service.GetAllPT(10215)
  1838. for _, item := range his {
  1839. //
  1840. //pro := &models.HisPrescriptionProjectTemplate{
  1841. // ProjectId: 1750,
  1842. // Price: 6.00,
  1843. // UserOrgId: 10215,
  1844. // Status: 1,
  1845. // Ctime: time.Now().Unix(),
  1846. // Mtime: time.Now().Unix(),
  1847. // PatientId: item.PatientId,
  1848. // RecordDate: 0,
  1849. // Count: 1,
  1850. // FeedetlSn: "",
  1851. // MedListCodg: "",
  1852. // SingleDose: "1",
  1853. // DeliveryWay: "",
  1854. // ExecutionFrequency: "",
  1855. // Day: "1",
  1856. // Remark: "",
  1857. // Unit: "",
  1858. // Type: 2,
  1859. // PrescriptionId: info.ID,
  1860. // FrequencyType: 1,
  1861. // DayCount: 0,
  1862. // WeekDay: "",
  1863. //}
  1864. //service.CreateHisPrescriptionProjectTemplate(pro)
  1865. //
  1866. //pro2 := &models.HisPrescriptionProjectTemplate{
  1867. // ProjectId: 2462,
  1868. // Price: 4.94,
  1869. // UserOrgId: 10215,
  1870. // Status: 1,
  1871. // Ctime: time.Now().Unix(),
  1872. // Mtime: time.Now().Unix(),
  1873. // PatientId: item.PatientId,
  1874. // RecordDate: 0,
  1875. // Count: 1,
  1876. // FeedetlSn: "",
  1877. // MedListCodg: "",
  1878. // SingleDose: "1",
  1879. // DeliveryWay: "",
  1880. // ExecutionFrequency: "",
  1881. // Day: "1",
  1882. // Remark: "",
  1883. // Unit: "",
  1884. // Type: 3,
  1885. // PrescriptionId: info.ID,
  1886. // FrequencyType: 1,
  1887. // DayCount: 0,
  1888. // WeekDay: "",
  1889. //}
  1890. //service.CreateHisPrescriptionProjectTemplate(pro2)
  1891. //
  1892. //
  1893. infos, _ := service.GetAllPTInfo(10215, item.ID)
  1894. // // fmt.Println(infos)
  1895. for _, subItem := range infos {
  1896. if len(subItem.HisPrescriptionAdviceTemplate) > 0 && len(subItem.HisPrescriptionProjectTemplate) == 0 {
  1897. for _, ssubItem := range subItem.HisPrescriptionAdviceTemplate {
  1898. //if ssubItem.DrugId == 1234 {
  1899. // pro := &models.HisPrescriptionProjectTemplate{
  1900. // ProjectId: 2326,
  1901. // Price: 0.86,
  1902. // UserOrgId: ssubItem.UserOrgId,
  1903. // Status: 1,
  1904. // Ctime: time.Now().Unix(),
  1905. // Mtime: time.Now().Unix(),
  1906. // PatientId: ssubItem.PatientId,
  1907. // RecordDate: ssubItem.AdviceDate,
  1908. // Count: 1,
  1909. // FeedetlSn: "",
  1910. // MedListCodg: "",
  1911. // SingleDose: "1",
  1912. // DeliveryWay: "",
  1913. // ExecutionFrequency: "",
  1914. // Day: "1",
  1915. // Remark: "",
  1916. // Unit: "",
  1917. // Type: 3,
  1918. // PrescriptionId: info.ID,
  1919. // FrequencyType: ssubItem.FrequencyType,
  1920. // DayCount: ssubItem.DayCount,
  1921. // WeekDay: ssubItem.WeekDay,
  1922. // }
  1923. // service.CreateHisPrescriptionProjectTemplate(pro)
  1924. //
  1925. //}
  1926. if ssubItem.DrugId == 1288 {
  1927. info := &models.HisPrescriptionInfoTemplate{
  1928. UserOrgId: item.UserOrgId,
  1929. RecordDate: 0,
  1930. PatientId: item.PatientId,
  1931. Status: 1,
  1932. Ctime: time.Now().Unix(),
  1933. Mtime: time.Now().Unix(),
  1934. Type: 2,
  1935. Creator: 0,
  1936. Modifier: 0,
  1937. PType: 0,
  1938. PTemplateId: item.ID,
  1939. MedType: "14",
  1940. }
  1941. service.CreateHisPrescriptionInfoTemplate(info)
  1942. pro2 := &models.HisPrescriptionProjectTemplate{
  1943. ProjectId: 1727,
  1944. Price: 2.50,
  1945. UserOrgId: ssubItem.UserOrgId,
  1946. Status: 1,
  1947. Ctime: time.Now().Unix(),
  1948. Mtime: time.Now().Unix(),
  1949. PatientId: ssubItem.PatientId,
  1950. RecordDate: ssubItem.AdviceDate,
  1951. Count: "1",
  1952. FeedetlSn: "",
  1953. MedListCodg: "",
  1954. SingleDose: "1",
  1955. DeliveryWay: "",
  1956. ExecutionFrequency: "",
  1957. Day: "1",
  1958. Remark: "",
  1959. Unit: "",
  1960. Type: 2,
  1961. PrescriptionId: info.ID,
  1962. FrequencyType: ssubItem.FrequencyType,
  1963. DayCount: ssubItem.DayCount,
  1964. WeekDay: ssubItem.WeekDay,
  1965. }
  1966. service.CreateHisPrescriptionProjectTemplate(pro2)
  1967. //pro := &models.HisPrescriptionProjectTemplate{
  1968. // ProjectId: 2326,
  1969. // Price: 0.86,
  1970. // UserOrgId: ssubItem.UserOrgId,
  1971. // Status: 1,
  1972. // Ctime: time.Now().Unix(),
  1973. // Mtime: time.Now().Unix(),
  1974. // PatientId: ssubItem.PatientId,
  1975. // RecordDate: ssubItem.AdviceDate,
  1976. // Count: 1,
  1977. // FeedetlSn: "",
  1978. // MedListCodg: "",
  1979. // SingleDose: "1",
  1980. // DeliveryWay: "",
  1981. // ExecutionFrequency: "",
  1982. // Day: "1",
  1983. // Remark: "",
  1984. // Unit: "",
  1985. // Type: 3,
  1986. // PrescriptionId: info.ID,
  1987. // FrequencyType: ssubItem.FrequencyType,
  1988. // DayCount: ssubItem.DayCount,
  1989. // WeekDay: ssubItem.WeekDay,
  1990. //}
  1991. //service.CreateHisPrescriptionProjectTemplate(pro)
  1992. }
  1993. //if ssubItem.DrugId == 1306 {
  1994. //
  1995. // pro := &models.HisPrescriptionProjectTemplate{
  1996. // ProjectId: 2325,
  1997. // Price: 1.11,
  1998. // UserOrgId: ssubItem.UserOrgId,
  1999. // Status: 1,
  2000. // Ctime: time.Now().Unix(),
  2001. // Mtime: time.Now().Unix(),
  2002. // PatientId: ssubItem.PatientId,
  2003. // RecordDate: ssubItem.AdviceDate,
  2004. // Count: 1,
  2005. // FeedetlSn: "",
  2006. // MedListCodg: "",
  2007. // SingleDose: "1",
  2008. // DeliveryWay: "",
  2009. // ExecutionFrequency: "",
  2010. // Day: "1",
  2011. // Remark: "",
  2012. // Unit: "",
  2013. // Type: 3,
  2014. // PrescriptionId: info.ID,
  2015. // FrequencyType: ssubItem.FrequencyType,
  2016. // DayCount: ssubItem.DayCount,
  2017. // WeekDay: ssubItem.WeekDay,
  2018. // }
  2019. // service.CreateHisPrescriptionProjectTemplate(pro)
  2020. //
  2021. // pro2 := &models.HisPrescriptionProjectTemplate{
  2022. // ProjectId: 1727,
  2023. // Price: 2.50,
  2024. // UserOrgId: ssubItem.UserOrgId,
  2025. // Status: 1,
  2026. // Ctime: time.Now().Unix(),
  2027. // Mtime: time.Now().Unix(),
  2028. // PatientId: ssubItem.PatientId,
  2029. // RecordDate: ssubItem.AdviceDate,
  2030. // Count: 1,
  2031. // FeedetlSn: "",
  2032. // MedListCodg: "",
  2033. // SingleDose: "1",
  2034. // DeliveryWay: "",
  2035. // ExecutionFrequency: "",
  2036. // Day: "1",
  2037. // Remark: "",
  2038. // Unit: "",
  2039. // Type: 2,
  2040. // PrescriptionId: info.ID,
  2041. // FrequencyType: ssubItem.FrequencyType,
  2042. // DayCount: ssubItem.DayCount,
  2043. // WeekDay: ssubItem.WeekDay,
  2044. // }
  2045. // service.CreateHisPrescriptionProjectTemplate(pro2)
  2046. //
  2047. //}
  2048. //if ssubItem.DrugId == 1291 {
  2049. //
  2050. // pro := &models.HisPrescriptionProjectTemplate{
  2051. // ProjectId: 2322,
  2052. // Price: 0.68,
  2053. // UserOrgId: ssubItem.UserOrgId,
  2054. // Status: 1,
  2055. // Ctime: time.Now().Unix(),
  2056. // Mtime: time.Now().Unix(),
  2057. // PatientId: ssubItem.PatientId,
  2058. // RecordDate: ssubItem.AdviceDate,
  2059. // Count: 1,
  2060. // FeedetlSn: "",
  2061. // MedListCodg: "",
  2062. // SingleDose: "1",
  2063. // DeliveryWay: "",
  2064. // ExecutionFrequency: "",
  2065. // Day: "1",
  2066. // Remark: "",
  2067. // Unit: "",
  2068. // Type: 3,
  2069. // PrescriptionId: info.ID,
  2070. // FrequencyType: ssubItem.FrequencyType,
  2071. // DayCount: ssubItem.DayCount,
  2072. // WeekDay: ssubItem.WeekDay,
  2073. // }
  2074. // service.CreateHisPrescriptionProjectTemplate(pro)
  2075. //
  2076. // pro2 := &models.HisPrescriptionProjectTemplate{
  2077. // ProjectId: 1727,
  2078. // Price: 2.50,
  2079. // UserOrgId: ssubItem.UserOrgId,
  2080. // Status: 1,
  2081. // Ctime: time.Now().Unix(),
  2082. // Mtime: time.Now().Unix(),
  2083. // PatientId: ssubItem.PatientId,
  2084. // RecordDate: ssubItem.AdviceDate,
  2085. // Count: 1,
  2086. // FeedetlSn: "",
  2087. // MedListCodg: "",
  2088. // SingleDose: "1",
  2089. // DeliveryWay: "",
  2090. // ExecutionFrequency: "",
  2091. // Day: "1",
  2092. // Remark: "",
  2093. // Unit: "",
  2094. // Type: 2,
  2095. // PrescriptionId: info.ID,
  2096. // FrequencyType: ssubItem.FrequencyType,
  2097. // DayCount: ssubItem.DayCount,
  2098. // WeekDay: ssubItem.WeekDay,
  2099. // }
  2100. // service.CreateHisPrescriptionProjectTemplate(pro2)
  2101. //}
  2102. }
  2103. }
  2104. }
  2105. }
  2106. }
  2107. func (c *PublicApiController) HandleExportAllData() {
  2108. orders, _ := service.GetHisOrderDetail9504()
  2109. c.ServeSuccessJSON(map[string]interface{}{
  2110. "order": orders,
  2111. })
  2112. }
  2113. func (c *PublicApiController) HandleExportData10138() {
  2114. orders, _ := service.GetHisOrderDetail10138()
  2115. c.ServeSuccessJSON(map[string]interface{}{
  2116. "order": orders,
  2117. })
  2118. }
  2119. func (c *PublicApiController) HandleData10265() {
  2120. orders, _ := service.GetHisOrder10265()
  2121. for _, items := range orders {
  2122. if items.AdviceId == 0 && items.ProjectId > 0 {
  2123. p, _ := service.GetHisPrescriptionProjectByIDTwo(items.ProjectId)
  2124. if p.Type == 2 {
  2125. if p.HisProject.CostClassify == 3 {
  2126. items.MedChrgitmType = "04"
  2127. }
  2128. if p.HisProject.CostClassify == 2 {
  2129. items.MedChrgitmType = "05"
  2130. }
  2131. if p.HisProject.CostClassify == 8 {
  2132. items.MedChrgitmType = "03"
  2133. }
  2134. //p.HisProject.CostClassify == 8
  2135. } else {
  2136. items.MedChrgitmType = "08"
  2137. }
  2138. }
  2139. service.SaveOrderInfo(items)
  2140. }
  2141. }
  2142. //func (c *PublicApiController) HandleOrderInfoData() {
  2143. // orders, _ := service.GetHisOrderInfoDetail()
  2144. // c.ServeSuccessJSON(map[string]interface{}{
  2145. // "info": orders,
  2146. // })
  2147. //}
  2148. //
  2149. //func (c *PublicApiController)HandleOrderInfoData10138(){
  2150. // start_time := c.GetString("start_time")
  2151. // end_time := c.GetString("end_time")
  2152. // timeLayout := "2006-01-02"
  2153. // loc, _ := time.LoadLocation("Local")
  2154. // startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2155. // if err != nil {
  2156. //
  2157. // }
  2158. // startRecordDateTime := startTime.Unix()
  2159. // endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2160. // if err != nil {
  2161. //
  2162. // }
  2163. // endRecordDateTime := endTime.Unix()
  2164. // orders, _ := service.GetHisAllPatientOrder(startRecordDateTime,endRecordDateTime)
  2165. // for _, item := range orders{
  2166. // for _, subItem := range item.HisOrder10138{
  2167. // info, _ := service.GetHisOrderInfoDetail10138(subItem.Number)
  2168. // subItem.VmHisOrderInfo9504 = info
  2169. // }
  2170. // }
  2171. // c.ServeSuccessJSON(map[string]interface{}{
  2172. // "info": orders,
  2173. // })
  2174. //
  2175. //}