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