bl_service.go 49KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984
  1. package service
  2. import (
  3. "fmt"
  4. "github.com/jinzhu/gorm"
  5. "strconv"
  6. "strings"
  7. "time"
  8. )
  9. type HisOrder struct {
  10. ID int64 `gorm:"column:id" json:"id" form:"id"`
  11. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  12. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  13. SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
  14. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  15. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  16. Status int64 `gorm:"column:status" json:"status" form:"status"`
  17. Number string `gorm:"column:number" json:"number" form:"number"`
  18. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  19. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  20. MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
  21. XtHisPatient XtHisPatient `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_patient"`
  22. }
  23. func (HisOrder) TableName() string {
  24. return "his_order"
  25. }
  26. type XtHisPatient struct {
  27. ID int64 `gorm:"column:id" json:"id" form:"id"`
  28. BalanceAccountsType int64 `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
  29. MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
  30. Name string `gorm:"column:name" json:"name" form:"name"`
  31. Gender int64 `gorm:"column:gender" json:"gender" form:"gender"`
  32. IdType int64 `gorm:"column:id_type" json:"id_type" form:"id_type"`
  33. MedicalTreatmentType int64 `gorm:"column:medical_treatment_type" json:"medical_treatment_type" form:"medical_treatment_type"`
  34. Birthday int64 `gorm:"column:birthday" json:"birthday" form:"birthday"`
  35. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  36. Age int64 `gorm:"column:age" json:"age" form:"age"`
  37. PhoneNumber string `gorm:"column:phone_number" json:"phone_number" form:"phone_number"`
  38. IdCardNo string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
  39. RegisterType int64 `gorm:"column:register_type" json:"register_type" form:"register_type"`
  40. AdminUserId int64 `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
  41. Departments int64 `gorm:"column:departments" json:"departments" form:"departments"`
  42. IsNeedCostOfProduction int64 `gorm:"column:is_need_cost_of_production" json:"is_need_cost_of_production" form:"is_need_cost_of_production"`
  43. RegisterCost float64 `gorm:"column:register_cost" json:"register_cost" form:"register_cost"`
  44. TreatmentCost float64 `gorm:"column:treatment_cost" json:"treatment_cost" form:"treatment_cost"`
  45. CostOfProduction float64 `gorm:"column:cost_of_production" json:"cost_of_production" form:"cost_of_production"`
  46. Total float64 `gorm:"column:total" json:"total" form:"total"`
  47. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  48. Status int64 `gorm:"column:status" json:"status" form:"status"`
  49. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  50. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  51. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  52. Number string `gorm:"column:number" json:"number" form:"number"`
  53. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  54. IsReturn int64 `gorm:"column:is_return" json:"is_return" form:"is_return"`
  55. Phone string `gorm:"column:phone" json:"phone" form:"phone"`
  56. SocialType int64 `gorm:"column:social_type" json:"social_type" form:"social_type"`
  57. IdCardType int64 `gorm:"column:id_card_type" json:"id_card_type" form:"id_card_type"`
  58. PType string `gorm:"column:p_type" json:"p_type" form:"p_type"`
  59. Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
  60. SickType int64 `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
  61. }
  62. func (XtHisPatient) TableName() string {
  63. return "his_patient"
  64. }
  65. type HisPrescription struct {
  66. ID int64 `gorm:"column:id" json:"id" form:"id"`
  67. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  68. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  69. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  70. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  71. Status int64 `gorm:"column:status" json:"status" form:"status"`
  72. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  73. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  74. Number string `gorm:"column:number" json:"number" form:"number"`
  75. Type int64 `gorm:"column:type" json:"type" form:"type"`
  76. Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
  77. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  78. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  79. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  80. PreTime int64 `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
  81. BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
  82. PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
  83. HisOrder HisOrder `gorm:"ForeignKey:Number;AssociationForeignKey:BatchNumber" json:"order"`
  84. Total string `gorm:"-" json:"total" form:"total"`
  85. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  86. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  87. }
  88. func (HisPrescription) TableName() string {
  89. return "his_prescription"
  90. }
  91. type CmSample struct {
  92. HospitalBarcode string `gorm:"column:hospital_barcode" json:"hospital_barcode" form:"hospital_barcode"`
  93. Hospsamplenumber string `gorm:"column:hospsamplenumber" json:"hospsamplenumber" form:"hospsamplenumber"`
  94. Pno string `gorm:"column:pno" json:"pno" form:"pno"`
  95. Ptype string `gorm:"column:ptype" json:"ptype" form:"ptype"`
  96. Bedno string `gorm:"column:bedno" json:"bedno" form:"bedno"`
  97. Pname string `gorm:"column:pname" json:"pname" form:"pname"`
  98. Psex string `gorm:"column:psex" json:"psex" form:"psex"`
  99. Page string `gorm:"column:page" json:"page" form:"page"`
  100. Pageunit string `gorm:"column:pageunit" json:"pageunit" form:"pageunit"`
  101. Ptel string `gorm:"column:ptel" json:"ptel" form:"ptel"`
  102. Stature string `gorm:"column:stature" json:"stature" form:"stature"`
  103. Avoirdupois string `gorm:"column:avoirdupois" json:"avoirdupois" form:"avoirdupois"`
  104. Gravweek string `gorm:"column:gravweek" json:"gravweek" form:"gravweek"`
  105. Collectiongravday string `gorm:"column:collectiongravday" json:"collectiongravday" form:"collectiongravday"`
  106. Birthday time.Time `gorm:"column:birthday" json:"birthday" form:"birthday"`
  107. Departname string `gorm:"column:departname" json:"departname" form:"departname"`
  108. Docname string `gorm:"column:docname" json:"docname" form:"docname"`
  109. Doctortel string `gorm:"column:doctortel" json:"doctortel" form:"doctortel"`
  110. Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
  111. Stype string `gorm:"column:stype" json:"stype" form:"stype"`
  112. Samstate string `gorm:"column:samstate" json:"samstate" form:"samstate"`
  113. Desccode string `gorm:"column:desccode" json:"desccode" form:"desccode"`
  114. Descr string `gorm:"column:descr" json:"descr" form:"descr"`
  115. Sampletime time.Time `gorm:"column:sampletime" json:"sampletime" form:"sampletime"`
  116. Senddate time.Time `gorm:"column:senddate" json:"senddate" form:"senddate"`
  117. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  118. Idcard string `gorm:"column:idcard" json:"idcard" form:"idcard"`
  119. CardClass string `gorm:"column:cardclass" json:"cardclass" form:"cardclass"`
  120. }
  121. func (CmSample) TableName() string {
  122. return "v_cm_sample"
  123. }
  124. type CmLisitems struct {
  125. ItemCode string `gorm:"column:item_code" json:"item_code" form:"item_code"`
  126. ItemName string `gorm:"column:item_name" json:"item_name" form:"item_name"`
  127. Testmethod string `gorm:"column:testmethod" json:"testmethod" form:"testmethod"`
  128. Iscompound string `gorm:"column:iscmpound" json:"iscmpound" form:"iscmpound"`
  129. DepartmentName string `gorm:"column:department_name" json:"department_name" form:"department_name"`
  130. }
  131. func (CmLisitems) TableName() string {
  132. return "v_cm_listtems"
  133. }
  134. type HisLabelPrintInfo struct {
  135. ID int64 `gorm:"column:id" json:"id" form:"id"`
  136. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  137. Number string `gorm:"column:number" json:"number" form:"number"`
  138. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  139. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  140. DoctorId int64 `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
  141. Status int64 `gorm:"column:status" json:"status" form:"status"`
  142. ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
  143. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  144. IsPrint int64 `gorm:"column:is_print" json:"is_print" form:"is_print"`
  145. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  146. ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
  147. PProjectId int64 `gorm:"column:p_project_id" json:"p_project_id" form:"p_project_id"`
  148. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  149. DoctorName string `gorm:"column:doctor_name" json:"doctor_name" form:"doctor_name"`
  150. PatientName string `gorm:"column:patient_name" json:"patient_name" form:"patient_name"`
  151. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  152. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  153. HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:PProjectId" json:"project"`
  154. }
  155. func (HisLabelPrintInfo) TableName() string {
  156. return "his_label_print_info"
  157. }
  158. type LisSyncProcessStatusInfo struct {
  159. ID int64 `gorm:"column:id" json:"id" form:"id"`
  160. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  161. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  162. Status int64 `gorm:"column:status" json:"status" form:"status"`
  163. LastId int64 `gorm:"column:last_id" json:"last_id" form:"last_id"`
  164. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  165. IsInsert int64 `gorm:"column:is_insert" json:"is_insert" form:"is_insert"`
  166. IsResult int64 `gorm:"column:is_result" json:"is_result" form:"is_result"`
  167. ResultDate int64 `gorm:"column:result_date" json:"result_date" form:"result_date"`
  168. }
  169. func (LisSyncProcessStatusInfo) TableName() string {
  170. return "lis_sync_process_status_info"
  171. }
  172. type CmResult struct {
  173. Barcode string `gorm:"column:barcode" json:"barcode" form:"barcode"`
  174. Itemcode string `gorm:"column:itemcode" json:"itemcode" form:"itemcode"`
  175. Itemname string `gorm:"column:itemname" json:"itemname" form:"itemname"`
  176. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  177. Result string `gorm:"column:result" json:"result" form:"result"`
  178. Refrange string `gorm:"column:refrange" json:"refrange" form:"refrange"`
  179. Ts string `gorm:"column:ts" json:"ts" form:"ts"`
  180. Jyys string `gorm:"column:jyys" json:"jyys" form:"jyys"`
  181. Shys string `gorm:"column:shys" json:"shys" form:"shys"`
  182. Hycode string `gorm:"column:hycode" json:"hycode" form:"hycode"`
  183. Reptype string `gorm:"column:reptype" json:"reptype" form:"reptype"`
  184. TJH string `gorm:"column:tjh" json:"tjh" form:"tjh"`
  185. Repdate string `gorm:"column:repdate" json:"repdate" form:"repdate"`
  186. Groupname string `gorm:"column:groupname" json:"groupname" form:"groupname"`
  187. Groupcode string `gorm:"column:groupcode" json:"groupcode" form:"groupcode"`
  188. Brkb string `gorm:"column:brkb" json:"brkb" form:"brkb"`
  189. Mic string `gorm:"column:mic" json:"mic" form:"mic"`
  190. Yjjy string `gorm:"column:yjjy" json:"yjjy" form:"yjjy"`
  191. Name string `gorm:"column:name" json:"name" form:"name"`
  192. }
  193. func (CmResult) TableName() string {
  194. return "v_cm_result"
  195. }
  196. type LisSyncResultStatusInfo struct {
  197. ID int64 `gorm:"column:id" json:"id" form:"id"`
  198. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  199. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  200. Status int64 `gorm:"column:status" json:"status" form:"status"`
  201. LastId int64 `gorm:"column:last_id" json:"last_id" form:"last_id"`
  202. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  203. IsResult int64 `gorm:"column:is_result" json:"is_result" form:"is_result"`
  204. ResultDate int64 `gorm:"column:result_date" json:"result_date" form:"result_date"`
  205. }
  206. func (LisSyncResultStatusInfo) TableName() string {
  207. return "lis_sync_result_status_info"
  208. }
  209. func GetLastSyncRecord(org_id int64) (record LisSyncProcessStatusInfo, err error) {
  210. err = readMiddleDb.Model(&LisSyncProcessStatusInfo{}).Where("org_id = ? AND status = 1", org_id).Last(&record).Error
  211. return
  212. }
  213. func GetLastSyncResultRecord(org_id int64) (record LisSyncResultStatusInfo, err error) {
  214. err = readDb.Model(&LisSyncResultStatusInfo{}).Where("org_id = ? AND status = 1", org_id).Last(&record).Error
  215. return
  216. }
  217. func GetResultRecord() (record []*CmResult, err error) {
  218. err = dataBase.Model(&CmResult{}).Order("barcode desc").Find(&record).Error
  219. return
  220. }
  221. func GetResultRecordByID(id int64) (record []*CmResult, err error) {
  222. err = readDb.Model(&CmResult{}).Where("barcode > ?", id).Order("barcode desc").Find(&record).Error
  223. return
  224. }
  225. func GetSaveResultRecord(record LisSyncResultStatusInfo) (err error) {
  226. err = dataBase.Save(record).Error
  227. return
  228. }
  229. func GetLisDataById(org_id int64, last_id int64) (list []*HisLabelPrintInfo, err error) {
  230. //err = readDb.Model(&HisLabelPrintInfo{}).Where("id > ? AND user_org_id = ? AND status = 1", last_id, org_id).Find(&list).Error
  231. err = readDb.Model(&HisLabelPrintInfo{}).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  232. return db.Preload("HisPrescription", func(db *gorm.DB) *gorm.DB {
  233. return db.Preload("HisOrder", func(db *gorm.DB) *gorm.DB {
  234. return db.Preload("XtHisPatient", func(db *gorm.DB) *gorm.DB {
  235. return db.Where("status = 1")
  236. }).Where("status = 1")
  237. }).Where("status = 1")
  238. }).Where("status = 1")
  239. }).Where("id > ? AND user_org_id = ? AND status = 1", last_id, org_id).Limit(100).Find(&list).Error
  240. return
  241. }
  242. func GetAllLisData(org_id int64) (list []*HisLabelPrintInfo, err error) {
  243. err = readDb.Model(&HisLabelPrintInfo{}).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  244. return db.Preload("HisPrescription", func(db *gorm.DB) *gorm.DB {
  245. return db.Preload("HisOrder", func(db *gorm.DB) *gorm.DB {
  246. return db.Preload("XtHisPatient", func(db *gorm.DB) *gorm.DB {
  247. return db.Where("status = 1")
  248. }).Where("status = 1")
  249. }).Where("status = 1")
  250. }).Where("status = 1")
  251. }).Where("user_org_id = ? AND status = 1", org_id).Limit(100).Find(&list).Error
  252. return
  253. }
  254. func GetAllLisResultData(org_id int64) (list []*CmResult, err error) {
  255. err = readDb.Model(&CmResult{}).Where("user_org_id = ? AND status = 1 ", org_id).Find(&list).Error
  256. return
  257. }
  258. func GetLisResultDataByRecord(org_id int64) (list []*CmResult, err error) {
  259. err = readDb.Model(&CmResult{}).Where("user_org_id = ? AND status = 1", org_id).Find(&list).Error
  260. return
  261. }
  262. //插入中间件逻辑
  263. func GetDataInsertDB(org_id int64) {
  264. record, _ := GetLastSyncRecord(org_id)
  265. if record.ID == 0 {
  266. var cms_arr []CmSample
  267. list, _ := GetAllLisData(org_id)
  268. //插入中间库中
  269. for _, item := range list {
  270. fmt.Println(item.HisPrescriptionProject)
  271. if item.ItemId > 0 {
  272. var cms CmSample
  273. cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
  274. cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
  275. cms.Ptype = "门诊"
  276. cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
  277. if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
  278. cms.Psex = "男"
  279. } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
  280. cms.Psex = "女"
  281. }
  282. cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
  283. cms.Pageunit = "岁"
  284. cms.Departname = "肾病学专业"
  285. role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
  286. cms.Docname = role.UserName
  287. diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
  288. //var config []*models.HisXtDiagnoseConfig
  289. var name string
  290. for _, item := range diagnosis_ids {
  291. id, _ := strconv.ParseInt(item, 10, 64)
  292. diagnosisConfig, _ := FindDiagnoseById(id)
  293. if len(name) == 0 {
  294. name = diagnosisConfig.ClassName
  295. } else {
  296. name = name + "," + diagnosisConfig.ClassName
  297. }
  298. }
  299. cms.Diagnosis = name
  300. cms.Stype = ""
  301. cms.Samstate = ""
  302. cms.Desccode = strconv.FormatInt(item.ID, 10)
  303. cms.Descr = item.ProjectName
  304. data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
  305. datatime := time.Unix(data/1000, 0)
  306. cms.Sampletime = datatime
  307. cms.Senddate = time.Now()
  308. cms_arr = append(cms_arr, cms)
  309. } else {
  310. var cms CmSample
  311. cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
  312. cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
  313. cms.Ptype = "门诊"
  314. cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
  315. if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
  316. cms.Psex = "男"
  317. } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
  318. cms.Psex = "女"
  319. }
  320. cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
  321. cms.Pageunit = "岁"
  322. cms.Departname = "肾病学专业"
  323. role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
  324. cms.Docname = role.UserName
  325. diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
  326. //var config []*models.HisXtDiagnoseConfig
  327. var name string
  328. for _, item := range diagnosis_ids {
  329. id, _ := strconv.ParseInt(item, 10, 64)
  330. diagnosisConfig, _ := FindDiagnoseById(id)
  331. if len(name) == 0 {
  332. name = diagnosisConfig.ClassName
  333. } else {
  334. name = name + "," + diagnosisConfig.ClassName
  335. }
  336. }
  337. cms.Diagnosis = name
  338. cms.Stype = ""
  339. cms.Samstate = ""
  340. cms.Desccode = strconv.FormatInt(item.ID, 10)
  341. cms.Descr = item.ProjectName
  342. tm := time.Unix(item.Ctime, 0)
  343. //data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
  344. //datatime := time.Unix(data/1000, 0)
  345. cms.Sampletime = tm
  346. cms.Senddate = time.Now()
  347. cms_arr = append(cms_arr, cms)
  348. }
  349. }
  350. //插入到中间库
  351. for _, item := range cms_arr {
  352. if len(item.Pno) > 0 {
  353. blDb.Save(item)
  354. }
  355. }
  356. //插入一条插入中间库记录数据
  357. var info LisSyncProcessStatusInfo
  358. info.Ctime = time.Now().Unix()
  359. info.Status = 1
  360. info.Mtime = time.Now().Unix()
  361. info.OrgId = org_id
  362. info.IsInsert = 1
  363. info.IsResult = 0
  364. info.LastId = list[len(list)-1].ID
  365. info.ResultDate = 0
  366. writeMiddleDb.Save(&info)
  367. } else {
  368. var cms_arr []CmSample
  369. if record.LastId != 0 {
  370. list, _ := GetLisDataById(org_id, record.LastId)
  371. //插入中间库中
  372. for _, item := range list {
  373. if item.ItemId > 0 {
  374. fmt.Println()
  375. //teams, _ := GetProjectTeamList(org_id, item.ItemId, item.PrescriptionId)
  376. //for _, subItem := range teams {
  377. var cms CmSample
  378. cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
  379. //cms.Hospsamplenumber = strconv.FormatInt(item.ID, 10)
  380. cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
  381. cms.Ptype = "门诊"
  382. cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
  383. if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
  384. cms.Psex = "男"
  385. } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
  386. cms.Psex = "女"
  387. }
  388. cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
  389. cms.Pageunit = "岁"
  390. cms.Departname = "肾病学专业"
  391. role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
  392. cms.Docname = role.UserName
  393. diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
  394. //var config []*models.HisXtDiagnoseConfig
  395. var name string
  396. for _, item := range diagnosis_ids {
  397. id, _ := strconv.ParseInt(item, 10, 64)
  398. diagnosisConfig, _ := FindDiagnoseById(id)
  399. if len(name) == 0 {
  400. name = diagnosisConfig.ClassName
  401. } else {
  402. name = name + "," + diagnosisConfig.ClassName
  403. }
  404. }
  405. cms.Diagnosis = name
  406. cms.Stype = ""
  407. cms.Samstate = ""
  408. cms.Desccode = strconv.FormatInt(item.ID, 10)
  409. cms.Descr = item.ProjectName
  410. //data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
  411. //datatime := time.Unix(data/1000, 0)
  412. //cms.Sampletime = datatime
  413. tm := time.Unix(item.Ctime, 0)
  414. cms.Sampletime = tm
  415. cms.Senddate = time.Now()
  416. cms_arr = append(cms_arr, cms)
  417. } else {
  418. var cms CmSample
  419. cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
  420. //cms.Hospsamplenumber = strconv.FormatInt(item.ID, 10)
  421. cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
  422. cms.Ptype = "门诊"
  423. cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
  424. if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
  425. cms.Psex = "男"
  426. } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
  427. cms.Psex = "女"
  428. }
  429. cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
  430. cms.Pageunit = "岁"
  431. cms.Departname = "肾病学专业"
  432. role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
  433. cms.Docname = role.UserName
  434. diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
  435. var name string
  436. for _, item := range diagnosis_ids {
  437. id, _ := strconv.ParseInt(item, 10, 64)
  438. diagnosisConfig, _ := FindDiagnoseById(id)
  439. if len(name) == 0 {
  440. name = diagnosisConfig.ClassName
  441. } else {
  442. name = name + "," + diagnosisConfig.ClassName
  443. }
  444. }
  445. cms.Diagnosis = name
  446. cms.Stype = ""
  447. cms.Samstate = ""
  448. cms.Desccode = strconv.FormatInt(item.ID, 10)
  449. cms.Descr = item.ProjectName
  450. tm := time.Unix(item.Ctime, 0)
  451. cms.Sampletime = tm
  452. cms.Senddate = time.Now()
  453. cms_arr = append(cms_arr, cms)
  454. }
  455. }
  456. //插入一条插入中间库记录数据
  457. for _, item := range cms_arr {
  458. if len(item.Pno) > 0 {
  459. blDb.Save(item)
  460. }
  461. }
  462. //插入一条插入中间库记录数据
  463. var info LisSyncProcessStatusInfo
  464. info.Ctime = time.Now().Unix()
  465. info.Status = 1
  466. info.Mtime = time.Now().Unix()
  467. info.OrgId = org_id
  468. info.IsInsert = 1
  469. info.IsResult = 0
  470. info.LastId = list[len(list)-1].ID
  471. info.ResultDate = 0
  472. writeMiddleDb.Save(&info)
  473. }
  474. }
  475. }
  476. //获取lis返回检验检查结果数据
  477. func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
  478. record, _ := GetLastSyncResultRecord(org_id)
  479. if record.ID == 0 {
  480. list, err := GetResultRecord()
  481. if err == nil {
  482. //插入一条查询检验检查结果记录状态数据
  483. var info LisSyncResultStatusInfo
  484. info.Ctime = time.Now().Unix()
  485. info.Status = 1
  486. info.Mtime = time.Now().Unix()
  487. info.OrgId = org_id
  488. info.IsResult = 1
  489. code, _ := strconv.ParseInt(list[0].Barcode, 10, 64)
  490. info.LastId = code
  491. info.ResultDate = time.Now().Unix()
  492. writeMiddleDb.Save(&info)
  493. //插入到系统检验检查数据
  494. //for _, item := range list{}
  495. //for _, item := range list {
  496. //
  497. // project_id := int64(0)
  498. // if len(item.Barcode) > 0 {
  499. // project_id, _ = GetGzjhProjectID(org_id, item.Groupname)
  500. // } else {
  501. // continue
  502. // }
  503. // printInfo, _ := GetHisLabelPrintInfoById(item.Barcode)
  504. //
  505. // item_id, _ := GetItemID(org_id, item.Groupname, item.Itemname, project_id)
  506. //
  507. // tx := writeMiddleDb.Begin()
  508. // var inspection models.MiddleInspection
  509. // var inspection_reference models.MiddleInspectionReference
  510. //
  511. // recordDateStr := ""
  512. //
  513. // if len(item.Repdate) == 0 {
  514. // recordDateStr = time.Now().Format("2006-01-02 15:04")
  515. // }
  516. //
  517. // inspect_date := item.Repdate
  518. // date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", recordDateStr)
  519. // record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
  520. // var total int
  521. // var RangeOptions string
  522. // var RangeMin string
  523. // var RangeMax string
  524. // // 判断检查类型
  525. // var ItemType int
  526. // if strings.Contains(item.Refrange, "[") && strings.Contains(item.Refrange, "]") {
  527. // ItemType = 1
  528. //
  529. // } else {
  530. // ItemType = 2
  531. //
  532. // }
  533. //
  534. // if ItemType == 1 {
  535. // item.Refrange = strings.Trim(item.Refrange, "[")
  536. // item.Refrange = strings.Trim(item.Refrange, "]")
  537. // Range := strings.Split(item.Refrange, "-")
  538. // RangeMin = Range[0]
  539. // RangeMax = Range[1]
  540. // } else {
  541. // RangeOptions = item.Refrange
  542. // }
  543. //
  544. // err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
  545. // if inspection_reference.ID > 0 {
  546. // ItemType = inspection_reference.RangeType
  547. // }
  548. // if total <= 0 {
  549. // inspection_reference.OrgId = org_id
  550. // inspection_reference.ProjectName = item.Groupname
  551. // inspection_reference.Project = item.Groupname
  552. // inspection_reference.ProjectId = project_id
  553. // inspection_reference.ItemName = item.Itemname
  554. // inspection_reference.ItemNameAddition = item.Barcode
  555. // inspection_reference.ItemId = item_id
  556. // inspection_reference.RangeType = ItemType
  557. // inspection_reference.RangeMin = RangeMin
  558. // inspection_reference.RangeMax = RangeMax
  559. // inspection_reference.RangeOptions = RangeOptions
  560. // inspection_reference.Unit = item.Unit
  561. // inspection_reference.Status = 1
  562. // inspection_reference.CreatedTime = time.Now().Unix()
  563. // inspection_reference.UpdatedTime = time.Now().Unix()
  564. // inspection_reference.InspectDate = inspect_date
  565. // inspection_reference.UTime = inspect_date
  566. // err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
  567. // if err != nil {
  568. // tx.Rollback()
  569. // }
  570. // }
  571. //
  572. // var itotal int
  573. // err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date, printInfo.PatientId).Find(&inspection).Count(&itotal).Error
  574. // if itotal <= 0 {
  575. // //item.Result = strings.Replace(item.Result, "&gt;", ">", -1)
  576. // //item.Result = strings.Replace(item.Result, "&lt;", "<", -1)
  577. // inspection.PatientId = printInfo.PatientId
  578. // inspection.OrgId = org_id
  579. // inspection.ProjectId = project_id
  580. // inspection.ItemName = inspection_reference.ItemName
  581. // inspection.ProjectName = inspection_reference.ProjectName
  582. // inspection.InspectType = ItemType
  583. // inspection.ItemId = item_id
  584. // inspection.InspectValue = item.Result
  585. // inspection.InspectDate = inspect_date
  586. // inspection.RecordDate = record_date.Unix()
  587. // inspection.Status = 1
  588. // inspection.CreatedTime = time.Now().Unix()
  589. // inspection.UpdatedTime = time.Now().Unix()
  590. // inspection.UTime = inspect_date
  591. // inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
  592. // err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
  593. // if err != nil {
  594. // tx.Rollback()
  595. // }
  596. // }
  597. //
  598. // tx.Commit()
  599. //
  600. //}
  601. }
  602. } else {
  603. if record.LastId != 0 {
  604. list, err := GetResultRecordByID(record.LastId)
  605. //插入中间库中
  606. //插入一条插入中间库记录数据
  607. if err == nil {
  608. //插入一条查询检验检查结果记录状态数据
  609. var info LisSyncResultStatusInfo
  610. info.Ctime = time.Now().Unix()
  611. info.Status = 1
  612. info.Mtime = time.Now().Unix()
  613. info.OrgId = org_id
  614. info.IsResult = 1
  615. code, _ := strconv.ParseInt(list[0].Barcode, 10, 64)
  616. info.LastId = code
  617. info.ResultDate = time.Now().Unix()
  618. writeMiddleDb.Save(&info)
  619. //插入到系统检验检查数据
  620. //for _, item := range list {
  621. //
  622. // project_id := int64(0)
  623. // if len(item.Barcode) > 0 {
  624. // project_id, _ = GetGzjhProjectID(org_id, item.Groupname)
  625. // } else {
  626. // continue
  627. // }
  628. // printInfo, _ := GetHisLabelPrintInfoById(item.Barcode)
  629. //
  630. // item_id, _ := GetItemID(org_id, item.Groupname, item.Itemname, project_id)
  631. //
  632. // tx := writeMiddleDb.Begin()
  633. // var inspection models.MiddleInspection
  634. // var inspection_reference models.MiddleInspectionReference
  635. //
  636. // recordDateStr := ""
  637. //
  638. // if len(item.Repdate) == 0 {
  639. // recordDateStr = time.Now().Format("2006-01-02 15:04")
  640. // }
  641. //
  642. // inspect_date := item.Repdate
  643. // date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", recordDateStr)
  644. // record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
  645. // var total int
  646. // var RangeOptions string
  647. // var RangeMin string
  648. // var RangeMax string
  649. // // 判断检查类型
  650. // var ItemType int
  651. // if strings.Contains(item.Refrange, "[") && strings.Contains(item.Refrange, "]") {
  652. // ItemType = 1
  653. //
  654. // } else {
  655. // ItemType = 2
  656. //
  657. // }
  658. //
  659. // if ItemType == 1 {
  660. // item.Refrange = strings.Trim(item.Refrange, "[")
  661. // item.Refrange = strings.Trim(item.Refrange, "]")
  662. // Range := strings.Split(item.Refrange, "-")
  663. // RangeMin = Range[0]
  664. // RangeMax = Range[1]
  665. // } else {
  666. // RangeOptions = item.Refrange
  667. // }
  668. //
  669. // err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
  670. // if inspection_reference.ID > 0 {
  671. // ItemType = inspection_reference.RangeType
  672. // }
  673. // if total <= 0 {
  674. // inspection_reference.OrgId = org_id
  675. // inspection_reference.ProjectName = item.Groupname
  676. // inspection_reference.Project = item.Groupname
  677. // inspection_reference.ProjectId = project_id
  678. // inspection_reference.ItemName = item.Itemname
  679. // inspection_reference.ItemNameAddition = item.Barcode
  680. // inspection_reference.ItemId = item_id
  681. // inspection_reference.RangeType = ItemType
  682. // inspection_reference.RangeMin = RangeMin
  683. // inspection_reference.RangeMax = RangeMax
  684. // inspection_reference.RangeOptions = RangeOptions
  685. // inspection_reference.Unit = item.Unit
  686. // inspection_reference.Status = 1
  687. // inspection_reference.CreatedTime = time.Now().Unix()
  688. // inspection_reference.UpdatedTime = time.Now().Unix()
  689. // inspection_reference.InspectDate = inspect_date
  690. // inspection_reference.UTime = inspect_date
  691. // err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
  692. // if err != nil {
  693. // tx.Rollback()
  694. // }
  695. // }
  696. //
  697. // var itotal int
  698. // err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date, printInfo.PatientId).Find(&inspection).Count(&itotal).Error
  699. // if itotal <= 0 {
  700. // //item.Result = strings.Replace(item.Result, "&gt;", ">", -1)
  701. // //item.Result = strings.Replace(item.Result, "&lt;", "<", -1)
  702. // inspection.PatientId = printInfo.PatientId
  703. // inspection.OrgId = org_id
  704. // inspection.ProjectId = project_id
  705. // inspection.ItemName = inspection_reference.ItemName
  706. // inspection.ProjectName = inspection_reference.ProjectName
  707. // inspection.InspectType = ItemType
  708. // inspection.ItemId = item_id
  709. // inspection.InspectValue = item.Result
  710. // inspection.InspectDate = inspect_date
  711. // inspection.RecordDate = record_date.Unix()
  712. // inspection.Status = 1
  713. // inspection.CreatedTime = time.Now().Unix()
  714. // inspection.UpdatedTime = time.Now().Unix()
  715. // inspection.UTime = inspect_date
  716. // inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
  717. // err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
  718. // if err != nil {
  719. // tx.Rollback()
  720. // }
  721. // }
  722. //
  723. // tx.Commit()
  724. //
  725. //}
  726. }
  727. }
  728. }
  729. return
  730. }
  731. func GetAdminUserInfoByID(org_id int64, admin_user_id int64) (role UserAdminRole, err error) {
  732. err = readUserDb.Model(&UserAdminRole{}).Where("org_id = ? AND status = 1 AND admin_user_id = ?", org_id, admin_user_id).First(&role).Error
  733. return
  734. }
  735. type UserAdminRole struct {
  736. ID int64 `gorm:"column:id" json:"id" form:"id"`
  737. AdminUserId int64 `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
  738. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  739. AppId int64 `gorm:"column:app_id" json:"app_id" form:"app_id"`
  740. RoleId int64 `gorm:"column:role_id" json:"role_id" form:"role_id"`
  741. UserName string `gorm:"column:user_name" json:"user_name" form:"user_name"`
  742. Avatar string `gorm:"column:avatar" json:"avatar" form:"avatar"`
  743. UserType int64 `gorm:"column:user_type" json:"user_type" form:"user_type"`
  744. UserTitle int64 `gorm:"column:user_title" json:"user_title" form:"user_title"`
  745. Intro string `gorm:"column:intro" json:"intro" form:"intro"`
  746. Status int64 `gorm:"column:status" json:"status" form:"status"`
  747. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  748. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  749. UserTitleName string `gorm:"column:user_title_name" json:"user_title_name" form:"user_title_name"`
  750. RoleIds string `gorm:"column:role_ids" json:"role_ids" form:"role_ids"`
  751. Message string `gorm:"column:message" json:"message" form:"message"`
  752. Sex int64 `gorm:"column:sex" json:"sex" form:"sex"`
  753. Birthday int64 `gorm:"column:birthday" json:"birthday" form:"birthday"`
  754. Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
  755. IsSort int64 `gorm:"column:is_sort" json:"is_sort" form:"is_sort"`
  756. Department string `gorm:"column:department" json:"department" form:"department"`
  757. DepartmentId int64 `gorm:"column:department_id" json:"department_id" form:"department_id"`
  758. Age int64 `gorm:"column:age" json:"age" form:"age"`
  759. Nation string `gorm:"column:nation" json:"nation" form:"nation"`
  760. CardType int64 `gorm:"column:card_type" json:"card_type" form:"card_type"`
  761. IdCard string `gorm:"column:id_card" json:"id_card" form:"id_card"`
  762. Education int64 `gorm:"column:education" json:"education" form:"education"`
  763. StudyMajorName string `gorm:"column:study_major_name" json:"study_major_name" form:"study_major_name"`
  764. WorkMajorName string `gorm:"column:work_major_name" json:"work_major_name" form:"work_major_name"`
  765. RoleType int64 `gorm:"column:role_type" json:"role_type" form:"role_type"`
  766. MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
  767. DoctorCode string `gorm:"column:doctor_code" json:"doctor_code" form:"doctor_code"`
  768. Licensing int64 `gorm:"column:licensing" json:"licensing" form:"licensing"`
  769. JobNumber string `gorm:"column:job_number" json:"job_number" form:"job_number"`
  770. PrescriptionQualificationIdentification int64 `gorm:"column:prescription_qualification_identification" json:"prescription_qualification_identification" form:"prescription_qualification_identification"`
  771. IdentificationOutpatients int64 `gorm:"column:identification_outpatients" json:"identification_outpatients" form:"identification_outpatients"`
  772. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  773. MedicalRangeCode int64 `gorm:"column:medical_range_code" json:"medical_range_code" form:"medical_range_code"`
  774. MedicalLevel int64 `gorm:"column:medical_level" json:"medical_level" form:"medical_level"`
  775. MedicalTypeJob int64 `gorm:"column:medical_type_job" json:"medical_type_job" form:"medical_type_job"`
  776. PharmacistRegistrationNumber string `gorm:"column:pharmacist_registration_number" json:"pharmacist_registration_number" form:"pharmacist_registration_number"`
  777. DoctorRangeCode int64 `gorm:"column:doctor_range_code" json:"doctor_range_code" form:"doctor_range_code"`
  778. DoctorLevel int64 `gorm:"column:doctor_level" json:"doctor_level" form:"doctor_level"`
  779. DoctorTypeJob int64 `gorm:"column:doctor_type_job" json:"doctor_type_job" form:"doctor_type_job"`
  780. DoctorNumber string `gorm:"column:doctor_number" json:"doctor_number" form:"doctor_number"`
  781. OutpatientIllnessCategory string `gorm:"column:outpatient_illness_category" json:"outpatient_illness_category" form:"outpatient_illness_category"`
  782. IsActive int64 `gorm:"column:is_active" json:"is_active" form:"is_active"`
  783. ActiveStatus int64 `gorm:"column:active_status" json:"active_status" form:"active_status"`
  784. }
  785. func (UserAdminRole) TableName() string {
  786. return "sgj_user_admin_role"
  787. }
  788. func FindDiagnoseById(id int64) (*HisXtDiagnoseConfig, error) {
  789. dealer := &HisXtDiagnoseConfig{}
  790. err := readDb.Model(&HisXtDiagnoseConfig{}).Where("id = ? AND status = 1", id).First(&dealer).Error
  791. return dealer, err
  792. }
  793. type HisXtDiagnoseConfig struct {
  794. ID int64 `gorm:"column:id" json:"id" form:"id"`
  795. ClassName string `gorm:"column:class_name" json:"class_name" form:"class_name"`
  796. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  797. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  798. ContentCode string `gorm:"column:content_code" json:"content_code" form:"content_code"`
  799. CountryCode string `gorm:"column:country_code" json:"country_code" form:"country_code"`
  800. CountryContentName string `gorm:"column:country_content_name" json:"country_content_name" form:"country_content_name"`
  801. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  802. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  803. Status int64 `gorm:"column:status" json:"status" form:"status"`
  804. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  805. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  806. }
  807. func (HisXtDiagnoseConfig) TableName() string {
  808. return "his_xt_diagnose_config"
  809. }
  810. type VMHisProjectTeam struct {
  811. ID int64 `gorm:"column:id" json:"id" form:"id"`
  812. ProjectTeam string `gorm:"column:project_team" json:"project_team" form:"project_team"`
  813. Price float64 `gorm:"column:price" json:"price" form:"price"`
  814. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  815. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  816. TubeColor int64 `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
  817. TeamType int64 `gorm:"column:team_type" json:"team_type" form:"team_type"`
  818. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  819. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  820. Status int64 `gorm:"column:status" json:"status" form:"status"`
  821. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  822. UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
  823. ProjectId string `gorm:"column:project_id" json:"project_id" form:"project_id"`
  824. VMItemProjectList []*VMItemProjectList `gorm:"-" json:"list" form:"list"`
  825. ItemId string `gorm:"column:item_id" json:"item_id" form:"item_id"`
  826. }
  827. func (VMHisProjectTeam) TableName() string {
  828. return "xt_his_project_team"
  829. }
  830. type VMItemProjectList struct {
  831. ID int64 `gorm:"column:id" json:"id" form:"id"`
  832. Number int64 `gorm:"column:number" json:"number" form:"number"`
  833. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  834. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  835. Status int64 `gorm:"column:status" json:"status" form:"status"`
  836. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  837. UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
  838. TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
  839. Type int64 `gorm:"column:type" json:"type" form:"type"`
  840. VMHisProject VMHisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
  841. }
  842. func (VMItemProjectList) TableName() string {
  843. return "xt_his_project_list"
  844. }
  845. type VMHisProject struct {
  846. ID int64 `gorm:"column:id" json:"id" form:"id"`
  847. ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
  848. Price float64 `gorm:"column:price" json:"price" form:"price"`
  849. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  850. CostClassify int64 `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
  851. StatisticalClassification int64 `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
  852. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  853. Status int64 `gorm:"column:status" json:"status" form:"status"`
  854. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  855. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  856. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  857. NumberDays string `gorm:"column:number_days" json:"number_days" form:"number_days"`
  858. MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
  859. }
  860. func (VMHisProject) TableName() string {
  861. return "xt_his_project"
  862. }
  863. type HisPrescriptionProject struct {
  864. ID int64 `gorm:"column:id" json:"id" form:"id"`
  865. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  866. Price float64 `gorm:"column:price" json:"price" form:"price"`
  867. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  868. Status int64 `gorm:"column:status" json:"status" form:"status"`
  869. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  870. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  871. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  872. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  873. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  874. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  875. Count int64 `gorm:"column:count" json:"count" form:"count"`
  876. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  877. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  878. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  879. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  880. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  881. Day string `gorm:"column:day" json:"day" form:"day"`
  882. VMHisProject VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
  883. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  884. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  885. Type int64 `gorm:"column:type" json:"type" form:"type"`
  886. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  887. ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
  888. ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
  889. ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
  890. CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
  891. CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
  892. Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
  893. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  894. TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
  895. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  896. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  897. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  898. HisPrescription HisPrescription `gorm:"ForeignKey:ID;AssociationForeignKey:PrescriptionId" json:"his_prescription"`
  899. }
  900. func (HisPrescriptionProject) TableName() string {
  901. return "his_prescription_project"
  902. }
  903. func GetProjectTeamList(orgid int64, id int64, p_id int64) (project []*HisPrescriptionProject, err error) {
  904. err = readDb.Model(&HisPrescriptionProject{}).Where("user_org_id = ? AND status = 1 AND team_id = ? AND prescription_id = ?", orgid, id, p_id).Find(&project).Error
  905. return
  906. }
  907. func GetHisLabelPrintInfoById(id string) (info HisLabelPrintInfo, err error) {
  908. err = readDb.Model(&HisLabelPrintInfo{}).Where("id = ?", id).First(&info).Error
  909. return
  910. }