123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921 |
- package controllers
-
- import (
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- "encoding/json"
- "fmt"
- "github.com/astaxie/beego"
- "github.com/jinzhu/gorm"
- "strconv"
- "strings"
- "time"
- )
-
- type HisProjectApiController struct {
- BaseAuthAPIController
- }
-
- func HisProjectRouters() {
-
- beego.Router("/api/his/saveproject", &HisProjectApiController{}, "Get:SaveProject")
- beego.Router("/api/his/getprojectlist", &HisProjectApiController{}, "Get:GetProjectList")
- beego.Router("/api/his/getprojectdetail", &HisProjectApiController{}, "Get:GetProjectDetail")
- beego.Router("/api/his/updatedproject", &HisProjectApiController{}, "Get:UpdatedProject")
- beego.Router("/api/his/deletehisproject", &HisProjectApiController{}, "Get:DeleteHisProject")
- beego.Router("/api/his/saveprojectteam", &HisProjectApiController{}, "Get:SaveProjectTeam")
- beego.Router("/api/his/getprojectteamlist", &HisProjectApiController{}, "Get:GetProjectTeamList")
- beego.Router("/api/his/getprojectteamdetail", &HisProjectApiController{}, "Get:GetProjectTeamDetail")
- beego.Router("/api/his/updateprojectteam", &HisProjectApiController{}, "Get:UpdatedProjectTeam")
- beego.Router("/api/his/deleteprojectteam", &HisProjectApiController{}, "Get:DeleteProjectTeam")
- beego.Router("/api/his/savedepartment", &HisProjectApiController{}, "Get:SaveDePartment")
- beego.Router("/api/his/getdepartmentlist", &HisProjectApiController{}, "Get:GetDepartMentList")
- beego.Router("/api/his/getdepartmentdetail", &HisProjectApiController{}, "Get:GetDepartMentDetail")
- beego.Router("/api/his/updagtedepartment", &HisProjectApiController{}, "Get:UpdatedDeparment")
- beego.Router("/api/his/deletedeparment", &HisProjectApiController{}, "Get:DeleteDepartment")
- beego.Router("/api/his/getallprojectlist", &HisProjectApiController{}, "Get:GetAllProjectList")
- beego.Router("/api/his/addprojectlist", &HisProjectApiController{}, "Get:AddProjectList")
- beego.Router("/api/his/deleteproject", &HisProjectApiController{}, "Get:DeleteProject")
- beego.Router("/api/his/gethisproject", &HisProjectApiController{}, "Get:GetHisProject")
- beego.Router("/api/his/getprojectteam", &HisProjectApiController{}, "Get:GetProjectTeam")
- beego.Router("/api/his/getalldoctorlist", &HisProjectApiController{}, "Get:GetAllDoctorList")
- beego.Router("/api/his/savehispatient", &HisProjectApiController{}, "Get:SaveHisPatient")
- //获取今日血透排班的患者
- beego.Router("/api/his/getbloodpatient", &HisProjectApiController{}, "Get:GetBloodPatientList")
- //获取患者的今日透析处方
- beego.Router("/api/his/gethisprescription", &HisProjectApiController{}, "Get:GetHisPrescription")
- //新增附加费用
- beego.Router("/api/his/additionalcharge", &HisProjectApiController{}, "Post:AdditionalCharge")
- //获取治疗单
- beego.Router("/api/his/gettreatlist", &HisProjectApiController{}, "Get:GetTreatmentList")
- beego.Router("/api/his/getpatientinformation", &HisProjectApiController{}, "Get:GetPatientInformation")
- beego.Router("/api/hist/getallprojecteam", &HisProjectApiController{}, "Get:GetAllProjectTeam")
- beego.Router("/api/his/getprojectlistbyid", &HisProjectApiController{}, "Get:GetProjectListById")
- beego.Router("/api/his/gethispatienthistory", &HisProjectApiController{}, "Get:GetHisPatientHistory")
- beego.Router("/api/patient/changepatient", &HisProjectApiController{}, "Get:ChangePatient")
- }
-
- func (this *HisProjectApiController) SaveProject() {
-
- project_name := this.GetString("project_name")
- pinyin := this.GetString("pinyin")
- wubi := this.GetString("wubi")
- price := this.GetString("price")
- price_float, err := strconv.ParseFloat(price, 64)
- unit := this.GetString("unit")
- cost_classify, _ := this.GetInt64("cost_classify")
- executive_section, _ := this.GetInt64("executive_section")
- medical_coverage, _ := this.GetInt64("medical_coverage")
- statistical_classification, _ := this.GetInt64("statistical_classification")
- disease_directory, _ := this.GetInt64("disease_directory")
- is_record, _ := this.GetInt64("is_record")
- medical_code := this.GetString("medical_code")
- tube_color, _ := this.GetInt64("tube_color")
- medical_status, _ := this.GetInt64("medical_status")
- remark := this.GetString("remark")
- sign, _ := this.GetInt64("sign")
- default_number := this.GetString("default_number")
- is_charge, _ := this.GetInt64("is_charge")
- is_estimate, _ := this.GetInt64("is_estimate")
- is_workload, _ := this.GetInt64("is_workload")
- sort := this.GetString("sort")
- is_advice, _ := this.GetInt64("is_advice")
- is_default, _ := this.GetInt64("is_default")
- single_dose := this.GetString("single_dose")
- delivery_way := this.GetString("delivery_way")
- execution_frequency := this.GetString("execution_frequency")
- number_days := this.GetString("number_days")
- total := this.GetString("total")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- hisProject := models.XtHisProject{
- ProjectName: project_name,
- Pinyin: pinyin,
- Wubi: wubi,
- Price: price_float,
- Unit: unit,
- CostClassify: cost_classify,
- ExecutiveSection: executive_section,
- MedicalCoverage: medical_coverage,
- StatisticalClassification: statistical_classification,
- DiseaseDirectory: disease_directory,
- IsRecord: is_record,
- MedicalCode: medical_code,
- TubeColor: tube_color,
- MedicalStatus: medical_status,
- Remark: remark,
- Sign: sign,
- DefaultNumber: default_number,
- IsCharge: is_charge,
- IsEstimate: is_estimate,
- IsWorkload: is_workload,
- Sort: sort,
- DoctorAdvice: is_advice,
- IsDefault: is_default,
- UserOrgId: orgId,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- SingleDose: single_dose,
- DeliveryWay: delivery_way,
- ExecutionFrequency: execution_frequency,
- NumberDays: number_days,
- Total: total,
- }
- //查询项目名称是否存在
- _, errcode := service.GetHisProjectIsExist(project_name, orgId)
- fmt.Println("9999999999999", errcode)
- if errcode == gorm.ErrRecordNotFound {
- fmt.Println("222")
- err = service.CreateHisProject(&hisProject)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "hisProject": hisProject,
- })
- return
- } else if errcode == nil {
- fmt.Println("3333")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- }
-
- func (this *HisProjectApiController) GetProjectList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- is_charge, _ := this.GetInt64("is_charge")
- is_start, _ := this.GetInt64("is_start")
- keyword := this.GetString("keyword")
- projecList, total, err := service.GetHisProjectList(orgId, limit, page, is_charge, is_start, keyword)
- fmt.Println("err", err)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "projecList": projecList,
- "total": total,
- })
- return
- }
-
- func (this *HisProjectApiController) GetProjectDetail() {
- id, _ := this.GetInt64("id")
- projectDetail, err := service.GetProjectDetail(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "projecDetail": projectDetail,
- })
- return
- }
-
- func (this *HisProjectApiController) UpdatedProject() {
-
- id, _ := this.GetInt64("id")
- project_name := this.GetString("project_name")
- pinyin := this.GetString("pinyin")
- wubi := this.GetString("wubi")
- price := this.GetString("price")
- price_float, _ := strconv.ParseFloat(price, 64)
- unit := this.GetString("unit")
- cost_classify, _ := this.GetInt64("cost_classify")
- executive_section, _ := this.GetInt64("executive_section")
- medical_coverage, _ := this.GetInt64("medical_coverage")
- statistical_classification, _ := this.GetInt64("statistical_classification")
- disease_directory, _ := this.GetInt64("disease_directory")
- is_record, _ := this.GetInt64("is_record")
- medical_code := this.GetString("medical_code")
- tube_color, _ := this.GetInt64("tube_color")
- medical_status, _ := this.GetInt64("medical_status")
- remark := this.GetString("remark")
- sign, _ := this.GetInt64("sign")
- default_number := this.GetString("default_number")
- is_charge, _ := this.GetInt64("is_charge")
- is_estimate, _ := this.GetInt64("is_estimate")
- is_workload, _ := this.GetInt64("is_workload")
- sort := this.GetString("sort")
- is_advice, _ := this.GetInt64("is_advice")
- is_default, _ := this.GetInt64("is_default")
- single_dose := this.GetString("single_dose")
- delivery_way := this.GetString("delivery_way")
- execution_frequency := this.GetString("execution_frequency")
- number_days := this.GetString("number_days")
- total := this.GetString("total")
- hisProject := models.XtHisProject{
- ProjectName: project_name,
- Pinyin: pinyin,
- Wubi: wubi,
- Price: price_float,
- Unit: unit,
- CostClassify: cost_classify,
- ExecutiveSection: executive_section,
- MedicalCoverage: medical_coverage,
- StatisticalClassification: statistical_classification,
- DiseaseDirectory: disease_directory,
- IsRecord: is_record,
- MedicalCode: medical_code,
- TubeColor: tube_color,
- MedicalStatus: medical_status,
- Remark: remark,
- Sign: sign,
- DefaultNumber: default_number,
- IsCharge: is_charge,
- IsEstimate: is_estimate,
- IsWorkload: is_workload,
- Sort: sort,
- DoctorAdvice: is_advice,
- IsDefault: is_default,
- UpdatedTime: time.Now().Unix(),
- SingleDose: single_dose,
- DeliveryWay: delivery_way,
- ExecutionFrequency: execution_frequency,
- NumberDays: number_days,
- Total: total,
- }
-
- err := service.UpdatedProject(id, &hisProject)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "hisProject": hisProject,
- })
- return
- }
-
- func (this *HisProjectApiController) DeleteHisProject() {
-
- id, _ := this.GetInt64("id")
- err := service.DeleteHisProject(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *HisProjectApiController) SaveProjectTeam() {
-
- project_team := this.GetString("project_team")
-
- price := this.GetString("price")
- price_float, _ := strconv.ParseFloat(price, 64)
- pinyin := this.GetString("pinyin")
- wubi := this.GetString("wubi")
- tube_color, _ := this.GetInt64("tube_color")
- team_type, _ := this.GetInt64("team_type")
- remark := this.GetString("remark")
- ids := this.GetString("ids")
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- projectTeam := models.XtHisProjectTeam{
- ProjectTeam: project_team,
- Price: price_float,
- Pinyin: pinyin,
- Wubi: wubi,
- TubeColor: tube_color,
- TeamType: team_type,
- Remark: remark,
- UserOrgId: orgId,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- ProjectId: ids,
- }
- fmt.Println(projectTeam)
-
- _, errcodes := service.GetHisProjectByNameOne(project_team, orgId)
-
- if errcodes == gorm.ErrRecordNotFound {
-
- err := service.CreatedProjectTeam(&projectTeam)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "projectTeam": projectTeam,
- })
- return
- } else if errcodes == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- }
-
- func (this *HisProjectApiController) GetProjectTeamList() {
-
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- keyword := this.GetString("keyword")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- projectTeamList, total, err := service.GetProjectTeamList(limit, page, orgId, keyword)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "projectTeamList": projectTeamList,
- "total": total,
- })
- return
- }
-
- func (this *HisProjectApiController) GetProjectTeamDetail() {
-
- id, _ := this.GetInt64("id")
- projectTeamDetail, err := service.GetProjectTeamDetail(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "projectTeamDetail": projectTeamDetail,
- })
- return
- }
-
- func (this *HisProjectApiController) UpdatedProjectTeam() {
-
- id, _ := this.GetInt64("id")
- project_team := this.GetString("project_team")
- price := this.GetString("price")
- price_float, _ := strconv.ParseFloat(price, 64)
- pinyin := this.GetString("pinyin")
- wubi := this.GetString("wubi")
- tube_color, _ := this.GetInt64("tube_color")
- team_type, _ := this.GetInt64("team_type")
- remark := this.GetString("remark")
- ids := this.GetString("ids")
- projectTeam := models.XtHisProjectTeam{
- ProjectTeam: project_team,
- Price: price_float,
- Pinyin: pinyin,
- Wubi: wubi,
- TubeColor: tube_color,
- TeamType: team_type,
- Remark: remark,
- ProjectId: ids,
- }
-
- err := service.UpdatedProjectTeam(id, &projectTeam)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "projectTeam": projectTeam,
- })
- return
- }
-
- func (this *HisProjectApiController) DeleteProjectTeam() {
-
- id, _ := this.GetInt64("id")
- err := service.DeleteProjectTeam(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *HisProjectApiController) SaveDePartment() {
-
- name := this.GetString("name")
- number := this.GetString("number")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- department := models.XtHisDepartment{
- Name: name,
- Number: number,
- UserOrgId: orgId,
- CreatedTime: time.Now().Unix(),
- Status: 1,
- }
- err := service.CreateDePartment(&department)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "department": department,
- })
- return
- }
-
- func (this *HisProjectApiController) GetDepartMentList() {
-
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- departMentList, total, err := service.GetDepartMentList(limit, page, orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "departMentList": departMentList,
- "total": total,
- })
- return
- }
-
- func (this *HisProjectApiController) GetDepartMentDetail() {
-
- id, _ := this.GetInt64("id")
- departDetail, err := service.GetDepartMentDetail(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "departDetail": departDetail,
- })
- return
- }
-
- func (this *HisProjectApiController) UpdatedDeparment() {
-
- id, _ := this.GetInt64("id")
- name := this.GetString("name")
- number := this.GetString("number")
- department := models.XtHisDepartment{
- Name: name,
- Number: number,
- }
- err := service.UpdatedDepartment(id, &department)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "department": department,
- })
- return
- }
-
- func (this *HisProjectApiController) DeleteDepartment() {
-
- id, _ := this.GetInt64("id")
- err := service.DeleteDepartment(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *HisProjectApiController) GetBloodPatientList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- fmt.Println("org", orgId)
- timeStr := time.Now().Format("2006-01-02")
- timeLayout := "2006-01-02 15:04:05"
- fmt.Println("timeStr:", timeStr)
- timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
- timenow := timeStringToTime.Unix()
-
- //统计血透排班的患者
- scheduleList, err := service.GetBloodPatientList(orgId, timenow)
- //统计当日挂号的患者
- hisPatient, _ := service.GetHisPatient(orgId, timenow)
- //统计今天开处方的患者
- prescription, _ := service.GetHisPrescriptionOther(orgId, timenow)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "scheduleList": scheduleList,
- "hisPatient": hisPatient,
- "prescription": prescription,
- })
- return
- }
-
- func (this *HisProjectApiController) GetHisPrescription() {
-
- id, _ := this.GetInt64("id")
- timeStr := time.Now().Format("2006-01-02")
- timeLayout := "2006-01-02 15:04:05"
- fmt.Println("timeStr:", timeStr)
- timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
- timenow := timeStringToTime.Unix()
- prescriptionList, err := service.GetHisPrescriptionByPatientId(id, timenow)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "prescriptionList": prescriptionList,
- })
- return
- }
-
- func (this *HisProjectApiController) AdditionalCharge() {
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
- his_patient_id := int64(dataBody["his_patient_id"].(float64))
- patient_id := int64(dataBody["patient_id"].(float64))
- fmt.Println("patient_id2222222222", patient_id)
- medicineData, _ := dataBody["medicineData"].([]interface{})
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- admin_user_id := adminUserInfo.AdminUser.Id
- timeStr := time.Now().Format("2006-01-02")
- timeLayout := "2006-01-02 15:04:05"
- fmt.Println("timeStr:", timeStr)
- timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
- timenow := timeStringToTime.Unix()
- for _, item := range medicineData {
- items := item.(map[string]interface{})
- //drug_id := int64(items["id"].(float64))
- money := items["money"].(string)
- moneys, _ := strconv.ParseInt(money, 10, 64)
- monStr := strconv.FormatInt(moneys, 10)
- monneyStr, _ := strconv.ParseFloat(monStr, 64)
- additionalCharge := models.HisAdditionalCharge{
- HisPatientId: his_patient_id,
- UserOrgId: orgId,
- PatientId: patient_id,
- RecordDate: timenow,
- Price: monneyStr,
- Status: 1,
- AdminUserId: admin_user_id,
- CreatedTime: time.Now().Unix(),
- }
-
- err := service.CreateAdditionalCharge(&additionalCharge)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "additionalCharge": additionalCharge,
- })
- return
- }
- }
-
- func (this *HisProjectApiController) GetTreatmentList() {
-
- patient_id, _ := this.GetInt64("patient_id")
- timeStr := time.Now().Format("2006-01-02")
- timeLayout := "2006-01-02 15:04:05"
- fmt.Println("timeStr:", timeStr)
- timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
- timenow := timeStringToTime.Unix()
- treatmentList, err := service.GetTreatmentList(patient_id, timenow)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "treatmentList": treatmentList,
- })
- return
- }
-
- func (this *HisProjectApiController) GetAllProjectList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- projectList, err := service.GetAllProjectList(orgId)
- //获取列表数据
- hisprojectlist, err := service.GetHisProjectListByOrgId(orgId)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "projectList": projectList,
- "hisprojectlist": hisprojectlist,
- })
- return
- }
-
- func (this *HisProjectApiController) AddProjectList() {
-
- id, _ := this.GetInt64("id")
- number, _ := this.GetInt64("number")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- projectList := models.XtHisProjectList{
- ProjectId: id,
- Number: number,
- UserOrgId: orgId,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- }
- err := service.CreateProjectList(&projectList)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "projectList": projectList,
- })
- return
- }
-
- func (this *HisProjectApiController) GetPatientInformation() {
-
- id, _ := this.GetInt64("id")
- information, err := service.GetHisPatientInformation(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "information": information,
- })
- return
- }
-
- func (this *HisProjectApiController) DeleteProject() {
-
- id, _ := this.GetInt64("id")
- err := service.DeleteProjectList(id)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *HisProjectApiController) GetHisProject() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- project, err := service.GetHisProject(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "project": project,
- })
- }
-
- func (this *HisProjectApiController) GetProjectTeam() {
-
- strids := this.GetString("strids")
-
- idStrs := strings.Split(strids, ",")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- team, err := service.GetProjectTeam(idStrs, orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "team": team,
- })
- }
-
- func (this *HisProjectApiController) GetAllDoctorList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- appId := adminUserInfo.CurrentAppId
- //获取所有的医生
- doctor, err := service.GetAllDoctor(orgId, appId)
- //获取所有的科室
- department, err := service.GetAllDepartMent(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "doctor": doctor,
- "department": department,
- })
- }
-
- func (this *HisProjectApiController) SaveHisPatient() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- age, _ := this.GetInt64("age")
- birthday := this.GetString("birthDay")
- birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
- birthUnix := birthdays.Unix()
- certificates, _ := this.GetInt64("certificates")
- cost_checked, _ := this.GetInt64("costChecked")
- cost, _ := this.GetInt64("cost")
- costs := strconv.FormatInt(cost, 10)
- cost_float, _ := strconv.ParseFloat(costs, 64)
- department, _ := this.GetInt64("department")
- doctor, _ := this.GetInt64("doctor")
- medicalcare, _ := this.GetInt64("medicalCare")
- idcard := this.GetString("idCard")
- medicalExpenses, _ := this.GetInt64("medicalExpenses")
- medicalExpense := strconv.FormatInt(medicalExpenses, 10)
- medicalExpense_float, _ := strconv.ParseFloat(medicalExpense, 64)
- medicalinsurancecard := this.GetString("medicalInsuranceCard")
-
- name := this.GetString("name")
- register, _ := this.GetInt64("register")
- registrationfee, _ := this.GetInt64("registrationFee")
- registrationfees := strconv.FormatInt(registrationfee, 10)
- registrationfees_float, _ := strconv.ParseFloat(registrationfees, 64)
- settlementValue, _ := this.GetInt64("settlementValue")
- sex, _ := this.GetInt64("sex")
- total, _ := this.GetInt64("total")
- totals := strconv.FormatInt(total, 10)
- totals_float, _ := strconv.ParseFloat(totals, 64)
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- recordDateStr := time.Now().Format("2006-01-02")
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- fmt.Println("parseDateErr", parseDateErr)
- nowtime := recordDate.Unix()
-
- bloodPatient, errcode := service.GetBloodPatientByIdCard(idcard, orgId)
- if errcode == gorm.ErrRecordNotFound {
- patient := models.XtHisPatient{
- Age: age,
- Birthday: birthUnix,
- IdType: certificates,
- CostOfProduction: cost_float,
- Departments: department,
- Doctor: doctor,
- AdminUserId: adminUserInfo.AdminUser.Id,
- MedicalTreatmentType: medicalcare,
- IdCardNo: idcard,
- IsNeedCostOfProduction: cost_checked,
- TreatmentCost: medicalExpense_float,
- MedicalInsuranceNumber: medicalinsurancecard,
- Name: name,
- RegisterType: register,
- RegisterCost: registrationfees_float,
- BalanceAccountsType: settlementValue,
- Gender: sex,
- Total: totals_float,
- UserOrgId: orgId,
- Status: 1,
- RecordDate: nowtime,
- IsReturn: 1,
- }
- err := service.CreateHisPatient(&patient)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- } else if errcode == nil {
- patient := models.XtHisPatient{
- Age: age,
- Birthday: birthUnix,
- IdType: certificates,
- CostOfProduction: cost_float,
- Departments: department,
- AdminUserId: doctor,
- MedicalTreatmentType: medicalcare,
- IdCardNo: idcard,
- IsNeedCostOfProduction: cost_checked,
- TreatmentCost: medicalExpense_float,
- MedicalInsuranceNumber: medicalinsurancecard,
- Name: name,
- RegisterType: register,
- RegisterCost: registrationfees_float,
- BalanceAccountsType: settlementValue,
- Gender: sex,
- Total: totals_float,
- UserOrgId: orgId,
- PatientId: bloodPatient.ID,
- }
- err := service.CreateHisPatient(&patient)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
- }
-
- func (this *HisProjectApiController) GetAllProjectTeam() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- fmt.Println("aaa")
- team, err := service.GetAllProjectTeam(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "team": team,
- })
- }
-
- func (this *HisProjectApiController) GetProjectListById() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- project_id := this.GetString("project_id")
- idStrs := strings.Split(project_id, ",")
- project, err := service.GetProjectListById(orgId, idStrs)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "project": project,
- })
- }
-
- func (this *HisProjectApiController) GetHisPatientHistory() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- keyword := this.GetString("keyword")
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- register_type, _ := this.GetInt64("register_type")
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- fmt.Println(keyword, start_time, end_time, register_type, limit, page)
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page, orgId)
-
- department, err := service.GetAllDepartMent(orgId)
- appId := adminUserInfo.CurrentAppId
- doctor, err := service.GetAllDoctor(orgId, appId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "history": history,
- "total": total,
- "department": department,
- "doctor": doctor,
- })
- }
-
- func (this *HisProjectApiController) ChangePatient() {
-
- id, _ := this.GetInt64("id")
- //查询该患者今日是否已经就诊
- recordDateStr := time.Now().Format("2006-01-02")
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- fmt.Println("parseDateErr", parseDateErr)
- nowtime := recordDate.Unix()
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- _, errcode := service.GetHisPrescriptionTwo(id, orgId, nowtime)
- if errcode == gorm.ErrRecordNotFound {
- err := service.ChangePatient(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- } else if errcode == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
-
- }
|