From fd3046308234dada189b0dd46171e61618a67abe Mon Sep 17 00:00:00 2001 From: ahdan15 Date: Thu, 15 May 2025 13:45:45 +0700 Subject: [PATCH] lengkap belum account --- internal/server/routes.go | 26 +- pkg/database/mongo/appointment.go | 26 +- pkg/database/mongo/encounter.go | 35 + pkg/database/mongo/episodeofcare.go | 36 + pkg/database/mongo/extension.go | 22 + pkg/database/mongo/patient.go | 20 +- pkg/database/mongo/practitioner.go | 27 + pkg/database/mongo/provinsi.go | 39 + pkg/database/satu_data/extension.go | 36 + pkg/handlers/Master/master.go | 55 + pkg/handlers/MongoHandler/Patient/patient.go | 4 +- .../MongoHandler/encounter/encounter.go | 57 ++ .../episodeofcare/episodeofcare.go | 57 ++ .../MongoHandler/practitioner/practitioner.go | 28 + pkg/handlers/appointment/appointment.go | 33 +- pkg/handlers/migrasi/location/location.go | 10 +- pkg/handlers/migrasi/medis/icd.go | 232 +++++ pkg/handlers/migrasi/medis/smf.go | 1 + pkg/handlers/migrasi/migrasi.go | 11 +- .../migrasi/practitioner/practitioner.go | 949 ++++++++++-------- pkg/models/mongo/appointment/appointment.go | 84 +- pkg/models/mongo/encounter/encounter.go | 114 ++- .../mongo/episodeofcare/episodeofcare.go | 36 +- .../master/masteraddress/masteraddress.go | 24 + pkg/models/simrs/icd.go | 2 +- pkg/models/simrs/practitioner.go | 5 +- pkg/models/simrs/smf.go | 8 + pkg/models/struct/fhir.go | 233 +++-- 28 files changed, 1571 insertions(+), 639 deletions(-) create mode 100644 pkg/database/mongo/encounter.go create mode 100644 pkg/database/mongo/episodeofcare.go create mode 100644 pkg/handlers/MongoHandler/encounter/encounter.go create mode 100644 pkg/handlers/MongoHandler/episodeofcare/episodeofcare.go create mode 100644 pkg/handlers/migrasi/medis/icd.go create mode 100644 pkg/handlers/migrasi/medis/smf.go create mode 100644 pkg/models/simrs/smf.go diff --git a/internal/server/routes.go b/internal/server/routes.go index 976c84c..5ebc08e 100644 --- a/internal/server/routes.go +++ b/internal/server/routes.go @@ -4,6 +4,8 @@ import ( MasterHandler "api-poliklinik/pkg/handlers/Master" patientHandler "api-poliklinik/pkg/handlers/MongoHandler/Patient" patientRelatedHandler "api-poliklinik/pkg/handlers/MongoHandler/PatientRelated" + "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" @@ -15,6 +17,8 @@ import ( 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" @@ -51,6 +55,9 @@ func (s *Server) RegisterRoutes() http.Handler { 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") @@ -99,6 +106,7 @@ func (s *Server) RegisterRoutes() http.Handler { Practitionermongo := v1.Group("/practitioner") { Practitionermongo.GET("/getdatapractitioner", practitionerHandler.GetDataPractitioner) + Practitionermongo.GET("/getdata/display/:display/value/:value", practitionerHandler.Getdatadokter) //Practitionermongo.POST("/insertpractitioner", personHandler.InsertPerson) //Practitionermongo.POST("/deletepractitioner", personHandler.DeletePersonHand) } @@ -117,11 +125,21 @@ func (s *Server) RegisterRoutes() http.Handler { //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) - //Location.POST("/insertlocation", personHandler.Inse rtPerson) - //Location.POST("/deletelocation", personHandler.DeletePersonHand) + Appointment.POST("/insertappointment", AppointmentHandler.Insertappointment) + } + + Episodeofcare := v1.Group("/episodeofcare") + { + Episodeofcare.GET("/getdataepisodeofcare", EpisodeHandler.Getepisode) + Episodeofcare.POST("/insertepisodeofcare", EpisodeHandler.InsertEpisode) } Master := v1.Group("/master") @@ -134,6 +152,10 @@ func (s *Server) RegisterRoutes() http.Handler { 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") { diff --git a/pkg/database/mongo/appointment.go b/pkg/database/mongo/appointment.go index 4ed86a2..a3e1685 100644 --- a/pkg/database/mongo/appointment.go +++ b/pkg/database/mongo/appointment.go @@ -4,6 +4,7 @@ import ( "api-poliklinik/pkg/models/mongo/appointment" "context" "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" "log" "time" ) @@ -11,7 +12,7 @@ import ( func (s *DatabaseService) Getappointment() ([]*appointment.Appointment, error) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - dataappointment, err := s.DBMongo.Collection("location").Find(ctx, bson.D{}) + dataappointment, err := s.DBMongo.Collection("appointment").Find(ctx, bson.D{}) if err != nil { log.Println(err) } @@ -23,3 +24,26 @@ func (s *DatabaseService) Getappointment() ([]*appointment.Appointment, error) { } return appointment, nil } + +func (s *DatabaseService) InsertApointmongo(req *appointment.Appointment) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + // Jika ID belum diinisialisasi, set ID baru + if req.ID.IsZero() { + req.ID = primitive.NewObjectID() + } + + result, err := s.DBMongo.Collection("appointment").InsertOne(ctx, req) + if err != nil { + log.Println(err) + return err + } + + // Mengambil ID yang dihasilkan dan memasukkannya kembali ke struct + if oid, ok := result.InsertedID.(primitive.ObjectID); ok { + req.ID = oid + } + + return nil +} diff --git a/pkg/database/mongo/encounter.go b/pkg/database/mongo/encounter.go new file mode 100644 index 0000000..164a823 --- /dev/null +++ b/pkg/database/mongo/encounter.go @@ -0,0 +1,35 @@ +package mongo + +import ( + "api-poliklinik/pkg/models/mongo/encounter" + "context" + "go.mongodb.org/mongo-driver/bson" + "log" + "time" +) + +func (s *DatabaseService) Getencounter() ([]*encounter.Encounter, error) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + dataencounter, err := s.DBMongo.Collection("encounter").Find(ctx, bson.D{}) + if err != nil { + log.Println(err) + } + var encounter []*encounter.Encounter + err = dataencounter.All(ctx, &encounter) + if err != nil { + log.Println(err) + return nil, err + } + return encounter, nil +} +func (s *DatabaseService) InsertEncounter(req *encounter.Encounter) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + _, err := s.DBMongo.Collection("encounter").InsertOne(ctx, req) + if err != nil { + log.Println(err) + return err + } + return nil +} diff --git a/pkg/database/mongo/episodeofcare.go b/pkg/database/mongo/episodeofcare.go new file mode 100644 index 0000000..47439b3 --- /dev/null +++ b/pkg/database/mongo/episodeofcare.go @@ -0,0 +1,36 @@ +package mongo + +import ( + "api-poliklinik/pkg/models/mongo/episodeofcare" + "context" + "go.mongodb.org/mongo-driver/bson" + "log" + "time" +) + +func (s *DatabaseService) Getepisode() ([]*episodeofcare.EpisodeOfCare, error) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + dataepisode, err := s.DBMongo.Collection("episodeofcare").Find(ctx, bson.D{}) + if err != nil { + log.Println(err) + } + var episode []*episodeofcare.EpisodeOfCare + err = dataepisode.All(ctx, &episode) + if err != nil { + log.Println(err) + return nil, err + } + return episode, nil +} + +func (s *DatabaseService) InsertEpisode(req *episodeofcare.EpisodeOfCare) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + _, err := s.DBMongo.Collection("episodeofcare").InsertOne(ctx, req) + if err != nil { + log.Println(err) + return err + } + return nil +} diff --git a/pkg/database/mongo/extension.go b/pkg/database/mongo/extension.go index a7815f6..eece3ef 100644 --- a/pkg/database/mongo/extension.go +++ b/pkg/database/mongo/extension.go @@ -196,3 +196,25 @@ func (s *DatabaseService) Getsuku() ([]*Mongomaster.Tribe, error) { } return suku, nil } + +func (s *DatabaseService) Inserticd(req Mongomaster.Icdmongo) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + _, err := s.DBMongo.Collection("icd").InsertOne(ctx, req) + if err != nil { + log.Println(err) + return err + } + return nil +} + +func (s *DatabaseService) InsertSMF(req Mongomaster.Smfmongo) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + _, err := s.DBMongo.Collection("smf").InsertOne(ctx, req) + if err != nil { + log.Println(err) + return err + } + return nil +} diff --git a/pkg/database/mongo/patient.go b/pkg/database/mongo/patient.go index 8a30dd0..0567933 100644 --- a/pkg/database/mongo/patient.go +++ b/pkg/database/mongo/patient.go @@ -48,11 +48,23 @@ func (s *DatabaseService) InsertPatient(req patient.Patient) error { func (s *DatabaseService) InsertPatientmongo(req *patient.Patient) error { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - _, err := s.DBMongo.Collection("patient").InsertOne(ctx, req) + + // Jika ID belum diinisialisasi, set ID baru + if req.ID.IsZero() { + req.ID = primitive.NewObjectID() + } + + result, err := s.DBMongo.Collection("patient").InsertOne(ctx, req) if err != nil { log.Println(err) return err } + + // Mengambil ID yang dihasilkan dan memasukkannya kembali ke struct + if oid, ok := result.InsertedID.(primitive.ObjectID); ok { + req.ID = oid + } + return nil } @@ -69,7 +81,7 @@ func (s *DatabaseService) GetPatientByIdentifier(display string, value string) ( }, } - cursor, err := s.DBMongo.Collection("patientbaru").Find(ctx, filter) + cursor, err := s.DBMongo.Collection("patient").Find(ctx, filter) if err != nil { log.Println(err) return nil, err @@ -134,7 +146,7 @@ func (s *DatabaseService) UpdatePatient(id string, req *patient.UpdatePatient) e "$set": req, } - _, err = s.DBMongo.Collection("patientbaru").UpdateOne(ctx, filter, update) + _, err = s.DBMongo.Collection("patient").UpdateOne(ctx, filter, update) if err != nil { log.Println(err) return err @@ -164,7 +176,7 @@ func (s *DatabaseService) DeletePatient(id string, req *patient.DeletePatient) e }, } - _, err = s.DBMongo.Collection("patientbaru").UpdateOne(ctx, filter, update) + _, err = s.DBMongo.Collection("patient").UpdateOne(ctx, filter, update) if err != nil { log.Println(err) return err diff --git a/pkg/database/mongo/practitioner.go b/pkg/database/mongo/practitioner.go index a746fdb..8091e39 100644 --- a/pkg/database/mongo/practitioner.go +++ b/pkg/database/mongo/practitioner.go @@ -28,3 +28,30 @@ func (s *DatabaseService) GetAllPractitioner(limit int64, skip int64) ([]*practi } return users, nil } + +func (s *DatabaseService) GetDokterBySMF(display string, value string) ([]*practitioner.Practitioner, error) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + filter := bson.M{ + "extension": bson.M{ + "$elemMatch": bson.M{ + "extension.valueDisplay": display, + "extension.valueCode": value, + }, + }, + } + + cursor, err := s.DBMongo.Collection("practitioner").Find(ctx, filter) + if err != nil { + log.Println(err) + return nil, err + } + defer cursor.Close(ctx) + var results []*practitioner.Practitioner + if err = cursor.All(ctx, &results); err != nil { + log.Println(err) + return nil, err + } + return results, nil +} diff --git a/pkg/database/mongo/provinsi.go b/pkg/database/mongo/provinsi.go index 08cc8c7..426be71 100644 --- a/pkg/database/mongo/provinsi.go +++ b/pkg/database/mongo/provinsi.go @@ -55,6 +55,45 @@ func (s *DatabaseService) InsertVillage(req Mongomaster.Village) error { } return nil } + +func (s *DatabaseService) Getsmf() ([]*Mongomaster.Smfmongo, error) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + datasmf, err := s.DBMongo.Collection("smf").Find(ctx, bson.D{}) + if err != nil { + log.Println(err) + } + var smf []*Mongomaster.Smfmongo + err = datasmf.All(ctx, &smf) + if err != nil { + log.Println(err) + return nil, err + } + return smf, nil +} + +func (s *DatabaseService) GetICD(limit int64, skip int64) ([]*Mongomaster.Icdmongo, error) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + findOptions := options.Find() + findOptions.SetLimit(limit) + findOptions.SetSkip(skip) + + filter := bson.M{ + "status": "active", + } + dataICD, err := s.DBMongo.Collection("icd").Find(ctx, filter, findOptions) + if err != nil { + log.Println(err) + } + var ICD []*Mongomaster.Icdmongo + err = dataICD.All(ctx, &ICD) + if err != nil { + log.Println(err) + return nil, err + } + return ICD, nil +} func (s *DatabaseService) Getdataprovinsi() ([]*Mongomaster.State, error) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() diff --git a/pkg/database/satu_data/extension.go b/pkg/database/satu_data/extension.go index f848986..f983735 100644 --- a/pkg/database/satu_data/extension.go +++ b/pkg/database/satu_data/extension.go @@ -132,3 +132,39 @@ from m_suku ms` } return datasuku } + +func (s *DatabaseService) GetICD() []*simrs.Icd { + var dataicd []*simrs.Icd + query := `select + i.icd_code as id_idicd, i.icd_code as nm_icd, i.jenis_penyakit as des_deskripsijenispenyakit, i.sebabpenyakit as com_penyebabpenyakit +from icd i` + errQuery := s.DB.Debug().Raw(query).Scan(&dataicd).Error + if errQuery != nil { + if errors.Is(errQuery, gorm.ErrRecordNotFound) { + errMsg := errors.New("Data Tidak Ditemukan") + log.Println(errMsg) + return nil + } + log.Println(errQuery) + return nil + } + return dataicd +} + +func (s *DatabaseService) GetSMF() []*simrs.Smfsimrs { + var datasmf []*simrs.Smfsimrs + query := `select + ms.idsmf as id_idsmf, ms.kdsmf as id_kodesmf, ms.namasmf as nm_namasmf, ms.aktif as st_smf +from m_smf ms` + errQuery := s.DB.Debug().Raw(query).Scan(&datasmf).Error + if errQuery != nil { + if errors.Is(errQuery, gorm.ErrRecordNotFound) { + errMsg := errors.New("Data Tidak Ditemukan") + log.Println(errMsg) + return nil + } + log.Println(errQuery) + return nil + } + return datasmf +} diff --git a/pkg/handlers/Master/master.go b/pkg/handlers/Master/master.go index c7f1fb5..ffdfaf2 100644 --- a/pkg/handlers/Master/master.go +++ b/pkg/handlers/Master/master.go @@ -6,6 +6,7 @@ import ( "github.com/gin-gonic/gin" "net/http" "os" + "strconv" ) func GetProvinsi(c *gin.Context) { @@ -179,3 +180,57 @@ func GetHierarchyFromProvinsi(c *gin.Context) { "message": "Hierarki dari provinsi berhasil diambil", }) } + +func GetSMF(c *gin.Context) { + local := os.Getenv("MONGODB_DEV_MASTER") + db := database.New(local).GetMongoDB() + if db == nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"}) + return + } + + mongoDB := mongo.NewDatabaseServiceMongo(db) + dataSmf, errSelect := mongoDB.Getsmf() + if errSelect != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{ + "data": dataSmf, + "message": "SMF Sukses Ter-ambil ", + }) +} + +func GetICD(c *gin.Context) { + local := os.Getenv("MONGODB_DEV_MASTER") + db := database.New(local).GetMongoDB() + if db == nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"}) + return + } + // Default values + limit := int64(0) + skip := int64(0) + + // Ambil dari query jika tersedia + if l := c.Query("limit"); l != "" { + if parsed, err := strconv.ParseInt(l, 10, 64); err == nil { + limit = parsed + } + } + if s := c.Query("skip"); s != "" { + if parsed, err := strconv.ParseInt(s, 10, 64); err == nil { + skip = parsed + } + } + mongoDB := mongo.NewDatabaseServiceMongo(db) + dataSmf, errSelect := mongoDB.GetICD(limit, skip) + if errSelect != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{ + "data": dataSmf, + "message": "ICD Sukses Ter-ambil ", + }) +} diff --git a/pkg/handlers/MongoHandler/Patient/patient.go b/pkg/handlers/MongoHandler/Patient/patient.go index 6c97dbd..5374406 100644 --- a/pkg/handlers/MongoHandler/Patient/patient.go +++ b/pkg/handlers/MongoHandler/Patient/patient.go @@ -63,7 +63,9 @@ func InsertPatient(c *gin.Context) { return } c.JSON(http.StatusOK, gin.H{ - "data": rekamMedikNumber, + "Norm": rekamMedikNumber, + "id": req.ID.Hex(), + "Nama": req.Name, "message": "Pasien berhasil di Buat", }) } diff --git a/pkg/handlers/MongoHandler/encounter/encounter.go b/pkg/handlers/MongoHandler/encounter/encounter.go new file mode 100644 index 0000000..46ab1d1 --- /dev/null +++ b/pkg/handlers/MongoHandler/encounter/encounter.go @@ -0,0 +1,57 @@ +package encounter + +import ( + "api-poliklinik/internal/database" + "api-poliklinik/pkg/database/mongo" + "api-poliklinik/pkg/models/mongo/encounter" + "github.com/gin-gonic/gin" + "net/http" + "os" + "time" +) + +func Getencounter(c *gin.Context) { + local := os.Getenv("MONGODB_DEV_LOCAL") + db := database.New(local).GetMongoDB() + if db == nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"}) + return + } + + mongoDB := mongo.NewDatabaseServiceMongo(db) + dataEncounter, errSelect := mongoDB.Getencounter() + if errSelect != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{ + "data": dataEncounter, + "message": "Encounter Sukses Ter-ambil ", + }) +} + +func InsertEncounter(c *gin.Context) { + local := os.Getenv("MONGODB_DEV_LOCAL") + db := database.New(local).GetMongoDB() + if db == nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"}) + return + } + mongoDB := mongo.NewDatabaseServiceMongo(db) + var req *encounter.Encounter + if err := c.ShouldBindJSON(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"message": "Invalid request format"}) + return + } + dateCreated := time.Now().Format("2006-01-02 15:04:05") + req.ResourceType = "Encounter" + req.CreatedAt = dateCreated + req.UpdatedAt = dateCreated + + errInsert := mongoDB.InsertEncounter(req) + if errInsert != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errInsert.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{"message": "Encounter berhasil di Buat"}) +} diff --git a/pkg/handlers/MongoHandler/episodeofcare/episodeofcare.go b/pkg/handlers/MongoHandler/episodeofcare/episodeofcare.go new file mode 100644 index 0000000..9c85e43 --- /dev/null +++ b/pkg/handlers/MongoHandler/episodeofcare/episodeofcare.go @@ -0,0 +1,57 @@ +package episodeofcare + +import ( + "api-poliklinik/internal/database" + "api-poliklinik/pkg/database/mongo" + EpisodeModels "api-poliklinik/pkg/models/mongo/episodeofcare" + "github.com/gin-gonic/gin" + "net/http" + "os" + "time" +) + +func Getepisode(c *gin.Context) { + local := os.Getenv("MONGODB_DEV_LOCAL") + db := database.New(local).GetMongoDB() + if db == nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"}) + return + } + + mongoDB := mongo.NewDatabaseServiceMongo(db) + dataEpisode, errSelect := mongoDB.Getepisode() + if errSelect != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{ + "data": dataEpisode, + "message": "Episode of care Sukses Ter-ambil ", + }) +} + +func InsertEpisode(c *gin.Context) { + local := os.Getenv("MONGODB_DEV_LOCAL") + db := database.New(local).GetMongoDB() + if db == nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"}) + return + } + mongoDB := mongo.NewDatabaseServiceMongo(db) + var req *EpisodeModels.EpisodeOfCare + if err := c.ShouldBindJSON(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"message": "Invalid request format"}) + return + } + dateCreated := time.Now().Format("2006-01-02 15:04:05") + req.ResourceType = "EpisodeofCare" + req.CreatedAt = dateCreated + req.UpdatedAt = dateCreated + + errInsert := mongoDB.InsertEpisode(req) + if errInsert != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errInsert.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{"message": "Episode Of Care berhasil di Buat"}) +} diff --git a/pkg/handlers/MongoHandler/practitioner/practitioner.go b/pkg/handlers/MongoHandler/practitioner/practitioner.go index 594c695..71aa4b8 100644 --- a/pkg/handlers/MongoHandler/practitioner/practitioner.go +++ b/pkg/handlers/MongoHandler/practitioner/practitioner.go @@ -44,3 +44,31 @@ func GetDataPractitioner(c *gin.Context) { "data": dataPractitioner, }) } + +func Getdatadokter(c *gin.Context) { + local := os.Getenv("MONGODB_DEV_LOCAL") + db := database.New(local).GetMongoDB() + if db == nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"}) + return + } + + display := c.Param("display") + value := c.Param("value") + if display == "" || value == "" { + c.JSON(http.StatusBadRequest, gin.H{"message": "Parameter 'display' dan 'value' dibutuhkan"}) + return + } + + mongoDB := mongo.NewDatabaseServiceMongo(db) + dataSMF, err := mongoDB.GetDokterBySMF(display, value) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()}) + return + } + + c.JSON(http.StatusOK, gin.H{ + "data": dataSMF, + "message": "Practitioner Dengan SMF berhasil di cari", + }) +} diff --git a/pkg/handlers/appointment/appointment.go b/pkg/handlers/appointment/appointment.go index 2a7917a..9268202 100644 --- a/pkg/handlers/appointment/appointment.go +++ b/pkg/handlers/appointment/appointment.go @@ -3,9 +3,11 @@ package appointment import ( "api-poliklinik/internal/database" "api-poliklinik/pkg/database/mongo" + "api-poliklinik/pkg/models/mongo/appointment" "github.com/gin-gonic/gin" "net/http" "os" + "time" ) func Getappointment(c *gin.Context) { @@ -24,6 +26,35 @@ func Getappointment(c *gin.Context) { } c.JSON(http.StatusOK, gin.H{ "data": dataAppointment, - "message": "location Sukses Ter-ambil ", + "message": "Apponment Sukses Ter-ambil ", + }) +} + +func Insertappointment(c *gin.Context) { + local := os.Getenv("MONGODB_DEV_LOCAL") + db := database.New(local).GetMongoDB() + if db == nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"}) + return + } + mongoDB := mongo.NewDatabaseServiceMongo(db) + var req *appointment.Appointment + if err := c.ShouldBindJSON(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"message": "Invalid request format"}) + return + } + dateCreated := time.Now().Format("2006-01-02 15:04:05") + req.ResourceType = "Appointment" + req.CreatedAt = dateCreated + req.UpdatedAt = dateCreated + + errInsert := mongoDB.InsertApointmongo(req) + if errInsert != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errInsert.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{ + "id": req.ID.Hex(), + "message": "Janji Temu berhasil di Buat", }) } diff --git a/pkg/handlers/migrasi/location/location.go b/pkg/handlers/migrasi/location/location.go index 9d93c13..215f6a5 100644 --- a/pkg/handlers/migrasi/location/location.go +++ b/pkg/handlers/migrasi/location/location.go @@ -205,7 +205,7 @@ func Migrasilokasi(c *gin.Context) { } fhirLokasi.Contact = _struct.ExtendedContactDetail{ - Purpose: _struct.Purpose{ + Purpose: _struct.CodeableConcept{ Coding: []_struct.Coding{ { System: "http://terminology.hl7.org/CodeSystem/contactentity-type", @@ -221,7 +221,7 @@ func Migrasilokasi(c *gin.Context) { System: "pager", Value: "1243", Use: "work", - Rank: 1, + Rank: "1", Period: _struct.Period{ Start: "", End: "", @@ -384,14 +384,14 @@ func Migrasilokasi(c *gin.Context) { System: "", Value: "", Use: "", - Rank: 0, + Rank: "0", Period: _struct.Period{ Start: "", End: "", }, }, AddressExtendedContact: _struct.ExtendedContactDetail{ - Purpose: _struct.Purpose{ + Purpose: _struct.CodeableConcept{ Coding: []_struct.Coding{ { System: "", @@ -421,7 +421,7 @@ func Migrasilokasi(c *gin.Context) { System: "", Value: "", Use: "", - Rank: 0, + Rank: "0", Period: _struct.Period{ Start: "", End: "", diff --git a/pkg/handlers/migrasi/medis/icd.go b/pkg/handlers/migrasi/medis/icd.go new file mode 100644 index 0000000..9e91967 --- /dev/null +++ b/pkg/handlers/migrasi/medis/icd.go @@ -0,0 +1,232 @@ +package medis + +import ( + "api-poliklinik/internal/database" + "api-poliklinik/pkg/database/mongo" + connDatabase "api-poliklinik/pkg/database/satu_data" + mongomaster "api-poliklinik/pkg/models/mongo/master/masteraddress" + _struct "api-poliklinik/pkg/models/struct" + "github.com/gin-gonic/gin" + "go.mongodb.org/mongo-driver/bson/primitive" + "log" + "net/http" + "os" + "time" +) + +func Migrasiicd(c *gin.Context) { + db := database.New().GetDB("simrs") + simrs := connDatabase.NewDatabaseService(db) + + dataIcd := simrs.GetICD() + if dataIcd == nil || len(dataIcd) == 0 { + c.JSON(http.StatusNotFound, gin.H{ + "status": "error", + "message": "Tidak ada data icd untuk dimigrasi", + }) + return + } + + local := os.Getenv("MONGODB_DEV_MASTER") + mongoDBConn := database.New(local).GetMongoDB() + if mongoDBConn == nil { + c.JSON(http.StatusInternalServerError, gin.H{ + "status": "error", + "message": "Koneksi database MongoDB gagal", + }) + return + } + mongoDB := mongo.NewDatabaseServiceMongo(mongoDBConn) + + migratedCount := 0 + failedCount := 0 + var migratedIDs []string + + for _, icd := range dataIcd { + dateCreated := time.Now().Format("2006-01-02 15:04:05") + objectID := primitive.NewObjectID() + var fhiricd = mongomaster.Icdmongo{ + ResourceType: "Diagnosis", + ID: objectID, + } + fhiricd.Identifier = []_struct.Identifier{ + { + Use: "usual", + System: "", + Value: icd.IDIcd, + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "icd_code", + Display: "ID icd Simrs 3.0", + UserSelected: true, + }, + }, + Text: "ID icd Simrs 3.0", + }, + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + } + + fhiricd.Status = "active" + fhiricd.Name = icd.NamaIcd + fhiricd.Description = icd.DesJenisPenyakit + fhiricd.Comment = icd.PenyebabPenyakit + fhiricd.Period = _struct.Period{ + Start: "", + End: "", + } + fhiricd.CreatedAt = dateCreated + fhiricd.UpdatedAt = dateCreated + + err := mongoDB.Inserticd(fhiricd) + + if err != nil { + log.Printf("Gagal migrasi data icd %s: %v", icd.IDIcd, err) + failedCount++ + continue + } + + migratedIDs = append(migratedIDs, objectID.Hex()) + migratedCount++ + } + + c.JSON(http.StatusOK, gin.H{ + "status": "success", + "message": "Migrasi data icd ke FHIR berhasil", + "total": len(dataIcd), + "migrated": migratedCount, + "failed": failedCount, + "migrated_ids": migratedIDs, + "timestamp": time.Now().Format(time.RFC3339), + }) +} + +func Migrasismf(c *gin.Context) { + db := database.New().GetDB("simrs") + simrs := connDatabase.NewDatabaseService(db) + + dataSmf := simrs.GetSMF() + if dataSmf == nil || len(dataSmf) == 0 { + c.JSON(http.StatusNotFound, gin.H{ + "status": "error", + "message": "Tidak ada data smf untuk dimigrasi", + }) + return + } + + local := os.Getenv("MONGODB_DEV_MASTER") + mongoDBConn := database.New(local).GetMongoDB() + if mongoDBConn == nil { + c.JSON(http.StatusInternalServerError, gin.H{ + "status": "error", + "message": "Koneksi database MongoDB gagal", + }) + return + } + mongoDB := mongo.NewDatabaseServiceMongo(mongoDBConn) + + migratedCount := 0 + failedCount := 0 + var migratedIDs []string + + for _, smf := range dataSmf { + dateCreated := time.Now().Format("2006-01-02 15:04:05") + objectID := primitive.NewObjectID() + var fhirsmf = mongomaster.Smfmongo{ + ResourceType: "SMF", + ID: objectID, + } + fhirsmf.Identifier = []_struct.Identifier{ + { + Use: "usual", + System: "", + Value: smf.IDsmf, + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "idsmf", + Display: "ID m_smf Simrs 3.0", + UserSelected: true, + }, + }, + Text: "ID m_smf Simrs 3.0", + }, + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + { + Use: "usual", + System: "", + Value: smf.Kodesmf, + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "kdsmf", + Display: "ID m_smf Simrs 3.0", + UserSelected: true, + }, + }, + Text: "ID m_smf Simrs 3.0", + }, + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + } + + fhirsmf.Status = "active" + fhirsmf.Name = smf.Namasmf + fhirsmf.Period = _struct.Period{ + Start: "", + End: "", + } + fhirsmf.CreatedAt = dateCreated + fhirsmf.UpdatedAt = dateCreated + + err := mongoDB.InsertSMF(fhirsmf) + + if err != nil { + log.Printf("Gagal migrasi data icd %s: %v", smf.IDsmf, err) + failedCount++ + continue + } + + migratedIDs = append(migratedIDs, objectID.Hex()) + migratedCount++ + } + + c.JSON(http.StatusOK, gin.H{ + "status": "success", + "message": "Migrasi data icd ke FHIR berhasil", + "total": len(dataSmf), + "migrated": migratedCount, + "failed": failedCount, + "migrated_ids": migratedIDs, + "timestamp": time.Now().Format(time.RFC3339), + }) +} diff --git a/pkg/handlers/migrasi/medis/smf.go b/pkg/handlers/migrasi/medis/smf.go new file mode 100644 index 0000000..6f3ede9 --- /dev/null +++ b/pkg/handlers/migrasi/medis/smf.go @@ -0,0 +1 @@ +package medis diff --git a/pkg/handlers/migrasi/migrasi.go b/pkg/handlers/migrasi/migrasi.go index 09aeee4..57e4da6 100644 --- a/pkg/handlers/migrasi/migrasi.go +++ b/pkg/handlers/migrasi/migrasi.go @@ -249,7 +249,7 @@ func MigratePasienToFHIR(c *gin.Context) { System: "Phone", Value: pasien.TeleponHp, Use: "mobile", - Rank: 1, + Rank: "1", Period: _struct.Period{ Start: "", End: "", @@ -259,7 +259,7 @@ func MigratePasienToFHIR(c *gin.Context) { System: "Home", Value: pasien.TeleponRumah, Use: "Home", - Rank: 2, + Rank: "2", Period: _struct.Period{ Start: "", End: "", @@ -269,7 +269,7 @@ func MigratePasienToFHIR(c *gin.Context) { System: "Home2", Value: pasien.TeleponRumah2, Use: "Home2", - Rank: 2, + Rank: "2", Period: _struct.Period{ Start: "", End: "", @@ -279,7 +279,7 @@ func MigratePasienToFHIR(c *gin.Context) { System: "Office", Value: pasien.TeleponKantor, Use: "Office", - Rank: 3, + Rank: "3", Period: _struct.Period{ Start: "", End: "", @@ -473,9 +473,8 @@ func MigratePasienToFHIR(c *gin.Context) { Display: pasien.Komunikasi, }, }, - Text: "", + Text: "Bahasa" + pasien.Komunikasi, }, - Text: "Bahasa" + pasien.Komunikasi, }, } diff --git a/pkg/handlers/migrasi/practitioner/practitioner.go b/pkg/handlers/migrasi/practitioner/practitioner.go index fd7e828..225cf5f 100644 --- a/pkg/handlers/migrasi/practitioner/practitioner.go +++ b/pkg/handlers/migrasi/practitioner/practitioner.go @@ -1,420 +1,533 @@ package practitioner -// -//// Membuat instance Practitioner -//fhirPractitioner := &models.Practitioner{ -//ResourceType: "Practitioner", -//ID: primitive.NewObjectID(), -//Active: true, -//} -// -//// Identifier -//fhirPractitioner.Identifier = []_struct.Identifier{ -//{ -//Use: "usual", -//Type: _struct.CodeableConcept{ -//Coding: []_struct.Coding{ -//{ -//System: "", -//Version: "", -//Code: "IDSIM", -//Display: "SIMRS ID", -//UserSelected: true, -//}, -//}, -//Text: "SIMRS ID", -//}, -//System: "", -//Value: "3090", -//Period: _struct.Period{ -//Start: "", -//End: "", -//}, -//Assigner: _struct.Reference{ -//Reference: "", -//Display: "", -//}, -//}, -//{ -//Use: "usual", -//Type: _struct.CodeableConcept{ -//Coding: []_struct.Coding{ -//{ -//System: "", -//Version: "", -//Code: "KDDPJP", -//Display: "Kode Dokter Penanggung Jawab", -//UserSelected: true, -//}, -//}, -//Text: "Kode Dokter Penanggung Jawab", -//}, -//System: "", -//Value: "DL_025", -//Period: _struct.Period{ -//Start: "", -//End: "", -//}, -//Assigner: _struct.Reference{ -//Reference: "", -//Display: "", -//}, -//}, -//{ -//Use: "usual", -//Type: _struct.CodeableConcept{ -//Coding: []_struct.Coding{ -//{ -//System: "", -//Version: "", -//Code: "NIP", -//Display: "Nomor Induk Pegawai", -//UserSelected: true, -//}, -//}, -//Text: "Nomor Induk Pegawai", -//}, -//System: "", -//Value: "198609092019031004", -//Period: _struct.Period{ -//Start: "", -//End: "", -//}, -//Assigner: _struct.Reference{ -//Reference: "", -//Display: "", -//}, -//}, -//{ -//Use: "usual", -//Type: _struct.CodeableConcept{ -//Coding: []_struct.Coding{ -//{ -//System: "", -//Version: "", -//Code: "NIK", -//Display: "Nomor Induk Kependudukan", -//UserSelected: true, -//}, -//}, -//Text: "NIK", -//}, -//System: "", -//Value: "3507090909860001", -//Period: _struct.Period{ -//Start: "", -//End: "", -//}, -//Assigner: _struct.Reference{ -//Reference: "", -//Display: "", -//}, -//}, -//{ -//Use: "usual", -//Type: _struct.CodeableConcept{ -//Coding: []_struct.Coding{ -//{ -//System: "", -//Version: "", -//Code: "HFIS", -//Display: "HFIS Code", -//UserSelected: true, -//}, -//}, -//Text: "HFIS", -//}, -//System: "", -//Value: "32352", -//Period: _struct.Period{ -//Start: "", -//End: "", -//}, -//Assigner: _struct.Reference{ -//Reference: "", -//Display: "", -//}, -//}, -//{ -//Use: "usual", -//Type: _struct.CodeableConcept{ -//Coding: []_struct.Coding{ -//{ -//System: "", -//Version: "", -//Code: "SATUSEHAT", -//Display: "SatuSehat Code", -//UserSelected: true, -//}, -//}, -//Text: "SATUSEHAT", -//}, -//System: "", -//Value: "10014437630", -//Period: _struct.Period{ -//Start: "", -//End: "", -//}, -//Assigner: _struct.Reference{ -//Reference: "", -//Display: "", -//}, -//}, -//} -// -//// Name -//fhirPractitioner.Name = []_struct.HumanName{ -//{ -//Use: "usual", -//Text: "dr.HERWINDO PUDJO BRAHMANTYO,Sp.PD", -//Family: "BRAHMANTYO", -//Given: []string{"HERWINDO", "PUDJO"}, -//Prefix: []string{"dr"}, -//Suffix: []string{"Sp.PD"}, -//Period: _struct.Period{ -//Start: "", -//End: "", -//}, -//}, -//} -// -//// Telecom -//fhirPractitioner.Telecom = []_struct.ContactPoint{ -//{ -//System: "phone", -//Value: "(081) 1365725", -//Use: "mobile", -//Rank: 1, -//Period: _struct.Period{ -//Start: "", -//End: "", -//}, -//}, -//{ -//System: "email", -//Value: "herwindopudjo@yahoo.com", -//Use: "work", -//Rank: 1, -//Period: _struct.Period{ -//Start: "", -//End: "", -//}, -//}, -//} -// -//// Address -//fhirPractitioner.Address = []_struct.Address{ -//{ -//Use: "home", -//Type: "both", -//Text: "JL Pasuruan No 10 Malang", -//Line: []string{"JL Pasuruan No 10"}, -//Village: "Karanganyar", -//District: "Panggungrejo", -//City: "Pasuruan", -//State: "Jawa Timur", -//PostalCode: "67131", -//Country: "Indonesia", -//Period: _struct.Period{ -//Start: "", -//End: "", -//}, -//Extension: []_struct.Extension{ -//{ -//URL: "", -//Extension: []_struct.ExtensionDetail{ -//{ -//URL: "state", -//ValueDisplay: "Jawa Timur", -//ValueCode: "35", -//}, -//{ -//URL: "city", -//ValueDisplay: "Malang", -//ValueCode: "3573", -//}, -//{ -//URL: "district", -//ValueDisplay: "Klojen", -//ValueCode: "3573030", -//}, -//{ -//URL: "village", -//ValueDisplay: "Klojen", -//ValueCode: "3573030008", -//}, -//{ -//URL: "rt", -//ValueDisplay: "", -//ValueCode: "", -//}, -//{ -//URL: "rw", -//ValueDisplay: "", -//ValueCode: "", -//}, -//}, -//}, -//}, -//}, -//} -// -//// Gender -//fhirPractitioner.Gender = "male" -// -//// BirthDate -//fhirPractitioner.BirthDate = "1986-09-09" -// -//// Qualification -//fhirPractitioner.Qualification = []_struct.Qualification{ -//{ -//Identifier: []_struct.Identifier{ -//{ -//Use: "usual", -//Type: _struct.CodeableConcept{ -//Coding: []_struct.Coding{ -//{ -//System: "", -//Version: "", -//Code: "SIP", -//Display: "Surat Ijin Praktek", -//UserSelected: true, -//}, -//}, -//Text: "SIP", -//}, -//System: "", -//Value: "", -//Period: _struct.Period{ -//Start: "2021-09-09", -//End: "2026-09-09", -//}, -//Assigner: _struct.Reference{ -//Reference: "", -//Display: "", -//}, -//}, -//{ -//Use: "usual", -//Type: _struct.CodeableConcept{ -//Coding: []_struct.Coding{ -//{ -//System: "", -//Version: "", -//Code: "SPK", -//Display: "Surat Perintah Kerja", -//UserSelected: true, -//}, -//}, -//Text: "SPK", -//}, -//System: "", -//Value: "", -//Period: _struct.Period{ -//Start: "2020-12-22", -//End: "2025-12-22", -//}, -//Assigner: _struct.Reference{ -//Reference: "", -//Display: "", -//}, -//}, -//}, -//Code: _struct.CodeableConcept{ -//Coding: []_struct.Coding{ -//{ -//System: "http://terminology.hl7.org/CodeSystem/v2-0360/2.7", -//Version: "", -//Code: "MD", -//Display: "Doctor of Medicine", -//UserSelected: true, -//}, -//}, -//Text: "Spesialis Penyakit Dalam", -//}, -//Period: _struct.Period{ -//Start: "", -//End: "", -//}, -//Issuer: _struct.Reference{ -//Reference: "", -//Display: "", -//}, -//}, -//} -// -//// Communication -//fhirPractitioner.Communication = []_struct.Communication{ -//{ -//Language: _struct.CodeableConcept{ -//Coding: []_struct.Coding{ -//{ -//System: "", -//Version: "", -//Code: "id", -//Display: "Indonesian", -//UserSelected: true, -//}, -//}, -//Text: "Bahasa Indonesia", -//}, -//}, -//{ -//Language: _struct.CodeableConcept{ -//Coding: []_struct.Coding{ -//{ -//System: "", -//Version: "", -//Code: "en", -//Display: "English", -//UserSelected: true, -//}, -//}, -//Text: "Bahasa Inggris", -//}, -//}, -//} -// -//// Extension -//fhirPractitioner.Extension = []_struct.Extension{ -//{ -//URL: "", -//Extension: []_struct.ExtensionDetail{ -//{ -//URL: "createdAt", -//ValueDisplay: "2025-02-19 08:04:55.000", -//ValueCode: "2025-02-19 08:04:55.000", -//}, -//{ -//URL: "updatedAt", -//ValueDisplay: "2025-03-25 12:04:55.000", -//ValueCode: "2025-03-25 12:04:55.000", -//}, -//{ -//URL: "birthPlace", -//ValueDisplay: "Malang", -//ValueCode: "3573", -//}, -//{ -//URL: "national", -//ValueDisplay: "Warga Negara Indonesia", -//ValueCode: "WNI", -//}, -//{ -//URL: "religion", -//ValueDisplay: "Islam", -//ValueCode: "IS", -//}, -//{ -//URL: "smf", -//ValueDisplay: "Ilmu Penyakit Dalam", -//ValueCode: "IPD", -//}, -//{ -//URL: "category", -//ValueDisplay: "RSUD dr. Saiful Anwar", -//ValueCode: "RSSA", -//}, -//}, -//}, -//} +import ( + "api-poliklinik/internal/database" + "api-poliklinik/pkg/database/mongo" + connDatabase "api-poliklinik/pkg/database/satu_data" + "api-poliklinik/pkg/models/mongo/practitioner" + _struct "api-poliklinik/pkg/models/struct" + "github.com/gin-gonic/gin" + "go.mongodb.org/mongo-driver/bson/primitive" + "log" + "net/http" + "os" + "strings" + "time" +) + +func Migratepractitioner(c *gin.Context) { + + db := database.New().GetDB("simrs") + simrs := connDatabase.NewDatabaseService(db) + + dataPractitioner := simrs.Getdokter() + if dataPractitioner == nil || len(dataPractitioner) == 0 { + c.JSON(http.StatusNotFound, gin.H{ + "status": "error", + "message": "Tidak ada data pasien untuk dimigrasi", + }) + return + } + + local := os.Getenv("MONGODB_DEV_LOCAL") + mongoDBConn := database.New(local).GetMongoDB() + if mongoDBConn == nil { + c.JSON(http.StatusInternalServerError, gin.H{ + "status": "error", + "message": "Koneksi database MongoDB gagal", + }) + return + } + mongoDB := mongo.NewDatabaseServiceMongo(mongoDBConn) + + migratedCount := 0 + failedCount := 0 + var migratedIDs []string + + for _, dokter := range dataPractitioner { + objectID := primitive.NewObjectID() + fullName := dokter.NamaDokter + humanName := ParseDoctorName(fullName) + var fhirDokter = practitioner.Practitioner{ + ResourceType: "Practitioner", + ID: objectID, + Active: true, + } + fhirDokter.Identifier = []_struct.Identifier{ + { + Use: "usual", + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "IDSIM", + Display: "SIMRS ID", + UserSelected: true, + }, + }, + Text: "SIMRS ID", + }, + System: "", + Value: dokter.IDDokter, + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + { + Use: "usual", + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "KDDPJP", + Display: "Kode Dokter Penanggung Jawab", + UserSelected: true, + }, + }, + Text: "Kode Dokter Penanggung Jawab", + }, + System: "", + Value: dokter.KodeDpjp, + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + { + Use: "usual", + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "NIP", + Display: "Nomor Induk Pegawai", + UserSelected: true, + }, + }, + Text: "Nomor Induk Pegawai", + }, + System: "", + Value: dokter.NIP, + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + { + Use: "usual", + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "HFIS", + Display: "HFIS Code", + UserSelected: true, + }, + }, + Text: "HFIS", + }, + System: "", + Value: "", + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + { + Use: "usual", + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "SATUSEHAT", + Display: "SatuSehat Code", + UserSelected: true, + }, + }, + Text: "SATUSEHAT", + }, + System: "", + Value: "", + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + } + + fhirDokter.Name = []_struct.HumanName{humanName} + fhirDokter.Telecom = []_struct.ContactPoint{ + { + System: "phone", + Value: dokter.NomorHP, + Use: "mobile", + Rank: "1", + Period: _struct.Period{ + Start: "", + End: "", + }, + }, + { + System: "email", + Value: dokter.Email, + Use: "work", + Rank: "1", + Period: _struct.Period{ + Start: "", + End: "", + }, + }, + } + + fhirDokter.Gender = "" + fhirDokter.BirthDate = "" + fhirDokter.Address = []_struct.Address{ + { + Use: "home", + Type: "both", + Text: "", + Line: []string{""}, + Village: "", + District: "", + City: "", + State: "", + PostalCode: "", + Country: "", + Period: _struct.Period{ + Start: "", + End: "", + }, + Extension: []_struct.Extension{ + { + URL: "", + Extension: []_struct.ExtensionDetail{ + { + URL: "state", + ValueDisplay: "", + ValueCode: "", + }, + { + URL: "city", + ValueDisplay: "", + ValueCode: "", + }, + { + URL: "district", + ValueDisplay: "", + ValueCode: "", + }, + { + URL: "village", + ValueDisplay: "", + ValueCode: "", + }, + { + URL: "rt", + ValueDisplay: "", + ValueCode: "", + }, + { + URL: "rw", + ValueDisplay: "", + ValueCode: "", + }, + }, + }, + }, + }, + } + + fhirDokter.Qualification = []_struct.Qualification{ + { + Identifier: []_struct.Identifier{ + { + Use: "usual", + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "SIP", + Display: "Surat Ijin Praktek", + UserSelected: true, + }, + }, + Text: "SIP", + }, + System: "", + Value: "", + Period: _struct.Period{ + Start: "", + End: dokter.QuSIP, + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + { + Use: "usual", + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "SPK", + Display: "Surat Perintah Kerja", + UserSelected: true, + }, + }, + Text: "SPK", + }, + System: "", + Value: "", + Period: _struct.Period{ + Start: "", + End: dokter.QuSPK, + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + }, + Code: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "http://terminology.hl7.org/CodeSystem/v2-0360/2.7", + Version: "", + Code: "MD", + Display: "Doctor of Medicine", + UserSelected: true, + }, + }, + Text: "", + }, + Period: _struct.Period{ + Start: "", + End: "", + }, + Issuer: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + } + + // Communication + fhirDokter.Communication = []_struct.Communication{ + { + Language: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "id", + Display: "Indonesian", + UserSelected: true, + }, + }, + Text: "Bahasa Indonesia", + }, + }, + { + Language: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "en", + Display: "English", + UserSelected: true, + }, + }, + Text: "Bahasa Inggris", + }, + }, + } + + // Extension + fhirDokter.Extension = []_struct.Extension{ + { + URL: "", + Extension: []_struct.ExtensionDetail{ + { + URL: "birthPlace", + ValueDisplay: "", + ValueCode: "", + }, + { + URL: "national", + ValueDisplay: "Warga Negara Indonesia", + ValueCode: "WNI", + }, + { + URL: "religion", + ValueDisplay: "", + ValueCode: "", + }, + { + URL: "smf", + ValueDisplay: "SMF", + ValueCode: dokter.SMF, + }, + { + URL: "category", + ValueDisplay: dokter.Kategori, + ValueCode: dokter.Kategori, + }, + }, + }, + } + err := mongoDB.InsertPractitioner(fhirDokter) + + if err != nil { + log.Printf("Gagal migrasi data praktisi %s: %v", dokter.IDDokter, err) + failedCount++ + continue + } + + migratedIDs = append(migratedIDs, objectID.Hex()) + migratedCount++ + } + + c.JSON(http.StatusOK, gin.H{ + "status": "success", + "message": "Migrasi data praktisi ke FHIR berhasil", + "total": len(dataPractitioner), + "migrated": migratedCount, + "failed": failedCount, + "migrated_ids": migratedIDs, + "timestamp": time.Now().Format(time.RFC3339), + }) +} + +// ParseDoctorName memisahkan nama dokter menjadi komponen-komponennya +func ParseDoctorName(fullName string) _struct.HumanName { + // Inisialisasi variabel hasil + var humanName _struct.HumanName + humanName.Use = "official" + humanName.Text = fullName // Simpan teks lengkap + + // Hilangkan spasi berlebih + fullName = strings.TrimSpace(fullName) + + // Cari gelar depan (prefix) + prefixPatterns := []string{"dr.", "DR.", "Dr.", "drg.", "DRG.", "Drg.", "prof.", "PROF.", "Prof."} + var prefix string + var nameWithoutPrefix string + + for _, pattern := range prefixPatterns { + if strings.HasPrefix(strings.ToLower(fullName), strings.ToLower(pattern)) { + prefix = pattern + nameWithoutPrefix = strings.TrimSpace(fullName[len(pattern):]) + break + } + } + + if prefix != "" { + humanName.Prefix = []string{strings.TrimSpace(prefix)} + } else { + humanName.Prefix = []string{} + nameWithoutPrefix = fullName + } + + // Cari gelar belakang (suffix) - seperti Sp.XX, M.Kes, dll + var suffixList []string + var nameWithoutSuffix string + + // Pola-pola gelar belakang yang umum + suffixPatterns := []string{ + "Sp.PD", "Sp.B", "Sp.OG", "Sp.A", "Sp.S", "Sp.THT", "Sp.KK", "Sp.JP", "Sp.M", "Sp.OT", + "M.Kes", "M.Si", "M.Biomed", "S.Kep", "S.Gz", "S.Farm", "S.Kep, Ns", "Ph.D", "S.Psi", + "MARS", "MPH", "MMR", "MH", "Ners", "MMRS", + } + + // Pisahkan string berdasarkan koma + parts := strings.Split(nameWithoutPrefix, ",") + + if len(parts) > 1 { + // Jika ada koma, bagian setelah koma adalah gelar belakang + nameWithoutSuffix = strings.TrimSpace(parts[0]) + + // Proses bagian setelah koma untuk mendapatkan gelar-gelar + suffixPart := strings.TrimSpace(parts[1]) + + // Pisahkan gelar jika ada beberapa (dipisahkan spasi) + suffixCandidates := strings.Split(suffixPart, " ") + for _, candidate := range suffixCandidates { + if candidate != "" { + suffixList = append(suffixList, strings.TrimSpace(candidate)) + } + } + } else { + // Jika tidak ada koma, periksa apakah ada gelar belakang yang umum + nameWithoutSuffix = nameWithoutPrefix + for _, pattern := range suffixPatterns { + if strings.Contains(nameWithoutPrefix, pattern) { + // Temukan posisi pattern + index := strings.Index(strings.ToUpper(nameWithoutPrefix), strings.ToUpper(pattern)) + if index > 0 { + nameWithoutSuffix = strings.TrimSpace(nameWithoutPrefix[:index]) + suffixList = append(suffixList, pattern) + break + } + } + } + } + + humanName.Suffix = suffixList + + // Pisahkan nama menjadi nama keluarga (family) dan nama depan (given) + nameParts := strings.Split(nameWithoutSuffix, " ") + + if len(nameParts) > 1 { + // Nama keluarga biasanya ada di akhir + humanName.Family = nameParts[len(nameParts)-1] + + // Nama depan adalah semua kata sebelum nama keluarga + humanName.Given = nameParts[:len(nameParts)-1] + } else if len(nameParts) == 1 { + // Jika hanya ada satu kata, itu dianggap sebagai nama keluarga + humanName.Family = nameParts[0] + humanName.Given = []string{} + } else { + // Jika tidak ada nama, set nilai default + humanName.Family = "" + humanName.Given = []string{} + } + + // Set period kosong + humanName.Period = _struct.Period{ + Start: "", + End: "", + } + + return humanName +} diff --git a/pkg/models/mongo/appointment/appointment.go b/pkg/models/mongo/appointment/appointment.go index 9f3523e..63e1e73 100644 --- a/pkg/models/mongo/appointment/appointment.go +++ b/pkg/models/mongo/appointment/appointment.go @@ -6,46 +6,46 @@ import ( ) type Appointment struct { - ResourceType string `json:"resourceType" bson:"resourceType"` - ID primitive.ObjectID `json:"id" bson:"_id"` - Identifier []_struct.Identifier `json:"identifier" bson:"identifier"` - Status string `json:"status" bson:"status"` - CancellationReason _struct.CodeableConcept `json:"cancellationReason" bson:"cancellationReason"` - Class []_struct.CodeableConcept `json:"class" bson:"class"` - ServiceCategory []_struct.CodeableConcept `json:"serviceCategory" bson:"serviceCategory"` - ServiceType []_struct.Value `json:"serviceType" bson:"serviceType"` - Specialty []_struct.CodeableConcept `json:"specialty" bson:"specialty"` - AppoinmentType _struct.CodeableConcept `json:"appoinmentType" bson:"appoinmentType"` - Reason []_struct.Value `json:"reason" bson:"reason"` - Priority _struct.CodeableConcept `json:"priority" bson:"priority"` - Description string `json:"description" bson:"description"` - Replaces _struct.Reference `json:"replaces" bson:"replaces"` - VirtualServiceDetail []_struct.VirtualService `json:"virtualServiceDetail" bson:"virtualServiceDetail"` - SupportingInformation []_struct.Reference `json:"supportingInformation" bson:"supportingInformation"` - PreviousAppointment _struct.Reference `json:"previousAppointment" bson:"previousAppointment"` - OriginatingAppointment _struct.Reference `json:"originatingAppointment" bson:"originatingAppointment"` - Start string `json:"start" bson:"start"` - End string `json:"end" bson:"end"` - MinutesDuration int `json:"minutesDuration" bson:"minutesDuration"` - RequestedPeriod []_struct.Period `json:"requestedPeriod" bson:"requestedPeriod"` - Slot []_struct.Reference `json:"slot" bson:"slot"` - Account []_struct.Reference `json:"account" bson:"account"` - Created string `json:"created" bson:"created"` - CancellationDate string `json:"cancellationDate" bson:"cancellationDate"` - Note []_struct.Note `json:"note" bson:"note"` - PatientInstruction []_struct.Concept `json:"patientInstruction" bson:"patientInstruction"` - BasedOn []_struct.Reference `json:"basedOn" bson:"basedOn"` - Subject _struct.Reference `json:"subject" bson:"subject"` - Participant []_struct.Participant `json:"participant" bson:"participant"` - RecurrenceId int `json:"recurrenceId" bson:"recurrenceId"` - OccurrenceChanged bool `json:"occurrenceChanged" bson:"occurrenceChanged"` - RecurrenceTemple []_struct.RecurrenceTemple `json:"recurrenceTemple" bson:"recurrenceTemple"` - WeeklyTemple _struct.WeeklyTemple `json:"weeklyTemple" bson:"weeklyTemple"` - MonthlyTemple _struct.MonthlyTemple `json:"monthlyTemple" bson:"monthlyTemple"` - YearlyTemple _struct.YearlyTemple `json:"yearlyTemple" bson:"yearlyTemple"` - ExcludingDate []string `json:"excludingDate" bson:"excludingDate"` - ExcludingRecurrenceId []int `json:"excludingRecurrenceId" bson:"excludingRecurrenceId"` - CreatedAt string `json:"createdAt" bson:"createdAt"` - UpdatedAt string `json:"updatedAt" bson:"updatedAt"` - Extension []_struct.Extension `json:"extension" bson:"extension"` + ResourceType string `json:"resourceType" bson:"resourceType"` + ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` + Identifier []_struct.Identifier `json:"identifier" bson:"identifier"` + Status string `json:"status" bson:"status"` + CancellationReason _struct.CodeableConcept `json:"cancellationReason" bson:"cancellationReason"` + Class []_struct.CodeableConcept `json:"class" bson:"class"` + ServiceCategory []_struct.CodeableConcept `json:"serviceCategory" bson:"serviceCategory"` + ServiceType []_struct.Value `json:"serviceType" bson:"serviceType"` + Specialty []_struct.CodeableConcept `json:"specialty" bson:"specialty"` + AppointmentType _struct.Coding `json:"appointmentType" bson:"appointmentType"` + Reason []_struct.Value `json:"reason" bson:"reason"` + Priority _struct.CodeableConcept `json:"priority" bson:"priority"` + Description string `json:"description" bson:"description"` + Replaces []_struct.Reference `json:"replaces" bson:"replaces"` + VirtualServiceDetail []_struct.VirtualServiceappoinmet `json:"virtualServiceDetail" bson:"virtualServiceDetail"` + SupportingInformation []_struct.Reference `json:"supportingInformation" bson:"supportingInformation"` + PreviousAppointment _struct.Reference `json:"previousAppointment" bson:"previousAppointment"` + OriginatingAppointment _struct.Reference `json:"originatingAppointment" bson:"originatingAppointment"` + Start string `json:"start" bson:"start"` + End string `json:"end" bson:"end"` + MinutesDuration int `json:"minutesDuration" bson:"minutesDuration"` + RequestedPeriod []_struct.Period `json:"requestedPeriod" bson:"requestedPeriod"` + Slot []_struct.Reference `json:"slot" bson:"slot"` + Account []_struct.Reference `json:"account" bson:"account"` + Created string `json:"created" bson:"created"` + CancellationDate string `json:"cancellationDate" bson:"cancellationDate"` + Note []_struct.Note `json:"note" bson:"note"` + PatientInstruction []_struct.Concept `json:"patientInstruction" bson:"patientInstruction"` + BasedOn []_struct.Reference `json:"basedOn" bson:"basedOn"` + Subject _struct.Reference `json:"subject" bson:"subject"` + Participant []_struct.Participant `json:"participant" bson:"participant"` + Recurrenceld string `json:"recurrenceld" bson:"recurrenceld"` + OccurrenceChanged bool `json:"occurrenceChanged" bson:"occurrenceChanged"` + RecurrenceTemple []_struct.RecurrenceTemple `json:"recurrenceTemple" bson:"recurrenceTemple"` + WeeklyTemple _struct.WeeklyTemple `json:"weeklyTemple" bson:"weeklyTemple"` + MonthlyTemple _struct.MonthlyTemple `json:"monthlyTemple" bson:"monthlyTemple"` + YearlyTemple _struct.YearlyTemple `json:"yearlyTemple" bson:"yearlyTemple"` + ExcludingDate []string `json:"excludingDate" bson:"excludingDate"` + ExcludingRecurrenceld []string `json:"excludingRecurrenceld" bson:"excludingRecurrenceld"` + CreatedAt string `json:"createdAt" bson:"createdAt"` + UpdatedAt string `json:"updatedAt" bson:"updatedAt"` + Extension []_struct.Extension `json:"extension" bson:"extension"` } diff --git a/pkg/models/mongo/encounter/encounter.go b/pkg/models/mongo/encounter/encounter.go index 0c2e4ba..642d64d 100644 --- a/pkg/models/mongo/encounter/encounter.go +++ b/pkg/models/mongo/encounter/encounter.go @@ -6,60 +6,78 @@ import ( ) type Encounter struct { - ResourceType string `json:"resourceType,omitempty" bson:"resourceType,omitempty"` - ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` - Identifier []_struct.Identifier `json:"identifier,omitempty" bson:"identifier,omitempty"` - Status string `json:"status,omitempty" bson:"status,omitempty"` - Class _struct.CodeableConcept `json:"class,omitempty" bson:"class,omitempty"` - Type []_struct.CodeableConcept `json:"type,omitempty" bson:"type,omitempty"` - ServiceType _struct.CodeableConcept `json:"serviceType,omitempty" bson:"serviceType,omitempty"` - Priority _struct.CodeableConcept `json:"priority,omitempty" bson:"priority,omitempty"` - Subject _struct.Reference `json:"subject,omitempty" bson:"subject,omitempty"` - EpisodeOfCare []_struct.Reference `json:"episodeOfCare,omitempty" bson:"episodeOfCare,omitempty"` - BasedOn []_struct.Reference `json:"basedOn,omitempty" bson:"basedOn,omitempty"` - Participant []EncounterParticipant `json:"participant,omitempty" bson:"participant,omitempty"` - Appointment []_struct.Reference `json:"appointment,omitempty" bson:"appointment,omitempty"` - Period _struct.Period `json:"period,omitempty" bson:"period,omitempty"` - Length _struct.Quantity `json:"length,omitempty" bson:"length,omitempty"` - ReasonCode []_struct.CodeableConcept `json:"reasonCode,omitempty" bson:"reasonCode,omitempty"` - Diagnosis []EncounterDiagnosis `json:"diagnosis,omitempty" bson:"diagnosis,omitempty"` - Account []_struct.Reference `json:"account,omitempty" bson:"account,omitempty"` - Hospitalization Hospitalization `json:"hospitalization,omitempty" bson:"hospitalization,omitempty"` - Location []EncounterLocation `json:"location,omitempty" bson:"location,omitempty"` - ServiceProvider _struct.Reference `json:"serviceProvider,omitempty" bson:"serviceProvider,omitempty"` - PartOf _struct.Reference `json:"partOf,omitempty" bson:"partOf,omitempty"` + ResourceType string `json:"resourceType" bson:"resourceType"` + ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` + Identifier []_struct.Identifier `json:"identifier" bson:"identifier"` + Status string `json:"status" bson:"status"` + Class []_struct.CodeableConcept `json:"class" bson:"class"` + Priority _struct.CodeableConcept `json:"priority" bson:"priority"` + Type []_struct.CodeableConcept `json:"type" bson:"type"` + ServiceType []_struct.Value `json:"serviceType" bson:"serviceType"` + Subject _struct.Reference `json:"subject" bson:"subject"` + SubjectStatus _struct.CodeableConcept `json:"subjectStatus" bson:"subjectStatus"` + EpisodeOfCare []_struct.Reference `json:"episodeOfCare" bson:"episodeOfCare"` + BaseOn []_struct.Reference `json:"baseOn" bson:"baseOn"` + CareTeam []_struct.Reference `json:"careTeam" bson:"careTeam"` + PartOf _struct.Reference `json:"partOf" bson:"partOf"` + ServiceProvider _struct.Reference `json:"serviceProvider" bson:"serviceProvider"` + Participant []Participant `json:"participant" bson:"participant"` + Appointment []_struct.Reference `json:"appointment" bson:"appointment"` + VirtualServiceDetail []_struct.VirtualServiceEncounter `json:"virtualServiceDetail" bson:"virtualServiceDetail"` + ActualPeriod _struct.Period `json:"actualPeriod" bson:"actualPeriod"` + PlannedStartDate string `json:"plannedStartDate" bson:"plannedStartDate"` + PlannedEndDate string `json:"plannedEndDate" bson:"plannedEndDate"` + Length Length `json:"length" bson:"length"` + Reason []_struct.Reasonencounter `json:"reason" bson:"reason"` + Diagnosis []_struct.Diagnosis `json:"diagnosis" bson:"diagnosis"` + Account []_struct.Reference `json:"account" bson:"account"` + DietPreference []_struct.CodeableConcept `json:"dietPreference" bson:"dietPreference"` + SpecialArrangement []_struct.CodeableConcept `json:"specialArrangement" bson:"specialArrangement"` + SpecialCourtesy []_struct.CodeableConcept `json:"specialCourtesy" bson:"specialCourtesy"` + Admission Admission `json:"admission" bson:"admission"` + Location []Location `json:"location" bson:"location"` + CreatedAt string `json:"createdAt" bson:"createdAt"` + UpdatedAt string `json:"updatedAt" bson:"updatedAt"` + Extension []_struct.Extension `json:"extension" bson:"extension"` } -// EncounterParticipant mendefinisikan orang yang terlibat dalam pertemuan -type EncounterParticipant struct { - Type []_struct.CodeableConcept `json:"type,omitempty" bson:"type,omitempty"` - Period _struct.Period `json:"period,omitempty" bson:"period,omitempty"` - Individual _struct.Reference `json:"individual,omitempty" bson:"individual,omitempty"` +// Struktur untuk Duration dalam Length +type Duration struct { + System string `json:"system" bson:"system"` + Version string `json:"version" bson:"version"` + Code string `json:"code" bson:"code"` + Display string `json:"display" bson:"display"` + UserSelected string `json:"userSelected" bson:"userSelected"` + Value float64 `json:"value" bson:"value"` + Unit string `json:"unit" bson:"unit"` } -// EncounterDiagnosis mendefinisikan diagnosis yang terkait dengan pertemuan -type EncounterDiagnosis struct { - Condition _struct.Reference `json:"condition,omitempty" bson:"condition,omitempty"` - Use _struct.CodeableConcept `json:"use,omitempty" bson:"use,omitempty"` - Rank int `json:"rank,omitempty" bson:"rank,omitempty"` +// Struktur untuk Length +type Length struct { + Duration Duration `json:"duration" bson:"duration"` } -// Hospitalization mendefinisikan detail tentang rawat inap yang terkait dengan pertemuan -type Hospitalization struct { - PreAdmissionIdentifier _struct.Identifier `json:"preAdmissionIdentifier,omitempty" bson:"preAdmissionIdentifier,omitempty"` - AdmitSource _struct.CodeableConcept `json:"admitSource,omitempty" bson:"admitSource,omitempty"` - ReAdmission _struct.CodeableConcept `json:"reAdmission,omitempty" bson:"reAdmission,omitempty"` - DietPreference []_struct.CodeableConcept `json:"dietPreference,omitempty" bson:"dietPreference,omitempty"` - SpecialCourtesy []_struct.CodeableConcept `json:"specialCourtesy,omitempty" bson:"specialCourtesy,omitempty"` - SpecialArrangement []_struct.CodeableConcept `json:"specialArrangement,omitempty" bson:"specialArrangement,omitempty"` - Destination _struct.Reference `json:"destination,omitempty" bson:"destination,omitempty"` - DischargeDisposition _struct.CodeableConcept `json:"dischargeDisposition,omitempty" bson:"dischargeDisposition,omitempty"` +// Struktur untuk Participant +type Participant struct { + Type []_struct.CodeableConcept `json:"type" bson:"type"` + Period _struct.Period `json:"period" bson:"period"` + Actor _struct.Reference `json:"actor" bson:"actor"` } -// EncounterLocation mendefinisikan lokasi di mana pertemuan terjadi -type EncounterLocation struct { - Location _struct.Reference `json:"location,omitempty" bson:"location,omitempty"` - Status string `json:"status,omitempty" bson:"status,omitempty"` - PhysicalType _struct.CodeableConcept `json:"physicalType,omitempty" bson:"physicalType,omitempty"` - Period _struct.Period `json:"period,omitempty" bson:"period,omitempty"` +// Struktur untuk Location +type Location struct { + Location _struct.Reference `json:"location" bson:"location"` + Status string `json:"status" bson:"status"` + Form _struct.CodeableConcept `json:"form" bson:"form"` + Period _struct.Period `json:"period" bson:"period"` +} + +// Struktur untuk Admission +type Admission struct { + PreAdmissionIdentifier _struct.Identifier `json:"preAdmissionIdentifier" bson:"preAdmissionIdentifier"` + Origin _struct.Reference `json:"origin" bson:"origin"` + AdmitSource _struct.CodeableConcept `json:"admitSource" bson:"admitSource"` + ReadmitSource _struct.CodeableConcept `json:"readmitSource" bson:"readmitSource"` + Destination _struct.Reference `json:"destination" bson:"destination"` + DischargeDisposition _struct.CodeableConcept `json:"dischargeDisposition" bson:"dischargeDisposition"` } diff --git a/pkg/models/mongo/episodeofcare/episodeofcare.go b/pkg/models/mongo/episodeofcare/episodeofcare.go index 362cb72..0e9705d 100644 --- a/pkg/models/mongo/episodeofcare/episodeofcare.go +++ b/pkg/models/mongo/episodeofcare/episodeofcare.go @@ -6,22 +6,22 @@ import ( ) type EpisodeOfCare struct { - ResourceType string `json:"resourceType" bson:"resourceType,omitempty" ` - ID primitive.ObjectID `bson:"_id,omitempty" json:"id" ` - Status bool `json:"status" bson:"status"` - StatusHistory []_struct.StatusHistrory `bson:"statusHistory,omitempty" json:"statusHistory" ` - Type []_struct.CodeableConcept `bson:"type,omitempty" json:"type" ` - Reason []_struct.Reason `bson:"reason,omitempty" json:"reason" ` - Diagnosis []_struct.Diagnosis `bson:"diagnosis,omitempty" json:"diagnosis" ` - Patient _struct.Reference `bson:"patient,omitempty" json:"patient" ` - ManagingOrganization []_struct.Reference `bson:"managingOrganization,omitempty" json:"managingOrganization" ` - Period []_struct.Period `bson:"period,omitempty" json:"period" ` - ReferralRequest _struct.Reference `bson:"referralRequest,omitempty" json:"referralRequest" ` - CareManager _struct.Reference `bson:"careManager,omitempty" json:"careManager" ` - CareTeam _struct.Reference `bson:"careTea,omitempty" json:"careTea" ` - Account _struct.Reference `bson:"account,omitempty" json:"account" ` - CreatedAt string `bson:"createdAt,omitempty" json:"createdAt" ` - UpdatedAt string `bson:"updatedAt,omitempty" json:"updatedAt" ` - DeletedAt string `bson:"deletedAt,omitempty" json:"deletedAt" ` - Extension []_struct.Extension `bson:"extension,omitempty" json:"extension" ` + ResourceType string `json:"resourceType" bson:"resourceType,omitempty" ` + ID primitive.ObjectID `bson:"_id,omitempty" json:"id" ` + Status string `json:"status" bson:"status"` + StatusHistory []_struct.StatusHistrory `bson:"statusHistory,omitempty" json:"statusHistory" ` + Type []_struct.CodeableConcept `bson:"type,omitempty" json:"type" ` + Reason []_struct.Reason `bson:"reason,omitempty" json:"reason" ` + Diagnosis []_struct.Diagnosisepisode `bson:"diagnosis,omitempty" json:"diagnosis" ` + Patient _struct.Reference `bson:"patient,omitempty" json:"patient" ` + ManagingOrganization _struct.Reference `bson:"managingOrganization,omitempty" json:"managingOrganization" ` + Period _struct.Period `bson:"period,omitempty" json:"period" ` + ReferralRequest []_struct.Reference `bson:"referralRequest,omitempty" json:"referralRequest" ` + CareManager _struct.Reference `bson:"careManager,omitempty" json:"careManager" ` + CareTeam []_struct.Reference `bson:"careTea,omitempty" json:"careTea" ` + Account []_struct.Reference `bson:"account,omitempty" json:"account" ` + CreatedAt string `bson:"createdAt,omitempty" json:"createdAt" ` + UpdatedAt string `bson:"updatedAt,omitempty" json:"updatedAt" ` + DeletedAt string `bson:"deletedAt,omitempty" json:"deletedAt" ` + Extension []_struct.Extension `bson:"extension,omitempty" json:"extension" ` } diff --git a/pkg/models/mongo/master/masteraddress/masteraddress.go b/pkg/models/mongo/master/masteraddress/masteraddress.go index 6c529bf..3e3c660 100644 --- a/pkg/models/mongo/master/masteraddress/masteraddress.go +++ b/pkg/models/mongo/master/masteraddress/masteraddress.go @@ -135,3 +135,27 @@ type Tribe struct { CreatedAt string `bson:"createdAt" json:"createdAt"` UpdatedAt string `bson:"updatedAt" json:"updatedAt"` } + +type Icdmongo struct { + ResourceType string `json:"resourceType" bson:"resourceType,omitempty" ` + ID primitive.ObjectID `bson:"_id,omitempty" json:"id" ` + Identifier []_struct.Identifier `bson:"identifier" json:"identifier"` + Status string `bson:"status" json:"status"` + Name string `bson:"name" json:"name"` + Description string `bson:"description" json:"description"` + Comment string `bson:"comment" json:"comment"` + Period _struct.Period `bson:"period" json:"period"` + CreatedAt string `bson:"createdAt" json:"createdAt"` + UpdatedAt string `bson:"updatedAt" json:"updatedAt"` +} + +type Smfmongo struct { + ResourceType string `json:"resourceType" bson:"resourceType,omitempty" ` + ID primitive.ObjectID `bson:"_id,omitempty" json:"id" ` + Identifier []_struct.Identifier `bson:"identifier" json:"identifier"` + Status string `bson:"status" json:"status"` + Name string `bson:"name" json:"name"` + Period _struct.Period `bson:"period" json:"period"` + CreatedAt string `bson:"createdAt" json:"createdAt"` + UpdatedAt string `bson:"updatedAt" json:"updatedAt"` +} diff --git a/pkg/models/simrs/icd.go b/pkg/models/simrs/icd.go index a24bf83..3433763 100644 --- a/pkg/models/simrs/icd.go +++ b/pkg/models/simrs/icd.go @@ -1,6 +1,6 @@ package simrs -type Icd10 struct { +type Icd struct { IDIcd string `gorm:"column:id_idicd" json:"id_icd"` NamaIcd string `gorm:"column:nm_icd" json:"nama_icd"` DesJenisPenyakit string `gorm:"column:des_deskripsijenispenyakit" json:"des_jenis_penyakit"` diff --git a/pkg/models/simrs/practitioner.go b/pkg/models/simrs/practitioner.go index 5ce1af8..7e0329d 100644 --- a/pkg/models/simrs/practitioner.go +++ b/pkg/models/simrs/practitioner.go @@ -3,14 +3,15 @@ package simrs type Practitionerdoktersimrs struct { IDDokter string `gorm:"column:id_kddokter" json:"kd_dokter"` KDPoly string `gorm:"column:id_kdpoly" json:"kdpoly"` - NIP string `gorm:"column:id_kodedpjp" json:"kodedpjp"` + KodeDpjp string `gorm:"column:id_kodedpjp" json:"kodedpjp"` + NIP string `gorm:"column:id_nip" json:"nip"` Aktif string `gorm:"column:st_aktif" json:"aktif"` NamaDokter string `gorm:"column:nm_namadokter" json:"nama_dokter"` NomorHP string `gorm:"column:te_nomorhp" json:"nomor_hp"` Email string `gorm:"column:te_email" json:"email"` QuSIP string `gorm:"column:qu_sip" json:"qu_sip"` QuSPK string `gorm:"column:qu_spk" json:"qu_spk"` - SMF string `gorm:"column:EX_smf" json:"smf"` + SMF string `gorm:"column:ex_smf" json:"smf"` Kategori string `gorm:"column:ex_kategori" json:"kategori"` } diff --git a/pkg/models/simrs/smf.go b/pkg/models/simrs/smf.go new file mode 100644 index 0000000..50a43bc --- /dev/null +++ b/pkg/models/simrs/smf.go @@ -0,0 +1,8 @@ +package simrs + +type Smfsimrs struct { + IDsmf string `gorm:"column:id_idsmf" json:"id_smf"` + Kodesmf string `gorm:"column:id_kodesmf" json:"kodesmf"` + Namasmf string `gorm:"column:nm_namasmf" json:"namasmf"` + Stsmf string `gorm:"column:st_smf" json:"stsmf"` +} diff --git a/pkg/models/struct/fhir.go b/pkg/models/struct/fhir.go index f7e5649..c720a6e 100644 --- a/pkg/models/struct/fhir.go +++ b/pkg/models/struct/fhir.go @@ -5,26 +5,26 @@ type StatusHistrory struct { Period Period `json:"period" ,bson:"period"` } type Identifier struct { - Use string `json:"use,omitempty" bson:"use"` - Type CodeableConcept `json:"type,omitempty" bson:"type"` - System string `json:"system,omitempty" bson:"system"` - Value string `json:"value,omitempty" bson:"value"` - Period Period `json:"period,omitempty" bson:"period"` - Assigner Reference `json:"assigner,omitempty" bson:"assigner"` - Coding Coding `json:"coding,omitempty" bson:"coding,omitempty"` + Use string `json:"use" bson:"use"` + Type CodeableConcept `json:"type" bson:"type"` + System string `json:"system" bson:"system"` + Value string `json:"value" bson:"value"` + Period Period `json:"period" bson:"period"` + Assigner Reference `json:"assigner" bson:"assigner"` + Coding Coding `json:"coding" bson:"coding"` } type CodeableConcept struct { Coding []Coding `json:"coding" bson:"coding"` - Text string `json:"text,omitempty" bson:"text"` + Text string `json:"text" bson:"text"` } type Coding struct { - System string `json:"system,omitempty" bson:"system"` - Version string `json:"version,omitempty" bson:"version"` - Code string `json:"code,omitempty" bson:"code"` - Display string `json:"display,omitempty" bson:"display"` - UserSelected bool `json:"userSelected,omitempty" bson:"userSelected"` + System string `json:"system" bson:"system"` + Version string `json:"version" bson:"version"` + Code string `json:"code" bson:"code"` + Display string `json:"display" bson:"display"` + UserSelected bool `json:"userSelected" bson:"userSelected"` } type Period struct { @@ -33,52 +33,52 @@ type Period struct { } type Reference struct { - Reference string `json:"reference,omitempty" bson:"reference"` - Display string `json:"display,omitempty" bson:"display"` + Reference string `json:"reference" bson:"reference"` + Display string `json:"display" bson:"display"` } type HumanName struct { - Use string `json:"use,omitempty" bson:"use"` - Text string `json:"text,omitempty" bson:"text"` - Family string `json:"family,omitempty" bson:"family"` - Given []string `json:"given,omitempty" bson:"given"` - Prefix []string `json:"prefix,omitempty" bson:"prefix"` - Suffix []string `json:"suffix,omitempty" bson:"suffix"` - Period Period `json:"period,omitempty" bson:"period"` + Use string `json:"use" bson:"use"` + Text string `json:"text" bson:"text"` + Family string `json:"family" bson:"family"` + Given []string `json:"given" bson:"given"` + Prefix []string `json:"prefix" bson:"prefix"` + Suffix []string `json:"suffix" bson:"suffix"` + Period Period `json:"period" bson:"period"` } type ContactPoint struct { System string `bson:"system" json:"system"` Value string `bson:"value" json:"value"` Use string `bson:"use" json:"use"` - Rank int `bson:"rank" json:"rank"` + Rank string `bson:"rank" json:"rank"` Period Period `bson:"period" json:"period"` } type Address struct { - Use string `json:"use,omitempty" bson:"use"` - Type string `json:"type,omitempty" bson:"type"` - Text string `json:"text,omitempty" bson:"text"` - Line []string `json:"line,omitempty" bson:"line"` - Village string `json:"village,omitempty" bson:"village"` - District string `json:"district,omitempty" bson:"district"` - City string `json:"city,omitempty" bson:"city"` - State string `json:"state,omitempty" bson:"state"` - PostalCode string `json:"postalCode,omitempty" bson:"postalCode"` - Country string `json:"country,omitempty" bson:"country"` - Period Period `json:"period,omitempty" bson:"period"` - Extension []Extension `json:"extension,omitempty" bson:"extension"` + Use string `json:"use" bson:"use"` + Type string `json:"type" bson:"type"` + Text string `json:"text" bson:"text"` + Line []string `json:"line" bson:"line"` + Village string `json:"village" bson:"village"` + District string `json:"district" bson:"district"` + City string `json:"city" bson:"city"` + State string `json:"state" bson:"state"` + PostalCode string `json:"postalCode" bson:"postalCode"` + Country string `json:"country" bson:"country"` + Period Period `json:"period" bson:"period"` + Extension []Extension `json:"extension" bson:"extension"` } type Extension struct { - URL string `json:"url,omitempty" bson:"url` - Extension []ExtensionDetail `json:"extension,omitempty" bson:"extension"` + URL string `json:"url" bson:"url"` + Extension []ExtensionDetail `json:"extension" bson:"extension"` } type ExtensionDetail struct { - URL string `json:"url,omitempty" bson:"url,omitempty"` - ValueDisplay string `json:"valueDisplay,omitempty" bson:"valueDisplay"` - ValueCode string `json:"valueCode,omitempty" bson:"valueCode"` + URL string `json:"url" bson:"url"` + ValueDisplay string `json:"valueDisplay" bson:"valueDisplay"` + ValueCode string `json:"valueCode" bson:"valueCode"` } type Photo struct { @@ -98,42 +98,36 @@ type Photo struct { } type Contact struct { - Relationship []CodeableConcept `json:"relationship,omitempty" bson:"relationship"` - Name HumanName `json:"name,omitempty" bson:"name"` - Telecom []ContactPoint `json:"telecom,omitempty" bson:"telecom"` - Address Address `json:"address,omitempty" bson:"address"` - Gender string `json:"gender,omitempty" bson:"gender"` - Organization Reference `json:"organization,omitempty" bson:"organization"` - Period Period `json:"period,omitempty" bson:"period"` + Relationship []CodeableConcept `json:"relationship" bson:"relationship"` + Name HumanName `json:"name" bson:"name"` + Telecom []ContactPoint `json:"telecom" bson:"telecom"` + Address Address `json:"address" bson:"address"` + Gender string `json:"gender" bson:"gender"` + Organization Reference `json:"organization" bson:"organization"` + Period Period `json:"period" bson:"period"` } type Communication struct { - Language CodeableConcept `json:"language,omitempty" bson:"language"` - Text string `json:"text,omitempty" bson:"text"` + Language CodeableConcept `json:"language" bson:"language"` } type Link struct { - Other Reference `json:"other,omitempty" bson:"other"` - Type string `json:"type,omitempty" bson:"type"` + Other Reference `json:"other" bson:"other"` + Type string `json:"type" bson:"type"` } type LinkTarget struct { - Target Reference `json:"target,omitempty" bson:"target,omitempty"` - Type string `json:"type,omitempty" bson:"type,omitempty"` + Target Reference `json:"target" bson:"target,omitempty"` + Type string `json:"type" bson:"type,omitempty"` } type ExtendedContactDetail struct { - Purpose Purpose `json:"purpose" bson:"purpose"` - Name []HumanName `json:"name,omitempty" bson:"name"` - Telecom []ContactPoint `json:"telecom,omitempty" bson:"telecom"` - Address []Address `json:"address,omitempty" bson:"address"` - Organization Reference `json:"organization,omitempty" bson:"organization"` - Period Period `json:"period,omitempty" bson:"period"` -} - -type Purpose struct { - Purpose CodeableConcept `json:"purpose" bson:"purpose"` - Coding []Coding `json:"coding" bson:"coding"` + Purpose CodeableConcept `json:"purpose" bson:"purpose"` + Name []HumanName `json:"name" bson:"name"` + Telecom []ContactPoint `json:"telecom" bson:"telecom"` + Address []Address `json:"address" bson:"address"` + Organization Reference `json:"organization" bson:"organization"` + Period Period `json:"period" bson:"period"` } type Reason struct { @@ -142,6 +136,12 @@ type Reason struct { Reference Reference `json:"reference" bson:"reference"` } +type Reasonencounter struct { + Use []CodeableConcept `json:"use" bson:"use"` + Value []Value `json:"value" bson:"value"` + Reference Reference `json:"reference" bson:"reference"` +} + type Value struct { Concept CodeableConcept `json:"concept" bson:"concept"` Reference Reference `json:"reference" bson:"reference"` @@ -151,24 +151,29 @@ type Diagnosis struct { Condition []Value `json:"condition" bson:"condition"` Use []CodeableConcept `json:"use" bson:"use"` } + +type Diagnosisepisode struct { + Condition []Value `json:"condition" bson:"condition"` + Use CodeableConcept `json:"use" bson:"use"` +} type Quantity struct { - Value float64 `json:"value,omitempty" bson:"value,omitempty"` - Comparator string `json:"comparator,omitempty" bson:"comparator,omitempty"` - Unit string `json:"unit,omitempty" bson:"unit,omitempty"` - System string `json:"system,omitempty" bson:"system,omitempty"` - Code string `json:"code,omitempty" bson:"code,omitempty"` + Value float64 `json:"value" bson:"value"` + Comparator string `json:"comparator" bson:"comparator"` + Unit string `json:"unit" bson:"unit"` + System string `json:"system" bson:"system"` + Code string `json:"code" bson:"code"` } type Qualification struct { - Identifier []Identifier `json:"identifier,omitempty" bson:"identifier,omitempty"` - Code CodeableConcept `json:"code,omitempty" bson:"code,omitempty"` - Period Period `json:"period,omitempty" bson:"period,omitempty"` - Issuer Reference `json:"issuer,omitempty" bson:"issuer,omitempty"` + Identifier []Identifier `json:"identifier" bson:"identifier"` + Code CodeableConcept `json:"code" bson:"code"` + Period Period `json:"period" bson:"period"` + Issuer Reference `json:"issuer" bson:"issuer"` } type Code struct { Code []CodeableConcept `json:"code" bson:"code"` - Comment string `json:"comment,omitempty" bson:"comment,omitempty"` + Comment string `json:"comment" bson:"comment"` } type Position struct { Longitude float64 `json:"longitude,omitempty" bson:"longitude,omitempty"` @@ -194,16 +199,63 @@ type AvailabilityNotAvailable struct { } type VirtualService struct { - ChannelType Coding `json:"channelType,omitempty" bson:"channelType,omitempty"` - AddressUrl string `json:"addressUrl,omitempty" bson:"addressUrl,omitempty"` - AddressString string `json:"addressString,omitempty" bson:"addressString,omitempty"` - AddressContactPoint ContactPoint `json:"addressContactPoint,omitempty" bson:"addressContactPoint,omitempty"` - AddressExtendedContact ExtendedContactDetail `json:"addressExtendedContact,omitempty" bson:"addressExtendedContact,omitempty"` - AdditionalInfo []string `json:"additionalInfo,omitempty" bson:"additionalInfo,omitempty"` - MaxParticipants int `json:"maxParticipants,omitempty" bson:"maxParticipants,omitempty"` - SessionKey string `json:"sessionKey,omitempty" bson:"sessionKey,omitempty"` + ChannelType Coding `json:"channelType" bson:"channelType"` + AddressUrl string `json:"addressUrl" bson:"addressUrl"` + AddressString string `json:"addressString" bson:"addressString"` + AddressContactPoint ContactPoint `json:"addressContactPoint" bson:"addressContactPoint"` + AddressExtendedContact ExtendedContactDetail `json:"addressExtendedContact" bson:"addressExtendedContact"` + AdditionalInfo []string `json:"additionalInfo" bson:"additionalInfo"` + MaxParticipants int `json:"maxParticipants" bson:"maxParticipants"` + SessionKey string `json:"sessionKey" bson:"sessionKey"` } +type VirtualServiceappoinmet struct { + ChannelType Coding `json:"channelType" bson:"channelType"` + Address Addressappoint `json:"address" bson:"address"` + AdditionalInfo []string `json:"additionalInfo" bson:"additionalInfo"` + MaxParticipants int `json:"maxParticipants" bson:"maxParticipants"` + SessionKey string `json:"sessionKey" bson:"sessionKey"` +} + +type Addressappoint struct { + AddressUrl string `json:"addressUrl" bson:"addressUrl"` + AddressString string `json:"addressString" bson:"addressString"` + AddressContactPoint ContactPoint `json:"addressContactPoint" bson:"addressContactPoint"` + AddressExtendedContactDetail ExtendedContactDetailappoint `json:"addressExtendedContactDetail" bson:"addressExtendedContactDetail"` +} + +type ExtendedContactDetailappoint struct { + Purpose CodeableConcept `json:"purpose" bson:"purpose"` + Name []HumanName `json:"name" bson:"name"` + Telecom []ContactPoint `json:"telecom" bson:"telecom"` + Address []Address `json:"address" bson:"address"` + Organization Reference `json:"organization" bson:"organization"` + Period Period `json:"period" bson:"period"` +} + +type VirtualServiceEncounter struct { + ChannelType Coding `json:"channelType" bson:"channelType"` + Address AddressEncounter `json:"address" bson:"address"` + AdditionalInfo []string `json:"additionalInfo" bson:"additionalInfo"` + MaxParticipants int `json:"maxParticipants" bson:"maxParticipants"` + SessionKey string `json:"sessionKey" bson:"sessionKey"` +} + +type AddressEncounter struct { + AddressUrl string `json:"addressUrl" bson:"addressUrl"` + AddressString string `json:"addressString" bson:"addressString"` + AddressContactPoint ContactPoint `json:"addressContactPoint" bson:"addressContactPoint"` + AddressExtendedContactDetail ExtendedContactDetailEncounter `json:"addressExtendedContactDetail" bson:"addressExtendedContactDetail"` +} + +type ExtendedContactDetailEncounter struct { + Purpose CodeableConcept `json:"purpose" bson:"purpose"` + Name []HumanName `json:"name" bson:"name"` + Telecom []ContactPoint `json:"telecom" bson:"telecom"` + Address Address `json:"address" bson:"address"` // Single address, not array + Organization Reference `json:"organization" bson:"organization"` + Period Period `json:"period" bson:"period"` +} type Payload struct { Type CodeableConcept `json:"type,omitempty" bson:"type,omitempty"` Mimetype []string `json:"mimetype,omitempty" bson:"mimetype,omitempty"` @@ -242,17 +294,18 @@ type RecurrenceTemple struct { } type WeeklyTemple struct { - Monday bool `json:"monday" bson:"monday"` - Tuesday bool `json:"tuesday" bson:"tuesday"` - Wednesday bool `json:"wednesday" bson:"wednesday"` - Thursday bool `json:"thursday" bson:"thursday"` - Friday bool `json:"friday" bson:"friday"` - Saturday bool `json:"saturday" bson:"saturday"` - Sunday bool `json:"sunday" bson:"sunday"` + Monday bool `json:"monday" bson:"monday"` + Tuesday bool `json:"tuesday" bson:"tuesday"` + Wednesday bool `json:"wednesday" bson:"wednesday"` + Thursday bool `json:"thursday" bson:"thursday"` + Friday bool `json:"friday" bson:"friday"` + Saturday bool `json:"saturday" bson:"saturday"` + Sunday bool `json:"sunday" bson:"sunday"` + WeekInterval string `json:"weekInterval" bson:"weekInterval"` } type MonthlyTemple struct { - DayOfmonth bool `json:"dayOfmonth" bson:"dayOfmonth"` + DayOfmonth string `json:"dayOfMonth" bson:"dayOfMonth"` NthWeekOfMonth Coding `json:"nthWeekOfMonth" bson:"nthWeekOfMonth"` DayOfWeek Coding `json:"dayOfWeek" bson:"dayOfWeek"` MonthInterval int `json:"monthInterval" bson:"monthInterval"`