12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676 |
- package controllers
-
- import (
- "Xcx_New/enums"
- "Xcx_New/models"
- "Xcx_New/service"
- "Xcx_New/utils"
- "encoding/json"
- "fmt"
- "github.com/astaxie/beego"
- "github.com/jinzhu/gorm"
- "reflect"
- "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{}, "post:SaveProjectTeam")
- beego.Router("/api/his/getprojectteamlist", &HisProjectApiController{}, "Get:GetProjectTeamList")
- beego.Router("/api/his/getprojectteamdetail", &HisProjectApiController{}, "Get:GetProjectTeamDetail")
- beego.Router("/api/his/updateprojectteam", &HisProjectApiController{}, "post: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/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")
-
- beego.Router("/api/patient/getpatientcasehistory", &HisProjectApiController{}, "Get:GetPatientcaseHistory")
- beego.Router("/api/doctorworkstation/gettemplatedetail", &HisProjectApiController{}, "Get:GetTemplateDetail")
- beego.Router("/api/doctorworkstation/updaterecordtemplate", &HisProjectApiController{}, "Get:UpdateRecordTemplate")
- beego.Router("/api/hispatient/gehispatient", &HisProjectApiController{}, "Get:GetHisPatient")
-
- //获取处方打印单
- beego.Router("/api/hispatient/getprescriptionprint", &HisProjectApiController{}, "Get:GetDoctorAdvicePrint")
- //获取项目打印单
- //beego.Router("/api/hispatient/getprojectprint",&HisApiController{},"Get:GetProjectPrint")
-
- beego.Router("/api/hispatient/postprinthistemplate", &HisProjectApiController{}, "Get:PostPrintHisTemplate")
- beego.Router("/api/gethisprinttemplate", &HisProjectApiController{}, "Get:GetHisPrintTemplate")
- beego.Router("/api/hispatient/postprescriptiontemplate", &HisProjectApiController{}, "Get:PostPrescriptionTempalte")
- beego.Router("/api/hispatient/getprescriptiontemplate", &HisProjectApiController{}, "Get:GetPrescriptionTemplate")
- beego.Router("/api/hispatient/posttreatprinttemplate", &HisProjectApiController{}, "Get:PostTreatPrintTemplate")
- beego.Router("/api/hispatient/gettreatprinttemplate", &HisProjectApiController{}, "Get:GetTreatPrintTemplate")
- beego.Router("/api/hispatient/postchargeprinttemplate", &HisProjectApiController{}, "Get:PostChargePrintTemplate")
- beego.Router("/api/hispatient/getchargeprinttemplate", &HisProjectApiController{}, "Get:GetChargePrintTemplate")
- beego.Router("/api/hispatient/getallhispatient", &HisProjectApiController{}, "Get:GetAllHisPatient")
- beego.Router("/api/hispatient/getchargeprint", &HisProjectApiController{}, "Get:GetChargePrint")
- beego.Router("/api/hispatient/gettodayschedulepatient", &HisProjectApiController{}, "Get:GetTodaySchedulePatient")
- beego.Router("/api/hispatient/gethispatientdetail", &HisProjectApiController{}, "Get:GetHisPatientDetail")
-
- beego.Router("/api/hispatient/getalldepartmentlist", &HisProjectApiController{}, "Get:GetAllDepartmentList")
- beego.Router("/api/hispatient/getprescription", &HisProjectApiController{}, "Get:GetPrescription")
- beego.Router("/api/histpatient/getpatientdetail", &HisProjectApiController{}, "Get:GetPatientDetail")
- beego.Router("/api/hispatient/savemaintemplate", &HisProjectApiController{}, "Get:SaveMainTemplate")
- beego.Router("/api/hispatient/getmedicaltemplatelist", &HisProjectApiController{}, "Get:GetMedicalTempalteList")
- beego.Router("/api/hispatient/getmaintemplatebyid", &HisProjectApiController{}, "Get:GetMainTemplateById")
- beego.Router("/api/hispatient/updatemaintemplate", &HisProjectApiController{}, "Get:UpdateMainTemplate")
- beego.Router("/api/hispatient/deletemaintemplate", &HisProjectApiController{}, "Get:DeleteMainTemplate")
- }
-
- func (this *HisProjectApiController) SaveProject() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- 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")
- category, _ := this.GetInt64("category")
- specail_project, _ := this.GetInt64("specail_project")
- social_security_directory_code := this.GetString("social_security_directory_code")
- record_date := this.GetString("record_date")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- 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,
- Category: category,
- SpecailProject: specail_project,
- SocialSecurityDirectoryCode: social_security_directory_code,
- RecordDate: theTime.Unix(),
- }
- //查询项目名称是否存在
- _, errcode := service.GetHisProjectIsExist(project_name, orgId)
- if errcode == gorm.ErrRecordNotFound {
- err = service.CreateHisProject(&hisProject)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "hisProject": hisProject,
- })
- return
- } else if errcode == nil {
-
- 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")
- is_mark, _ := this.GetInt64("is_mark")
- projecList, total, err := service.GetHisProjectList(orgId, limit, page, is_charge, is_start, keyword, is_mark)
- 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() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- 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")
- category, _ := this.GetInt64("category")
- total := this.GetString("total")
- specail_project, _ := this.GetInt64("specail_project")
- social_security_directory_code := this.GetString("social_security_directory_code")
- record_date := this.GetString("record_date")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- 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,
- Category: category,
- SpecailProject: specail_project,
- SocialSecurityDirectoryCode: social_security_directory_code,
- RecordDate: theTime.Unix(),
- }
-
- 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")
- //item_id := this.GetString("item_id")
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- 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,
- //ItemId: item_id,
- }
- //fmt.Println(projectTeam)
-
- _, errcodes := service.GetHisProjectByNameOne(project_team, orgId)
-
- if errcodes == gorm.ErrRecordNotFound {
- err := service.CreatedProjectTeam(&projectTeam)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- if dataBody["info"] != nil && reflect.TypeOf(dataBody["info"]).String() == "[]interface {}" {
- infos, _ := dataBody["info"].([]interface{})
- if len(infos) > 0 {
- var ids []string
-
- for _, item := range infos {
- items := item.(map[string]interface{})
- if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
- utils.ErrorLog("id")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- id := int64(items["id"].(float64))
-
- if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
- utils.ErrorLog("type")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- types := int64(items["type"].(float64))
-
- if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
- utils.ErrorLog("number")
- }
-
- number, _ := strconv.ParseInt(items["number"].(string), 10, 64)
-
- list := models.XtHisProjectList{
- Number: number,
- UserOrgId: adminUserInfo.CurrentOrgId,
- ProjectId: id,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- TeamId: projectTeam.ID,
- Type: types,
- }
-
- service.CreateProjectList(&list)
-
- ids = append(ids, strconv.FormatInt(list.ID, 10))
-
- }
- ids_str := strings.Join(ids, ",")
- projectTeam.ItemId = ids_str
- service.SaveProjectTeam(&projectTeam)
- 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")
- //adminUserInfo := this.GetAdminUserInfo()
- //orgId := adminUserInfo.CurrentOrgId
- projectTeamDetail, err := service.GetProjectTeamDetail(id)
-
- ids := strings.Split(projectTeamDetail.ItemId, ",")
- hisList, err := service.GetProjectHisListByIds(ids)
-
- //list, err := service.GetAllProjectList(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "projectTeamDetail": projectTeamDetail,
- //"list": list,
- "hisList": hisList,
- })
- 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")
-
- projectTeam, _ := service.GetProjectTeamDetail(id)
-
- projectTeam.ProjectTeam = project_team
- projectTeam.Price = price_float
- projectTeam.Pinyin = pinyin
- projectTeam.Wubi = wubi
- projectTeam.TubeColor = tube_color
- projectTeam.TeamType = team_type
- projectTeam.Remark = remark
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- err = service.UpdatedProjectTeam(id, &projectTeam)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
-
- if dataBody["info"] != nil && reflect.TypeOf(dataBody["info"]).String() == "[]interface {}" {
- infos, _ := dataBody["info"].([]interface{})
- if len(infos) > 0 {
- var ids []string
-
- for _, item := range infos {
- items := item.(map[string]interface{})
- if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
- utils.ErrorLog("id")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- id := int64(items["id"].(float64))
-
- if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
- utils.ErrorLog("type")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- types := int64(items["type"].(float64))
-
- if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
- utils.ErrorLog("number")
- }
-
- number, _ := strconv.ParseInt(items["number"].(string), 10, 64)
-
- list := models.XtHisProjectList{
- Number: number,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ProjectId: id,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- TeamId: projectTeam.ID,
- Type: types,
- }
-
- service.CreateProjectList(&list)
-
- ids = append(ids, strconv.FormatInt(list.ID, 10))
-
- }
- ids_str := strings.Join(ids, ",")
- projectTeam.ItemId = projectTeam.ItemId + "," + ids_str
- service.SaveProjectTeam(&projectTeam)
- this.ServeSuccessJSON(map[string]interface{}{
- "projectTeam": projectTeam,
- })
- }
- }
-
- 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
- timeStr := time.Now().Format("2006-01-02")
- timeLayout := "2006-01-02 15:04:05"
- 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"
- 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) GetTreatmentList() {
-
- patient_id, _ := this.GetInt64("patient_id")
- timeStr := time.Now().Format("2006-01-02")
- timeLayout := "2006-01-02 15:04:05"
- 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() {
- keyword := this.GetString("keyword")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- projectList, err := service.GetAllProjectList(orgId, keyword)
- goodInfos, err := service.GetGoodInfomationList(orgId, keyword)
-
- //获取列表数据
- hisprojectlist, err := service.GetHisProjectListByOrgId(orgId)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "projectList": projectList,
- "hisprojectlist": hisprojectlist,
- "good_info": goodInfos,
- })
- 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)
- detail, _ := service.GetProjectDetail(id)
-
- item, err := service.GetLastItem(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "projectList": detail,
- "item": item,
- })
- 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)
- good_info, err := service.GetGoodInfoMation(orgId)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "project": project,
- "good_info": good_info,
- })
- }
-
- 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")
-
- patient_id, _ := this.GetInt64("id")
-
- 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("medical_care")
- idcard := this.GetString("id_card")
- medicalExpenses, _ := this.GetInt64("medical_expenses")
- medicalExpense := strconv.FormatInt(medicalExpenses, 10)
- medicalExpense_float, _ := strconv.ParseFloat(medicalExpense, 64)
- medicalinsurancecard := this.GetString("medical_insurance_card")
-
- name := this.GetString("name")
- register, _ := this.GetInt64("register")
- registrationfee, _ := this.GetInt64("registration_fee")
- registrationfees := strconv.FormatInt(registrationfee, 10)
- registrationfees_float, _ := strconv.ParseFloat(registrationfees, 64)
- settlementValue, _ := this.GetInt64("settlement_value")
- 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, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- nowtime := recordDate.Unix()
- phone := this.GetString("phone")
- social_type, _ := this.GetInt64("social_type")
- id_card_type, _ := this.GetInt64("id_card_type")
-
- //diagnosis_id, _ := this.GetInt64("diagnosis")
-
- diagnosis_ids := this.GetString("diagnosis")
-
- sick_type, _ := this.GetInt64("sick_type")
- reg_type := this.GetString("p_type")
-
- tempPatient, _ := service.GetPatientByIDCardAndName(idcard, adminUserInfo.CurrentOrgId, name)
- if tempPatient.ID == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoBloodPatientException)
- return
- }
-
- var patient service.Patients
- if patient_id == 0 {
- patient, _ = service.GetPatientByIDCard(idcard, adminUserInfo.CurrentOrgId)
-
- } else {
- patient, _ = service.GetPatientByIDTwo(adminUserInfo.CurrentOrgId, patient_id)
-
- }
-
- if patient.ID == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- if len(patient.IdCardNo) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
- return
- }
-
- timeStr := time.Now().Format("2006-01-02 15:04:05")
- fmt.Println(timeStr)
- timeArr := strings.Split(timeStr, " ")
- timeArrTwo := strings.Split(timeArr[0], "-")
- timeArrThree := strings.Split(timeArr[1], ":")
- var str = timeArrTwo[0] + timeArrTwo[1] + timeArrTwo[2] + timeArrThree[0] + timeArrThree[1] + timeArrThree[2] + strconv.FormatInt(patient.ID, 10)
-
- //his, _ := service.GetHisPatientInfoTwo(adminUserInfo.CurrentOrgId, patient.ID, recordDate.Unix())
- //if len(his) >= 1 {
- // order, _ := service.GetNewHisOrderTwo(adminUserInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDate.Unix())
- // if len(his) >= 1 && order.ID == 0 {
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
- // return
- // }
- //}
- var hisPatient models.XtHisPatient
- //if err == gorm.ErrRecordNotFound || his.ID == 0 {
- hisPatient = models.XtHisPatient{
- PatientId: patient_id,
- 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,
- Age: age,
- Number: str,
- RegisterType: register,
- RegisterCost: registrationfees_float,
- BalanceAccountsType: settlementValue,
- Gender: sex,
- Total: totals_float,
- UserOrgId: orgId,
- Status: 1,
- RecordDate: nowtime,
- IsReturn: 1,
- Ctime: time.Now().Unix(),
- Phone: phone,
- SocialType: social_type,
- IdCardType: id_card_type,
- Diagnosis: diagnosis_ids,
- PType: reg_type,
- SickType: sick_type,
- }
- service.CreateHisPatient(&hisPatient)
- this.ServeSuccessJSON(map[string]interface{}{
- "his_info": hisPatient,
- })
- //}
- //else {
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisRegisterException)
- // return
- //}
-
- }
-
- func (this *HisProjectApiController) GetAllProjectTeam() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- 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")
- 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, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
-
- 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
- }
-
- }
-
- func (this *HisProjectApiController) GetPatientcaseHistory() {
-
- patient_id, _ := this.GetInt64("patient_id")
- patient, err := service.GetBloodPatientInfoById(patient_id)
- history, _ := service.GetPatientCaseHistory(patient_id)
- hispatient, _ := service.GetHisPatientById(patient_id)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "history": history,
- "hispatient": hispatient,
- })
- }
-
- func (this *HisProjectApiController) GetTemplateDetail() {
-
- id, _ := this.GetInt64("id")
- templateDetail, err := service.GetTemplateDetail(id)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "templateDetail": templateDetail,
- })
- }
-
- func (this *HisProjectApiController) UpdateRecordTemplate() {
- id, _ := this.GetInt64("id")
- template_name := this.GetString("template_name")
- template_remark := this.GetString("template_remark")
-
- diagnostic := this.GetString("diagnostic")
- chief_conplaint := this.GetString("chief_conplaint")
- history_of_present_illness := this.GetString("history_of_present_illness")
- past_history := this.GetString("past_history")
- personal_history := this.GetString("personal_history")
- family_history := this.GetString("family_history")
- doctor_advice := this.GetString("doctor_advice")
- remark := this.GetString("remark")
- adminUserInfo := this.GetAdminUserInfo()
- creater := adminUserInfo.AdminUser.Id
- historyTemplate := models.HisCaseHistoryTemplate{
- HistoryOfPresentIllness: history_of_present_illness,
- PastHistory: past_history,
- ChiefConplaint: chief_conplaint,
- PersonalHistory: personal_history,
- FamilyHistory: family_history,
- Diagnostic: diagnostic,
- Status: 1,
- Mtime: time.Now().Unix(),
- RecordDate: time.Now().Unix(),
- TemplateName: template_name,
- TemplateRemark: template_remark,
- Modifier: creater,
- DoctorAdvice: doctor_advice,
- Remark: remark,
- }
- err := service.UpdateCaseHistoryTemplate(&historyTemplate, id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "templateDetail": historyTemplate,
- })
- }
-
- func (this *HisProjectApiController) GetHisPatient() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- keyword := this.GetString("keyword")
- patient, err := service.GetHistPatient(orgId, keyword)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *HisProjectApiController) GetDoctorAdvicePrint() {
-
- patient_id, _ := this.GetInt64("patient_id")
- record_date := this.GetString("record_date")
- schIDStr := this.GetString("ids")
- if len(schIDStr) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- idStrs := strings.Split(schIDStr, ",")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- recordDateTime := theTime.Unix()
- //prescription_id, _ := this.GetInt64("prescription_id")
- adminUserInfo := this.GetAdminUserInfo()
- advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId)
- projectlist, err := service.GetAllProjectList(adminUserInfo.CurrentOrgId, "")
- his, _ := service.GetLastHisPatient(patient_id, adminUserInfo.CurrentOrgId)
- //prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
- hisPatient, _ := service.GetHisPatientById(patient_id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "advicePrint": advicePrint,
- "projectlist": projectlist,
- "hisPatient": hisPatient,
- "his": his,
- })
- }
-
- func (this *HisProjectApiController) GetProjectPrint() {
-
- his_patient_id, _ := this.GetInt64("his_patient_id")
- hisPatient, _ := service.GetHisPatientById(his_patient_id)
- projectPrint, err := service.GetProjectPrint(his_patient_id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "hisPatient": hisPatient,
- "projectPrint": projectPrint,
- })
- }
-
- func (this *HisProjectApiController) PostPrintHisTemplate() {
-
- template_id, _ := this.GetInt64("template_id")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- _, errcode := service.GetHisTemplateId(template_id, orgId)
- //fmt.Println("errcode", errcode)
- if errcode == gorm.ErrRecordNotFound {
- template := models.XtHisTemplate{
- TemplateId: template_id,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
- err := service.CreateHisTemplate(&template)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- "template_id": template_id,
- })
- } else if errcode == nil {
-
- template := models.XtHisTemplate{
- TemplateId: template_id,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- }
- err := service.UpdateHisTemplate(&template)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- "template_id": template_id,
- })
- }
- }
-
- func (this *HisProjectApiController) GetHisPrintTemplate() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- template, err := service.GetHisPrintTemplate(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- }
-
- func (this *HisProjectApiController) PostPrescriptionTempalte() {
-
- template_id, _ := this.GetInt64("template_id")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- _, errcode := service.GetPrescriptionTemplate(template_id, orgId)
- if errcode == gorm.ErrRecordNotFound {
- template := models.XtHisAdviceTemplate{
- TemplateId: template_id,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
- err := service.CreatePrescriptionTemplate(&template)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- "template_id": template_id,
- })
- } else if errcode == nil {
- template := models.XtHisAdviceTemplate{
- TemplateId: template_id,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
- err := service.UpdatePrescriptionTemplate(&template)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- "template_id": template_id,
- })
- }
- }
-
- func (this *HisProjectApiController) GetPrescriptionTemplate() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- template, err := service.GetPrescriptionTemplateById(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- }
-
- func (this *HisProjectApiController) PostTreatPrintTemplate() {
-
- template_id, _ := this.GetInt64("template_id")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- _, errcode := service.GetTreatPrintTemplate(template_id, orgId)
- if errcode == gorm.ErrRecordNotFound {
- template := models.XtHisTreatmentTemplate{
- TemplateId: template_id,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
- err := service.CreateTreatPrintTemplate(&template)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- "template_id": template_id,
- })
- } else if errcode == nil {
- template := models.XtHisTreatmentTemplate{
- TemplateId: template_id,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
- err := service.UpdatedTreateTemplate(&template)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- "template_id": template_id,
- })
- }
- }
-
- func (this *HisProjectApiController) GetTreatPrintTemplate() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- template, err := service.GetTreatTtreatPrintTemplate(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- }
-
- func (this *HisProjectApiController) PostChargePrintTemplate() {
-
- template_id, _ := this.GetInt64("template_id")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- _, errcode := service.GetChargeTemplate(template_id, orgId)
- if errcode == gorm.ErrRecordNotFound {
- template := models.XtHisChargeTemplate{
- TemplateId: template_id,
- UserOrgId: orgId,
- Ctime: time.Now().Unix(),
- Status: 1,
- }
- err := service.CreateChargePrintTemplate(&template)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- "template_id": template_id,
- })
- } else if errcode == nil {
- template := models.XtHisChargeTemplate{
- TemplateId: template_id,
- UserOrgId: orgId,
- Ctime: time.Now().Unix(),
- Status: 1,
- }
- err := service.UpdateChargePrintTemplate(&template)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- "template_id": template_id,
- })
- }
- }
-
- func (this *HisProjectApiController) GetChargePrintTemplate() {
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- template, err := service.GetChargePrintTemplate(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- }
-
- func (this *HisProjectApiController) GetAllHisPatient() {
- record_date := this.GetString("record_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- recordDateTime := theTime.Unix()
- adminUserInfo := this.GetAdminUserInfo()
- patients, err := service.GetScheduleHisPatientList(adminUserInfo.CurrentOrgId, "", recordDateTime, 0)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": patients,
- })
-
- }
-
- func (this *HisProjectApiController) GetChargePrint() {
- record_date := this.GetString("record_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- recordDateTime := theTime.Unix()
- patient_id, _ := this.GetInt64("patient_id")
- prescription_id, _ := this.GetInt64("prescription_id")
- adminUserInfo := this.GetAdminUserInfo()
- chargePrint, err := service.GetChargePrint(recordDateTime, patient_id, adminUserInfo.CurrentOrgId)
- prescription, err := service.GetHisPrescriptionNight(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, prescription_id)
- patient, err := service.GetPatientByID(adminUserInfo.CurrentOrgId, patient_id)
- hisPatient, err := service.GetHisPatientById(patient_id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": chargePrint,
- "prescription": prescription,
- "patient": patient,
- "hisPatient": hisPatient,
- })
- }
-
- func (this *HisProjectApiController) GetTodaySchedulePatient() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- recordDateStr := time.Now().Format("2006-01-02")
- recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- scheduleDate := recordDate.Unix()
-
- patient, err := service.GetTodaySchedulePatient(orgId, scheduleDate)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *HisProjectApiController) GetHisPatientDetail() {
- patient_id, _ := this.GetInt64("patient_id")
-
- hisPatient, err := service.GetHisPatientById(patient_id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "hisPatient": hisPatient,
- })
- }
-
- func (this *HisProjectApiController) GetAllDepartmentList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- departMent, err := service.GetAllDepartMent(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "departMent": departMent,
- })
- }
-
- func (this *HisProjectApiController) GetPrescription() {
-
- patient_id, _ := this.GetInt64("patient_id")
- p_type, _ := this.GetInt64("p_type")
-
- fmt.Println("patient_id", 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()
- list, err := service.GetPrescriptionByPatientId(patient_id, timenow, p_type)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *HisProjectApiController) GetPatientDetail() {
-
- id, _ := this.GetInt64("id")
- adminUserInfo := this.GetAdminUserInfo()
- patient, err := service.GetPatientByID(adminUserInfo.CurrentOrgId, id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *HisProjectApiController) SaveMainTemplate() {
-
- title := this.GetString("title")
- content := this.GetString("content")
- remark := this.GetString("remark")
- template_id, _ := this.GetInt64("template_id")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- template := models.XtHisMedicalTemplate{
- Title: title,
- Content: content,
- Remark: remark,
- UserOrgId: orgId,
- TemplateId: template_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
- err := service.CreateHisMedicalTemplate(&template)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- }
-
- func (this *HisProjectApiController) GetMedicalTempalteList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- list, err := service.GetMedicalTemplateList(orgId)
- listOne, err := service.GetMedicalTemplateListOne(orgId)
- listTwo, err := service.GetMedicalTemplateListTwo(orgId)
- listThree, err := service.GetMedicalTemplateListThree(orgId)
- listFour, err := service.GetMedicalTemplateListFour(orgId)
- listFive, err := service.GetMedicalTemplateListFive(orgId)
- listSix, err := service.GetMedicalTemplateListSix(orgId)
- listSeven, err := service.GetMedicalTemplateListSeven(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "listOne": listOne,
- "listTwo": listTwo,
- "listThree": listThree,
- "listFour": listFour,
- "listFive": listFive,
- "listSix": listSix,
- "listSeven": listSeven,
- })
- }
-
- func (this *HisProjectApiController) GetMainTemplateById() {
-
- id, _ := this.GetInt64("id")
- template, err := service.GetMainTemplateById(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- }
-
- func (this *HisProjectApiController) UpdateMainTemplate() {
-
- title := this.GetString("title")
- content := this.GetString("content")
- remark := this.GetString("remark")
- id, _ := this.GetInt64("id")
-
- template := models.XtHisMedicalTemplate{
- Title: title,
- Content: content,
- Remark: remark,
- }
-
- err := service.UpdateMainTemplate(&template, id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- }
-
- func (this *HisProjectApiController) DeleteMainTemplate() {
-
- id, _ := this.GetInt64("id")
- err := service.DeleteMainTemplateById(id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
-
- }
|