Files
api-poliklinik/internal/server/routes.go
2025-07-01 12:42:28 +07:00

205 lines
7.7 KiB
Go

package server
import (
MasterHandler "api-poliklinik/pkg/handlers/Master"
patientHandler "api-poliklinik/pkg/handlers/MongoHandler/Patient"
patientRelatedHandler "api-poliklinik/pkg/handlers/MongoHandler/PatientRelated"
AccountHandler "api-poliklinik/pkg/handlers/MongoHandler/account"
ConditionHandler "api-poliklinik/pkg/handlers/MongoHandler/condition"
CoverageHandler "api-poliklinik/pkg/handlers/MongoHandler/coverage"
"api-poliklinik/pkg/handlers/MongoHandler/encounter"
EpisodeHandler "api-poliklinik/pkg/handlers/MongoHandler/episodeofcare"
personHandler "api-poliklinik/pkg/handlers/MongoHandler/person"
practitionerHandler "api-poliklinik/pkg/handlers/MongoHandler/practitioner"
datarelatedpersonHandler "api-poliklinik/pkg/handlers/MongoHandler/relatedperson"
datapoliklinikHandler "api-poliklinik/pkg/handlers/Poliklinik"
dataAlamatHandler "api-poliklinik/pkg/handlers/address"
AppointmentHandler "api-poliklinik/pkg/handlers/appointment"
LocationHandler "api-poliklinik/pkg/handlers/location"
MigrasiHandler "api-poliklinik/pkg/handlers/migrasi"
MigrasiAddress "api-poliklinik/pkg/handlers/migrasi/address"
MigrasiExtension "api-poliklinik/pkg/handlers/migrasi/extension"
MigrasiLocation "api-poliklinik/pkg/handlers/migrasi/location"
MigrasiIcd "api-poliklinik/pkg/handlers/migrasi/medis"
MigarasiDokter "api-poliklinik/pkg/handlers/migrasi/practitioner"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"net/http"
)
func (s *Server) RegisterRoutes() http.Handler {
r := gin.Default()
r.Use(cors.New(cors.Config{
AllowOrigins: []string{"*"}, // or specific domains like "http://example.com"
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Origin", "Content-Type"},
AllowCredentials: true,
}))
r.GET("/", s.HelloWorldHandler)
r.GET("/health", s.healthHandler)
v1 := r.Group("/api")
migrasi := v1.Group("/migrasi")
{
//migrasi.POST("/migrate/practitioners", MigrasiPractitioner.MigratePractitionerToFHIR)
migrasi.POST("/migrate/pasien", MigrasiHandler.MigratePasienToFHIR)
migrasi.POST("/migrate/provinsi", MigrasiAddress.Migrasiprovinsi)
migrasi.POST("/migrate/kota", MigrasiAddress.Migrasikota)
migrasi.POST("/migrate/kecamatan", MigrasiAddress.Migrasikecamatan)
migrasi.POST("/migrate/kelurahan", MigrasiAddress.Migrasikelurahan)
migrasi.POST("/migrate/bahasa", MigrasiExtension.Migrasibahasa)
migrasi.POST("/migrate/disabilitas", MigrasiExtension.Migrasidisbilitas)
migrasi.POST("/migrate/pendidikan", MigrasiExtension.Migrasipendidikan)
migrasi.POST("/migrate/pekerjaan", MigrasiExtension.Migrasipekerjaan)
migrasi.POST("/migrate/pernikahan", MigrasiExtension.Migrasipernikahan)
migrasi.POST("/migrate/agama", MigrasiExtension.Migrasiagama)
migrasi.POST("/migrate/suku", MigrasiExtension.Migrasisuku)
migrasi.POST("/migrate/location", MigrasiLocation.Migrasilokasi)
migrasi.POST("/migrate/icd", MigrasiIcd.Migrasiicd)
migrasi.POST("/migrate/smf", MigrasiIcd.Migrasismf)
migrasi.POST("/migrate/dokter", MigarasiDokter.Migratepractitioner)
}
Poliklinik := v1.Group("/poliklinik")
{
Poliklinik.GET("/getdata/statuspelayanan/:statuspelayanan", datapoliklinikHandler.GetDataPoliklinik)
}
Alamat := v1.Group("/Alamat")
{
Alamat.GET("/getdata", dataAlamatHandler.GetDataAlamat)
//Alamat.GET("/getprovinsi", MigrasiAddress.GetProvinsi)
}
Relasi := v1.Group("/relasi")
{
Relasi.POST("/insertpatientrelatedperson", patientRelatedHandler.InsertPatientRelated)
Relasi.GET("/getdatapatientrelated", patientRelatedHandler.GetAllPatientdanRelated)
}
condition := v1.Group("/condition")
{
condition.GET("/get", ConditionHandler.GetCondition)
}
account := v1.Group("/account")
{
account.GET("/get", AccountHandler.GetAccount)
}
cover := v1.Group("/coverage")
{
cover.GET("/get", CoverageHandler.GetCover)
}
patient := v1.Group("/patient")
{
patient.POST("/insertpatient", patientHandler.InsertPatient)
patient.GET("/getallpatient", patientHandler.GetAllPatient)
patient.PUT("/updatepatient", patientHandler.UpdatePatient)
patient.POST("/deletepatient", patientHandler.DeletePatient)
patient.GET("/getdata/display/:display/value/:value", patientHandler.GetDataBY)
patient.GET("id/:id", patientHandler.GetpasienByID)
//patient.POST("/getdataby", patientHandler.GetDataIdentifier)
}
Relatedperson := v1.Group("/relatedperson")
{
Relatedperson.GET("/getdatarelatedperson", datarelatedpersonHandler.GetDataRelatedPerson)
Relatedperson.POST("/insertrelatedperson", datarelatedpersonHandler.InsertRelatedPerson)
Relatedperson.POST("/deleterelatedperson", datarelatedpersonHandler.DeleteRelatedPersonHand)
}
Person := v1.Group("/person")
{
Person.GET("/getdataperson", personHandler.GetDataPerson)
Person.POST("/insertperson", personHandler.InsertPerson)
//Person.POST("/deleteperson", personHandler.DeletePersonHand)
}
Practitionermongo := v1.Group("/practitioner")
{
Practitionermongo.GET("/getdatapractitioner", practitionerHandler.GetDataPractitioner)
Practitionermongo.GET("/id/:id", practitionerHandler.GetPractitionerbyID)
Practitionermongo.GET("/getdata/display/:display/value/:value", practitionerHandler.Getdatadokter)
//Practitionermongo.POST("/insertpractitioner", personHandler.InsertPerson)
//Practitionermongo.POST("/deletepractitioner", personHandler.DeletePersonHand)
}
Organization := v1.Group("/organization")
{
Organization.GET("/getdataorganization", personHandler.GetDataPerson)
//Organization.POST("/insertorganization", personHandler.Inse rtPerson)
//Organization.POST("/deleteorganization", personHandler.DeletePersonHand)
}
Location := v1.Group("/location")
{
Location.GET("/getdatalocation", LocationHandler.Getlocation)
Location.GET("/subsistem/:subsistem", LocationHandler.Getlocationbysubs)
//Location.POST("/insertlocation", personHandler.Inse rtPerson)
//Location.POST("/deletelocation", personHandler.DeletePersonHand)
}
Encounter := v1.Group("/encounter")
{
Encounter.GET("/getdataencounter", encounter.Getencounter)
Encounter.POST("/insertencounter", encounter.InsertEncounter)
}
Appointment := v1.Group("/appointment")
{
Appointment.GET("/getdataappointment", AppointmentHandler.Getappointment)
Appointment.POST("/insertappointment", AppointmentHandler.Insertappointment)
}
Episodeofcare := v1.Group("/episodeofcare")
{
Episodeofcare.GET("/getdataepisodeofcare", EpisodeHandler.Getepisode)
Episodeofcare.POST("/insertepisodeofcare", EpisodeHandler.InsertEpisode)
}
Master := v1.Group("/master")
{
Master.GET("/getdataprovinsi", MasterHandler.GetProvinsi)
Master.GET("/getdatakota", MasterHandler.GetKota)
Master.GET("/getdatakecamatan", MasterHandler.GetKecamatan)
Master.GET("/getdatakelurahan", MasterHandler.GetKelurahan)
Master.GET("/kelurahan/search", MasterHandler.SearchKelurahan)
Master.GET("/address/kelurahan/id/:id", MasterHandler.GetHierarchyByKelurahan)
Master.GET("/hierarchy/provinsi/:id", MasterHandler.GetHierarchyFromProvinsi)
Master.GET("/getdatasmf", MasterHandler.GetSMF)
Master.GET("/getdataicd", MasterHandler.GetICD)
}
Extension := v1.Group("/extension")
{
Extension.GET("/getcommunication", MasterHandler.GetCommunication)
Extension.GET("/getdisability", MasterHandler.Getdisability)
Extension.GET("/geteducation", MasterHandler.Geteducation)
Extension.GET("/getjob", MasterHandler.Getjob)
Extension.GET("/getmartial", MasterHandler.Getmartial)
Extension.GET("/getreligion", MasterHandler.Getreligion)
Extension.GET("/gettribe", MasterHandler.Gettribe)
}
return r
}
func (s *Server) HelloWorldHandler(c *gin.Context) {
resp := make(map[string]string)
resp["message"] = "Hello World"
c.JSON(http.StatusOK, resp)
}
func (s *Server) healthHandler(c *gin.Context) {
c.JSON(http.StatusOK, s.db.Health())
}