From 61e62d4726adfdf1846ba5a9923137dd4d082030 Mon Sep 17 00:00:00 2001 From: sindhu Date: Wed, 5 Jun 2024 09:35:14 +0700 Subject: [PATCH] step 10 : proses add data dokter --- handlers/dev/md.doctor.handlers.go | 1652 ++++++++++++++++- handlers/routes.go | 1 + models/doctor.models.go | 6 +- services/dev/md.doctor.services.go | 408 +++- views/dev/mddoctor/mddoctor.templ | 18 +- views/dev/mddoctor/mddoctor_templ.go | 262 +-- views/dev/mddoctor/mddoctorformmodal.templ | 34 +- views/dev/mddoctor/mddoctorformmodal_templ.go | 28 +- 8 files changed, 2193 insertions(+), 216 deletions(-) diff --git a/handlers/dev/md.doctor.handlers.go b/handlers/dev/md.doctor.handlers.go index 35018df..aad5670 100644 --- a/handlers/dev/md.doctor.handlers.go +++ b/handlers/dev/md.doctor.handlers.go @@ -6,11 +6,13 @@ import ( navbarmenu "cpone/component/navbar" "cpone/component/pagination" sidebaruserprofile "cpone/component/sidebar_user_profile" + customtoastv2 "cpone/component/toastbootstrap" "cpone/models" "cpone/services" "cpone/utils" "fmt" "strconv" + "strings" dev_mddoctorview "cpone/views/dev/mddoctor" @@ -27,10 +29,13 @@ type MdDoctorServices interface { // DeleteMdGroupResult(id string) (models.DoctorV1, error) GetMdDoctorBreadcrumb(title string) (models.BreadCrumbV1, error) GetListMdSapaan() ([]models.TitleSapaan, error) - GetJenisKelamin() ([]models.HardCodeDropdownV0, error) + GetJenisKelamin() ([]models.HardCodeDropdownJKV0, error) GetKewarganegaraan() ([]models.HardCodeRadioButtonV0, error) GetListMdSpesialis() ([]models.SpecialistV0, error) GetDateNow() (string, error) + AddMdDoctor(inp models.DoctorV1) (models.DoctorV1, error) + GetMdDoctorCode(tipe string) (string, error) + GetMdDoctorByID(id string) (models.DoctorV1, error) } func NewMdDoctorHandler(us MdDoctorServices) *MdDoctorHandler { @@ -107,17 +112,17 @@ func (lh *MdDoctorHandler) HandleShowMdDoctorScreen(c echo.Context) error { sidebaruserprofileComponent := sidebaruserprofile.Navbaruserprofile(dataUser) //Table component - dataGroupResult, totalPage, err := lh.MdDoctorServices.GetListMdDoctor("", 1, 5) + dataListDoctor, totalPage, err := lh.MdDoctorServices.GetListMdDoctor("", 1, 5) if err != nil { defer logger.Sync() logger.Info("ERROR GET GROUP RESULT", zap.Any("error", err), ) - fmt.Println(dataGroupResult) + fmt.Println(dataListDoctor) return err } - tableComponent := dev_mddoctorview.TableDoctor(dataGroupResult, + tableComponent := dev_mddoctorview.TableDoctor(dataListDoctor, tableID, "/dev/md/doctorv2/openedit", "#"+dialogEditBodyID, @@ -165,6 +170,18 @@ func (lh *MdDoctorHandler) HandleShowMdDoctorScreen(c echo.Context) error { return err } + // dataResultSapaan = append(dataResultSapaan, models.TitleSapaan{ + // M_TitleID: 0, + // M_TitleName: "Sapaan", + // }) + + dataResultSapaan = append([]models.TitleSapaan{ + { + M_TitleID: 0, + M_TitleName: "Sapaan", + }, + }, dataResultSapaan...) + // listItem Jenis Kelamin dataResultJenisKelamin, err := lh.MdDoctorServices.GetJenisKelamin() fmt.Println(dataResultJenisKelamin) @@ -178,6 +195,18 @@ func (lh *MdDoctorHandler) HandleShowMdDoctorScreen(c echo.Context) error { return err } + // dataResultJenisKelamin = append(dataResultJenisKelamin, models.HardCodeDropdownJKV0{ + // ID: 0, + // Text: "Jenis Kelamin", + // }) + + dataResultJenisKelamin = append([]models.HardCodeDropdownJKV0{ + { + ID: 0, + Text: "Jenis Kelamin", + }, + }, dataResultJenisKelamin...) + // listItem Golongan Darah dataResultGolonganDarah, err := services.GetTerminologyList( models.TerminologyParamv0{ @@ -196,6 +225,15 @@ func (lh *MdDoctorHandler) HandleShowMdDoctorScreen(c echo.Context) error { return err } + dataResultGolonganDarah = append([]models.TerminologyV0{ + { + AttributePath: "Person.blood.type", + CodeSystem: "http://loinc.org", + Code: "default", + Display: "Golongan Darah", + }, + }, dataResultGolonganDarah...) + // listItem Kewarganegaraan dataResultKewarganegaraan, err := lh.MdDoctorServices.GetKewarganegaraan() fmt.Println(dataResultKewarganegaraan) @@ -222,6 +260,13 @@ func (lh *MdDoctorHandler) HandleShowMdDoctorScreen(c echo.Context) error { return err } + dataResultSpecialist = append([]models.SpecialistV0{ + { + M_SpecialistID: 0, + M_SpecialistName: "Pilih Spesialis", + }, + }, dataResultSpecialist...) + // listItem Pendidikan dataResultPend, err := services.GetTerminologyList( models.TerminologyParamv0{ @@ -240,6 +285,15 @@ func (lh *MdDoctorHandler) HandleShowMdDoctorScreen(c echo.Context) error { return err } + dataResultPend = append([]models.TerminologyV0{ + { + AttributePath: "Person.education", + CodeSystem: "xhis.code.education.level", + Code: "default", + Display: "Pendidikan Terakhir", + }, + }, dataResultPend...) + // listItem Identitas dataResultIdentitas, err := services.GetTerminologyList( models.TerminologyParamv0{ @@ -258,6 +312,15 @@ func (lh *MdDoctorHandler) HandleShowMdDoctorScreen(c echo.Context) error { return err } + dataResultIdentitas = append([]models.TerminologyV0{ + { + AttributePath: "Person.identifier.type", + CodeSystem: "http://terminology.hl7.org/CodeSystem/v2-0203", + Code: "default", + Display: "Pilih Identitas", + }, + }, dataResultIdentitas...) + // listItem dataResultBloodRhesus dataResultBloodRhesus, err := services.GetTerminologyList( models.TerminologyParamv0{ @@ -276,6 +339,15 @@ func (lh *MdDoctorHandler) HandleShowMdDoctorScreen(c echo.Context) error { return err } + dataResultBloodRhesus = append([]models.TerminologyV0{ + { + AttributePath: "Person.blood.rhesus", + CodeSystem: "http://snomed.info/sct", + Code: "default", + Display: "Rhesus", + }, + }, dataResultBloodRhesus...) + // listItem dataResultEtnis dataResultEtnis, err := services.GetTerminologyList( models.TerminologyParamv0{ @@ -294,6 +366,15 @@ func (lh *MdDoctorHandler) HandleShowMdDoctorScreen(c echo.Context) error { return err } + dataResultEtnis = append([]models.TerminologyV0{ + { + AttributePath: "Person.etnicity", + CodeSystem: "xhis.code.etnicity", + Code: "default", + Display: "Etnis", + }, + }, dataResultEtnis...) + // tanggal sekarang dataTglNow, err := lh.MdDoctorServices.GetDateNow() fmt.Println(dataTglNow) @@ -313,45 +394,65 @@ func (lh *MdDoctorHandler) HandleShowMdDoctorScreen(c echo.Context) error { ) // Component Dropdown MCU - listItemResultSapaanComponent := dev_mddoctorview.ItemDropdownSapaan(dataResultSapaan, 0, "Sapaan") + listItemResultSapaanComponent := dev_mddoctorview.ItemDropdownSapaan(dataResultSapaan, 0) // Component Dropdown JK - listItemResultJKComponent := dev_mddoctorview.ItemDropdownJenisKelamin(dataResultJenisKelamin, 0, "Jenis Kelamin") + listItemResultJKComponent := dev_mddoctorview.ItemDropdownJenisKelamin(dataResultJenisKelamin, 0) // Component Dropdown Golongan Darah listItemResultGDComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultGolonganDarah, - models.TerminologySelectedV0{}, - "Golongan Darah", + models.TerminologySelectedV0{ + AttributePath: "Person.blood.type", + CodeSystem: "http://loinc.org", + Code: "default", + Display: "Golongan Darah", + }, ) // Component Radio Button Kewarganegaraan - listItemResultKewarganegaraanComponent := dev_mddoctorview.ItemRadioButtonKewarganegaraan(dataResultKewarganegaraan, 0) + listItemResultKewarganegaraanComponent := dev_mddoctorview.ItemRadioButtonKewarganegaraan(dataResultKewarganegaraan, 1) - // Component Dropdown MCU - listItemResultSpesialisComponent := dev_mddoctorview.ItemDropdownSpesialis(dataResultSpecialist, 0, "Pilih Spesialis") + // Component Dropdown Spesialis + listItemResultSpesialisComponent := dev_mddoctorview.ItemDropdownSpesialis(dataResultSpecialist, 0) // Component Dropdown Pendidikan Terakhir listItemResultPendComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultPend, - models.TerminologySelectedV0{}, - "Pendidikan Terakhir", + models.TerminologySelectedV0{ + AttributePath: "Person.education", + CodeSystem: "xhis.code.education.level", + Code: "default", + Display: "Pendidikan Terakhir", + }, ) // Component Dropdown Identitas listItemResultIdentitasComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultIdentitas, - models.TerminologySelectedV0{}, - "Pilih Identitas", + models.TerminologySelectedV0{ + AttributePath: "Person.identifier.type", + CodeSystem: "http://terminology.hl7.org/CodeSystem/v2-0203", + Code: "default", + Display: "Pilih Identitas", + }, ) // Component Dropdown Rhesus listItemResultBloodRhesusComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultBloodRhesus, - models.TerminologySelectedV0{}, - "Rhesus", + models.TerminologySelectedV0{ + AttributePath: "Person.blood.rhesus", + CodeSystem: "http://snomed.info/sct", + Code: "default", + Display: "Rhesus", + }, ) // Component Dropdown Etnis listItemResultEtnisComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultEtnis, - models.TerminologySelectedV0{}, - "Etnis", + models.TerminologySelectedV0{ + AttributePath: "Person.etnicity", + CodeSystem: "xhis.code.etnicity", + Code: "default", + Display: "Etnis", + }, ) //modal add form @@ -798,3 +899,1516 @@ func (lh *MdDoctorHandler) HandleChangePageMdDoctor(c echo.Context) error { retval = append(retval, userGroupPaginationComponent) return utils.ViewMulti(c, retval) } + +// PROSES ADD DATA +func (lh *MdDoctorHandler) HandleAddMdDoctor(c echo.Context) error { + + logger, _ := zap.NewProduction() + defer logger.Sync() + + //prm form addusergroup + // DARI FORM ADD NYA + doctorID := c.FormValue("doctorid") + doctorTglNow := c.FormValue("doctortglnow") + doctorTglLahirEdit := c.FormValue("doctortgllahiredit") + doctorSapaan := c.FormValue("doctorsapaan") + doctorImbuhanAwal1 := c.FormValue("doctorimbuhanawal1") + doctorImbuhanAwal2 := c.FormValue("doctorimbuhanawal2") + doctorJenisKelamin := c.FormValue("doctorjeniskelamin") + doctorGolonganDarah := c.FormValue("doctorgolongandarah") + doctorKewarganegaraan := c.FormValue("doctorkewarganegaraan") + doctorNomorIdentitas := c.FormValue("doctornomoridentitas") + doctorSpesialis := c.FormValue("doctorspesialis") + doctorImbuhanAkhir1 := c.FormValue("doctorimbuhanakhir1") + doctorImbuhanAkhir2 := c.FormValue("doctorimbuhanakhir2") + doctorImbuhanTahun := c.FormValue("doctorimbuhantahun") + doctorImbuhanBulan := c.FormValue("doctorimbuhanbulan") + doctorImbuhanHari := c.FormValue("doctorimbuhanhari") + doctorPendidikanTerakhir := c.FormValue("doctorpendidikanterakhir") + doctorIdentitas := c.FormValue("doctoridentitas") + doctorImbuhanEmail := c.FormValue("doctorimbuhanemail") + doctorImbuhanNama := c.FormValue("doctorimbuhannama") + doctorImbuhanTanggalLahir := c.FormValue("doctorimbuhantanggallahir") + doctorGolonganBloodRhesus := c.FormValue("doctorgolonganbloodrhesus") + doctorGolonganEtnis := c.FormValue("doctorgolonganetnis") + doctorImbuhanNoHP := c.FormValue("doctorimbuhannohp") + + separator := "$$" + + tableID := c.FormValue("tableID") + paginationID := c.FormValue("paginationID") + searchID := c.FormValue("searchID") + search := c.FormValue("search") + currPagePrm := c.FormValue("currpage" + paginationID) + dialogAddBodyID := c.FormValue("dialogAddBodyID") + dialogAddID := c.FormValue("dialogAddID") + dialogEditBodyID := c.FormValue("dialogEditBodyID") + dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID") + + currPage, err := strconv.Atoi(currPagePrm) + if err != nil { + return err + } + logger.Info("ADD DOCTOR PARAM", + zap.String("doctorID", doctorID), + zap.String("doctorTglNow", doctorTglNow), + zap.String("doctorTglLahirEdit", doctorTglLahirEdit), + zap.String("doctorSapaan", doctorSapaan), + zap.String("doctorImbuhanAwal1", doctorImbuhanAwal1), + zap.String("doctorImbuhanAwal2", doctorImbuhanAwal2), + zap.String("doctorJenisKelamin", doctorJenisKelamin), + zap.String("doctorGolonganDarah", doctorGolonganDarah), + zap.String("doctorKewarganegaraan", doctorKewarganegaraan), + zap.String("doctorNomorIdentitas", doctorNomorIdentitas), + zap.String("doctorSpesialis", doctorSpesialis), + zap.String("doctorImbuhanAkhir1", doctorImbuhanAkhir1), + zap.String("doctorImbuhanAkhir2", doctorImbuhanAkhir2), + zap.String("doctorImbuhanTahun", doctorImbuhanTahun), + zap.String("doctorImbuhanBulan", doctorImbuhanBulan), + zap.String("doctorImbuhanHari", doctorImbuhanHari), + zap.String("doctorPendidikanTerakhir", doctorPendidikanTerakhir), + zap.String("doctorIdentitas", doctorIdentitas), + zap.String("doctorImbuhanEmail", doctorImbuhanEmail), + zap.String("doctorImbuhanNama", doctorImbuhanNama), + zap.String("doctorImbuhanTanggalLahir", doctorImbuhanTanggalLahir), + zap.String("doctorGolonganBloodRhesus", doctorGolonganBloodRhesus), + zap.String("doctorGolonganEtnis", doctorGolonganEtnis), + zap.String("doctorImbuhanNoHP", doctorImbuhanNoHP), + zap.Any("tableid", tableID), + zap.Any("search", search), + zap.Any("currpage", currPage), + ) + + // listItem Sapaan + dataResultSapaan, err := lh.MdDoctorServices.GetListMdSapaan() + fmt.Println(dataResultSapaan) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultSapaan) + return err + } + + dataResultSapaan = append([]models.TitleSapaan{ + { + M_TitleID: 0, + M_TitleName: "Sapaan", + }, + }, dataResultSapaan...) + + // Component Dropdown Sapaan + listItemResultSapaanComponent := dev_mddoctorview.ItemDropdownSapaan(dataResultSapaan, 0) + + // check dropdown Sapaan + var idSelectedSapaan int + idSelectedSapaan, err = strconv.Atoi(doctorSapaan) + if err != nil { + // Tangani kesalahan konversi + fmt.Println("Error converting string to int sapaan:", err) + // return + coba := utils.View(c, + customtoastv2.CustomToastV2Show("Error", "Error converting string to int sapaan", "danger"), + // test + ) + return coba + } + + var idSapaanAdd int + for _, x := range dataResultSapaan { + if x.M_TitleID == idSelectedSapaan { + idSapaanAdd = idSelectedSapaan + } + } + + // listItem Jenis Kelamin + dataResultJenisKelamin, err := lh.MdDoctorServices.GetJenisKelamin() + fmt.Println(dataResultJenisKelamin) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultJenisKelamin) + return err + } + + dataResultJenisKelamin = append([]models.HardCodeDropdownJKV0{ + { + ID: 0, + Text: "Jenis Kelamin", + }, + }, dataResultJenisKelamin...) + + // Component Dropdown JK + listItemResultJKComponent := dev_mddoctorview.ItemDropdownJenisKelamin(dataResultJenisKelamin, 0) + + // check dropdown JK + var idSelectedJk int + idSelectedJk, err = strconv.Atoi(doctorJenisKelamin) + if err != nil { + // Tangani kesalahan konversi + fmt.Println("Error converting string to int jenis kelamin:", err) + // return + coba := utils.View(c, + customtoastv2.CustomToastV2Show("Error", "Error converting string to int jenis kelamin", "danger"), + // test + ) + return coba + } + + var doctorJKAdd string + for _, x := range dataResultJenisKelamin { + if x.ID == idSelectedJk { + doctorJKAdd = x.Text + } + } + + // listItem Golongan Darah + strArrayGD := strings.Split(doctorGolonganDarah, separator) + dataResultGolonganDarah, err := services.GetTerminologyList( + models.TerminologyParamv0{ + AttributePath: "Person.blood.type", + CodeSystem: "http://loinc.org", + }, + ) + fmt.Println(dataResultGolonganDarah) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultGolonganDarah) + return err + } + + dataResultGolonganDarah = append([]models.TerminologyV0{ + { + AttributePath: "Person.blood.type", + CodeSystem: "http://loinc.org", + Code: "default", + Display: "Golongan Darah", + }, + }, dataResultGolonganDarah...) + + // Component Dropdown GD + listItemResultGDComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultGolonganDarah, models.TerminologySelectedV0{ + AttributePath: "Person.blood.type", + CodeSystem: "http://loinc.org", + Code: strArrayGD[0], + }) + + // listItem Kewarganegaraan + dataResultKewarganegaraan, err := lh.MdDoctorServices.GetKewarganegaraan() + fmt.Println(dataResultKewarganegaraan) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultKewarganegaraan) + return err + } + + // Component Radio Button Kewarganegaraan + listItemResultKewarganegaraanComponent := dev_mddoctorview.ItemRadioButtonKewarganegaraan(dataResultKewarganegaraan, 1) + + // check Radio Button Kewarganegaraan + var idSelectedKewarganegaraan int + idSelectedKewarganegaraan, err = strconv.Atoi(doctorKewarganegaraan) + if err != nil { + // Tangani kesalahan konversi + fmt.Println("Error converting string to int kewarganegaraan:", err) + // return + coba := utils.View(c, + customtoastv2.CustomToastV2Show("Error", "Error converting string to int kewarganegaraan", "danger"), + // test + ) + return coba + } + + var idKewarganegaraanAdd string + for _, x := range dataResultKewarganegaraan { + if x.ID == idSelectedKewarganegaraan { + idKewarganegaraanAdd = x.Text + } + } + + // listItem Specialist + dataResultSpecialist, err := lh.MdDoctorServices.GetListMdSpesialis() + fmt.Println(dataResultSpecialist) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultSpecialist) + return err + } + + dataResultSpecialist = append([]models.SpecialistV0{ + { + M_SpecialistID: 0, + M_SpecialistName: "Pilih Spesialis", + }, + }, dataResultSpecialist...) + + // Component Dropdown Spesialis + listItemResultSpesialisComponent := dev_mddoctorview.ItemDropdownSpesialis(dataResultSpecialist, 0) + + // check Dropdown Spesialis + var idSelectedSpesialis int + idSelectedSpesialis, err = strconv.Atoi(doctorSpesialis) + if err != nil { + // Tangani kesalahan konversi + fmt.Println("Error converting string to int spesialis:", err) + // return + coba := utils.View(c, + customtoastv2.CustomToastV2Show("Error", "Error converting string to int spesialis", "danger"), + // test + ) + return coba + } + + var idSpesialisAdd string + for _, x := range dataResultSpecialist { + if x.M_SpecialistID == idSelectedSpesialis { + idSpesialisAdd = strconv.Itoa(idSelectedSpesialis) + } + } + + // listItem Pendidikan Terakhir + strArrayPD := strings.Split(doctorPendidikanTerakhir, separator) + dataResultPendidikanTerakhir, err := services.GetTerminologyList( + models.TerminologyParamv0{ + AttributePath: "Person.education", + CodeSystem: "xhis.code.education.level", + }, + ) + fmt.Println(dataResultPendidikanTerakhir) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultPendidikanTerakhir) + return err + } + + dataResultPendidikanTerakhir = append([]models.TerminologyV0{ + { + AttributePath: "Person.education", + CodeSystem: "xhis.code.education.level", + Code: "default", + Display: "Pendidikan Terakhir", + }, + }, dataResultPendidikanTerakhir...) + + // Component Dropdown Pendidikan Terakhir + listItemResultPendComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultPendidikanTerakhir, models.TerminologySelectedV0{ + AttributePath: "Person.education", + CodeSystem: "xhis.code.education.level", + Code: strArrayPD[0], + }) + + // listItem Identitas + strArrayIdentitas := strings.Split(doctorIdentitas, separator) + dataResultIdentitas, err := services.GetTerminologyList( + models.TerminologyParamv0{ + AttributePath: "Person.identifier.type", + CodeSystem: "http://terminology.hl7.org/CodeSystem/v2-0203", + }, + ) + fmt.Println(dataResultIdentitas) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultIdentitas) + return err + } + + dataResultIdentitas = append([]models.TerminologyV0{ + { + AttributePath: "Person.identifier.type", + CodeSystem: "http://terminology.hl7.org/CodeSystem/v2-0203", + Code: "default", + Display: "Pilih Identitas", + }, + }, dataResultIdentitas...) + + // Component Dropdown Identitas + listItemResultIdentitasComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultIdentitas, models.TerminologySelectedV0{ + AttributePath: "Person.identifier.type", + CodeSystem: "http://terminology.hl7.org/CodeSystem/v2-0203", + Code: strArrayIdentitas[0], + }) + + // listItem Rhesus + strArrayRhesus := strings.Split(doctorGolonganBloodRhesus, separator) + dataResultBloodRhesus, err := services.GetTerminologyList( + models.TerminologyParamv0{ + AttributePath: "Person.blood.rhesus", + CodeSystem: "http://snomed.info/sct", + }, + ) + fmt.Println(dataResultBloodRhesus) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultBloodRhesus) + return err + } + + dataResultBloodRhesus = append([]models.TerminologyV0{ + { + AttributePath: "Person.blood.rhesus", + CodeSystem: "http://snomed.info/sct", + Code: "default", + Display: "Rhesus", + }, + }, dataResultBloodRhesus...) + + // Component Dropdown Rhesus + listItemResultBloodRhesusComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultBloodRhesus, models.TerminologySelectedV0{ + AttributePath: "Person.blood.rhesus", + CodeSystem: "http://snomed.info/sct", + Code: strArrayRhesus[0], + }) + + // listItem Etnis + strArrayEtnis := strings.Split(doctorGolonganEtnis, separator) + dataResultEtnis, err := services.GetTerminologyList( + models.TerminologyParamv0{ + AttributePath: "Person.etnicity", + CodeSystem: "xhis.code.etnicity", + }, + ) + fmt.Println(dataResultEtnis) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataResultEtnis) + return err + } + + dataResultEtnis = append([]models.TerminologyV0{ + { + AttributePath: "Person.etnicity", + CodeSystem: "xhis.code.etnicity", + Code: "default", + Display: "Etnis", + }, + }, dataResultEtnis...) + + // Component Dropdown Etnis + listItemResultEtnisComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultEtnis, models.TerminologySelectedV0{ + AttributePath: "Person.etnicity", + CodeSystem: "xhis.code.etnicity", + Code: strArrayEtnis[0], + }) + + formValidation := "" + nameValidation := "" + jkValidation := "" + + if strings.TrimSpace(doctorImbuhanNama) == "" { + formValidation = "Nama tidak boleh kosong" + nameValidation = "Nama tidak boleh kosong" + } + + if strings.TrimSpace(doctorJenisKelamin) == "0" { + formValidation = "Jenis Kelamin Harus dipilih" + jkValidation = "Jenis Kelamin Harus dipilih" + } + + if formValidation != "" || nameValidation != "" || jkValidation != "" { + + // Component Dropdown JK + listItemResultJKComponent := dev_mddoctorview.ItemDropdownJenisKelamin(dataResultJenisKelamin, idSelectedJk) + + // Component Dropdown Sapaan + listItemResultSapaanComponent := dev_mddoctorview.ItemDropdownSapaan(dataResultSapaan, idSelectedSapaan) + + // Component Dropdown GD + listItemResultGDComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultGolonganDarah, models.TerminologySelectedV0{ + AttributePath: "Person.blood.type", + CodeSystem: "http://loinc.org", + Code: strArrayGD[0], + }) + + // Component Radio Button Kewarganegaraan + listItemResultKewarganegaraanComponent := dev_mddoctorview.ItemRadioButtonKewarganegaraan(dataResultKewarganegaraan, idSelectedKewarganegaraan) + + // Component Dropdown Spesialis + listItemResultSpesialisComponent := dev_mddoctorview.ItemDropdownSpesialis(dataResultSpecialist, idSelectedSpesialis) + + // Component Dropdown Pendidikan Terakhir + listItemResultPendComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultPendidikanTerakhir, models.TerminologySelectedV0{ + AttributePath: "Person.education", + CodeSystem: "xhis.code.education.level", + Code: strArrayPD[0], + }) + + // Component Dropdown Identitas + listItemResultIdentitasComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultIdentitas, models.TerminologySelectedV0{ + AttributePath: "Person.identifier.type", + CodeSystem: "http://terminology.hl7.org/CodeSystem/v2-0203", + Code: strArrayIdentitas[0], + }) + + // Component Dropdown Rhesus + listItemResultBloodRhesusComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultBloodRhesus, models.TerminologySelectedV0{ + AttributePath: "Person.blood.rhesus", + CodeSystem: "http://snomed.info/sct", + Code: strArrayRhesus[0], + }) + + // Component Dropdown Etnis + listItemResultEtnisComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultEtnis, models.TerminologySelectedV0{ + AttributePath: "Person.etnicity", + CodeSystem: "xhis.code.etnicity", + Code: strArrayEtnis[0], + }) + newForm := dev_mddoctorview.BodyFormDoctor( + // doctorid + models.CustomTextFieldv2Prm{ + Label: "Doctor ID", + Name: "doctorid", + Placeholder: "Doctor ID", + Type: "hidden", + ID: "doctorid", + }, + // tgl sekarang hidden + models.CustomTextFieldv2Prm{ + Label: "Tgl Sekarang", + Name: "doctortglnow", + Placeholder: "Tgl Sekarang", + Type: "hidden", + ID: "doctortglnow", + Value: doctorTglNow, + }, + // tgl lahir edit hidden + models.CustomTextFieldv2Prm{ + Label: "Tanggal Lahir Edit", + Name: "doctortgllahiredit", + Placeholder: "Tanggal Lahir Edit", + Type: "hidden", + ID: "doctortgllahiredit", + // Value: "2021-01-01", + }, + // sapaan + models.CustomDropdownv1Prm{ + Label: "Sapaan", + Name: "doctorsapaan", + ID: "doctorsapaan", + }, + listItemResultSapaanComponent, + // imbuhan awal1 + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Awal 1", + Name: "doctorimbuhanawal1", + Placeholder: "Awal 1", + Type: "text", + ID: "doctorimbuhanawal1", + Value: doctorImbuhanAwal1, + }, + // imbuhan awal2 + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Awal 2", + Name: "doctorimbuhanawal2", + Placeholder: "Awal 2", + Type: "text", + ID: "doctorimbuhanawal2", + Value: doctorImbuhanAwal2, + }, + // jenis kelamin + models.CustomDropdownv1Prm{ + Label: "Jenis Kelamin", + Name: "doctorjeniskelamin", + ID: "doctorjeniskelamin", + ErrorMsg: "Jenis Kelamin Harus Dipilih", + }, + listItemResultJKComponent, + // golongan darah + models.CustomDropdownv1Prm{ + Label: "Golongan Darah", + Name: "doctorgolongandarah", + ID: "doctorgolongandarah", + }, + listItemResultGDComponent, + // kewarganegaraan + models.CustomRadioButtonv1Prm{ + Label: "Kewarganegaraan", + Name: "doctorkewarganegaraan", + ID: "doctorkewarganegaraan", + }, + listItemResultKewarganegaraanComponent, + // nomor identitas + models.CustomTextFieldv2Prm{ + Label: "Nomor Identitas", + Name: "doctornomoridentitas", + Placeholder: "Nomor Identitas", + Type: "text", + ID: "doctornomoridentitas", + Value: doctorNomorIdentitas, + }, + // spesialis + models.CustomDropdownv1Prm{ + Label: "Spesialis", + Name: "doctorspesialis", + ID: "doctorspesialis", + }, + listItemResultSpesialisComponent, + // imbuhan akhir 1 + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Akhir 1", + Name: "doctorimbuhanakhir1", + Placeholder: "Akhir 1", + Type: "text", + ID: "doctorimbuhanakhir1", + Value: doctorImbuhanAkhir1, + }, + // imbuhan akhir 2 + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Akhir 2", + Name: "doctorimbuhanakhir2", + Placeholder: "Akhir 2", + Type: "text", + ID: "doctorimbuhanakhir2", + Value: doctorImbuhanAkhir2, + }, + // imbuhan tahun + models.CustomTextFieldv2Prm{ + Label: "Tahun", + Name: "doctorimbuhantahun", + Placeholder: "Tahun", + Type: "text", + ID: "doctorimbuhantahun", + Value: doctorImbuhanTahun, + }, + // imbuhan bulan + models.CustomTextFieldv2Prm{ + Label: "Bulan", + Name: "doctorimbuhanbulan", + Placeholder: "Bulan", + Type: "text", + ID: "doctorimbuhanbulan", + Value: doctorImbuhanBulan, + }, + // imbuhan hari + models.CustomTextFieldv2Prm{ + Label: "Hari", + Name: "doctorimbuhanhari", + Placeholder: "Hari", + Type: "text", + ID: "doctorimbuhanhari", + Value: doctorImbuhanHari, + }, + // pendidikan terakhir + models.CustomDropdownv1Prm{ + Label: "Pendidikan Terakhir", + Name: "doctorpendidikanterakhir", + ID: "doctorpendidikanterakhir", + }, + listItemResultPendComponent, + // identitas + models.CustomDropdownv1Prm{ + Label: "Identitas", + Name: "doctoridentitas", + ID: "doctoridentitas", + }, + listItemResultIdentitasComponent, + // email + models.CustomTextFieldv2Prm{ + Label: "Email", + Name: "doctorimbuhanemail", + Placeholder: "Email", + Type: "text", + ID: "doctorimbuhanemail", + Value: doctorImbuhanEmail, + }, + // nama + models.CustomTextFieldv2Prm{ + Label: "Nama", + Name: "doctorimbuhannama", + Placeholder: "Nama", + Type: "text", + ID: "doctorimbuhannama", + Value: doctorImbuhanNama, + ErrorMsg: "Nama Tidak Boleh Kosong", + }, + // tanggal lahir + models.CustomTextFieldv2Prm{ + Label: "Tanggal Lahir", + Name: "doctorimbuhantanggallahir", + Placeholder: "Tanggal Lahir", + Type: "date", + ID: "doctorimbuhantanggallahir", + Value: doctorImbuhanTanggalLahir, + }, + // rhesus + models.CustomDropdownv1Prm{ + Label: "Rhesus", + Name: "doctorgolonganbloodrhesus", + ID: "doctorgolonganbloodrhesus", + }, + listItemResultBloodRhesusComponent, + // etnis + models.CustomDropdownv1Prm{ + Label: "Ernis", + Name: "doctorgolonganetnis", + ID: "doctorgolonganetnis", + }, + listItemResultEtnisComponent, + // no hp + models.CustomTextFieldv2Prm{ + Label: "Nomor HP", + Name: "doctorimbuhannohp", + Placeholder: "Nomor HP", + Type: "text", + ID: "doctorimbuhannohp", + Value: doctorImbuhanNoHP, + }, + dialogAddBodyID, dev_mddoctorview.JsHideModalDoctor("")) + return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Warning", formValidation, "warning"), newForm}) + } + + doctorCode, err := lh.MdDoctorServices.GetMdDoctorCode("D") + if err != nil { + // Tangani kesalahan konversi + fmt.Println("Error Get Doctor Code:", err) + + // Component Dropdown JK + listItemResultJKComponent := dev_mddoctorview.ItemDropdownJenisKelamin(dataResultJenisKelamin, idSelectedJk) + + // Component Dropdown Sapaan + listItemResultSapaanComponent := dev_mddoctorview.ItemDropdownSapaan(dataResultSapaan, idSelectedSapaan) + + // Component Dropdown GD + listItemResultGDComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultGolonganDarah, models.TerminologySelectedV0{ + AttributePath: "Person.blood.type", + CodeSystem: "http://loinc.org", + Code: strArrayGD[0], + }) + + // Component Radio Button Kewarganegaraan + listItemResultKewarganegaraanComponent := dev_mddoctorview.ItemRadioButtonKewarganegaraan(dataResultKewarganegaraan, idSelectedKewarganegaraan) + + // Component Dropdown Spesialis + listItemResultSpesialisComponent := dev_mddoctorview.ItemDropdownSpesialis(dataResultSpecialist, idSelectedSpesialis) + + // Component Dropdown Pendidikan Terakhir + listItemResultPendComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultPendidikanTerakhir, models.TerminologySelectedV0{ + AttributePath: "Person.education", + CodeSystem: "xhis.code.education.level", + Code: strArrayPD[0], + }) + + // Component Dropdown Identitas + listItemResultIdentitasComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultIdentitas, models.TerminologySelectedV0{ + AttributePath: "Person.identifier.type", + CodeSystem: "http://terminology.hl7.org/CodeSystem/v2-0203", + Code: strArrayIdentitas[0], + }) + + // Component Dropdown Rhesus + listItemResultBloodRhesusComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultBloodRhesus, models.TerminologySelectedV0{ + AttributePath: "Person.blood.rhesus", + CodeSystem: "http://snomed.info/sct", + Code: strArrayRhesus[0], + }) + + // Component Dropdown Etnis + listItemResultEtnisComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultEtnis, models.TerminologySelectedV0{ + AttributePath: "Person.etnicity", + CodeSystem: "xhis.code.etnicity", + Code: strArrayEtnis[0], + }) + + newForm := dev_mddoctorview.BodyFormDoctor( + // doctorid + models.CustomTextFieldv2Prm{ + Label: "Doctor ID", + Name: "doctorid", + Placeholder: "Doctor ID", + Type: "hidden", + ID: "doctorid", + }, + // tgl sekarang hidden + models.CustomTextFieldv2Prm{ + Label: "Tgl Sekarang", + Name: "doctortglnow", + Placeholder: "Tgl Sekarang", + Type: "hidden", + ID: "doctortglnow", + Value: doctorTglNow, + }, + // tgl lahir edit hidden + models.CustomTextFieldv2Prm{ + Label: "Tanggal Lahir Edit", + Name: "doctortgllahiredit", + Placeholder: "Tanggal Lahir Edit", + Type: "hidden", + ID: "doctortgllahiredit", + // Value: "2021-01-01", + }, + // sapaan + models.CustomDropdownv1Prm{ + Label: "Sapaan", + Name: "doctorsapaan", + ID: "doctorsapaan", + }, + listItemResultSapaanComponent, + // imbuhan awal1 + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Awal 1", + Name: "doctorimbuhanawal1", + Placeholder: "Awal 1", + Type: "text", + ID: "doctorimbuhanawal1", + Value: doctorImbuhanAwal1, + }, + // imbuhan awal2 + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Awal 2", + Name: "doctorimbuhanawal2", + Placeholder: "Awal 2", + Type: "text", + ID: "doctorimbuhanawal2", + Value: doctorImbuhanAwal2, + }, + // jenis kelamin + models.CustomDropdownv1Prm{ + Label: "Jenis Kelamin", + Name: "doctorjeniskelamin", + ID: "doctorjeniskelamin", + ErrorMsg: "Jenis Kelamin Harus Dipilih", + }, + listItemResultJKComponent, + // golongan darah + models.CustomDropdownv1Prm{ + Label: "Golongan Darah", + Name: "doctorgolongandarah", + ID: "doctorgolongandarah", + }, + listItemResultGDComponent, + // kewarganegaraan + models.CustomRadioButtonv1Prm{ + Label: "Kewarganegaraan", + Name: "doctorkewarganegaraan", + ID: "doctorkewarganegaraan", + }, + listItemResultKewarganegaraanComponent, + // nomor identitas + models.CustomTextFieldv2Prm{ + Label: "Nomor Identitas", + Name: "doctornomoridentitas", + Placeholder: "Nomor Identitas", + Type: "text", + ID: "doctornomoridentitas", + Value: doctorNomorIdentitas, + }, + // spesialis + models.CustomDropdownv1Prm{ + Label: "Spesialis", + Name: "doctorspesialis", + ID: "doctorspesialis", + }, + listItemResultSpesialisComponent, + // imbuhan akhir 1 + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Akhir 1", + Name: "doctorimbuhanakhir1", + Placeholder: "Akhir 1", + Type: "text", + ID: "doctorimbuhanakhir1", + Value: doctorImbuhanAkhir1, + }, + // imbuhan akhir 2 + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Akhir 2", + Name: "doctorimbuhanakhir2", + Placeholder: "Akhir 2", + Type: "text", + ID: "doctorimbuhanakhir2", + Value: doctorImbuhanAkhir2, + }, + // imbuhan tahun + models.CustomTextFieldv2Prm{ + Label: "Tahun", + Name: "doctorimbuhantahun", + Placeholder: "Tahun", + Type: "text", + ID: "doctorimbuhantahun", + Value: doctorImbuhanTahun, + }, + // imbuhan bulan + models.CustomTextFieldv2Prm{ + Label: "Bulan", + Name: "doctorimbuhanbulan", + Placeholder: "Bulan", + Type: "text", + ID: "doctorimbuhanbulan", + Value: doctorImbuhanBulan, + }, + // imbuhan hari + models.CustomTextFieldv2Prm{ + Label: "Hari", + Name: "doctorimbuhanhari", + Placeholder: "Hari", + Type: "text", + ID: "doctorimbuhanhari", + Value: doctorImbuhanHari, + }, + // pendidikan terakhir + models.CustomDropdownv1Prm{ + Label: "Pendidikan Terakhir", + Name: "doctorpendidikanterakhir", + ID: "doctorpendidikanterakhir", + }, + listItemResultPendComponent, + // identitas + models.CustomDropdownv1Prm{ + Label: "Identitas", + Name: "doctoridentitas", + ID: "doctoridentitas", + }, + listItemResultIdentitasComponent, + // email + models.CustomTextFieldv2Prm{ + Label: "Email", + Name: "doctorimbuhanemail", + Placeholder: "Email", + Type: "text", + ID: "doctorimbuhanemail", + Value: doctorImbuhanEmail, + }, + // nama + models.CustomTextFieldv2Prm{ + Label: "Nama", + Name: "doctorimbuhannama", + Placeholder: "Nama", + Type: "text", + ID: "doctorimbuhannama", + Value: doctorImbuhanNama, + ErrorMsg: "Nama Tidak Boleh Kosong", + }, + // tanggal lahir + models.CustomTextFieldv2Prm{ + Label: "Tanggal Lahir", + Name: "doctorimbuhantanggallahir", + Placeholder: "Tanggal Lahir", + Type: "date", + ID: "doctorimbuhantanggallahir", + Value: doctorImbuhanTanggalLahir, + }, + // rhesus + models.CustomDropdownv1Prm{ + Label: "Rhesus", + Name: "doctorgolonganbloodrhesus", + ID: "doctorgolonganbloodrhesus", + }, + listItemResultBloodRhesusComponent, + // etnis + models.CustomDropdownv1Prm{ + Label: "Ernis", + Name: "doctorgolonganetnis", + ID: "doctorgolonganetnis", + }, + listItemResultEtnisComponent, + // no hp + models.CustomTextFieldv2Prm{ + Label: "Nomor HP", + Name: "doctorimbuhannohp", + Placeholder: "Nomor HP", + Type: "text", + ID: "doctorimbuhannohp", + Value: doctorImbuhanNoHP, + }, + dialogAddBodyID, dev_mddoctorview.JsHideModalDoctor("")) + return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Error", "Error Get Doctor Code", "danger"), newForm}) + + } + + //Add doctor service + doctor := models.DoctorV1{ + M_DoctorM_TitleID: idSapaanAdd, + M_DoctorCode: doctorCode, + M_DoctorPrefix: doctorImbuhanAwal1, + M_DoctorPrefix2: doctorImbuhanAwal2, + M_DoctorName: doctorImbuhanNama, + M_DoctorSuffix: doctorImbuhanAkhir1, + M_DoctorSuffix2: doctorImbuhanAkhir2, + M_DoctorGender: doctorJKAdd, + M_DoctorDOB: doctorImbuhanTanggalLahir, + M_DoctorReligionCode: "", + M_DoctorReligionSystem: "", + M_DoctorBloodTypeCode: strArrayGD[0], + M_DoctorBloodTypeSystem: strArrayGD[1], + M_DoctorBloodRhCode: strArrayRhesus[0], + M_DoctorBloodRhSystem: strArrayRhesus[1], + M_DoctorEducationCode: strArrayPD[0], + M_DoctorEducationSystem: strArrayPD[1], + M_DoctorCitizenship: idKewarganegaraanAdd, + M_DoctorEtnicCode: strArrayEtnis[0], + M_DoctorEtnicSystem: strArrayEtnis[1], + M_DoctorIdentifierCode: strArrayIdentitas[0], + M_DoctorIdentifierSystem: strArrayIdentitas[1], + M_DoctorIdentifierValue: doctorNomorIdentitas, + M_DoctorHp: doctorImbuhanNoHP, + M_DoctorEmail: doctorImbuhanEmail, + M_DoctorM_SpecialistID: idSpesialisAdd, + M_DoctorAddress: "", + M_DoctorAddressRegionalCd: 0, + M_DoctorAddressCity: "", + M_DoctorAddressDistrict: "", + M_DoctorAddressState: "", + M_DoctorAddressCountry: "", + M_DoctorIsActive: "Y", + M_DoctorCreatedUserID: "1", + } + + dataDoctorAdd, err := lh.MdDoctorServices.AddMdDoctor(doctor) + + if err != nil { + logger.Info("Error", + zap.Any("Error", err), + zap.String("doctorID", doctorID), + zap.String("doctorTglNow", doctorTglNow), + zap.String("doctorTglLahirEdit", doctorTglLahirEdit), + zap.String("doctorSapaan", doctorSapaan), + zap.String("doctorImbuhanAwal1", doctorImbuhanAwal1), + zap.String("doctorImbuhanAwal2", doctorImbuhanAwal2), + zap.String("doctorJenisKelamin", doctorJenisKelamin), + zap.String("doctorGolonganDarah", doctorGolonganDarah), + zap.String("doctorKewarganegaraan", doctorKewarganegaraan), + zap.String("doctorNomorIdentitas", doctorNomorIdentitas), + zap.String("doctorSpesialis", doctorSpesialis), + zap.String("doctorImbuhanAkhir1", doctorImbuhanAkhir1), + zap.String("doctorImbuhanAkhir2", doctorImbuhanAkhir2), + zap.String("doctorImbuhanTahun", doctorImbuhanTahun), + zap.String("doctorImbuhanBulan", doctorImbuhanBulan), + zap.String("doctorImbuhanHari", doctorImbuhanHari), + zap.String("doctorPendidikanTerakhir", doctorPendidikanTerakhir), + zap.String("doctorIdentitas", doctorIdentitas), + zap.String("doctorImbuhanEmail", doctorImbuhanEmail), + zap.String("doctorImbuhanNama", doctorImbuhanNama), + zap.String("doctorImbuhanTanggalLahir", doctorImbuhanTanggalLahir), + zap.String("doctorGolonganBloodRhesus", doctorGolonganBloodRhesus), + zap.String("doctorGolonganEtnis", doctorGolonganEtnis), + zap.String("doctorImbuhanNoHP", doctorImbuhanNoHP), + ) + + // Component Dropdown JK + listItemResultJKComponent := dev_mddoctorview.ItemDropdownJenisKelamin(dataResultJenisKelamin, idSelectedJk) + + // Component Dropdown Sapaan + listItemResultSapaanComponent := dev_mddoctorview.ItemDropdownSapaan(dataResultSapaan, idSelectedSapaan) + + // Component Dropdown GD + listItemResultGDComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultGolonganDarah, models.TerminologySelectedV0{ + AttributePath: "Person.blood.type", + CodeSystem: "http://loinc.org", + Code: strArrayGD[0], + }) + + // Component Radio Button Kewarganegaraan + listItemResultKewarganegaraanComponent := dev_mddoctorview.ItemRadioButtonKewarganegaraan(dataResultKewarganegaraan, idSelectedKewarganegaraan) + + // Component Dropdown Spesialis + listItemResultSpesialisComponent := dev_mddoctorview.ItemDropdownSpesialis(dataResultSpecialist, idSelectedSpesialis) + + // Component Dropdown Pendidikan Terakhir + listItemResultPendComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultPendidikanTerakhir, models.TerminologySelectedV0{ + AttributePath: "Person.education", + CodeSystem: "xhis.code.education.level", + Code: strArrayPD[0], + }) + + // Component Dropdown Identitas + listItemResultIdentitasComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultIdentitas, models.TerminologySelectedV0{ + AttributePath: "Person.identifier.type", + CodeSystem: "http://terminology.hl7.org/CodeSystem/v2-0203", + Code: strArrayIdentitas[0], + }) + + // Component Dropdown Rhesus + listItemResultBloodRhesusComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultBloodRhesus, models.TerminologySelectedV0{ + AttributePath: "Person.blood.rhesus", + CodeSystem: "http://snomed.info/sct", + Code: strArrayRhesus[0], + }) + + // Component Dropdown Etnis + listItemResultEtnisComponent := dev_mddoctorview.ItemDropdownTerminology(dataResultEtnis, models.TerminologySelectedV0{ + AttributePath: "Person.etnicity", + CodeSystem: "xhis.code.etnicity", + Code: strArrayEtnis[0], + }) + + newForm := dev_mddoctorview.BodyFormDoctor( + // doctorid + models.CustomTextFieldv2Prm{ + Label: "Doctor ID", + Name: "doctorid", + Placeholder: "Doctor ID", + Type: "hidden", + ID: "doctorid", + }, + // tgl sekarang hidden + models.CustomTextFieldv2Prm{ + Label: "Tgl Sekarang", + Name: "doctortglnow", + Placeholder: "Tgl Sekarang", + Type: "hidden", + ID: "doctortglnow", + Value: doctorTglNow, + }, + // tgl lahir edit hidden + models.CustomTextFieldv2Prm{ + Label: "Tanggal Lahir Edit", + Name: "doctortgllahiredit", + Placeholder: "Tanggal Lahir Edit", + Type: "hidden", + ID: "doctortgllahiredit", + // Value: "2021-01-01", + }, + // sapaan + models.CustomDropdownv1Prm{ + Label: "Sapaan", + Name: "doctorsapaan", + ID: "doctorsapaan", + }, + listItemResultSapaanComponent, + // imbuhan awal1 + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Awal 1", + Name: "doctorimbuhanawal1", + Placeholder: "Awal 1", + Type: "text", + ID: "doctorimbuhanawal1", + Value: doctorImbuhanAwal1, + }, + // imbuhan awal2 + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Awal 2", + Name: "doctorimbuhanawal2", + Placeholder: "Awal 2", + Type: "text", + ID: "doctorimbuhanawal2", + Value: doctorImbuhanAwal2, + }, + // jenis kelamin + models.CustomDropdownv1Prm{ + Label: "Jenis Kelamin", + Name: "doctorjeniskelamin", + ID: "doctorjeniskelamin", + }, + listItemResultJKComponent, + // golongan darah + models.CustomDropdownv1Prm{ + Label: "Golongan Darah", + Name: "doctorgolongandarah", + ID: "doctorgolongandarah", + }, + listItemResultGDComponent, + // kewarganegaraan + models.CustomRadioButtonv1Prm{ + Label: "Kewarganegaraan", + Name: "doctorkewarganegaraan", + ID: "doctorkewarganegaraan", + }, + listItemResultKewarganegaraanComponent, + // nomor identitas + models.CustomTextFieldv2Prm{ + Label: "Nomor Identitas", + Name: "doctornomoridentitas", + Placeholder: "Nomor Identitas", + Type: "text", + ID: "doctornomoridentitas", + Value: doctorNomorIdentitas, + }, + // spesialis + models.CustomDropdownv1Prm{ + Label: "Spesialis", + Name: "doctorspesialis", + ID: "doctorspesialis", + }, + listItemResultSpesialisComponent, + // imbuhan akhir 1 + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Akhir 1", + Name: "doctorimbuhanakhir1", + Placeholder: "Akhir 1", + Type: "text", + ID: "doctorimbuhanakhir1", + Value: doctorImbuhanAkhir1, + }, + // imbuhan akhir 2 + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Akhir 2", + Name: "doctorimbuhanakhir2", + Placeholder: "Akhir 2", + Type: "text", + ID: "doctorimbuhanakhir2", + Value: doctorImbuhanAkhir2, + }, + // imbuhan tahun + models.CustomTextFieldv2Prm{ + Label: "Tahun", + Name: "doctorimbuhantahun", + Placeholder: "Tahun", + Type: "text", + ID: "doctorimbuhantahun", + Value: doctorImbuhanTahun, + }, + // imbuhan bulan + models.CustomTextFieldv2Prm{ + Label: "Bulan", + Name: "doctorimbuhanbulan", + Placeholder: "Bulan", + Type: "text", + ID: "doctorimbuhanbulan", + Value: doctorImbuhanBulan, + }, + // imbuhan hari + models.CustomTextFieldv2Prm{ + Label: "Hari", + Name: "doctorimbuhanhari", + Placeholder: "Hari", + Type: "text", + ID: "doctorimbuhanhari", + Value: doctorImbuhanHari, + }, + // pendidikan terakhir + models.CustomDropdownv1Prm{ + Label: "Pendidikan Terakhir", + Name: "doctorpendidikanterakhir", + ID: "doctorpendidikanterakhir", + }, + listItemResultPendComponent, + // identitas + models.CustomDropdownv1Prm{ + Label: "Identitas", + Name: "doctoridentitas", + ID: "doctoridentitas", + }, + listItemResultIdentitasComponent, + // email + models.CustomTextFieldv2Prm{ + Label: "Email", + Name: "doctorimbuhanemail", + Placeholder: "Email", + Type: "text", + ID: "doctorimbuhanemail", + Value: doctorImbuhanEmail, + }, + // nama + models.CustomTextFieldv2Prm{ + Label: "Nama", + Name: "doctorimbuhannama", + Placeholder: "Nama", + Type: "text", + ID: "doctorimbuhannama", + Value: doctorImbuhanNama, + }, + // tanggal lahir + models.CustomTextFieldv2Prm{ + Label: "Tanggal Lahir", + Name: "doctorimbuhantanggallahir", + Placeholder: "Tanggal Lahir", + Type: "date", + ID: "doctorimbuhantanggallahir", + Value: doctorImbuhanTanggalLahir, + }, + // rhesus + models.CustomDropdownv1Prm{ + Label: "Rhesus", + Name: "doctorgolonganbloodrhesus", + ID: "doctorgolonganbloodrhesus", + }, + listItemResultBloodRhesusComponent, + // etnis + models.CustomDropdownv1Prm{ + Label: "Ernis", + Name: "doctorgolonganetnis", + ID: "doctorgolonganetnis", + }, + listItemResultEtnisComponent, + // no hp + models.CustomTextFieldv2Prm{ + Label: "Nomor HP", + Name: "doctorimbuhannohp", + Placeholder: "Nomor HP", + Type: "text", + ID: "doctorimbuhannohp", + Value: doctorImbuhanNoHP, + }, + dialogAddBodyID, dev_mddoctorview.JsHideModalDoctor("")) + return utils.ViewMulti(c, []templ.Component{ + customtoastv2.CustomToastV2Show("Error", err.Error(), "danger"), + newForm}) + + } + logger.Info("ADD DOCTOR", + zap.Any("return", dataDoctorAdd), + zap.String("doctorID", doctorID), + zap.String("doctorTglNow", doctorTglNow), + zap.String("doctorTglLahirEdit", doctorTglLahirEdit), + zap.String("doctorSapaan", doctorSapaan), + zap.String("doctorImbuhanAwal1", doctorImbuhanAwal1), + zap.String("doctorImbuhanAwal2", doctorImbuhanAwal2), + zap.String("doctorJenisKelamin", doctorJenisKelamin), + zap.String("doctorGolonganDarah", doctorGolonganDarah), + zap.String("doctorKewarganegaraan", doctorKewarganegaraan), + zap.String("doctorNomorIdentitas", doctorNomorIdentitas), + zap.String("doctorSpesialis", doctorSpesialis), + zap.String("doctorImbuhanAkhir1", doctorImbuhanAkhir1), + zap.String("doctorImbuhanAkhir2", doctorImbuhanAkhir2), + zap.String("doctorImbuhanTahun", doctorImbuhanTahun), + zap.String("doctorImbuhanBulan", doctorImbuhanBulan), + zap.String("doctorImbuhanHari", doctorImbuhanHari), + zap.String("doctorPendidikanTerakhir", doctorPendidikanTerakhir), + zap.String("doctorIdentitas", doctorIdentitas), + zap.String("doctorImbuhanEmail", doctorImbuhanEmail), + zap.String("doctorImbuhanNama", doctorImbuhanNama), + zap.String("doctorImbuhanTanggalLahir", doctorImbuhanTanggalLahir), + zap.String("doctorGolonganBloodRhesus", doctorGolonganBloodRhesus), + zap.String("doctorGolonganEtnis", doctorGolonganEtnis), + zap.String("doctorImbuhanNoHP", doctorImbuhanNoHP), + ) + //get list user group for table + dataDoctorList, totalPage, err := lh.MdDoctorServices.GetListMdDoctor(search, currPage, 5) + if err != nil { + defer logger.Sync() + logger.Info("ERROR GET DOCTOR RESULT", + zap.Any("error", err), + ) + fmt.Println(dataDoctorList) + return err + } + //table component + tableComponent := dev_mddoctorview.TableDoctor(dataDoctorList, + tableID, + "/dev/md/doctorv2/openedit", + "#"+dialogEditBodyID, + "outerHTML", + "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "/dev/md/doctorv2/opendelete", + "#"+dialogDeleteBodyID, + "outerHTML", + "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + ) + //pagination component + //Pagination + userGroupPaginationComponent := pagination.PaginationV3( + totalPage, + currPage, + "/dev/md/doctorv2/changepage", + paginationID, + "#tableID, #searchID, #"+searchID+", #paginationID, #dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID", + "#"+paginationID, + "outerHTML", "", "true", + dev_mddoctorview.BeforeRequestContentMdDoctor(), + dev_mddoctorview.AfterRequestContentMdDoctor(), + ) + + dataTglNow, err := lh.MdDoctorServices.GetDateNow() + fmt.Println(dataTglNow) + fmt.Println(err) + if err != nil { + defer logger.Sync() + logger.Info("ERROR BREADCRUMB DEV", + zap.Any("error", err), + ) + fmt.Println(dataTglNow) + return err + } + + newForm := dev_mddoctorview.BodyFormDoctor( + models.CustomTextFieldv2Prm{ + Label: "Doctor ID", + Name: "doctorid", + Placeholder: "Doctor ID", + Type: "hidden", + ID: "doctorid", + }, + models.CustomTextFieldv2Prm{ + Label: "Tgl Sekarang", + Name: "doctortglnow", + Placeholder: "Tgl Sekarang", + Type: "hidden", + ID: "doctortglnow", + Value: dataTglNow, + }, + models.CustomTextFieldv2Prm{ + Label: "Tanggal Lahir Edit", + Name: "doctortgllahiredit", + Placeholder: "Tanggal Lahir Edit", + Type: "hidden", + ID: "doctortgllahiredit", + // Value: "2021-01-01", + }, + models.CustomDropdownv1Prm{ + Label: "Sapaan", + Name: "doctorsapaan", + ID: "doctorsapaan", + }, + listItemResultSapaanComponent, + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Awal 1", + Name: "doctorimbuhanawal1", + Placeholder: "Awal 1", + Type: "text", + ID: "doctorimbuhanawal1", + }, + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Awal 2", + Name: "doctorimbuhanawal2", + Placeholder: "Awal 2", + Type: "text", + ID: "doctorimbuhanawal2", + }, + models.CustomDropdownv1Prm{ + Label: "Jenis Kelamin", + Name: "doctorjeniskelamin", + ID: "doctorjeniskelamin", + }, + listItemResultJKComponent, + models.CustomDropdownv1Prm{ + Label: "Golongan Darah", + Name: "doctorgolongandarah", + ID: "doctorgolongandarah", + }, + listItemResultGDComponent, + models.CustomRadioButtonv1Prm{ + Label: "Kewarganegaraan", + Name: "doctorkewarganegaraan", + ID: "doctorkewarganegaraan", + }, + listItemResultKewarganegaraanComponent, + models.CustomTextFieldv2Prm{ + Label: "Nomor Identitas", + Name: "doctornomoridentitas", + Placeholder: "Nomor Identitas", + Type: "text", + ID: "doctornomoridentitas", + }, + models.CustomDropdownv1Prm{ + Label: "Spesialis", + Name: "doctorspesialis", + ID: "doctorspesialis", + }, + listItemResultSpesialisComponent, + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Akhir 1", + Name: "doctorimbuhanakhir1", + Placeholder: "Akhir 1", + Type: "text", + ID: "doctorimbuhanakhir1", + }, + models.CustomTextFieldv2Prm{ + Label: "Imbuhan Akhir 2", + Name: "doctorimbuhanakhir2", + Placeholder: "Akhir 2", + Type: "text", + ID: "doctorimbuhanakhir2", + }, + models.CustomTextFieldv2Prm{ + Label: "Tahun", + Name: "doctorimbuhantahun", + Placeholder: "Tahun", + Type: "text", + ID: "doctorimbuhantahun", + }, + models.CustomTextFieldv2Prm{ + Label: "Bulan", + Name: "doctorimbuhanbulan", + Placeholder: "Bulan", + Type: "text", + ID: "doctorimbuhanbulan", + }, + models.CustomTextFieldv2Prm{ + Label: "Hari", + Name: "doctorimbuhanhari", + Placeholder: "Hari", + Type: "text", + ID: "doctorimbuhanhari", + }, + models.CustomDropdownv1Prm{ + Label: "Pendidikan Terakhir", + Name: "doctorpendidikanterakhir", + ID: "doctorpendidikanterakhir", + }, + listItemResultPendComponent, + models.CustomDropdownv1Prm{ + Label: "Identitas", + Name: "doctoridentitas", + ID: "doctoridentitas", + }, + listItemResultIdentitasComponent, + models.CustomTextFieldv2Prm{ + Label: "Email", + Name: "doctorimbuhanemail", + Placeholder: "Email", + Type: "text", + ID: "doctorimbuhanemail", + }, + models.CustomTextFieldv2Prm{ + Label: "Nama", + Name: "doctorimbuhannama", + Placeholder: "Nama", + Type: "text", + ID: "doctorimbuhannama", + }, + models.CustomTextFieldv2Prm{ + Label: "Tanggal Lahir", + Name: "doctorimbuhantanggallahir", + Placeholder: "Tanggal Lahir", + Type: "date", + ID: "doctorimbuhantanggallahir", + }, + models.CustomDropdownv1Prm{ + Label: "Rhesus", + Name: "doctorgolonganbloodrhesus", + ID: "doctorgolonganbloodrhesus", + }, + listItemResultBloodRhesusComponent, + models.CustomDropdownv1Prm{ + Label: "Ernis", + Name: "doctorgolonganetnis", + ID: "doctorgolonganetnis", + }, + listItemResultEtnisComponent, + models.CustomTextFieldv2Prm{ + Label: "Nomor HP", + Name: "doctorimbuhannohp", + Placeholder: "Nomor HP", + Type: "text", + ID: "doctorimbuhannohp", + }, + dialogAddBodyID, dev_mddoctorview.JsHideModalDoctor("#"+dialogAddID)) + toastSuccess := customtoastv2.CustomToastV2Show("Success", "Success add master doctor "+doctorImbuhanNama, "success") + + return utils.ViewMulti(c, []templ.Component{ + toastSuccess, + tableComponent, + userGroupPaginationComponent, + newForm}) +} diff --git a/handlers/routes.go b/handlers/routes.go index 42ab1c1..02087fa 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -298,4 +298,5 @@ func SetupRoutesDev(app *echo.Echo, appStore db.AppStore) { dev.GET("/md/doctorv2", devMdDChandlers.HandleShowMdDoctorScreen) dev.GET("/md/doctorv2/filter", devMdDChandlers.HandleFilterMdDoctor) dev.GET("/md/doctorv2/changepage", devMdDChandlers.HandleChangePageMdDoctor) + dev.POST("/md/doctorv2/add", devMdDChandlers.HandleAddMdDoctor) } diff --git a/models/doctor.models.go b/models/doctor.models.go index 4b5a5e6..a2ac661 100644 --- a/models/doctor.models.go +++ b/models/doctor.models.go @@ -9,6 +9,7 @@ import ( type DoctorV1 struct { Nomor string `db:"nomor"` M_DoctorID int `db:"M_DoctorID"` + M_DoctorM_TitleID int `db:"M_DoctorM_TitleID"` M_DoctorCode string `db:"M_DoctorCode"` M_DoctorPrefix string `db:"M_DoctorPrefix"` M_DoctorPrefix2 string `db:"M_DoctorPrefix2"` @@ -28,6 +29,8 @@ type DoctorV1 struct { M_DoctorCitizenship string `db:"M_DoctorCitizenship"` M_DoctorEtnicCode string `db:"M_DoctorEtnicCode"` M_DoctorEtnicSystem string `db:"M_DoctorEtnicSystem"` + M_DoctorIdentifierCode string `db:"M_DoctorIdentifierCode"` + M_DoctorIdentifierSystem string `db:"M_DoctorIdentifierSystem"` M_DoctorIdentifierValue string `db:"M_DoctorIdentifierValue"` M_DoctorHp string `db:"M_DoctorHp"` M_DoctorEmail string `db:"M_DoctorEmail"` @@ -47,6 +50,7 @@ type DoctorV1 struct { M_DoctorLastUpdatedUserID string `db:"M_DoctorLastUpdatedUserID"` M_DoctorDeletedUserID string `db:"M_DoctorDeletedUserID"` M_DoctorDeleted string `db:"M_DoctorDeleted"` + M_DoctorIsActive string `db:"M_DoctorIsActive"` } // title @@ -77,7 +81,7 @@ type SpecialistV0 struct { } // hardcode dropdown(jenis kelamin) -type HardCodeDropdownV0 struct { +type HardCodeDropdownJKV0 struct { ID int `json:"ID"` Text string `json:"Text"` } diff --git a/services/dev/md.doctor.services.go b/services/dev/md.doctor.services.go index 754e9c7..6ee2588 100644 --- a/services/dev/md.doctor.services.go +++ b/services/dev/md.doctor.services.go @@ -6,6 +6,7 @@ import ( dbx "cpone/package/database" "fmt" "math" + "strconv" "strings" "go.uber.org/zap" @@ -633,8 +634,8 @@ func (su *ServicesMdDoctor) GetListMdSapaan() ([]models.TitleSapaan, error) { } // jenis kelamin -func (su *ServicesMdDoctor) GetJenisKelamin() ([]models.HardCodeDropdownV0, error) { - data := []models.HardCodeDropdownV0{ +func (su *ServicesMdDoctor) GetJenisKelamin() ([]models.HardCodeDropdownJKV0, error) { + data := []models.HardCodeDropdownJKV0{ { ID: 1, Text: "male", @@ -758,6 +759,7 @@ func (su *ServicesMdDoctor) GetListMdDoctor(search string, currentPage int, rowP SELECT ROW_NUMBER() OVER () AS nomor, d.M_DoctorID, + d.M_DoctorM_TitleID, ifnull(d.M_DoctorCode,'') as M_DoctorCode, ifnull(d.M_DoctorPrefix,'') as M_DoctorPrefix, ifnull(d.M_DoctorPrefix2,'') as M_DoctorPrefix2, @@ -787,12 +789,14 @@ func (su *ServicesMdDoctor) GetListMdDoctor(search string, currentPage int, rowP d.M_DoctorCitizenship, d.M_DoctorEtnicCode, d.M_DoctorEtnicSystem, + d.M_DoctorIdentifierCode, + d.M_DoctorIdentifierSystem, d.M_DoctorIdentifierValue, d.M_DoctorHp, d.M_DoctorEmail, d.M_DoctorM_SpecialistID, - spesialis.M_SpecialistID, - spesialis.M_SpecialistName, + IFNULL(spesialis.M_SpecialistID, 0) as M_SpecialistID, + IFNULL(spesialis.M_SpecialistName, '') as M_SpecialistName, IFNULL(d.M_DoctorAddress, '') as M_DoctorAddress, IFNULL(title.M_TitleName, '') as M_TitleName, d.M_DoctorCreated, @@ -800,7 +804,8 @@ func (su *ServicesMdDoctor) GetListMdDoctor(search string, currentPage int, rowP d.M_DoctorLastUpdated, d.M_DoctorLastUpdatedUserID, d.M_DoctorDeletedUserID, - d.M_DoctorDeleted + d.M_DoctorDeleted, + d.M_DoctorIsActive FROM m_doctor as d -- join m_title LEFT JOIN m_title as title @@ -836,3 +841,396 @@ func (su *ServicesMdDoctor) GetListMdDoctor(search string, currentPage int, rowP return doctorList, totalPage, nil } + +// Get Doctor Code +func (su *ServicesMdDoctor) GetMdDoctorCode(tipe string) (string, error) { + var doctorCode string + + logger, _ := zap.NewProduction() + defer logger.Sync() + + query := ` + select fn_numbering(?) as doctorCode + ` + + logger.Info("QUERY DOCTOR CODE", + zap.String("query search", query), + ) + + if err := dbx.Handlex.Get(&doctorCode, query, + tipe, + ); err != nil { + return "", fmt.Errorf("error querying database: %v", err) + } + + return doctorCode, nil +} + +// GET BY ID +func (ug *ServicesMdDoctor) GetMdDoctorByID(id string) (models.DoctorV1, error) { + logger, _ := zap.NewProduction() + + var data models.DoctorV1 + err := dbx.Handlex.Get(&data, `SELECT + ROW_NUMBER() OVER () AS nomor, + d.M_DoctorID, + d.M_DoctorM_TitleID, + ifnull(d.M_DoctorCode,'') as M_DoctorCode, + ifnull(d.M_DoctorPrefix,'') as M_DoctorPrefix, + ifnull(d.M_DoctorPrefix2,'') as M_DoctorPrefix2, + CONCAT( + IFNULL(d.M_DoctorPrefix, ''), + ' ', + IFNULL(d.M_DoctorPrefix2, ''), + ' ', + IFNULL(d.M_DoctorName, ''), + ' ', + IFNULL(d.M_DoctorSuffix, ''), + ' ', + IFNULL(d.M_DoctorSuffix2, '') + ) as M_DoctorName, + ifnull(d.M_DoctorSuffix,'') as M_DoctorSuffix, + ifnull(d.M_DoctorSuffix2,'') as M_DoctorSuffix2, + d.M_DoctorGender, + d.M_DoctorDOB, + d.M_DoctorReligionCode, + d.M_DoctorReligionSystem, + d.M_DoctorBloodTypeCode, + d.M_DoctorBloodTypeSystem, + d.M_DoctorBloodRhCode, + d.M_DoctorBloodRhSystem, + d.M_DoctorEducationCode, + d.M_DoctorEducationSystem, + d.M_DoctorCitizenship, + d.M_DoctorEtnicCode, + d.M_DoctorEtnicSystem, + d.M_DoctorIdentifierCode, + d.M_DoctorIdentifierSystem, + d.M_DoctorIdentifierValue, + d.M_DoctorHp, + d.M_DoctorEmail, + d.M_DoctorM_SpecialistID, + IFNULL(spesialis.M_SpecialistID, 0) as M_SpecialistID, + IFNULL(spesialis.M_SpecialistName, '') as M_SpecialistName, + IFNULL(d.M_DoctorAddress, '') as M_DoctorAddress, + IFNULL(title.M_TitleName, '') as M_TitleName, + d.M_DoctorCreated, + d.M_DoctorCreatedUserID, + d.M_DoctorLastUpdated, + d.M_DoctorLastUpdatedUserID, + d.M_DoctorDeletedUserID, + d.M_DoctorDeleted, + d.M_DoctorIsActive + FROM m_doctor as d + -- join m_title + LEFT JOIN m_title as title + ON d.M_DoctorM_TitleID = title.M_TitleID + AND title.M_TitleIsActive = 'Y' + -- join m_specialist + LEFT JOIN m_specialist as spesialis + ON d.M_DoctorM_SpecialistID = spesialis.M_SpecialistID + AND spesialis.M_SpecialistIsActive = 'Y' + WHERE d.M_DoctorIsActive = 'Y' AND + d.M_DoctorID = ?`, id) + + if err != nil { + defer logger.Sync() + logger.Error("Error get data gr by id vs", + zap.String("ID", id), + zap.Error(err), + ) + return data, fmt.Errorf("QUERY_FAILED") + } + return data, nil +} + +// PROSES ADD DOCTOR +func (su *ServicesMdDoctor) AddMdDoctor(inp models.DoctorV1) (models.DoctorV1, error) { + logger, _ := zap.NewProduction() + var data models.DoctorV1 + var datacek []models.DoctorV1 + + defer logger.Sync() + logger.Error("VALUE YANG DI ADD", + zap.Any("INPUTAN VALUE", inp), + ) + + prm := "%" + strings.TrimSpace(inp.M_DoctorName) + "%" + qryCek := `SELECT M_DoctorName + FROM m_doctor + WHERE M_DoctorName LIKE ? + AND M_DoctorIsActive = 'Y'` + err := dbx.Handlex.Select(&datacek, qryCek, prm) + + if err != nil { + defer logger.Sync() + logger.Error("Error cek data by doctorname", + zap.String("doctorname", inp.M_DoctorName), + zap.Any("datacek", datacek), + ) + return data, fmt.Errorf("QUERY_FAILED") + } + if len(datacek) > 0 { + defer logger.Sync() + logger.Error("Doctor Name already taken by another data", + zap.String("doctorname", inp.M_DoctorName), + ) + return data, fmt.Errorf("doctor Name sudah dipakai") + } + + // VARIABLE START + M_DoctorM_TitleID := 0 + M_DoctorCode := "" + M_DoctorPrefix := "" + M_DoctorPrefix2 := "" + M_DoctorName := inp.M_DoctorName + M_DoctorSuffix := "" + M_DoctorSuffix2 := "" + M_DoctorGender := inp.M_DoctorGender + M_DoctorDOB := "0000-00-00 00:00:00" + M_DoctorReligionCode := "" + M_DoctorReligionSystem := "" + M_DoctorBloodTypeCode := "" + M_DoctorBloodTypeSystem := "" + M_DoctorBloodRhCode := "" + M_DoctorBloodRhSystem := "" + M_DoctorEducationCode := "" + M_DoctorEducationSystem := "" + M_DoctorCitizenship := inp.M_DoctorCitizenship + M_DoctorEtnicCode := "" + M_DoctorEtnicSystem := "" + M_DoctorIdentifierCode := "" + M_DoctorIdentifierSystem := "" + M_DoctorIdentifierValue := inp.M_DoctorIdentifierValue + M_DoctorHp := "" + M_DoctorEmail := "" + M_DoctorS_SpecialistID := 0 + M_DoctorAddress := "" + M_DoctorAddressRegionalCd := 0 + M_DoctorAddressCity := "" + M_DoctorAddressDistrict := "" + M_DoctorAddressState := "" + M_DoctorAddressCountry := "" + // VARIABLE END + + // CHECK PARAMS + if inp.M_DoctorM_TitleID != 0 { + M_DoctorM_TitleID = inp.M_DoctorM_TitleID + } + + if inp.M_DoctorCode != "" { + M_DoctorCode = inp.M_DoctorCode + } + + if inp.M_DoctorPrefix != "" { + M_DoctorPrefix = inp.M_DoctorPrefix + } + + if inp.M_DoctorPrefix2 != "" { + M_DoctorPrefix2 = inp.M_DoctorPrefix2 + } + + if inp.M_DoctorSuffix != "" { + M_DoctorSuffix = inp.M_DoctorSuffix + } + + if inp.M_DoctorSuffix2 != "" { + M_DoctorSuffix2 = inp.M_DoctorSuffix2 + } + + if inp.M_DoctorDOB != "" { + M_DoctorDOB = inp.M_DoctorDOB + } + + if inp.M_DoctorReligionCode != "default" { + M_DoctorReligionCode = inp.M_DoctorReligionCode + M_DoctorReligionSystem = inp.M_DoctorReligionSystem + } + + if inp.M_DoctorBloodTypeCode != "default" { + M_DoctorBloodTypeCode = inp.M_DoctorBloodTypeCode + M_DoctorBloodTypeSystem = inp.M_DoctorBloodTypeSystem + } + + if inp.M_DoctorBloodRhCode != "default" { + M_DoctorBloodRhCode = inp.M_DoctorBloodRhCode + M_DoctorBloodRhSystem = inp.M_DoctorBloodRhSystem + } + + if inp.M_DoctorEducationCode != "default" { + M_DoctorEducationCode = inp.M_DoctorEducationCode + M_DoctorEducationSystem = inp.M_DoctorEducationSystem + } + + if inp.M_DoctorEtnicCode != "default" { + M_DoctorEtnicCode = inp.M_DoctorEtnicCode + M_DoctorEtnicSystem = inp.M_DoctorEtnicSystem + } + + if inp.M_DoctorIdentifierCode != "default" { + M_DoctorIdentifierCode = inp.M_DoctorIdentifierCode + M_DoctorIdentifierSystem = inp.M_DoctorIdentifierSystem + } + + if inp.M_DoctorHp != "" { + M_DoctorHp = inp.M_DoctorHp + } + + if inp.M_DoctorEmail != "" { + M_DoctorEmail = inp.M_DoctorEmail + } + + if inp.M_DoctorM_SpecialistID != "0" { + M_DoctorS_SpecialistID, err = strconv.Atoi(inp.M_DoctorM_SpecialistID) + if err != nil { + defer logger.Sync() + logger.Error("Error CONVERT DOCTOR SPECIALIS", + zap.Any("M_SpecialistID", M_DoctorS_SpecialistID), + ) + return data, fmt.Errorf("error CONVERT DOCTOR SPECIALIS") + } + } + + if inp.M_DoctorAddressRegionalCd != 0 { + M_DoctorAddressRegionalCd = inp.M_DoctorAddressRegionalCd + M_DoctorAddress = inp.M_DoctorAddress + M_DoctorAddressCity = inp.M_DoctorAddressCity + M_DoctorAddressDistrict = inp.M_DoctorAddressDistrict + M_DoctorAddressState = inp.M_DoctorAddressState + M_DoctorAddressCountry = inp.M_DoctorAddressCountry + } + + // CHECK PARAMS + + query := `INSERT INTO m_doctor + ( + M_DoctorM_TitleID, + M_DoctorCode, + M_DoctorPrefix, + M_DoctorPrefix2, + M_DoctorName, + M_DoctorSuffix, + M_DoctorSuffix2, + M_DoctorGender, + M_DoctorDOB, + M_DoctorReligionCode, + M_DoctorReligionSystem, + M_DoctorBloodTypeCode, + M_DoctorBloodTypeSystem, + M_DoctorBloodRhCode, + M_DoctorBloodRhSystem, + M_DoctorEducationCode, + M_DoctorEducationSystem, + M_DoctorCitizenship, + M_DoctorEtnicCode, + M_DoctorEtnicSystem, + M_DoctorIdentifierCode, + M_DoctorIdentifierSystem, + M_DoctorIdentifierValue, + M_DoctorHp, + M_DoctorEmail, + M_DoctorM_SpecialistID, + M_DoctorAddress, + M_DoctorAddressRegionalCd, + M_DoctorAddressCity, + M_DoctorAddressDistrict, + M_DoctorAddressState, + M_DoctorAddressCountry, + M_DoctorIsActive, + M_DoctorCreatedUserID + ) + VALUES + ( + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ? + )` + + rst := dbx.Handlex.MustExec(query, + M_DoctorM_TitleID, + M_DoctorCode, + M_DoctorPrefix, + M_DoctorPrefix2, + M_DoctorName, + M_DoctorSuffix, + M_DoctorSuffix2, + M_DoctorGender, + M_DoctorDOB, + M_DoctorReligionCode, + M_DoctorReligionSystem, + M_DoctorBloodTypeCode, + M_DoctorBloodTypeSystem, + M_DoctorBloodRhCode, + M_DoctorBloodRhSystem, + M_DoctorEducationCode, + M_DoctorEducationSystem, + M_DoctorCitizenship, + M_DoctorEtnicCode, + M_DoctorEtnicSystem, + M_DoctorIdentifierCode, + M_DoctorIdentifierSystem, + M_DoctorIdentifierValue, + M_DoctorHp, + M_DoctorEmail, + M_DoctorS_SpecialistID, + M_DoctorAddress, + M_DoctorAddressRegionalCd, + M_DoctorAddressCity, + M_DoctorAddressDistrict, + M_DoctorAddressState, + M_DoctorAddressCountry, + "Y", + "1", + ) + insertedID, err := rst.LastInsertId() + if err != nil { + defer logger.Sync() + logger.Error("Error Insert doctor", + zap.Any("object doctoraddv1", inp), + ) + return data, fmt.Errorf("QUERY_FAILED LastInsertId") + } + s := strconv.Itoa(int(insertedID)) + data, err = su.GetMdDoctorByID(s) + if err != nil { + defer logger.Sync() + logger.Error("Error get doctor by id", + // zap.Any("object doctoraddv1", inp), + zap.Any("ERROR MSG", err.Error()), + zap.Any("id last insert", s), + ) + return data, fmt.Errorf("QUERY_FAILED GET DATA AFTER INSERT") + } + return data, nil +} diff --git a/views/dev/mddoctor/mddoctor.templ b/views/dev/mddoctor/mddoctor.templ index 148941d..36e4772 100644 --- a/views/dev/mddoctor/mddoctor.templ +++ b/views/dev/mddoctor/mddoctor.templ @@ -104,11 +104,11 @@ templ MdDoctorScreen( } // for item dropdown sapaan -templ ItemDropdownSapaan(dataDropdown []models.TitleSapaan, selectedId int, defaultValueLabel string) { +templ ItemDropdownSapaan(dataDropdown []models.TitleSapaan, selectedId int) { if len(dataDropdown) == 0 { } else { - + // for _, v := range dataDropdown { if (selectedId == v.M_TitleID) { @@ -124,11 +124,11 @@ func ConcatValueTerminology(code string, codeSystem string) string { } // for item dropdown jenis kelamin -templ ItemDropdownJenisKelamin(dataDropdown []models.HardCodeDropdownV0, selectedId int, defaultValueLabel string) { +templ ItemDropdownJenisKelamin(dataDropdown []models.HardCodeDropdownJKV0, selectedId int) { if len(dataDropdown) == 0 { } else { - + // for _, v := range dataDropdown { if (selectedId == v.ID) { @@ -140,11 +140,11 @@ templ ItemDropdownJenisKelamin(dataDropdown []models.HardCodeDropdownV0, selecte } // for item dropdown terminology -templ ItemDropdownTerminology(dataDropdown []models.TerminologyV0, selectedItem models.TerminologySelectedV0, defaultValueLabel string) { +templ ItemDropdownTerminology(dataDropdown []models.TerminologyV0, selectedItem models.TerminologySelectedV0) { if len(dataDropdown) == 0 { } else { - + // for _, v := range dataDropdown { if (selectedItem.CodeSystem == v.CodeSystem) && (selectedItem.AttributePath == v.AttributePath) && (selectedItem.Code == v.Code) { @@ -161,7 +161,7 @@ templ ItemRadioButtonKewarganegaraan(data []models.HardCodeRadioButtonV0, select for _, v := range data { if (selectedRadioButton == v.ID) { } else { @@ -175,11 +175,11 @@ templ ItemRadioButtonKewarganegaraan(data []models.HardCodeRadioButtonV0, select } // for item dropdown spesialis -templ ItemDropdownSpesialis(dataDropdown []models.SpecialistV0, selectedId int, defaultValueLabel string) { +templ ItemDropdownSpesialis(dataDropdown []models.SpecialistV0, selectedId int) { if len(dataDropdown) == 0 { } else { - + // for _, v := range dataDropdown { if (selectedId == v.M_SpecialistID) { diff --git a/views/dev/mddoctor/mddoctor_templ.go b/views/dev/mddoctor/mddoctor_templ.go index a3bf93d..4e9017f 100644 --- a/views/dev/mddoctor/mddoctor_templ.go +++ b/views/dev/mddoctor/mddoctor_templ.go @@ -191,7 +191,7 @@ func MdDoctorScreen( } // for item dropdown sapaan -func ItemDropdownSapaan(dataDropdown []models.TitleSapaan, selectedId int, defaultValueLabel string) templ.Component { +func ItemDropdownSapaan(dataDropdown []models.TitleSapaan, selectedId int) templ.Component { return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) if !templ_7745c5c3_IsBuffer { @@ -210,35 +210,18 @@ func ItemDropdownSapaan(dataDropdown []models.TitleSapaan, selectedId int, defau return templ_7745c5c3_Err } } else { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } for _, v := range dataDropdown { if selectedId == v.M_TitleID { _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } for _, v := range dataDropdown { if selectedId == v.ID { _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } for _, v := range dataDropdown { if (selectedItem.CodeSystem == v.CodeSystem) && (selectedItem.AttributePath == v.AttributePath) && (selectedItem.Code == v.Code) { _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("