diff --git a/internal/server/routes.go b/internal/server/routes.go index 2ca1909..d67b380 100644 --- a/internal/server/routes.go +++ b/internal/server/routes.go @@ -1,9 +1,15 @@ package server import ( - patientHandler "api-poliklinik/pkg/handlers/Patient" + patientHandler "api-poliklinik/pkg/handlers/MongoHandler/Patient" + patientRelatedHandler "api-poliklinik/pkg/handlers/MongoHandler/PatientRelated" + 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" datapractitionerHandler "api-poliklinik/pkg/handlers/Practitioner" + dataAlamatHandler "api-poliklinik/pkg/handlers/address" + MigrasiHandler "api-poliklinik/pkg/handlers/migrasi" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" "net/http" @@ -11,6 +17,12 @@ import ( 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"}, + AllowHeaders: []string{"Origin", "Content-Type"}, + AllowCredentials: true, + })) r.GET("/", s.HelloWorldHandler) @@ -18,27 +30,85 @@ func (s *Server) RegisterRoutes() http.Handler { v1 := r.Group("/api") + migrasi := v1.Group("/migrasi") + { + migrasi.POST("/migrate/practitioners", MigrasiHandler.MigratePractitionerToFHIR) + migrasi.POST("/migrate/pasien", MigrasiHandler.MigratePasienToFHIR) + } + Poliklinik := v1.Group("/poliklinik") { Poliklinik.GET("/getdata/statuspelayanan/:statuspelayanan", datapoliklinikHandler.GetDataPoliklinik) } - Practitioner := v1.Group("/practitioner") + + Practitioner := v1.Group("/practitionersatu") { Practitioner.GET("/getdata", datapractitionerHandler.GetDataPractitioner) + Practitioner.GET("/getdatapasien", datapractitionerHandler.GetDataMPasien) + + } + Alamat := v1.Group("/Alamat") + { + Alamat.GET("/getdata", dataAlamatHandler.GetDataAlamat) + } + + Relasi := v1.Group("/relasi") + { + Relasi.POST("/insertpatientrelatedperson", patientRelatedHandler.InsertPatientRelated) + Relasi.GET("/getdatapatientrelated", patientRelatedHandler.GetAllPatientdanRelated) } patient := v1.Group("/patient") { - patient.POST("/insertpatient", patientHandler.InsertPatient) + //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.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.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", personHandler.GetDataPerson) + //Location.POST("/insertlocation", personHandler.Inse rtPerson) + //Location.POST("/deletelocation", personHandler.DeletePersonHand) + } + + Master := v1.Group("createdocument") + { + Master.GET("/getdatamaster", personHandler.GetDataPerson) } - r.Use(cors.New(cors.Config{ - AllowOrigins: []string{"*"}, // or specific domains like "http://example.com" - AllowMethods: []string{"GET", "POST", "PUT", "DELETE"}, - AllowHeaders: []string{"Origin", "Content-Type"}, - AllowCredentials: true, - })) return r } diff --git a/pkg/database/mongo/patient.go b/pkg/database/mongo/patient.go index eedd4dc..cb1cf4a 100644 --- a/pkg/database/mongo/patient.go +++ b/pkg/database/mongo/patient.go @@ -1,15 +1,40 @@ package mongo import ( - "api-poliklinik/pkg/models/patient" + patient "api-poliklinik/pkg/models/mongo/insertpatient" + "context" + "fmt" "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo/options" "log" "time" ) -func (s *DatabaseService) InsertPatient(req *patient.Patient) error { +func (s *DatabaseService) GetNextRekamMedikNumber() (string, error) { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + filter := bson.M{"_id": "RekamMedik"} + update := bson.M{"$inc": bson.M{"seq": 1}} + opts := options.FindOneAndUpdate().SetUpsert(true).SetReturnDocument(options.After) + + var result struct { + Seq int `bson:"seq"` + } + + err := s.DBMongo.Collection("counters").FindOneAndUpdate(ctx, filter, update, opts).Decode(&result) + if err != nil { + log.Println("Error generating rekamedik number:", err) + return "", err + } + + // Format nomor menjadi 7 digit, misalnya "0002032" + return fmt.Sprintf("%012d", result.Seq), nil +} + +func (s *DatabaseService) InsertPatient(req patient.Patient) error { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() _, err := s.DBMongo.Collection("patient").InsertOne(ctx, req) @@ -20,6 +45,42 @@ func (s *DatabaseService) InsertPatient(req *patient.Patient) error { return nil } +func (s *DatabaseService) GetPatientByIdentifier(display string, value string) ([]*patient.Patient, error) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + filter := bson.M{ + "identifier": bson.M{ + "$elemMatch": bson.M{ + "type.coding.display": display, + "value": value, + }, + }, + } + + cursor, err := s.DBMongo.Collection("patientbaru").Find(ctx, filter) + if err != nil { + log.Println(err) + return nil, err + } + defer cursor.Close(ctx) + var results []*patient.Patient + if err = cursor.All(ctx, &results); err != nil { + log.Println(err) + return nil, err + } + return results, nil +} + +//filter := bson.M{ +//"identifier": bson.M{ +//"$elemMatch": bson.M{ +//"type.coding.display": display, +//"value": value, +//}, +//}, +//} + func (s *DatabaseService) GetAllDataPatient(limit int64, skip int64) ([]*patient.Patient, error) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() @@ -27,7 +88,10 @@ func (s *DatabaseService) GetAllDataPatient(limit int64, skip int64) ([]*patient findOptions.SetLimit(limit) findOptions.SetSkip(skip) - dataUser, err := s.DBMongo.Collection("patient").Find(ctx, bson.D{}, findOptions) + filter := bson.M{ + "active": true, + } + dataUser, err := s.DBMongo.Collection("patient").Find(ctx, filter, findOptions) if err != nil { log.Println(err) } @@ -39,3 +103,61 @@ func (s *DatabaseService) GetAllDataPatient(limit int64, skip int64) ([]*patient } return users, nil } + +func (s *DatabaseService) UpdatePatient(id string, req *patient.UpdatePatient) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + // Konversi id menjadi ObjectID + objectID, err := primitive.ObjectIDFromHex(id) + if err != nil { + log.Println(err) + return err + } + + req.ID = "" // Kosongkan ID agar tidak ikut terupdate + + filter := bson.M{"_id": objectID} + + update := bson.M{ + "$set": req, + } + + _, err = s.DBMongo.Collection("patientbaru").UpdateOne(ctx, filter, update) + if err != nil { + log.Println(err) + return err + } + + return nil +} + +func (s *DatabaseService) DeletePatient(id string, req *patient.DeletePatient) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + // Konversi id menjadi ObjectID + objectID, err := primitive.ObjectIDFromHex(id) + if err != nil { + log.Println(err) + return err + } + + req.ID = "" // Kosongkan ID agar tidak ikut terupdate + + filter := bson.M{"_id": objectID} + + update := bson.M{ + "$set": bson.M{ + "active": req.Active, + }, + } + + _, err = s.DBMongo.Collection("patientbaru").UpdateOne(ctx, filter, update) + if err != nil { + log.Println(err) + return err + } + + return nil +} diff --git a/pkg/database/mongo/patientrelated.go b/pkg/database/mongo/patientrelated.go new file mode 100644 index 0000000..e156b7f --- /dev/null +++ b/pkg/database/mongo/patientrelated.go @@ -0,0 +1,170 @@ +package mongo + +import ( + patient "api-poliklinik/pkg/models/mongo/insertpatient" + "api-poliklinik/pkg/models/mongo/person" + relatedperson "api-poliklinik/pkg/models/mongo/relatedperson" + _struct "api-poliklinik/pkg/models/struct" + + "context" + "fmt" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo/options" + "log" + "strings" + "time" +) + +func addRekamMedikIdentifier(identifierList *[]_struct.Identifier, rekamMedikNumber string) { + identifier := _struct.Identifier{ + Use: "usual", + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + Code: "RM", + Display: "RekamMedik", + UserSelected: true, + }, + }, + Text: "RM", + }, + Value: rekamMedikNumber, + Period: _struct.Period{ + Start: time.Now().Format("2006-01-02"), + }, + Assigner: _struct.Reference{}, + } + *identifierList = append(*identifierList, identifier) +} + +func (s *DatabaseService) GetAllDataPatientWithRelated(limit int64, skip int64) ([]*relatedperson.Getrelatedperson, error) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + findOptions := options.Find() + findOptions.SetLimit(limit) + findOptions.SetSkip(skip) + + cursor, err := s.DBMongo.Collection("patientbaru").Find(ctx, bson.D{}, findOptions) + if err != nil { + log.Println(err) + return nil, err + } + defer cursor.Close(ctx) + + var patients []*patient.Patient + if err := cursor.All(ctx, &patients); err != nil { + log.Println(err) + return nil, err + } + + var results []*relatedperson.Getrelatedperson + for _, patientData := range patients { + dataGabungan := &relatedperson.Getrelatedperson{ + Patient: *patientData, + } + + if len(patientData.Link) > 0 { + refStr := patientData.Link[0].Other.Reference + idStr := strings.TrimPrefix(refStr, "RelatedPerson/") + if objectID, err := primitive.ObjectIDFromHex(idStr); err == nil { + var relatedPerson relatedperson.RelatedPerson + err := s.DBMongo.Collection("relatedperson").FindOne(ctx, bson.M{"_id": objectID}).Decode(&relatedPerson) + if err == nil { + dataGabungan.RelatedPerson = relatedPerson + } + } + } + + results = append(results, dataGabungan) + } + + return results, nil +} + +func (s *DatabaseService) InsertPatientlagi(req patient.Patient) (primitive.ObjectID, error) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + result, err := s.DBMongo.Collection("patientbaru").InsertOne(ctx, req) + if err != nil { + log.Println(err) + return primitive.NilObjectID, err + } + + oid, ok := result.InsertedID.(primitive.ObjectID) + if !ok { + return primitive.NilObjectID, fmt.Errorf("Failed to assert insertedID to ObjectID") + } + + return oid, nil +} + +func (s *DatabaseService) UpdateIDpatient(id primitive.ObjectID, related patient.Patient) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + filter := bson.M{"_id": id} + update := bson.M{"$set": related} + _, err := s.DBMongo.Collection("patientbaru").UpdateOne(ctx, filter, update) + return err +} + +/* PUNYA RELATED PERSON */ +func (s *DatabaseService) CreateRelatedperson(req relatedperson.RelatedPerson) (primitive.ObjectID, error) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + result, err := s.DBMongo.Collection("relatedperson").InsertOne(ctx, req) + if err != nil { + log.Println(err) + return primitive.NilObjectID, err + } + + oid, ok := result.InsertedID.(primitive.ObjectID) + if !ok { + return primitive.NilObjectID, fmt.Errorf("Failed to assert insertedID to ObjectID") + } + + return oid, nil +} + +func (s *DatabaseService) UpdateIDrelated(id primitive.ObjectID, related relatedperson.RelatedPerson) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + filter := bson.M{"_id": id} + update := bson.M{"$set": related} + _, err := s.DBMongo.Collection("relatedperson").UpdateOne(ctx, filter, update) + return err +} + +/* PUNYA PERSON */ +func (s *DatabaseService) InsertPERSON(req person.Person) (primitive.ObjectID, error) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + result, err := s.DBMongo.Collection("person").InsertOne(ctx, req) + if err != nil { + log.Println(err) + return primitive.NilObjectID, err + } + + oid, ok := result.InsertedID.(primitive.ObjectID) + if !ok { + return primitive.NilObjectID, fmt.Errorf("Failed to assert insertedID to ObjectID") + } + + return oid, nil +} + +func (s *DatabaseService) UpdateIDperson(id primitive.ObjectID, related person.Person) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + filter := bson.M{"_id": id} + update := bson.M{"$set": related} + _, err := s.DBMongo.Collection("person").UpdateOne(ctx, filter, update) + return err +} diff --git a/pkg/database/mongo/person.go b/pkg/database/mongo/person.go new file mode 100644 index 0000000..f8c562a --- /dev/null +++ b/pkg/database/mongo/person.go @@ -0,0 +1,41 @@ +package mongo + +import ( + "api-poliklinik/pkg/models/mongo/person" + "context" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo/options" + "log" + "time" +) + +func (s *DatabaseService) GetAllPerson(limit int64, skip int64) ([]*person.Person, error) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + findOptions := options.Find() + findOptions.SetLimit(limit) + findOptions.SetSkip(skip) + + dataUser, err := s.DBMongo.Collection("person").Find(ctx, bson.D{}, findOptions) + if err != nil { + log.Println(err) + } + var users []*person.Person + err = dataUser.All(ctx, &users) + if err != nil { + log.Println(err) + return nil, err + } + return users, nil +} + +func (s *DatabaseService) InsertPerson(req *person.Person) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + _, err := s.DBMongo.Collection("person").InsertOne(ctx, req) + if err != nil { + log.Println(err) + return err + } + return nil +} diff --git a/pkg/database/mongo/practitioner.go b/pkg/database/mongo/practitioner.go new file mode 100644 index 0000000..a746fdb --- /dev/null +++ b/pkg/database/mongo/practitioner.go @@ -0,0 +1,30 @@ +package mongo + +import ( + "api-poliklinik/pkg/models/mongo/practitioner" + "context" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo/options" + "log" + "time" +) + +func (s *DatabaseService) GetAllPractitioner(limit int64, skip int64) ([]*practitioner.Practitioner, error) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + findOptions := options.Find() + findOptions.SetLimit(limit) + findOptions.SetSkip(skip) + + dataUser, err := s.DBMongo.Collection("practitioner").Find(ctx, bson.D{}, findOptions) + if err != nil { + log.Println(err) + } + var users []*practitioner.Practitioner + err = dataUser.All(ctx, &users) + if err != nil { + log.Println(err) + return nil, err + } + return users, nil +} diff --git a/pkg/database/mongo/practitionermigrasi.go b/pkg/database/mongo/practitionermigrasi.go new file mode 100644 index 0000000..ecbf61c --- /dev/null +++ b/pkg/database/mongo/practitionermigrasi.go @@ -0,0 +1,19 @@ +package mongo + +import ( + "api-poliklinik/pkg/models/mongo/practitioner" + "context" + "log" + "time" +) + +func (s *DatabaseService) InsertPractitioner(req practitioner.Practitioner) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + _, err := s.DBMongo.Collection("practitioner").InsertOne(ctx, req) + if err != nil { + log.Println(err) + return err + } + return nil +} diff --git a/pkg/database/mongo/relatedperson.go b/pkg/database/mongo/relatedperson.go new file mode 100644 index 0000000..a855a1d --- /dev/null +++ b/pkg/database/mongo/relatedperson.go @@ -0,0 +1,73 @@ +package mongo + +import ( + "api-poliklinik/pkg/models/mongo/relatedperson" + "context" + "fmt" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo/options" + "log" + "time" +) + +func (s *DatabaseService) GetAllDataRelatedPerson(limit int64, skip int64) ([]*relatedperson.RelatedPerson, error) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + findOptions := options.Find() + findOptions.SetLimit(limit) + findOptions.SetSkip(skip) + + dataUser, err := s.DBMongo.Collection("relatedperson").Find(ctx, bson.D{}, findOptions) + if err != nil { + log.Println(err) + } + var users []*relatedperson.RelatedPerson + err = dataUser.All(ctx, &users) + if err != nil { + log.Println(err) + return nil, err + } + return users, nil +} + +func (s *DatabaseService) InsertRelatedPerson(req *relatedperson.RelatedPerson) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + _, err := s.DBMongo.Collection("relatedperson").InsertOne(ctx, req) + if err != nil { + log.Println(err) + return err + } + return nil +} + +func (s *DatabaseService) DeleteRelatedPerson(id string, req *relatedperson.DeletedataRelatedPerson) error { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + objectID, err := primitive.ObjectIDFromHex(id) + if err != nil { + log.Println("Invalid ID:", err) + return err + } + (*req).ID = "" + filter := bson.M{"_id": objectID} + update := bson.M{ + "$set": bson.M{ + "active": req.Active, + }, + } + + res, err := s.DBMongo.Collection("relatedperson").UpdateOne(ctx, filter, update) + if err != nil { + log.Println("Error updating document:", err) + return err + } + + if res.MatchedCount == 0 { + return fmt.Errorf("no document found with id: %s", id) + } + + return nil +} diff --git a/pkg/database/satu_data/address.go b/pkg/database/satu_data/address.go index de0536e..2236934 100644 --- a/pkg/database/satu_data/address.go +++ b/pkg/database/satu_data/address.go @@ -7,10 +7,18 @@ import ( "log" ) -func (s *DatabaseService) GetDataAddress(Status_pelayanan string) []*satu_data.PoliklinikGetData { - var dataaddress []*satu_data.PoliklinikGetData - query := `select dlr."Nama",dlr."Kode",dlr."id" from daftar_lokasi_ruang dlr where dlr."Status_pelayanan" = ?` - errQuery := s.DB.Debug().Raw(query, Status_pelayanan).Scan(&dataaddress).Error +func (s *DatabaseService) GetDataAddress() []*satu_data.GetWilayah { + var dataaddress []*satu_data.GetWilayah + query := `SELECT mp.idprovinsi, mp.namaprovinsi, + mko.idkota, mko.namakota, + mkc.idkecamatan, mkc.namakecamatan, + mke.idkelurahan, mke.namakelurahan +FROM m_provinsi mp +JOIN m_kota mko ON mp.idprovinsi = mko.idprovinsi +JOIN m_kecamatan mkc ON mko.idkota = mkc.idkota +JOIN m_kelurahan mke ON mkc.idkecamatan = mke.idkecamatan +LIMIT 10` + errQuery := s.DB.Debug().Raw(query).Scan(&dataaddress).Error if errQuery != nil { if errors.Is(errQuery, gorm.ErrRecordNotFound) { errMsg := errors.New("Data Tidak Ditemukan") diff --git a/pkg/database/satu_data/pasien.go b/pkg/database/satu_data/pasien.go new file mode 100644 index 0000000..629d892 --- /dev/null +++ b/pkg/database/satu_data/pasien.go @@ -0,0 +1,45 @@ +package satu_data + +import ( + "api-poliklinik/pkg/models/migrasipatient" + "errors" + "gorm.io/gorm" + + "log" +) + +func (s *DatabaseService) GetPasien() []*migrasipatient.MPasienSIMRS { + var datapasien []*migrasipatient.MPasienSIMRS + query := `select + mp.id as id_id, mp.nomr as id_nomr, mp.noktp as id_noktp, mp.no_kartu as id_nomorkartu, mp.sim as id_sim, mp.paspor as id_paspor, + mp.title as nm_title, mp.nama as nm_nama, + mp.no_hp as te_teleponhp, mp.notelprumah1 as te_teleponrumah1, mp.notelprumah2 as te_teleponrumah2, mp.notelpkantor as te_telkantor, + mp.tgllahir as bd_tgllahir, + mp.jeniskelamin as jk_jeniskelamin, + mp.alamat as ad_alamat, mp.alamat_ktp as ad_alamatktp, mp.txt_kelurahan as ad_kelurahan, + mp.txt_kecamatan as ad_kecamatan, mp.txt_kelurahan as ad_kelurahan, mp.txt_kota as ad_kota, mp.txt_provinsi as ad_provinsi, + mp.kdkecamatan as adid_kecamatan, mp.kelurahan as adid_kelurahan, mp.kota as adid_kota, mp.kdprovinsi as adid_provinsi, + mp.penanggungjawab_nama as ctpj_nama, mp.penanggungjawab_hubungan as ctpj_hubungan, mp.penanggungjawab_alamat as ctpj_alamat, + mp.penanggungjawab_phone as ctpj_telepon, mp.nama_ayah as ctpj_namaayah, mp.nama_ibu as ctpj_namaibu, + mp.pendidikan_ayah as ctpjid_pendidikanayah, mpp2.nama_pendidikan as ctpj_pendidikanayah, + mp.pendidikan_ibu as ctpj_pendidikanibu, mpp3.nama_pendidikan as ctpj_pendidikanibu, + mp.ktp_file as pt_ktpfile, mp.kk_file as pt_kkfile, + mp.bahasa as com_bahasa, + mp.pendidikan as exid_pendidikan, mpp.nama_pendidikan as ex_pendidikan, mp.disabilitas as ex_disabiltas, mp.kebangsaan as ex_kebangsaan, mp.suku as ex_suku, mp.agama as exid_agama, map.nama_agama as ex_agama, mp.created_at as ex_createat, mp.updated_at as ex_updateat + from m_pasien mp + join m_pendidikan_pasien mpp on mp.pendidikan = mpp.id_pendidikan + join m_agama_pasien map on mp.agama = map.id_agama + join m_pendidikan_pasien mpp2 on cast(mp.pendidikan_ayah as int8) = mpp2.id_pendidikan + left join m_pendidikan_pasien mpp3 on cast(mp.pendidikan_ibu as int8) = mpp3.id_pendidikan limit 10 ` + errQuery := s.DB.Debug().Raw(query).Scan(&datapasien).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 datapasien +} diff --git a/pkg/handlers/MongoHandler/Patient/patient.go b/pkg/handlers/MongoHandler/Patient/patient.go new file mode 100644 index 0000000..607c14e --- /dev/null +++ b/pkg/handlers/MongoHandler/Patient/patient.go @@ -0,0 +1,261 @@ +package Patient + +import ( + "api-poliklinik/internal/database" + "api-poliklinik/pkg/database/mongo" + patient "api-poliklinik/pkg/models/mongo/insertpatient" + _struct "api-poliklinik/pkg/models/struct" + "github.com/gin-gonic/gin" + "net/http" + "os" + "strconv" + "time" +) + +//func InsertPatient(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 *patient.Patient +// err := c.Bind(&req) +// if err != nil { +// c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()}) +// return +// } +// +// rekamMedikNumber, err := mongoDB.GetNextRekamMedikNumber() +// if err != nil { +// c.JSON(http.StatusInternalServerError, gin.H{"message": "Failed to generate rekamedik number"}) +// return +// } +// +// req.Identifier = append(req.Identifier, _struct.Identifier{ +// Use: "usual", +// Type: _struct.CodeableConcept{ +// Coding: []_struct.Coding{ +// { +// Code: "RM", +// Display: "RekamMedik", +// UserSelected: true, +// }, +// }, +// Text: "RM", +// }, +// Value: rekamMedikNumber, +// Period: _struct.Period{ +// Start: time.Now().Format("2006-01-02"), +// }, +// Assigner: _struct.Reference{}, +// }) +// +// dateCreated := time.Now().Format("2006-01-02 15:04:05") +// updateCreated := time.Now().Format("2006-01-02 15:04:05") +// +// if len(req.Extension) > 0 { +// req.Extension[0].Extension = append(req.Extension[0].Extension, +// _struct.ExtensionDetail{ +// URL: "createdAt", +// ValueDisplay: dateCreated, +// ValueCode: "", +// }, +// _struct.ExtensionDetail{ +// URL: "updatedAt", +// ValueDisplay: updateCreated, +// ValueCode: "", +// }, +// ) +// } +// errInsert := mongoDB.InsertPatient(req) +// if errInsert != nil { +// c.JSON(http.StatusInternalServerError, gin.H{"message": errInsert.Error()}) +// return +// } +// c.JSON(http.StatusOK, gin.H{ +// "data": rekamMedikNumber, +// "message": "Pasien berhasil di Buat", +// }) +//} + +func GetDataBY(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) + dataBy, err := mongoDB.GetPatientByIdentifier(display, value) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()}) + return + } + + c.JSON(http.StatusOK, gin.H{ + "data": dataBy, + "message": "Pasien Dengan noRM berhasil di cari", + }) +} + +func GetAllPatient(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 + } + + // 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) + dataPatient, errSelect := mongoDB.GetAllDataPatient(limit, skip) + if errSelect != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{ + "data": dataPatient, + "message": "Pasien Sukses Ter-ambil ", + }) +} + +//func GetDataIdentifier(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 *patient.GetBY +// err := c.Bind(&req) +// if err != nil { +// c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()}) +// } +// if len(req.Identifier) == 0 || len(req.Identifier[0].Type.Coding) == 0 { +// c.JSON(http.StatusBadRequest, gin.H{"message": "Identifier incomplete"}) +// return +// } +// display := req.Identifier[0].Type.Coding[0].Display +// value := req.Identifier[0].Value +// +// data, err := mongoDB.GetPatientByIdentifier(display, value) +// if err != nil { +// c.JSON(http.StatusNotFound, gin.H{"message": err.Error()}) +// return +// } +// c.JSON(http.StatusOK, data) +//} + +func UpdatePatient(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 *patient.UpdatePatient + err := c.Bind(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()}) + return + } + id := req.ID + if id == "" { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Patient ID is empty"}) + return + } + req.ResourceType = "Patient" + dateCreated := time.Now().Format("2006-01-02 15:04:05") + updateCreated := time.Now().Format("2006-01-02 15:04:05") + + if len(req.Extension) > 0 { + req.Extension[0].Extension = append(req.Extension[0].Extension, + _struct.ExtensionDetail{ + URL: "createdAt", + ValueDisplay: dateCreated, + ValueCode: "", + }, + _struct.ExtensionDetail{ + URL: "updateAt", + ValueDisplay: updateCreated, + ValueCode: "", + }, + ) + } + errUpdate := mongoDB.UpdatePatient(id, req) + if errUpdate != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errUpdate.Error()}) + return + } + + c.JSON(http.StatusOK, gin.H{"message": "Pasien Sukses Ter-Update "}) +} + +func DeletePatient(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 *patient.DeletePatient + err := c.Bind(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()}) + return + } + id := req.ID + if id == "" { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Patient ID is empty"}) + return + } + deletedAt := time.Now().Format("2006-01-02 15:04:05") + + if len(req.Extension) > 0 { + req.Extension[0].Extension = append(req.Extension[0].Extension, + _struct.ExtensionDetail{ + URL: "deletedAt", + ValueDisplay: deletedAt, + ValueCode: "", + }, + ) + } + + errUpdate := mongoDB.DeletePatient(id, req) + if errUpdate != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errUpdate.Error()}) + return + } + + c.JSON(http.StatusOK, gin.H{"message": "Pasien Sukses Ter-hapus"}) +} diff --git a/pkg/handlers/MongoHandler/PatientRelated/patientrelated.go b/pkg/handlers/MongoHandler/PatientRelated/patientrelated.go new file mode 100644 index 0000000..01fc515 --- /dev/null +++ b/pkg/handlers/MongoHandler/PatientRelated/patientrelated.go @@ -0,0 +1,205 @@ +package PatientRelated + +import ( + "api-poliklinik/internal/database" + "api-poliklinik/pkg/database/mongo" + patient "api-poliklinik/pkg/models/mongo/insertpatient" + "api-poliklinik/pkg/models/mongo/person" + "api-poliklinik/pkg/models/mongo/relatedperson" + _struct "api-poliklinik/pkg/models/struct" + "github.com/gin-gonic/gin" + "net/http" + "os" + "time" +) + +func addRekamMedikIdentifier(identifierList *[]_struct.Identifier, rekamMedikNumber string) { + identifier := _struct.Identifier{ + Use: "usual", + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + Code: "RM", + Display: "RekamMedik", + UserSelected: true, + }, + }, + Text: "RM", + }, + Value: rekamMedikNumber, + Period: _struct.Period{ + Start: time.Now().Format("2006-01-02"), + }, + Assigner: _struct.Reference{}, + } + *identifierList = append(*identifierList, identifier) +} + +func InsertPatientRelated(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"}) + } + var payload struct { + PATIENT patient.Patient `json:"patient"` + RELATED relatedperson.RelatedPerson `json:"relatedPerson"` + PERSON person.Person `json:"person"` + } + if err := c.Bind(&payload); err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()}) + return + } + mongoDB := mongo.NewDatabaseServiceMongo(db) + + payload.PATIENT.ResourceType = "Patient" + payload.RELATED.ResourceType = "relatePerson" + payload.PERSON.ResourceType = "person" + + rekamMedikNumber, err := mongoDB.GetNextRekamMedikNumber() + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Failed to generate rekamedik number"}) + return + } + + addRekamMedikIdentifier(&payload.PATIENT.Identifier, rekamMedikNumber) + + addRekamMedikIdentifier(&payload.PERSON.Identifier, rekamMedikNumber) + + relatedID, errCreate := mongoDB.CreateRelatedperson(payload.RELATED) + if errCreate != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errCreate.Error()}) + return + } + + patientID, errCreate := mongoDB.InsertPatientlagi(payload.PATIENT) + if errCreate != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errCreate.Error()}) + return + } + personID, errCreate := mongoDB.InsertPERSON(payload.PERSON) + if errCreate != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errCreate.Error()}) + return + } + + // assign ObjectID ke patient + payload.PATIENT.Link = []_struct.Link{ + { + Other: _struct.Reference{ + Reference: "RelatedPerson/" + relatedID.Hex(), + Display: "", + }, + Type: "", + }, + } + payload.PERSON.Link = []_struct.LinkTarget{ + { + Target: _struct.Reference{ + Reference: "Patient/" + patientID.Hex(), + Display: "", + }, + Type: "", + }, + } + + payload.RELATED.Link = []_struct.Link{ + { + Other: _struct.Reference{ + Reference: "Person/" + personID.Hex(), + Display: "", + }, + Type: "", + }, + } + + payload.RELATED.Patient = _struct.Reference{ + Reference: "Patient/" + patientID.Hex(), + Display: "", + } + + dateCreated := time.Now().Format("2006-01-02 15:04:05") + updateCreated := time.Now().Format("2006-01-02 15:04:05") + + if len(payload.PATIENT.Extension) > 0 { + payload.PATIENT.Extension[0].Extension = append(payload.PATIENT.Extension[0].Extension, + _struct.ExtensionDetail{ + URL: "dateCreated", + ValueDisplay: dateCreated, + ValueCode: "", + }, + _struct.ExtensionDetail{ + URL: "UpdateCreated", + ValueDisplay: updateCreated, + ValueCode: "", + }, + ) + } + + if len(payload.RELATED.Extension) > 0 { + payload.RELATED.Extension[0].Extension = append(payload.RELATED.Extension[0].Extension, + _struct.ExtensionDetail{ + URL: "dateCreated", + ValueDisplay: dateCreated, + ValueCode: "", + }, + _struct.ExtensionDetail{ + URL: "UpdateCreated", + ValueDisplay: updateCreated, + ValueCode: "", + }, + ) + } + + if len(payload.PERSON.Extension) > 0 { + payload.PERSON.Extension[0].Extension = append(payload.PERSON.Extension[0].Extension, + _struct.ExtensionDetail{ + URL: "dateCreated", + ValueDisplay: dateCreated, + ValueCode: "", + }, + _struct.ExtensionDetail{ + URL: "UpdateCreated", + ValueDisplay: updateCreated, + ValueCode: "", + }, + ) + } + + if err := mongoDB.UpdateIDpatient(patientID, payload.PATIENT); err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Failed to update patient with link"}) + return + } + if err := mongoDB.UpdateIDrelated(relatedID, payload.RELATED); err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Failed to update relatedPerson with reference"}) + return + } + + if err := mongoDB.UpdateIDperson(personID, payload.PERSON); err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Failed to update relatedPerson with reference"}) + return + } + + c.JSON(http.StatusOK, gin.H{"message": "Patient ,RelatedPerson, Person Sukses di buat"}) +} + +func GetAllPatientdanRelated(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 + } + + limit := int64(0) // atau ambil dari query param + skip := int64(0) + + mongoDB := mongo.NewDatabaseServiceMongo(db) + data, err := mongoDB.GetAllDataPatientWithRelated(limit, skip) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()}) + return + } + + c.JSON(http.StatusOK, data) +} diff --git a/pkg/handlers/MongoHandler/person/person.go b/pkg/handlers/MongoHandler/person/person.go new file mode 100644 index 0000000..f37f36c --- /dev/null +++ b/pkg/handlers/MongoHandler/person/person.go @@ -0,0 +1,130 @@ +package person + +import ( + "api-poliklinik/internal/database" + "api-poliklinik/pkg/database/mongo" + person "api-poliklinik/pkg/models/mongo/person" + _struct "api-poliklinik/pkg/models/struct" + "github.com/gin-gonic/gin" + "net/http" + "os" + "strconv" + "time" +) + +func GetDataPerson(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 + } + + // 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) + dataPerson, errSelect := mongoDB.GetAllPerson(limit, skip) + if errSelect != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{ + "message": "success", + "data": dataPerson, + }) +} + +func InsertPerson(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 *person.Person + err := c.Bind(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()}) + return + } + + rekamMedikNumber, err := mongoDB.GetNextRekamMedikNumber() + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": "Failed to generate rekamedik number"}) + return + } + + // Cek apakah identifier dengan tipe "RM" (Rekamedik) sudah ada + identifierExists := false + for i, identifier := range req.Identifier { + if identifier.Type.Text == "RM" { // Jika ada "RM", update value-nya + req.Identifier[i].Value = rekamMedikNumber + identifierExists = true + break + } + } + + // Jika tidak ada "RM", tambahkan identifier Rekamedik baru + if !identifierExists { + req.Identifier = append(req.Identifier, _struct.Identifier{ + Use: "usual", + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + Code: "RM", + Display: "RekamMedik", + UserSelected: true, + }, + }, + Text: "RM", + }, + Value: rekamMedikNumber, + Period: _struct.Period{ + Start: time.Now().Format("2006-01-02"), + }, + Assigner: _struct.Reference{}, + }) + } + + dateCreated := time.Now().Format("2006-01-02 15:04:05") + updateCreated := time.Now().Format("2006-01-02 15:04:05") + + if len(req.Extension) > 0 { + req.Extension[0].Extension = append(req.Extension[0].Extension, + _struct.ExtensionDetail{ + URL: "dateCreated", + ValueDisplay: dateCreated, + ValueCode: "", + }, + _struct.ExtensionDetail{ + URL: "UpdateCreated", + ValueDisplay: updateCreated, + ValueCode: "", + }, + ) + } + errInsert := mongoDB.InsertPerson(req) + if errInsert != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errInsert.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{ + "data": rekamMedikNumber, + "message": "Person Dengan noRM berhasil di Buat", + }) +} diff --git a/pkg/handlers/MongoHandler/practitioner/practitioner.go b/pkg/handlers/MongoHandler/practitioner/practitioner.go new file mode 100644 index 0000000..594c695 --- /dev/null +++ b/pkg/handlers/MongoHandler/practitioner/practitioner.go @@ -0,0 +1,46 @@ +package practitioner + +import ( + "api-poliklinik/internal/database" + "api-poliklinik/pkg/database/mongo" + "github.com/gin-gonic/gin" + "net/http" + "os" + "strconv" +) + +func GetDataPractitioner(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 + } + + // 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) + dataPractitioner, errSelect := mongoDB.GetAllPractitioner(limit, skip) + if errSelect != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{ + "message": "success", + "data": dataPractitioner, + }) +} diff --git a/pkg/handlers/MongoHandler/relatedperson/relatedperson.go b/pkg/handlers/MongoHandler/relatedperson/relatedperson.go new file mode 100644 index 0000000..824db02 --- /dev/null +++ b/pkg/handlers/MongoHandler/relatedperson/relatedperson.go @@ -0,0 +1,133 @@ +package relatedperson + +import ( + "api-poliklinik/internal/database" + "api-poliklinik/pkg/database/mongo" + relatedperson "api-poliklinik/pkg/models/mongo/relatedperson" + _struct "api-poliklinik/pkg/models/struct" + "github.com/gin-gonic/gin" + "net/http" + "os" + "strconv" + "time" +) + +func GetDataRelatedPerson(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 + } + + // 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) + dataRelatedPerson, errSelect := mongoDB.GetAllDataRelatedPerson(limit, skip) + if errSelect != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()}) + return + } + c.JSON(http.StatusOK, dataRelatedPerson) +} + +func InsertRelatedPerson(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 *relatedperson.RelatedPerson + err := c.Bind(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()}) + return + } + req.ResourceType = "RelatedPerson" + dateCreated := time.Now().Format("2006-01-02 15:04:05") + updateCreated := time.Now().Format("2006-01-02 15:04:05") + + if len(req.Extension) > 0 { + req.Extension[0].Extension = append(req.Extension[0].Extension, + _struct.ExtensionDetail{ + URL: "dateCreated", + ValueDisplay: dateCreated, + ValueCode: "", + }, + _struct.ExtensionDetail{ + URL: "UpdateCreated", + ValueDisplay: updateCreated, + ValueCode: "", + }, + ) + } + errInsert := mongoDB.InsertRelatedPerson(req) + if errInsert != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errInsert.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{"message": "RelatedPerson successfully inserted"}) +} + +func DeleteRelatedPersonHand(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 *relatedperson.DeletedataRelatedPerson + err := c.Bind(&req) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()}) + return + } + id := req.ID + if id == "" { + c.JSON(http.StatusInternalServerError, gin.H{"message": "RelatedPerson ID is empty"}) + return + } + dateCreated := time.Now().Format("2006-01-02 15:04:05") + updateCreated := time.Now().Format("2006-01-02 15:04:05") + + if len(req.Extension) > 0 { + req.Extension[0].Extension = append(req.Extension[0].Extension, + _struct.ExtensionDetail{ + URL: "dateCreated", + ValueDisplay: dateCreated, + ValueCode: "", + }, + _struct.ExtensionDetail{ + URL: "UpdateCreated", + ValueDisplay: updateCreated, + ValueCode: "", + }, + ) + } + + errUpdate := mongoDB.DeleteRelatedPerson(id, req) + if errUpdate != nil { + c.JSON(http.StatusInternalServerError, gin.H{"message": errUpdate.Error()}) + return + } + + c.JSON(http.StatusOK, gin.H{"message": "Related Person successfully Deleted"}) +} diff --git a/pkg/handlers/Patient/patient.go b/pkg/handlers/Patient/patient.go deleted file mode 100644 index 4014d73..0000000 --- a/pkg/handlers/Patient/patient.go +++ /dev/null @@ -1,72 +0,0 @@ -package Patient - -import ( - "api-poliklinik/internal/database" - "api-poliklinik/pkg/database/mongo" - "api-poliklinik/pkg/models/patient" - "github.com/gin-gonic/gin" - "net/http" - "os" - "strconv" - "time" -) - -func InsertPatient(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 *patient.Patient - err := c.Bind(&req) - if err != nil { - c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()}) - return - } - - dateCreated := time.Now().Format("2006-01-02 15:04:05") - req.ResourceType = "Patient" - req.CreatedAt = dateCreated - - errInsert := mongoDB.InsertPatient(req) - if errInsert != nil { - c.JSON(http.StatusInternalServerError, gin.H{"message": errInsert.Error()}) - return - } - c.JSON(http.StatusOK, gin.H{"message": "Patient successfully inserted"}) -} - -func GetAllPatient(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 - } - - // Default values - limit := int64(10) - 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) - dataPatient, errSelect := mongoDB.GetAllDataPatient(limit, skip) - if errSelect != nil { - c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()}) - return - } - c.JSON(http.StatusOK, dataPatient) -} diff --git a/pkg/handlers/Practitioner/Practitioner.go b/pkg/handlers/Practitioner/Practitioner.go index 0f2e081..b2457f4 100644 --- a/pkg/handlers/Practitioner/Practitioner.go +++ b/pkg/handlers/Practitioner/Practitioner.go @@ -36,3 +36,12 @@ func GetDataPractitioner(c *gin.Context) { c.JSON(http.StatusOK, responsePractitioner) } + +func GetDataMPasien(c *gin.Context) { + db := database.New().GetDB("simrs") + simrs := connDatabase.NewDatabaseService(db) + + dataMPasien := simrs.GetPasien() + c.JSON(http.StatusOK, dataMPasien) + +} diff --git a/pkg/handlers/address/address.go b/pkg/handlers/address/address.go new file mode 100644 index 0000000..4e99e64 --- /dev/null +++ b/pkg/handlers/address/address.go @@ -0,0 +1,19 @@ +package address + +import ( + "api-poliklinik/internal/database" + connDatabase "api-poliklinik/pkg/database/satu_data" + "github.com/gin-gonic/gin" + "log" + "net/http" +) + +func GetDataAlamat(c *gin.Context) { + db := database.New().GetDB("simrs") + simrs := connDatabase.NewDatabaseService(db) + + log.Println("REQUEST") + dataAlamat := simrs.GetDataAddress() + + c.JSON(http.StatusOK, dataAlamat) +} diff --git a/pkg/handlers/migrasi/episodeofcare/episodeofcare.go b/pkg/handlers/migrasi/episodeofcare/episodeofcare.go new file mode 100644 index 0000000..2af2aa2 --- /dev/null +++ b/pkg/handlers/migrasi/episodeofcare/episodeofcare.go @@ -0,0 +1,142 @@ +package episodeofcare + +//fhirEpisode := &models.EpisodeOfCare{ +//ResourceType: "EpisodeOfCare", +//ID: primitive.NewObjectID(), +//Status: "active", +//} +// +//// StatusHistory +//fhirEpisode.StatusHistory = []_struct.StatusHistory{ +//{ +//Status: "planned", +//Period: _struct.Period{ +//Start: "", +//End: "", +//}, +//}, +//} +// +//// Type +//fhirEpisode.Type = []_struct.CodeableConcept{ +//{ +//Coding: []_struct.Coding{ +//{ +//System: "http://terminology.hl7.org/CodeSystem/episodeofcare-type", +//Version: "", +//Code: "hacc", +//Display: "Home and Community Care", +//UserSelected: false, +//}, +//}, +//Text: "Rawat Jalan", +//}, +//} +// +//// Reason +//fhirEpisode.Reason = []_struct.EpisodeReason{ +//{ +//Use: _struct.CodeableConcept{ +//Coding: []_struct.Coding{ +//{ +//System: "", +//Version: "", +//Code: "", +//Display: "", +//UserSelected: false, +//}, +//}, +//Text: "", +//}, +//Value: []_struct.Reference{ +//{ +//Reference: "", +//Display: "", +//}, +//}, +//}, +//} +// +//// Diagnosis +//fhirEpisode.Diagnosis = []_struct.EpisodeDiagnosis{ +//{ +//Condition: []_struct.CodeableReference{ +//{ +//Concept: _struct.CodeableConcept{ +//Coding: []_struct.Coding{ +//{ +//System: "", +//Version: "", +//Code: "", +//Display: "", +//UserSelected: false, +//}, +//}, +//Text: "", +//}, +//Reference: "Condition/diabetes-001", +//Display: "Diabetes Mellitus Tipe 2", +//}, +//}, +//Use: _struct.CodeableConcept{ +//Coding: []_struct.Coding{ +//{ +//System: "http://terminology.hl7.org/CodeSystem/diagnosis-role", +//Version: "", +//Code: "AD", +//Display: "Admission diagnosis", +//UserSelected: false, +//}, +//}, +//Text: "", +//}, +//}, +//} +// +//// Patient +//fhirEpisode.Patient = _struct.Reference{ +//Reference: "Patient/pasien-001", +//Display: "Budi Santoso", +//} +// +//// ManagingOrganization +//fhirEpisode.ManagingOrganization = _struct.Reference{ +//Reference: "Organization/rsud-saifulanwar", +//Display: "RSUD Dr. Saiful Anwar", +//} +// +//// Period +//fhirEpisode.Period = _struct.Period{ +//Start: "", +//End: "", +//} +// +//// ReferralRequest +//fhirEpisode.ReferralRequest = []_struct.Reference{ +//{ +//Reference: "ServiceRequest/rujukan-001", +//Display: "Rujukan dari Puskesmas Sehat", +//}, +//} +// +//// CareManager +//fhirEpisode.CareManager = _struct.Reference{ +//Reference: "Practitioner/dr-andika", +//Display: "dr. Andika Prasetyo, Sp.PD", +//} +// +//// CareTeam +//fhirEpisode.CareTeam = []_struct.Reference{ +//{ +//Reference: "CareTeam/team-interna-001", +//Display: "Tim Medis Penyakit Dalam", +//}, +//} +// +//// Account +//fhirEpisode.Account = []_struct.Reference{ +//{ +//Reference: "Account/tagihan-001", +//Display: "Tagihan Rawat Inap Mei 2025", +//}, +//} diff --git a/pkg/handlers/migrasi/location/location.go b/pkg/handlers/migrasi/location/location.go new file mode 100644 index 0000000..19edfaf --- /dev/null +++ b/pkg/handlers/migrasi/location/location.go @@ -0,0 +1,401 @@ +package location + +// +// +//// Membuat instance Location +//fhirLocation := &models.Location{ +//ResourceType: "Location", +//ID: primitive.NewObjectID(), +//} +// +//// Identifier +//fhirLocation.Identifier = []_struct.Identifier{ +//{ +//Use: "official", +//Type: _struct.CodeableConcept{ +//Coding: []_struct.Coding{ +//{ +//System: "", +//Version: "", +//Code: "", +//Display: "ID m_ruang SIMRS", +//UserSelected: true, +//}, +//}, +//Text: "ID m_ruang SIMRS", +//}, +//System: "", +//Value: "227", +//Period: _struct.Period{ +//Start: "", +//End: "", +//}, +//Assigner: _struct.Reference{ +//Reference: "", +//Display: "", +//}, +//}, +//{ +//Use: "official", +//Type: _struct.CodeableConcept{ +//Coding: []_struct.Coding{ +//{ +//System: "", +//Version: "", +//Code: "", +//Display: "Kode Ruang", +//UserSelected: true, +//}, +//}, +//Text: "Kode Ruang", +//}, +//System: "", +//Value: "KL-BDH", +//Period: _struct.Period{ +//Start: "", +//End: "", +//}, +//Assigner: _struct.Reference{ +//Reference: "", +//Display: "", +//}, +//}, +//} +// +//// Status +//fhirLocation.Status = "active" +// +//// OperationalStatus +//fhirLocation.OperationalStatus = _struct.Coding{ +//System: "", +//Version: "", +//Code: "", +//Display: "", +//UserSelected: false, +//} +// +//// Name +//fhirLocation.Name = "Poliklinik Bedah TKV" +// +//// Alias +//fhirLocation.Alias = []string{"Poli Bedah TKV", "Klinik Bedah TKV", "Bedah TKV"} +// +//// Description +//fhirLocation.Description = "Lokasi layanan rawat jalan untuk pasien bedah TKV" +// +//// Mode +//fhirLocation.Mode = "instance" +// +//// Type +//fhirLocation.Type = []_struct.CodeableConcept{ +//{ +//Coding: []_struct.Coding{ +//{ +//System: "http://terminology.hl7.org/CodeSystem/v3-RoleCode", +//Version: "", +//Code: "SU", +//Display: "Surgery clinic", +//UserSelected: false, +//}, +//}, +//Text: "Poliklinik Rawat Jalan", +//}, +//{ +//Coding: []_struct.Coding{ +//{ +//System: "", +//Version: "", +//Code: "IRJA", +//Display: "Instalasi Rawat Jalan", +//UserSelected: false, +//}, +//}, +//Text: "Instalasi Rawat Jalan", +//}, +//{ +//Coding: []_struct.Coding{ +//{ +//System: "", +//Version: "", +//Code: "SUBSISTEM", +//Display: "Rawat Jalan Reguler", +//UserSelected: false, +//}, +//}, +//Text: "Rawat Jalan Reguler", +//}, +//} +// +//// Contact +//fhirLocation.Contact = []_struct.ExtendedContactDetail{ +//{ +//Purpose: _struct.CodeableConcept{ +//Coding: []_struct.Coding{ +//{ +//System: "http://terminology.hl7.org/CodeSystem/contactentity-type", +//Code: "PATINF", +//Display: "Patient", +//}, +//}, +//}, +//Telecom: []_struct.ContactPoint{ +//{ +//System: "pager", +//Value: "1243", +//Use: "work", +//Rank: 1, +//Period: _struct.Period{ +//Start: "", +//End: "", +//}, +//}, +//}, +//Address: _struct.Address{ +//Use: "work", +//Type: "both", +//Text: "Jl. Jaksa Agung Suprapto No.2, Klojen, Kec. Klojen, Kota Malang, Jawa Timur 65112", +//Line: []string{"Jl. Jaksa Agung Suprapto No.2"}, +//Village: "Klojen", +//District: "Klojen", +//City: "Malang", +//State: "Jawa Timur", +//PostalCode: "65112", +//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: "", +//}, +//}, +//}, +//}, +//}, +//Period: _struct.Period{ +//Start: "", +//End: "", +//}, +//}, +//} +// +//// Address +//fhirLocation.Address = _struct.Address{ +//Use: "work", +//Type: "both", +//Text: "Jl. Jaksa Agung Suprapto No.2, Klojen, Kec. Klojen, Kota Malang, Jawa Timur 65112", +//Line: []string{"Jl. Jaksa Agung Suprapto No.2"}, +//Village: "Klojen", +//District: "Klojen", +//City: "Malang", +//State: "Jawa Timur", +//PostalCode: "65112", +//Country: "Indonesia", +//Period: _struct.Period{ +//Start: "", +//End: "", +//}, +//} +// +//// Form +//fhirLocation.Form = []_struct.CodeableConcept{ +//{ +//Coding: []_struct.Coding{ +//{ +//System: "", +//Version: "", +//Code: "", +//Display: "", +//UserSelected: false, +//}, +//}, +//Text: "", +//}, +//} +// +//// Position +//fhirLocation.Position = _struct.Position{ +//Longitude: 112.630348, +//Latitude: -7.981894, +//Altitude: 440, +//} +// +//// ManagingOrganization +//fhirLocation.ManagingOrganization = _struct.Reference{ +//Reference: "Organization/1", +//Display: "RSUD dr. Saiful Anwar Jatim Prov", +//} +// +//// PartOf +//fhirLocation.PartOf = _struct.Reference{ +//Reference: "", +//Display: "", +//} +// +//// Characteristic +//fhirLocation.Characteristic = []_struct.CodeableConcept{ +//{ +//Coding: []_struct.Coding{ +//{ +//System: "", +//Version: "", +//Code: "", +//Display: "", +//UserSelected: false, +//}, +//}, +//Text: "", +//}, +//} +// +//// HoursOfOperation +//fhirLocation.HoursOfOperation = []_struct.HoursOfOperation{ +//{ +//AvailableTime: []_struct.AvailableTime{ +//{ +//DaysOfWeek: []string{"mon", "tue", "wed", "thu", "fri"}, +//AllDay: false, +//AvailableStartTime: "07:00", +//AvailableEndTime: "15:00", +//}, +//}, +//NotAvailableTime: []_struct.NotAvailableTime{ +//{ +//Description: "", +//During: _struct.During{ +//Period: _struct.Period{ +//Start: "", +//End: "", +//}, +//}, +//}, +//}, +//}, +//} +// +//// VirtualService +//fhirLocation.VirtualService = []_struct.VirtualService{ +//{ +//ChannelType: _struct.Coding{ +//System: "", +//Version: "", +//Code: "", +//Display: "", +//UserSelected: false, +//}, +//AddressUrl: "", +//AddressString: "", +//AddressContactPoint: _struct.ContactPoint{ +//System: "", +//Value: "", +//Use: "", +//Rank: 0, +//Period: _struct.Period{ +//Start: "", +//End: "", +//}, +//}, +//AddressExtendedContactDetail: _struct.ExtendedContactDetail{ +//Purpose: _struct.CodeableConcept{ +//Coding: []_struct.Coding{ +//{ +//System: "", +//Code: "", +//Display: "", +//}, +//}, +//}, +//Name: []_struct.HumanName{ +//{ +//Use: "", +//Text: "", +//Family: "", +//Given: []string{}, +//Prefix: []string{}, +//Suffix: []string{}, +//Period: _struct.Period{ +//Start: "", +//End: "", +//}, +//}, +//}, +//Telecom: []_struct.ContactPoint{ +//{ +//System: "", +//Value: "", +//Use: "", +//Rank: 0, +//Period: _struct.Period{ +//Start: "", +//End: "", +//}, +//}, +//}, +//Address: _struct.Address{ +//Use: "", +//Type: "", +//Text: "", +//Line: []string{}, +//City: "", +//District: "", +//State: "", +//PostalCode: "", +//Country: "", +//Period: _struct.Period{ +//Start: "", +//End: "", +//}, +//}, +//Organization: _struct.Reference{ +//Reference: "", +//Display: "", +//}, +//Period: _struct.Period{ +//Start: "", +//End: "", +//}, +//}, +//AdditionalInfo: []string{}, +//MaxParticipants: 0, +//SessionKey: "", +//}, +//} +// +//// Endpoint +//fhirLocation.Endpoint = []_struct.Reference{ +//{ +//Reference: "", +//Display: "", +//}, +//} diff --git a/pkg/handlers/migrasi/migrasi.go b/pkg/handlers/migrasi/migrasi.go new file mode 100644 index 0000000..e5b491c --- /dev/null +++ b/pkg/handlers/migrasi/migrasi.go @@ -0,0 +1,718 @@ +package migrasi + +import ( + "api-poliklinik/internal/database" + "api-poliklinik/pkg/database/mongo" + connDatabase "api-poliklinik/pkg/database/satu_data" + "api-poliklinik/pkg/models/mongo/insertpatient" + Practitionermongo "api-poliklinik/pkg/models/mongo/practitioner" + _struct "api-poliklinik/pkg/models/struct" + "api-poliklinik/utils" + "github.com/gin-gonic/gin" + "go.mongodb.org/mongo-driver/bson/primitive" + "log" + "net/http" + "os" + "strings" + "time" +) + +func MigratePractitionerToFHIR(c *gin.Context) { + // 1. Ambil data dari PostgreSQL + db := database.New().GetDB("satudata") + satudata := connDatabase.NewDatabaseService(db) + + // Mendapatkan data praktisi dari PostgreSQL + dataPractitioner := satudata.PractitionerGetData() + if dataPractitioner == nil || len(dataPractitioner) == 0 { + c.JSON(http.StatusNotFound, gin.H{ + "status": "error", + "message": "Tidak ada data praktisi untuk dimigrasi", + }) + return + } + + // 2. Setup koneksi MongoDB - berdasarkan contoh yang diberikan + 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) + + // 3. Transformasi dan migrasi data + migratedCount := 0 + failedCount := 0 + var migratedIDs []string + + for _, practitioner := range dataPractitioner { + // Membuat nama lengkap dengan gelar + gelarDepan := utils.ReplaceGelar(practitioner.GelarDepan) + gelarBelakang := utils.ReplaceGelar(practitioner.GelarBelakang) + namaLengkap := gelarDepan + " " + practitioner.NamaLengkap + " " + gelarBelakang + namaLengkap = strings.TrimPrefix(namaLengkap, " ") + namaLengkap = strings.TrimSuffix(namaLengkap, " ") + + // Mengonversi jenis kelamin ke format FHIR (male/female) + gender := "unknown" + if strings.ToLower(practitioner.JenisKelamin) == "laki-laki" { + gender = "male" + } else if strings.ToLower(practitioner.JenisKelamin) == "perempuan" { + gender = "female" + } + + objectID := primitive.NewObjectID() + + var fhirPractitioner = Practitionermongo.Practitioner{ + ResourceType: "Patient", + ID: objectID, + Identifier: []_struct.Identifier{ + { + Use: "usual", + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "IDSIM", + Display: "SIMRS ID", + UserSelected: true, + }, + }, + Text: "SIMRS ID", + }, + System: "http://example.org/fhir/identifier/nip", + Value: practitioner.ID, + Period: _struct.Period{}, + Assigner: _struct.Reference{}, + }, + { + Use: "usual", + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "NIP", + Display: "Nomor Induk Pegawai", + UserSelected: true, + }, + }, + Text: "Nomor Induk Pegawai", + }, + System: "http://example.org/fhir/identifier/nip", + Value: practitioner.NIP, + Period: _struct.Period{}, + Assigner: _struct.Reference{}, + }, + }, + Active: true, + Name: []_struct.HumanName{ + { + Use: "official", + Text: namaLengkap, + Family: practitioner.NamaLengkap, + Given: []string{gelarDepan, gelarBelakang}, + }, + }, + Gender: gender, + + Extension: []_struct.Extension{ + { + URL: "http://example.org/fhir/StructureDefinition/practitioner-originalData", + Extension: []_struct.ExtensionDetail{ + { + URL: "originalId", + ValueDisplay: practitioner.ID, + }, + { + URL: "sourceSystem", + ValueDisplay: "PostgreSQL", + }, + }, + }, + }, + } // Menyimpan ke MongoDB + err := mongoDB.InsertPractitioner(fhirPractitioner) + if err != nil { + log.Printf("Gagal migrasi data praktisi %s: %v", practitioner.ID, err) + failedCount++ + continue + } + + migratedIDs = append(migratedIDs, objectID.Hex()) + migratedCount++ + } + + // 4. Mengembalikan hasil migrasi + 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), + }) +} + +func MigratePasienToFHIR(c *gin.Context) { + // 1. Ambil data dari PostgreSQL + db := database.New().GetDB("simrs") + simrs := connDatabase.NewDatabaseService(db) + + dataPasien := simrs.GetPasien() + if dataPasien == nil || len(dataPasien) == 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 _, pasien := range dataPasien { + objectID := primitive.NewObjectID() + var given []string + var family string + var text string + + namaSplit := strings.Split(pasien.Nama, " ") + + if len(namaSplit) > 1 { + + family = namaSplit[len(namaSplit)-1] + given = namaSplit[:len(namaSplit)-1] + text = pasien.Nama + } else if len(namaSplit) == 1 { + + family = namaSplit[0] + given = []string{} + text = pasien.Nama + } else { + + family = "" + given = []string{} + text = "" + } + + gender := "unknown" + if strings.ToLower(pasien.JenisKelamin) == "l" { + gender = "male" + } else if strings.ToLower(pasien.JenisKelamin) == "p" { + gender = "female" + } + + var fhirPasien = insertpatient.Patient{ + ResourceType: "Patient", + ID: objectID, + Active: true, + } + // Mengisi properti Identifier + fhirPasien.Identifier = []_struct.Identifier{ + { + Use: "usual", + System: "", + Value: pasien.ID, + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "ID", + Display: "SIMRSID", + }, + }, + Text: "ID", + }, + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + { + Use: "usual", + System: "", + Value: pasien.Nomr, + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "RM", + Display: "RekamMedik", + }, + }, + Text: "RM", + }, + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, { + Use: "usual", + System: "", + Value: pasien.NomorKartu, + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "NK", + Display: "Nomor Kartu", + }, + }, + Text: "NK", + }, + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + { + Use: "usual", + System: "", + Value: pasien.Noktp, + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "NIK", + Display: "Nomor Induk Kependudukan", + }, + }, + Text: "NIK", + }, + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + { + Use: "usual", + System: "", + Value: pasien.SIM, + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "SIM", + Display: "Surat Ijin Mengemudi", + }, + }, + Text: "SIM", + }, + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + { + Use: "usual", + System: "", + Value: pasien.Paspor, + Type: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "Paspor", + Display: "Paspor", + }, + }, + Text: "Paspor", + }, + Period: _struct.Period{ + Start: "", + End: "", + }, + Assigner: _struct.Reference{ + Reference: "", + Display: "", + }, + }, + } + + fhirPasien.Name = []_struct.HumanName{ + { + Use: "usual", + Text: text, + Family: family, + Given: given, + Prefix: []string{pasien.Title}, + Suffix: []string{""}, + Period: _struct.Period{ + Start: "", + End: "", + }, + }, + } + + // Mengisi properti Telecom + fhirPasien.Telecom = []_struct.ContactPoint{ + { + System: "Phone", + Value: pasien.TeleponHp, + Use: "mobile", + Rank: 1, + Period: _struct.Period{ + Start: "", + End: "", + }, + }, + { + System: "Home", + Value: pasien.TeleponRumah, + Use: "Home", + Rank: 2, + Period: _struct.Period{ + Start: "", + End: "", + }, + }, + { + System: "Home2", + Value: pasien.TeleponRumah2, + Use: "Home2", + Rank: 2, + Period: _struct.Period{ + Start: "", + End: "", + }, + }, + { + System: "Office", + Value: pasien.TeleponKantor, + Use: "Office", + Rank: 3, + Period: _struct.Period{ + Start: "", + End: "", + }, + }, + } + + // Mengisi properti Gender + fhirPasien.Gender = gender + + // Mengisi properti BirthDate + fhirPasien.BirthDate = pasien.Tanggallahir + + // Mengisi properti Address + fhirPasien.Address = []_struct.Address{ + { + Use: "home", + Type: "both", + Text: pasien.AlamatKTP, + Line: []string{pasien.AlamatKTP}, + Village: pasien.Kelurahan, + District: pasien.Kecamatan, + City: pasien.Kota, + State: pasien.Provinsi, + PostalCode: "", + Country: "Indonesia", + Period: _struct.Period{ + Start: "", + End: "", + }, + Extension: []_struct.Extension{ + { + URL: "", + Extension: []_struct.ExtensionDetail{ + { + URL: "state", + ValueDisplay: pasien.Provinsi, + ValueCode: pasien.IDProvinsi, + }, { + URL: "city", + ValueDisplay: pasien.Kota, + ValueCode: pasien.Kota, + }, { + URL: "district", + ValueDisplay: pasien.Kecamatan, + ValueCode: pasien.Kecamatan, + }, + { + URL: "village", + ValueDisplay: pasien.Kelurahan, + ValueCode: pasien.Kelurahan, + }, + { + URL: "rw", + ValueDisplay: "", + ValueCode: "", + }, + { + URL: "rw", + ValueDisplay: "", + ValueCode: "", + }, + }, + }, + }, + }, + } + + fhirPasien.MaritalStatus = _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Version: "", + Code: "", + Display: "", + UserSelected: false, + }, + }, + Text: "", + } + + fhirPasien.Contact = []_struct.Contact{ + { + Relationship: []_struct.CodeableConcept{ + { + Coding: []_struct.Coding{ + { + System: "", + Code: "", + Display: pasien.HubunganPenanggungjawab, + }, + }, + Text: "Hubungan Penanggung Jawab", + }, + }, + Name: _struct.HumanName{ + + Use: "usual", + Text: pasien.NamaAyah, + Family: "", + Prefix: []string{""}, + Suffix: []string{""}, + Period: _struct.Period{ + Start: "", + End: "", + }, + }, + Telecom: []_struct.ContactPoint{ + { + System: "phone", + Value: pasien.TeleponPenanggungjawab, + Use: "phone", + }, + }, + Address: _struct.Address{ + Use: "Home", + Type: "", + Text: pasien.AlamatPenanggungjawab, + Line: []string{pasien.AlamatPenanggungjawab}, + City: "", + Country: "", + }, + Gender: "male", + Organization: _struct.Reference{ + Reference: pasien.IDPendidikanAyah, + Display: pasien.PendidikanAyah, + }, + Period: _struct.Period{ + Start: "", + End: "", + }, + }, { + Relationship: []_struct.CodeableConcept{ + { + Coding: []_struct.Coding{ + { + System: "", + Code: "", + Display: pasien.HubunganPenanggungjawab, + }, + }, + Text: "Hubungan Penanggung Jawab", + }, + }, + Name: _struct.HumanName{ + + Use: "usual", + Text: pasien.NamaIbu, + Family: "", + Prefix: []string{""}, + Suffix: []string{""}, + Period: _struct.Period{ + Start: "", + End: "", + }, + }, + Telecom: []_struct.ContactPoint{ + { + System: "phone", + Value: pasien.TeleponPenanggungjawab, + Use: "phone", + }, + }, + Address: _struct.Address{ + Use: "Home", + Type: "", + Text: pasien.AlamatPenanggungjawab, + Line: []string{pasien.AlamatPenanggungjawab}, + City: "", + Country: "", + }, + Gender: "female", + Organization: _struct.Reference{ + Reference: pasien.IDPendidikanIbu, + Display: pasien.PendidikanIbu, + }, + Period: _struct.Period{ + Start: "", + End: "", + }, + }, + } + + fhirPasien.Communication = []_struct.Communication{ + { + Language: _struct.CodeableConcept{ + Coding: []_struct.Coding{ + { + System: "", + Code: "", + Display: pasien.Komunikasi, + }, + }, + Text: "", + }, + Text: "Bahasa" + pasien.Komunikasi, + }, + } + + // Mengisi properti Photo + fhirPasien.Photo = []_struct.Photo{ + { + ContentType: "", + Language: "", + Data: "", + URL: "", + Size: 0, + Hash: 0, + Title: "", + Creation: "", + Height: 0, + Width: 0, + Frames: 0, + Duration: 0, + Pages: 0, + }, + } + + fhirPasien.Link = []_struct.Link{ + { + Other: _struct.Reference{ + Reference: "", + Display: "", + }, + Type: "", + }, + } + + fhirPasien.Extension = []_struct.Extension{ + { + URL: "", + Extension: []_struct.ExtensionDetail{ + { + URL: "CreatedAt", + ValueDisplay: pasien.CreatedAt, + ValueCode: "", + }, { + URL: "UpdateAt", + ValueDisplay: pasien.UpdatedAt, + ValueCode: "", + }, + { + URL: "trible", + ValueDisplay: pasien.Suku, + ValueCode: "", + }, + { + URL: "national", + ValueDisplay: "Warga" + pasien.Kebangsaan, + ValueCode: "", + }, + { + URL: "disabilitas", + ValueDisplay: pasien.Disabiltas, + ValueCode: "", + }, + { + URL: "education", + ValueDisplay: pasien.Pendidikan, + ValueCode: pasien.IDpendidikan, + }, + { + URL: "religion", + ValueDisplay: pasien.Agama, + ValueCode: pasien.IDAgama, + }, + }, + }, + } + err := mongoDB.InsertPatient(fhirPasien) + + if err != nil { + log.Printf("Gagal migrasi data praktisi %s: %v", pasien.ID, 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(dataPasien), + "migrated": migratedCount, + "failed": failedCount, + "migrated_ids": migratedIDs, + "timestamp": time.Now().Format(time.RFC3339), + }) +} diff --git a/pkg/handlers/migrasi/patient/migrasipatient.go b/pkg/handlers/migrasi/patient/migrasipatient.go new file mode 100644 index 0000000..d556cdf --- /dev/null +++ b/pkg/handlers/migrasi/patient/migrasipatient.go @@ -0,0 +1 @@ +package patient diff --git a/pkg/handlers/migrasi/practitioner/practitioner.go b/pkg/handlers/migrasi/practitioner/practitioner.go new file mode 100644 index 0000000..fd7e828 --- /dev/null +++ b/pkg/handlers/migrasi/practitioner/practitioner.go @@ -0,0 +1,420 @@ +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", +//}, +//}, +//}, +//} diff --git a/pkg/models/address/address.go b/pkg/models/address/address.go new file mode 100644 index 0000000..1afa3e0 --- /dev/null +++ b/pkg/models/address/address.go @@ -0,0 +1,26 @@ +package address + +type FHIRAddress struct { + ResourceType string `bson:"resourceType"` + Use string `bson:"use,omitempty"` // home | work | temp | old | billing - purpose of this address + Type string `bson:"type,omitempty"` // postal | physical | both + Text string `bson:"text,omitempty"` // Text representation of the address + Line []string `bson:"line,omitempty"` // Street name, number, direction & P.O. Box etc. + City string `bson:"city,omitempty"` // Name of city, town etc. + District string `bson:"district,omitempty"` // District name (aka county) + State string `bson:"state,omitempty"` // Sub-unit of country (abbreviations ok) + PostalCode string `bson:"postalCode,omitempty"` // Postal code for area + Country string `bson:"country,omitempty"` // Country (e.g. can be ISO 3166 2 or 3 letter code) + Period Period `bson:"period,omitempty"` // Time period when address was/is in use + Extension []Extension `bson:"extension,omitempty"` // Additional content defined by implementations +} + +type Period struct { + Start string `bson:"start,omitempty"` // Starting time with inclusive boundary + End string `bson:"end,omitempty"` // End time with inclusive boundary, if not ongoing +} + +type Extension struct { + URL string `bson:"url"` // identifies the meaning of the extension + ValueString string `bson:"valueString,omitempty"` // Value of extension +} diff --git a/pkg/models/getrelatedperson/getrelatedperson.go b/pkg/models/getrelatedperson/getrelatedperson.go new file mode 100644 index 0000000..d493ce2 --- /dev/null +++ b/pkg/models/getrelatedperson/getrelatedperson.go @@ -0,0 +1,8 @@ +package getrelatedperson + +import "api-poliklinik/pkg/models/insertpatient" + +type getrelatedperson struct { + Patient insertpatient.Patientcoba `json:"patient" bson:"patient"` + RelatedPerson insertpatient.InsertRelatedPerson `json:"relatedPerson" bson:"relatedPerson" ` +} diff --git a/pkg/models/migrasipatient/migrasipatient.go b/pkg/models/migrasipatient/migrasipatient.go new file mode 100644 index 0000000..0b2f6f9 --- /dev/null +++ b/pkg/models/migrasipatient/migrasipatient.go @@ -0,0 +1,50 @@ +package migrasipatient + +type MPasienSIMRS struct { + ID string `gorm:"column:id_id" json:"id"` + Nomr string `gorm:"column:id_nomr" json:"nomr"` + Noktp string `gorm:"column:id_noktp" json:"noktp"` + NomorKartu string `gorm:"column:id_nomorkartu" json:"nomorKartu"` + SIM string `gorm:"column:id_sim" json:"sim"` + Paspor string `gorm:"column:id_paspor" json:"paspor"` + Title string `gorm:"column:nm_title" json:"title"` + Nama string `gorm:"column:nm_nama" json:"nama"` + TeleponHp string `gorm:"column:te_teleponhp" json:"teleponHp"` + TeleponRumah string `gorm:"column:te_teleponrumah1" json:"teleponRumah"` + TeleponRumah2 string `gorm:"column:te_teleponrumah2" json:"teleponRumah2"` + TeleponKantor string `gorm:"column:te_telkantor" json:"teleponKantor"` + Tanggallahir string `gorm:"column:bd_tgllahir" json:"tanggallahir"` + JenisKelamin string `gorm:"column:jk_jeniskelamin" json:"jenis_kelamin"` + Alamat string `gorm:"column:ad_alamat" json:"alamat"` + AlamatKTP string `gorm:"column:ad_alamatktp" json:"alamat_ktp"` + Kelurahan string `gorm:"column:ad_kelurahan" json:"kelurahan"` + Kecamatan string `gorm:"column:ad_kecamatan" json:"kecamatan"` + Kota string `gorm:"column:ad_kota" json:"kota"` + Provinsi string `gorm:"column:ad_provinsi" json:"provinsi"` + IDKelurahan string `gorm:"column:adid_kelurahan" json:"id_kelurahan"` + IDkecamatan string `gorm:"column:adid_kecamatan" json:"idkecamatan"` + IDKota string `gorm:"column:adid_kota" json:"id_kota"` + IDProvinsi string `gorm:"column:adid_provinsi" json:"id_provinsi"` + NamaPenanggungjawab string `gorm:"column:ctpj_nama" json:"namaPenanggungjawab"` + HubunganPenanggungjawab string `gorm:"column:ctpj_hubungan" json:"hubunganPenanggungjawab"` + AlamatPenanggungjawab string `gorm:"column:ctpj_alamat" json:"alamatPenanggungjawab"` + TeleponPenanggungjawab string `gorm:"column:ctpj_telepon" json:"teleponPenanggungjawab"` + NamaAyah string `gorm:"column:ctpj_namaayah" json:"namaAyah"` + NamaIbu string `gorm:"column:ctpj_namaibu" json:"namaIbu"` + IDPendidikanAyah string `gorm:"column:ctpjid_pendidikanayah" json:"IDpendidikanAyah"` + PendidikanAyah string `gorm:"column:ctpj_pendidikanayah" json:"pendidikanAyah"` + IDPendidikanIbu string `gorm:"column:ctpjid_pendidikanibu" json:"IDpendidikanIbu"` + PendidikanIbu string `gorm:"column:ctpj_pendidikanibu" json:"pendidikanIbu"` + PhotoKtp string `gorm:"column:pt_ktpfile" json:"photoKtp"` + PhotoKk string `gorm:"column:pt_kkfile" json:"photoKk"` + Komunikasi string `gorm:"column:com_bahasa" json:"komunikasi"` + IDpendidikan string `gorm:"column:exid_pendidikan" json:"IDpendidikan"` + Pendidikan string `gorm:"column:ex_pendidikan" json:"Pendidikan"` + Disabiltas string `gorm:"column:ex_disabiltas" json:"disabiltas"` + Kebangsaan string `gorm:"column:ex_kebangsaan" json:"kebangsaan"` + Suku string `gorm:"column:ex_suku" json:"suku"` + IDAgama string `gorm:"column:exid_agama" json:"id_agama"` + Agama string `gorm:"column:ex_agama" json:"agama"` + CreatedAt string `gorm:"column:ex_createdat" json:"created_at"` + UpdatedAt string `gorm:"column:ex_updatedat" json:"updated_at"` +} diff --git a/pkg/models/mongo/encounter/encounter.go b/pkg/models/mongo/encounter/encounter.go new file mode 100644 index 0000000..0c2e4ba --- /dev/null +++ b/pkg/models/mongo/encounter/encounter.go @@ -0,0 +1,65 @@ +package encounter + +import ( + _struct "api-poliklinik/pkg/models/struct" + "go.mongodb.org/mongo-driver/bson/primitive" +) + +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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} diff --git a/pkg/models/mongo/endpoint/endpoint.go b/pkg/models/mongo/endpoint/endpoint.go new file mode 100644 index 0000000..1a11aec --- /dev/null +++ b/pkg/models/mongo/endpoint/endpoint.go @@ -0,0 +1,21 @@ +package endpoint + +import ( + _struct "api-poliklinik/pkg/models/struct" + "go.mongodb.org/mongo-driver/bson/primitive" +) + +type Endpoint struct { + ResourceType string `bson:"resourceType"` + ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"` + Identifier []_struct.Identifier `bson:"identifier,omitempty" json:"identifier,omitempty"` + Status string `bson:"status" json:"status"` + ConnectionType []_struct.Coding `bson:"connectionType,omitempty" json:"connectionType,omitempty"` + Name string `bson:"name" json:"name"` + ManagingOrganization _struct.Reference `bson:"managingOrganization,omitempty" json:"managingOrganization"` + Contact []_struct.ContactPoint `bson:"contact,omitempty" json:"contact,omitempty"` + Period []_struct.Period `bson:"period,omitempty" json:"period,omitempty"` + Payload []_struct.Payload `bson:"payload,omitempty" json:"payload,omitempty"` + Address string `bson:"address" json:"address"` + Header []string `bson:"header,omitempty" json:"header,omitempty"` +} diff --git a/pkg/models/mongo/insertpatient/insertPatientRelated.go b/pkg/models/mongo/insertpatient/insertPatientRelated.go new file mode 100644 index 0000000..a40a989 --- /dev/null +++ b/pkg/models/mongo/insertpatient/insertPatientRelated.go @@ -0,0 +1,76 @@ +package insertpatient + +import ( + _struct "api-poliklinik/pkg/models/struct" + "go.mongodb.org/mongo-driver/bson/primitive" +) + +type Patient struct { + ResourceType string `json:"resourceType" bson:"resourceType,omitempty" ` + ID primitive.ObjectID `bson:"_id,omitempty" json:"id" ` + Identifier []_struct.Identifier `json:"identifier" bson:"identifier,omitempty" ` + Active bool `json:"active" bson:"active,omitempty"` + Name []_struct.HumanName `json:"name" bson:"name,omitempty" ` + Telecom []_struct.ContactPoint `json:"telecom" bson:"telecom,omitempty" ` + Gender string `json:"gender" bson:"gender,omitempty" ` + BirthDate string `json:"birthDate" bson:"birthDate,omitempty" ` + DeceasedBoolean bool `json:"deceasedBoolean" bson:"deceasedBoolean,omitempty" ` + DeceasedDateTime string `json:"deceasedDateTime" bson:"deceasedDateTime,omitempty" ` + Address []_struct.Address `json:"address" bson:"address,omitempty" ` + MaritalStatus _struct.CodeableConcept `json:"maritalStatus" bson:"maritalStatus,omitempty" ` + MultipleBirthBoolean bool `json:"multipleBirthBoolean" bson:"multipleBirthBoolean,omitempty" ` + MultipleBirthInteger int `json:"multipleBirthInteger" bson:"multipleBirthInteger,omitempty" ` + Photo []_struct.Photo `json:"photo" bson:"photo,omitempty" ` + Contact []_struct.Contact `json:"contact" bson:"contact,omitempty" ` + Communication []_struct.Communication `json:"communication" bson:"communication,omitempty" ` + Link []_struct.Link `json:"link" bson:"link,omitempty" ` + Extension []_struct.Extension `json:"extension" bson:"extension,omitempty" ` +} + +type GetBY struct { + Identifier []_struct.Identifier `json:"identifier,omitempty" bson:"identifier,omitempty" ` +} + +type UpdatePatient struct { + ResourceType string `json:"resourceType,omitempty" bson:"resourceType,omitempty"` + ID string `bson:"-"` + Identifier []_struct.Identifier `json:"identifier,omitempty" bson:"identifier,omitempty"` + Active bool `json:"active,omitempty" bson:"active,omitempty"` + Name []_struct.HumanName `json:"name,omitempty" bson:"name,omitempty"` + Telecom []_struct.ContactPoint `json:"telecom,omitempty" bson:"telecom,omitempty"` + Gender string `json:"gender,omitempty" bson:"gender,omitempty"` + BirthDate string `json:"birthDate,omitempty" bson:"birthDate,omitempty"` + DeceasedBoolean bool `json:"deceasedBoolean,omitempty" bson:"deceasedBoolean,omitempty"` + DeceasedDateTime string `json:"deceasedDateTime,omitempty" bson:"deceasedDateTime,omitempty"` + Address []_struct.Address `json:"address,omitempty" bson:"address,omitempty"` + MaritalStatus _struct.CodeableConcept `json:"maritalStatus,omitempty" bson:"maritalStatus,omitempty"` + MultipleBirthBoolean bool `json:"multipleBirthBoolean,omitempty" bson:"multipleBirthBoolean,omitempty"` + MultipleBirthInteger int `json:"multipleBirthInteger,omitempty" bson:"multipleBirthInteger,omitempty"` + Photo []_struct.Photo `json:"photo,omitempty" bson:"photo,omitempty"` + Contact []_struct.Contact `json:"contact,omitempty" bson:"contact,omitempty"` + Communication []_struct.Communication `json:"communication,omitempty" bson:"communication,omitempty"` + Link []_struct.Link `json:"link,omitempty" bson:"link,omitempty"` + Extension []_struct.Extension `json:"extension,omitempty" bson:"extension,omitempty"` +} + +type DeletePatient struct { + ResourceType string `json:"resourceType,omitempty" bson:"resourceType,omitempty"` + ID string `bson:"-"` + Identifier []_struct.Identifier `json:"identifier,omitempty" bson:"identifier,omitempty"` + Active bool `json:"active,omitempty" bson:"active,omitempty"` + Name []_struct.HumanName `json:"name,omitempty" bson:"name,omitempty"` + Telecom []_struct.ContactPoint `json:"telecom,omitempty" bson:"telecom,omitempty"` + Gender string `json:"gender,omitempty" bson:"gender,omitempty"` + BirthDate string `json:"birthDate,omitempty" bson:"birthDate,omitempty"` + DeceasedBoolean bool `json:"deceasedBoolean,omitempty" bson:"deceasedBoolean,omitempty"` + DeceasedDateTime string `json:"deceasedDateTime,omitempty" bson:"deceasedDateTime,omitempty"` + Address []_struct.Address `json:"address,omitempty" bson:"address,omitempty"` + MaritalStatus _struct.CodeableConcept `json:"maritalStatus,omitempty" bson:"maritalStatus,omitempty"` + MultipleBirthBoolean bool `json:"multipleBirthBoolean,omitempty" bson:"multipleBirthBoolean,omitempty"` + MultipleBirthInteger int `json:"multipleBirthInteger,omitempty" bson:"multipleBirthInteger,omitempty"` + Photo []_struct.Photo `json:"photo,omitempty" bson:"photo,omitempty"` + Contact []_struct.Contact `json:"contact,omitempty" bson:"contact,omitempty"` + Communication []_struct.Communication `json:"communication,omitempty" bson:"communication,omitempty"` + Link []_struct.Link `json:"link,omitempty" bson:"link,omitempty"` + Extension []_struct.Extension `json:"extension,omitempty" bson:"extension,omitempty"` +} diff --git a/pkg/models/mongo/location/location.go b/pkg/models/mongo/location/location.go new file mode 100644 index 0000000..4c40e4e --- /dev/null +++ b/pkg/models/mongo/location/location.go @@ -0,0 +1,30 @@ +package location + +import ( + _struct "api-poliklinik/pkg/models/struct" + "go.mongodb.org/mongo-driver/bson/primitive" +) + +type Location struct { + ResourceType string `bson:"resourceType"` + ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"` + Identifier []_struct.Identifier `bson:"identifier,omitempty" json:"identifier,omitempty"` + Status bool `bson:"status" json:"status"` + OperationaStatus _struct.Coding `bson:"operationalstatus,omitempty" json:"operational,omitempty"` + Name string `bson:"name" json:"name"` + Alias []string `bson:"alias,omitempty" json:"alias,omitempty"` + Description string `bson:"description,omitempty" json:"description,omitempty"` + Mode string `bson:"mode,omitempty" json:"mode,omitempty"` + Type []_struct.CodeableConcept `bson:"type,omitempty" json:"type,omitempty"` + Contact []_struct.ExtendedContactDetail `bson:"contact,omitempty" json:"contact,omitempty"` + Telecom []_struct.ContactPoint `bson:"telecom,omitempty" json:"telecom,omitempty"` + Address _struct.Address `bson:"address,omitempty" json:"address,omitempty"` + Form []_struct.CodeableConcept `bson:"form,omitempty" json:"form,omitempty"` + Position _struct.Position `bson:"position,omitempty" json:"position,omitempty"` + ManagingOrganization _struct.Reference `bson:"managingOrganization,omitempty" json:"managingOrganization,omitempty"` + PartOf _struct.Reference `bson:"partOf,omitempty" json:"partOf,omitempty"` + Characteristic []_struct.CodeableConcept `bson:"characteristic,omitempty" json:"characteristic,omitempty"` + HoursOfOperation []_struct.Availability `bson:"hoursOfOperation,omitempty" json:"hoursOfOperation,omitempty"` + VirtualService _struct.VirtualService `bson:"virtualService,omitempty" json:"virtualService,omitempty"` + Endpoint _struct.Reference `bson:"endpoint,omitempty" json:"endpoint,omitempty"` +} diff --git a/pkg/models/mongo/organization/organization.go b/pkg/models/mongo/organization/organization.go new file mode 100644 index 0000000..5a4c831 --- /dev/null +++ b/pkg/models/mongo/organization/organization.go @@ -0,0 +1,21 @@ +package organization + +import ( + _struct "api-poliklinik/pkg/models/struct" + "go.mongodb.org/mongo-driver/bson/primitive" +) + +type Organization struct { + ResourceType string `bson:"resourceType"` + ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"` + Identifier []_struct.Identifier `bson:"identifier,omitempty" json:"identifier,omitempty"` + Active bool `bson:"active" json:"active"` + Type []_struct.CodeableConcept `bson:"type,omitempty" json:"type,omitempty"` + Name string `bson:"name" json:"name"` + Alias []string `bson:"alias,omitempty" json:"alias,omitempty"` + Description string `bson:"description,omitempty" json:"description,omitempty"` + Contact []_struct.ExtendedContactDetail `bson:"contact,omitempty" json:"contact,omitempty"` + PartOf _struct.Reference `bson:"partOf,omitempty" json:"partOf,omitempty"` + Endpoint _struct.Reference `bson:"endpoint,omitempty" json:"endpoint,omitempty"` + Qualification []_struct.Qualification `bson:"qualification,omitempty" json:"qualification,omitempty"` +} diff --git a/pkg/models/mongo/person/person.go b/pkg/models/mongo/person/person.go new file mode 100644 index 0000000..dead67f --- /dev/null +++ b/pkg/models/mongo/person/person.go @@ -0,0 +1,25 @@ +package person + +import ( + _struct "api-poliklinik/pkg/models/struct" + "go.mongodb.org/mongo-driver/bson/primitive" +) + +type Person struct { + ResourceType string `bson:"resourceType"` + ID primitive.ObjectID `bson:"_id,omitempty" json:"id" ` + Identifier []_struct.Identifier `bson:"identifier,omitempty" json:"identifier,omitempty"` + Active bool `bson:"active,omitempty" json:"active,omitempty"` + Name []_struct.HumanName `bson:"name,omitempty" json:"name,omitempty"` + Telecom []_struct.ContactPoint `bson:"telecom,omitempty" json:"telecom,omitempty"` + Gender string `bson:"gender,omitempty" json:"gender,omitempty"` + BirthDate string `bson:"birthDate,omitempty" json:"birthDate,omitempty"` + DeceasedBoolean bool `json:"deceasedBoolean,omitempty" bson:"deceasedBoolean,omitempty"` + DeceasedDateTime string `json:"deceasedDateTime,omitempty" bson:"deceasedDateTime,omitempty"` + Address []_struct.Address `bson:"address,omitempty" json:"address,omitempty"` + MaritalStatus _struct.CodeableConcept `json:"maritalStatus,omitempty" bson:"maritalStatus,omitempty"` + Photo []_struct.Photo `json:"photo,omitempty" bson:"photo,omitempty"` + Communication []_struct.Communication `bson:"communication" json:"communication"` + Link []_struct.LinkTarget `json:"link,omitempty" bson:"link,omitempty"` + Extension []_struct.Extension `json:"extension,omitempty" bson:"extension,omitempty"` +} diff --git a/pkg/models/mongo/practitioner/practitioner.go b/pkg/models/mongo/practitioner/practitioner.go new file mode 100644 index 0000000..5abc501 --- /dev/null +++ b/pkg/models/mongo/practitioner/practitioner.go @@ -0,0 +1,21 @@ +package practitioner + +import ( + _struct "api-poliklinik/pkg/models/struct" + "go.mongodb.org/mongo-driver/bson/primitive" +) + +type Practitioner struct { + ResourceType string `bson:"resourceType"` + ID primitive.ObjectID `bson:"_id" json:"id,omitempty"` + Identifier []_struct.Identifier `bson:"identifier" json:"identifier,omitempty"` + Active bool `bson:"active" json:"active"` + Name []_struct.HumanName `bson:"name" json:"name"` + Telecom []_struct.ContactPoint `bson:"telecom" json:"telecom,omitempty"` + Address []_struct.Address `bson:"address" json:"address,omitempty"` + Gender string `bson:"gender" json:"gender,omitempty"` + BirthDate string `bson:"birthDate" json:"birthDate,omitempty"` + Qualification []_struct.Qualification `bson:"qualification" json:"qualification,omitempty"` + Communication []_struct.Communication `bson:"communication" json:"communication,omitempty"` + Extension []_struct.Extension `json:"extension,omitempty" bson:"extension"` +} diff --git a/pkg/models/mongo/relatedperson/relatedperson.go b/pkg/models/mongo/relatedperson/relatedperson.go new file mode 100644 index 0000000..1b0c213 --- /dev/null +++ b/pkg/models/mongo/relatedperson/relatedperson.go @@ -0,0 +1,39 @@ +package relatedperson + +import ( + patient "api-poliklinik/pkg/models/mongo/insertpatient" + _struct "api-poliklinik/pkg/models/struct" + "go.mongodb.org/mongo-driver/bson/primitive" +) + +type RelatedPerson struct { + ResourceType string `bson:"resourceType"` + ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"` + Identifier []_struct.Identifier `bson:"identifier"` + Active bool `bson:"active"` + Patient _struct.Reference `bson:"patient" json:"patient"` + Relationship []_struct.CodeableConcept `bson:"relationship" json:"relationship"` + Name []_struct.HumanName `bson:"name" json:"name"` + Telecom []_struct.ContactPoint `bson:"telecom" json:"telecom"` + Gender string `bson:"gender" json:"gender"` + BirthDate string `bson:"birthDate" json:"birthDate"` + Address []_struct.Address `bson:"address" json:"address"` + Photo []_struct.Photo `bson:"photo" json:"photo"` + Period _struct.Period `bson:"period" json:"period"` + Communication []_struct.Communication `bson:"communication" json:"communication"` + Preferred bool `bson:"preferred" json:"preferred"` + Link []_struct.Link `json:"link,omitempty" bson:"link,omitempty"` + Extension []_struct.Extension `json:"extension,omitempty" bson:"extension,omitempty"` +} + +type DeletedataRelatedPerson struct { + ID string `bson:"-"` + Active bool `bson:"active"` + Extension []_struct.Extension `json:"extension,omitempty" bson:"extension,omitempty"` +} + +/* gabungan patient dan related person */ +type Getrelatedperson struct { + Patient patient.Patient `json:"patient" bson:"patient"` + RelatedPerson RelatedPerson `json:"relatedPerson,omitempty" bson:"relatedPerson, omitempty"` +} diff --git a/pkg/models/patient/patient.go b/pkg/models/patient/patient.go deleted file mode 100644 index fe81d03..0000000 --- a/pkg/models/patient/patient.go +++ /dev/null @@ -1,167 +0,0 @@ -package patient - -type Coding struct { - System string `bson:"system,omitempty"` - Version string `bson:"version,omitempty"` - Code string `bson:"code,omitempty"` - Display string `bson:"display,omitempty"` - UserSelected bool `bson:"userSelected,omitempty"` -} - -type Identifier struct { - Use string `bson:"use,omitempty"` - Type CodeableConcept `bson:"type,omitempty"` - System string `bson:"system,omitempty"` - Value string `bson:"value,omitempty"` - Period Period `bson:"period,omitempty"` - Assigner struct{} `bson:"assigner,omitempty"` -} - -type CodeableConcept struct { - Coding []Coding `bson:"coding,omitempty"` - Text string `bson:"text,omitempty"` -} - -type Period struct { - Start string `bson:"start,omitempty"` - End string `bson:"end,omitempty"` -} - -type ContactPoint struct { - System string `bson:"system,omitempty"` - Value string `bson:"value,omitempty"` - Use string `bson:"use,omitempty"` - Rank int `bson:"rank,omitempty"` - Period Period `bson:"period,omitempty"` -} - -type HumanName struct { - Use string `bson:"use,omitempty"` - Text string `bson:"text,omitempty"` - Family string `bson:"family,omitempty"` - Given []string `bson:"given,omitempty"` - Prefix []string `bson:"prefix,omitempty"` - Suffix []string `bson:"suffix,omitempty"` - Period Period `bson:"period,omitempty"` -} - -type Address struct { - Use string `bson:"use,omitempty"` - Type string `bson:"type,omitempty"` - Text string `bson:"text,omitempty"` - Line []string `bson:"line,omitempty"` - City string `bson:"city,omitempty"` - District string `bson:"district,omitempty"` - State string `bson:"state,omitempty"` - PostalCode string `bson:"postalCode,omitempty"` - Country string `bson:"country,omitempty"` - Period Period `bson:"period,omitempty"` -} - -type Organization struct { - Reference string `bson:"reference,omitempty"` -} - -type Contact struct { - Relationship []CodeableConcept `bson:"relationship,omitempty"` - Name []HumanName `bson:"name,omitempty"` - Telecom []ContactPoint `bson:"telecom,omitempty"` - Address Address `bson:"address,omitempty"` - Organization Organization `bson:"organization,omitempty"` - Gender string `bson:"gender,omitempty"` - Period Period `bson:"period,omitempty"` -} - -type Communication struct { - Language CodeableConcept `bson:"language,omitempty"` - Preferred bool `bson:"preferred,omitempty"` -} - -type ReqInsertCommunication struct { - Language Coding `bson:"language,omitempty"` - Preferred bool `bson:"preferred,omitempty"` -} - -type Link struct { - RelatePerson []RelatePerson `bson:"relatePerson,omitempty"` -} - -type RelatePerson struct { - Identifier []Identifier `bson:"identifier,omitempty"` - Active bool `bson:"active"` - Patient string `bson:"patient"` - Relationship CodeableConcept `bson:"relationship"` - Name []HumanName `bson:"name,omitempty"` - Telecom []ContactPoint `bson:"telecom,omitempty"` - Gender string `bson:"gender,omitempty"` - BirthDate string `bson:"birthDate,omitempty"` - Address []Address `bson:"address,omitempty"` - Photo string `bson:"photo,omitempty"` - Period Period `bson:"period,omitempty"` - Communication []Communication `bson:"communication,omitempty"` - Preferred bool `bson:"preferred"` -} - -type Deceased struct { - DeceasedBoolean bool `bson:"deceasedBoolean,omitempty"` - DeceasedDateTime string `bson:"deceasedDateTime,omitempty"` -} - -type MultipleBirth struct { - MultipleBirthBoolean bool `bson:"multipleBirthBoolean,omitempty"` - MultipleBirthInteger int `bson:"multipleBirthInteger,omitempty"` -} - -type Patient struct { - ResourceType string `bson:"resourceType"` - ID string `bson:"_id"` - Identifier []Identifier `bson:"identifier,omitempty"` - Active bool `bson:"active"` - Name []HumanName `bson:"name,omitempty"` - Telecom []ContactPoint `bson:"telecom,omitempty"` - Gender string `bson:"gender,omitempty"` - BirthPlace string `bson:"birthPlace,omitempty"` - BirthDate string `bson:"birthDate,omitempty"` - Address []Address `bson:"address,omitempty"` - MaritalStatus CodeableConcept `bson:"maritalStatus,omitempty"` - Job CodeableConcept `bson:"job,omitempty"` - Religion CodeableConcept `bson:"religion,omitempty"` - Tribe CodeableConcept `bson:"tribe,omitempty"` - Link Link `bson:"link,omitempty"` - Communication []Communication `bson:"communication,omitempty"` - Disability bool `bson:"disability,omitempty"` - National string `bson:"national,omitempty"` - Deceased Deceased `bson:"deceased,omitempty"` - MultipleBirth MultipleBirth `bson:"multipleBirth,omitempty"` - CreatedAt string `bson:"createdAt"` - UpdatedAt string `bson:"updatedAt"` -} - -type ReqInsertIdentifier struct { - Use string `bson:"use,omitempty"` - Type Coding `bson:"type,omitempty"` - System string `bson:"system,omitempty"` - Value string `bson:"value,omitempty"` - Period Period `bson:"period,omitempty"` -} - -type ReqInsertPatient struct { - Identifier []ReqInsertIdentifier `bson:"identifier,omitempty"` - Active bool `bson:"active"` - Name []HumanName `bson:"name,omitempty"` - Telecom []ContactPoint `bson:"telecom,omitempty"` - Gender string `bson:"gender,omitempty"` - BirthPlace string `bson:"birthPlace,omitempty"` - BirthDate string `bson:"birthDate,omitempty"` - Address []Address `bson:"address,omitempty"` - MaritalStatus []CodeableConcept `bson:"maritalStatus,omitempty"` - Job []CodeableConcept `bson:"job,omitempty"` - Religion []CodeableConcept `bson:"religion,omitempty"` - Tribe []CodeableConcept `bson:"tribe,omitempty"` - Link Link `bson:"link,omitempty"` - Communication []Communication `bson:"communication,omitempty"` - Disability bool `bson:"disability,omitempty"` - National string `bson:"national,omitempty"` - Deceased Deceased `bson:"deceased,omitempty"` - MultipleBirth MultipleBirth `bson:"multipleBirth,omitempty"` -} diff --git a/pkg/models/satu_data/data_wilayah.go b/pkg/models/satu_data/data_wilayah.go index 360be81..c8a6547 100644 --- a/pkg/models/satu_data/data_wilayah.go +++ b/pkg/models/satu_data/data_wilayah.go @@ -1,27 +1,12 @@ package satu_data -type Desakelurahan struct { - ID uint - NamaDesa string `gorm:"column:Desa_Kelurahan"` - Kecamatan Kecamatan `gorm:"foreignkey:Kecamatan_ID"` - Kecamatan_ID uint -} - -type Kecamatan struct { - ID uint - NamaKecamatan string `gorm:"column:Kecamatan"` - KabupatenKota KabupatenKota `gorm:"foreignkey:Kabupaten_kota_id"` - Kabupaten_kota_ID uint -} - -type KabupatenKota struct { - ID uint - NamaKabupaten string `gorm:"column:Kabupaten_Kota"` - Provinsi Provinsi `gorm:"foreignkey:Provinsi_id"` - Provinsi_id uint -} - -type Provinsi struct { - ID uint - NamaProvinsi string `gorm:"column:Provinsi"` +type GetWilayah struct { + IDProvinsi int `gorm:"column:idprovinsi" json:"id_provinsi"` + NamaProvinsi string `gorm:"column:namaprovinsi" json:"nama_provinsi"` + IDKabupaten int `gorm:"column:idkota" json:"id_kabupaten"` + NamaKabupaten string `gorm:"column:namakota" json:"nama_kabupaten"` + IDKecamatan int `gorm:"column:idkecamatan" json:"id_kecamatan"` + NamaKecamatan string `gorm:"column:namakecamatan" json:"nama_kecamatan"` + IDDesa int `gorm:"column:idkelurahan" json:"id_desa"` + NamaDesa string `gorm:"column:namakelurahan" json:"nama_desa"` } diff --git a/pkg/models/struct/fhir.go b/pkg/models/struct/fhir.go new file mode 100644 index 0000000..597ab05 --- /dev/null +++ b/pkg/models/struct/fhir.go @@ -0,0 +1,181 @@ +package _struct + +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 +} + +type CodeableConcept struct { + Coding []Coding `json:"coding" bson:"coding"` + Text string `json:"text,omitempty" 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"` +} + +type Period struct { + Start string `json:"start,omitempty" bson:"start"` + End string `json:"end,omitempty" bson:"end"` +} + +type Reference struct { + Reference string `json:"reference,omitempty" bson:"reference"` + Display string `json:"display,omitempty" 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"` +} + +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"` + 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"` +} + +type Extension struct { + URL string `json:"url,omitempty" bson:"url` + Extension []ExtensionDetail `json:"extension,omitempty" 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"` +} + +type Photo struct { + ContentType string `json:"contentType,omitempty" bson:"contentType,omitempty"` + Language string `json:"language,omitempty" bson:"language,omitempty"` + Data string `json:"data,omitempty" bson:"data,omitempty"` + URL string `json:"url,omitempty" bson:"url,omitempty"` + Size int `json:"size,omitempty" bson:"size,omitempty"` + Hash int `json:"hash,omitempty" bson:"hash,omitempty"` + Title string `json:"title,omitempty" bson:"title,omitempty"` + Creation string `json:"creation,omitempty" bson:"creation,omitempty"` + Height int `json:"height,omitempty" bson:"height,omitempty"` + Width int `json:"width,omitempty" bson:"width,omitempty"` + Frames int `json:"frames,omitempty" bson:"frames,omitempty"` + Duration int `json:"duration,omitempty" bson:"duration,omitempty"` + Pages int `json:"pages,omitempty" bson:"pages,omitempty"` +} + +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"` +} + +type Communication struct { + Language CodeableConcept `json:"language,omitempty" bson:"language"` + Text string `json:"preferred,omitempty" bson:"preferred"` +} + +type Link struct { + Other Reference `json:"other,omitempty" bson:"other"` + Type string `json:"type,omitempty" bson:"type"` +} + +type LinkTarget struct { + Target Reference `json:"target,omitempty" bson:"target,omitempty"` + Type string `json:"type,omitempty" bson:"type,omitempty"` +} + +type ExtendedContactDetail struct { + Purpose CodeableConcept `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 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"` +} + +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"` +} +type Position struct { + Longitude float64 `json:"longitude,omitempty" bson:"longitude,omitempty"` + Latitude float64 `json:"latitude,omitempty" bson:"latitude,omitempty"` + Altitude float64 `json:"altitude,omitempty" bson:"altitude,omitempty"` +} + +type Availability struct { + AvailableTime []AvailabilityAvailableTime `json:"availableTime" bson:"availableTime,omitempty"` + NotAvailableTime []AvailabilityNotAvailable `json:"notAvailableTime" bson:"notAvailableTime,omitempty"` +} + +type AvailabilityAvailableTime struct { + DaysOfWeek []string `json:"daysOfWeek" bson:"daysOfWeek,omitempty"` + AllDay bool `json:"allDay" bson:"allDay,omitempty"` + AvailableStartTime string `json:"availableStartTime" bson:"availableStartTime,omitempty"` + AvailableEndTime string `json:"availableEndTime" bson:"availableEndTime,omitempty"` +} + +type AvailabilityNotAvailable struct { + Description string `json:"description" bson:"description"` // Required + During Period `json:"during,omitempty" bson:"during,omitempty"` +} + +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 string `json:"maxParticipants,omitempty" bson:"maxParticipants,omitempty"` + SessionKey string `json:"sessionKey,omitempty" bson:"sessionKey,omitempty"` +} + +type Payload struct { + Type CodeableConcept `json:"type,omitempty" bson:"type,omitempty"` + Mimetype []string `json:"mimetype,omitempty" bson:"mimetype,omitempty"` +}