pembaruhan baru
This commit is contained in:
@@ -1 +1,149 @@
|
||||
package Master
|
||||
|
||||
import (
|
||||
"api-poliklinik/internal/database"
|
||||
"api-poliklinik/pkg/database/mongo"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func GetCommunication(c *gin.Context) {
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
db := database.New(local).GetMongoDB()
|
||||
if db == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"})
|
||||
return
|
||||
}
|
||||
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(db)
|
||||
dataCommunication, errSelect := mongoDB.Getcommunication()
|
||||
if errSelect != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": dataCommunication,
|
||||
"message": "komunikasi Sukses Ter-ambil ",
|
||||
})
|
||||
}
|
||||
|
||||
func Getdisability(c *gin.Context) {
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
db := database.New(local).GetMongoDB()
|
||||
if db == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"})
|
||||
return
|
||||
}
|
||||
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(db)
|
||||
dataDisability, errSelect := mongoDB.Getdisability()
|
||||
if errSelect != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": dataDisability,
|
||||
"message": "disabilitas Sukses Ter-ambil ",
|
||||
})
|
||||
}
|
||||
|
||||
func Geteducation(c *gin.Context) {
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
db := database.New(local).GetMongoDB()
|
||||
if db == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"})
|
||||
return
|
||||
}
|
||||
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(db)
|
||||
dataEducation, errSelect := mongoDB.Geteducation()
|
||||
if errSelect != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": dataEducation,
|
||||
"message": "disabilitas Sukses Ter-ambil ",
|
||||
})
|
||||
}
|
||||
|
||||
func Getjob(c *gin.Context) {
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
db := database.New(local).GetMongoDB()
|
||||
if db == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"})
|
||||
return
|
||||
}
|
||||
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(db)
|
||||
dataJob, errSelect := mongoDB.Getjob()
|
||||
if errSelect != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": dataJob,
|
||||
"message": "pekerjaan Sukses Ter-ambil ",
|
||||
})
|
||||
}
|
||||
|
||||
func Getmartial(c *gin.Context) {
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
db := database.New(local).GetMongoDB()
|
||||
if db == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"})
|
||||
return
|
||||
}
|
||||
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(db)
|
||||
dataMartial, errSelect := mongoDB.Getmartial()
|
||||
if errSelect != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": dataMartial,
|
||||
"message": "pernikahan Sukses Ter-ambil ",
|
||||
})
|
||||
}
|
||||
|
||||
func Getreligion(c *gin.Context) {
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
db := database.New(local).GetMongoDB()
|
||||
if db == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"})
|
||||
return
|
||||
}
|
||||
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(db)
|
||||
dataReligion, errSelect := mongoDB.Getreligion()
|
||||
if errSelect != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": dataReligion,
|
||||
"message": "agama Sukses Ter-ambil ",
|
||||
})
|
||||
}
|
||||
|
||||
func Gettribe(c *gin.Context) {
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
db := database.New(local).GetMongoDB()
|
||||
if db == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": "Database connection failed"})
|
||||
return
|
||||
}
|
||||
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(db)
|
||||
dataTribe, errSelect := mongoDB.Getsuku()
|
||||
if errSelect != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": dataTribe,
|
||||
"message": "suku Sukses Ter-ambil ",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,47 +1,35 @@
|
||||
package Practitioner
|
||||
|
||||
import (
|
||||
"api-poliklinik/internal/database"
|
||||
connDatabase "api-poliklinik/pkg/database/satu_data"
|
||||
"api-poliklinik/pkg/models/satu_data"
|
||||
|
||||
"api-poliklinik/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetDataPractitioner(c *gin.Context) {
|
||||
db := database.New().GetDB("satudata")
|
||||
satudata := connDatabase.NewDatabaseService(db)
|
||||
|
||||
log.Println("REQUEST")
|
||||
dataPractitioner := satudata.PractitionerGetData()
|
||||
var responsePractitioner []satu_data.DataResponse
|
||||
for _, k := range dataPractitioner {
|
||||
gelarDepan := utils.ReplaceGelar(k.GelarDepan)
|
||||
gelarBelakang := utils.ReplaceGelar(k.GelarBelakang)
|
||||
namaLengkap := gelarDepan + " " + k.NamaLengkap + " " + gelarBelakang
|
||||
namaLengkap = strings.TrimPrefix(namaLengkap, " ")
|
||||
namaLengkap = strings.TrimSuffix(namaLengkap, " ")
|
||||
|
||||
responsePractitioner = append(responsePractitioner, satu_data.DataResponse{
|
||||
ID: k.ID,
|
||||
NIP: k.NIP,
|
||||
JenisKelamin: k.JenisKelamin,
|
||||
NamaLengkapFull: namaLengkap,
|
||||
})
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
}
|
||||
//func GetDataPractitioner(c *gin.Context) {
|
||||
// db := database.New().GetDB("satudata")
|
||||
// satudata := connDatabase.NewDatabaseService(db)
|
||||
//
|
||||
// log.Println("REQUEST")
|
||||
// dataPractitioner := satudata.PractitionerGetData()
|
||||
// var responsePractitioner []satu_data.DataResponse
|
||||
// for _, k := range dataPractitioner {
|
||||
// gelarDepan := utils.ReplaceGelar(k.GelarDepan)
|
||||
// gelarBelakang := utils.ReplaceGelar(k.GelarBelakang)
|
||||
// namaLengkap := gelarDepan + " " + k.NamaLengkap + " " + gelarBelakang
|
||||
// namaLengkap = strings.TrimPrefix(namaLengkap, " ")
|
||||
// namaLengkap = strings.TrimSuffix(namaLengkap, " ")
|
||||
//
|
||||
// responsePractitioner = append(responsePractitioner, satu_data.DataResponse{
|
||||
// ID: k.ID,
|
||||
// NIP: k.NIP,
|
||||
// JenisKelamin: k.JenisKelamin,
|
||||
// NamaLengkapFull: namaLengkap,
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package appointment
|
||||
|
||||
import (
|
||||
"api-poliklinik/internal/database"
|
||||
"api-poliklinik/pkg/database/mongo"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func Getappointment(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)
|
||||
dataAppointment, errSelect := mongoDB.Getappointment()
|
||||
if errSelect != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": dataAppointment,
|
||||
"message": "location Sukses Ter-ambil ",
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package location
|
||||
|
||||
import (
|
||||
"api-poliklinik/internal/database"
|
||||
"api-poliklinik/pkg/database/mongo"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func Getlocation(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)
|
||||
dataLocation, errSelect := mongoDB.Getlocation()
|
||||
if errSelect != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": errSelect.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": dataLocation,
|
||||
"message": "location Sukses Ter-ambil ",
|
||||
})
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
_struct "api-poliklinik/pkg/models/struct"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
@@ -17,8 +18,8 @@ func Migrasibahasa(c *gin.Context) {
|
||||
db := database.New().GetDB("simrs")
|
||||
simrs := connDatabase.NewDatabaseService(db)
|
||||
|
||||
dataKelurahan := simrs.Getkelurahan()
|
||||
if dataKelurahan == nil || len(dataKelurahan) == 0 {
|
||||
datakomunikasi := simrs.Getbahasa()
|
||||
if datakomunikasi == nil || len(datakomunikasi) == 0 {
|
||||
c.JSON(http.StatusNotFound, gin.H{
|
||||
"status": "error",
|
||||
"message": "Tidak ada data pasien untuk dimigrasi",
|
||||
@@ -41,29 +42,29 @@ func Migrasibahasa(c *gin.Context) {
|
||||
failedCount := 0
|
||||
var migratedIDs []string
|
||||
|
||||
for _, kelurahan := range dataKelurahan {
|
||||
for _, komunikasi := range datakomunikasi {
|
||||
dateCreated := time.Now().Format("2006-01-02 15:04:05")
|
||||
objectID := primitive.NewObjectID()
|
||||
var fhirkelurahan = mongomaster.Village{
|
||||
ResourceType: "Village",
|
||||
var fhirkomunikasi = mongomaster.Communication{
|
||||
ResourceType: "Communication",
|
||||
ID: objectID,
|
||||
}
|
||||
fhirkelurahan.Identifier = []_struct.Identifier{
|
||||
fhirkomunikasi.Identifier = []_struct.Identifier{
|
||||
{
|
||||
Use: "usual",
|
||||
System: "",
|
||||
Value: kelurahan.IDKelurahan,
|
||||
Value: komunikasi.IDBahasa,
|
||||
Type: _struct.CodeableConcept{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "idkelurahan",
|
||||
Display: "ID m_kelurahan Simrs 3.0",
|
||||
Code: "idxbahasa",
|
||||
Display: "ID m_bahasa Simrs 3.0",
|
||||
UserSelected: true,
|
||||
},
|
||||
},
|
||||
Text: "ID m_kelurahan Simrs 3.0",
|
||||
Text: "ID m_bahasa Simrs 3.0",
|
||||
},
|
||||
Period: _struct.Period{
|
||||
Start: "",
|
||||
@@ -76,23 +77,20 @@ func Migrasibahasa(c *gin.Context) {
|
||||
},
|
||||
}
|
||||
|
||||
fhirkelurahan.Status = "active"
|
||||
fhirkelurahan.Name = kelurahan.NamaKelurahan
|
||||
fhirkelurahan.District = _struct.Reference{
|
||||
Reference: "Distric/" + kelurahan.IDKecamatan,
|
||||
Display: kelurahan.NamaKecamatan,
|
||||
}
|
||||
fhirkelurahan.Period = _struct.Period{
|
||||
fhirkomunikasi.Status = "active"
|
||||
fhirkomunikasi.Name = komunikasi.NamaBahasa
|
||||
fhirkomunikasi.Description = ""
|
||||
fhirkomunikasi.Period = _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
}
|
||||
fhirkelurahan.CreatedAt = dateCreated
|
||||
fhirkelurahan.UpdatedAt = dateCreated
|
||||
fhirkomunikasi.CreatedAt = dateCreated
|
||||
fhirkomunikasi.UpdatedAt = dateCreated
|
||||
|
||||
err := mongoDB.InsertVillage(fhirkelurahan)
|
||||
err := mongoDB.Insertcommunication(fhirkomunikasi)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Gagal migrasi data kelurahan %s: %v", kelurahan.IDKelurahan, err)
|
||||
log.Printf("Gagal migrasi data bahasa %s: %v", komunikasi.IDBahasa, err)
|
||||
failedCount++
|
||||
continue
|
||||
}
|
||||
@@ -103,8 +101,584 @@ func Migrasibahasa(c *gin.Context) {
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "success",
|
||||
"message": "Migrasi data kelurahan ke FHIR berhasil",
|
||||
"total": len(dataKelurahan),
|
||||
"message": "Migrasi data bahasa ke FHIR berhasil",
|
||||
"total": len(datakomunikasi),
|
||||
"migrated": migratedCount,
|
||||
"failed": failedCount,
|
||||
"migrated_ids": migratedIDs,
|
||||
"timestamp": time.Now().Format(time.RFC3339),
|
||||
})
|
||||
}
|
||||
|
||||
func Migrasidisbilitas(c *gin.Context) {
|
||||
db := database.New().GetDB("simrs")
|
||||
simrs := connDatabase.NewDatabaseService(db)
|
||||
|
||||
datadisabilitas := simrs.Getdisabilitas()
|
||||
if datadisabilitas == nil || len(datadisabilitas) == 0 {
|
||||
c.JSON(http.StatusNotFound, gin.H{
|
||||
"status": "error",
|
||||
"message": "Tidak ada data pasien untuk dimigrasi",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
mongoDBConn := database.New(local).GetMongoDB()
|
||||
if mongoDBConn == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"status": "error",
|
||||
"message": "Koneksi database MongoDB gagal",
|
||||
})
|
||||
return
|
||||
}
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(mongoDBConn)
|
||||
|
||||
migratedCount := 0
|
||||
failedCount := 0
|
||||
var migratedIDs []string
|
||||
|
||||
for _, disabilitas := range datadisabilitas {
|
||||
dateCreated := time.Now().Format("2006-01-02 15:04:05")
|
||||
objectID := primitive.NewObjectID()
|
||||
var fhirdisabilitas = mongomaster.Disability{
|
||||
ResourceType: "Disability",
|
||||
ID: objectID,
|
||||
}
|
||||
fhirdisabilitas.Identifier = []_struct.Identifier{
|
||||
{
|
||||
Use: "usual",
|
||||
System: "",
|
||||
Value: disabilitas.IDDisabilitas,
|
||||
Type: _struct.CodeableConcept{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "kode_disabilitas",
|
||||
Display: "ID m_disabilitas Simrs 3.0",
|
||||
UserSelected: true,
|
||||
},
|
||||
},
|
||||
Text: "ID m_disabilitas Simrs 3.0",
|
||||
},
|
||||
Period: _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
},
|
||||
Assigner: _struct.Reference{
|
||||
Reference: "",
|
||||
Display: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fhirdisabilitas.Status = "active"
|
||||
fhirdisabilitas.Name = disabilitas.NamaDisabilitas
|
||||
fhirdisabilitas.Description = ""
|
||||
fhirdisabilitas.Period = _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
}
|
||||
fhirdisabilitas.CreatedAt = dateCreated
|
||||
fhirdisabilitas.UpdatedAt = dateCreated
|
||||
|
||||
err := mongoDB.Insertdisability(fhirdisabilitas)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Gagal migrasi data disabilitas %s: %v", disabilitas.IDDisabilitas, err)
|
||||
failedCount++
|
||||
continue
|
||||
}
|
||||
|
||||
migratedIDs = append(migratedIDs, objectID.Hex())
|
||||
migratedCount++
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "success",
|
||||
"message": "Migrasi data disabilitas ke FHIR berhasil",
|
||||
"total": len(datadisabilitas),
|
||||
"migrated": migratedCount,
|
||||
"failed": failedCount,
|
||||
"migrated_ids": migratedIDs,
|
||||
"timestamp": time.Now().Format(time.RFC3339),
|
||||
})
|
||||
}
|
||||
|
||||
func Migrasipendidikan(c *gin.Context) {
|
||||
db := database.New().GetDB("simrs")
|
||||
simrs := connDatabase.NewDatabaseService(db)
|
||||
|
||||
datapendidikan := simrs.Getpendidikan()
|
||||
if datapendidikan == nil || len(datapendidikan) == 0 {
|
||||
c.JSON(http.StatusNotFound, gin.H{
|
||||
"status": "error",
|
||||
"message": "Tidak ada data pasien untuk dimigrasi",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
mongoDBConn := database.New(local).GetMongoDB()
|
||||
if mongoDBConn == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"status": "error",
|
||||
"message": "Koneksi database MongoDB gagal",
|
||||
})
|
||||
return
|
||||
}
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(mongoDBConn)
|
||||
|
||||
migratedCount := 0
|
||||
failedCount := 0
|
||||
var migratedIDs []string
|
||||
|
||||
for _, pendidikan := range datapendidikan {
|
||||
dateCreated := time.Now().Format("2006-01-02 15:04:05")
|
||||
objectID := primitive.NewObjectID()
|
||||
var fhirpendidikan = mongomaster.Education{
|
||||
ResourceType: "Education",
|
||||
ID: objectID,
|
||||
}
|
||||
fhirpendidikan.Identifier = []_struct.Identifier{
|
||||
{
|
||||
Use: "usual",
|
||||
System: "",
|
||||
Value: pendidikan.IDPendidikan,
|
||||
Type: _struct.CodeableConcept{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "id_pendidikan",
|
||||
Display: "ID m_pendidikan_pasien Simrs 3.0",
|
||||
UserSelected: true,
|
||||
},
|
||||
},
|
||||
Text: "ID m_pendidikan_pasien Simrs 3.0",
|
||||
},
|
||||
Period: _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
},
|
||||
Assigner: _struct.Reference{
|
||||
Reference: "",
|
||||
Display: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fhirpendidikan.Status = "active"
|
||||
fhirpendidikan.Name = pendidikan.NamaPendidikan
|
||||
fhirpendidikan.Description = ""
|
||||
fhirpendidikan.Period = _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
}
|
||||
fhirpendidikan.CreatedAt = dateCreated
|
||||
fhirpendidikan.UpdatedAt = dateCreated
|
||||
|
||||
err := mongoDB.Inserteducation(fhirpendidikan)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Gagal migrasi data pendidikan %s: %v", pendidikan.IDPendidikan, err)
|
||||
failedCount++
|
||||
continue
|
||||
}
|
||||
|
||||
migratedIDs = append(migratedIDs, objectID.Hex())
|
||||
migratedCount++
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "success",
|
||||
"message": "Migrasi data pendidikan ke FHIR berhasil",
|
||||
"total": len(datapendidikan),
|
||||
"migrated": migratedCount,
|
||||
"failed": failedCount,
|
||||
"migrated_ids": migratedIDs,
|
||||
"timestamp": time.Now().Format(time.RFC3339),
|
||||
})
|
||||
}
|
||||
|
||||
func Migrasipekerjaan(c *gin.Context) {
|
||||
db := database.New().GetDB("simrs")
|
||||
simrs := connDatabase.NewDatabaseService(db)
|
||||
|
||||
datapekerjaan := simrs.Getpekerjaan()
|
||||
if datapekerjaan == nil || len(datapekerjaan) == 0 {
|
||||
c.JSON(http.StatusNotFound, gin.H{
|
||||
"status": "error",
|
||||
"message": "Tidak ada data pasien untuk dimigrasi",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
mongoDBConn := database.New(local).GetMongoDB()
|
||||
if mongoDBConn == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"status": "error",
|
||||
"message": "Koneksi database MongoDB gagal",
|
||||
})
|
||||
return
|
||||
}
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(mongoDBConn)
|
||||
|
||||
migratedCount := 0
|
||||
failedCount := 0
|
||||
var migratedIDs []string
|
||||
|
||||
for _, pekerjaan := range datapekerjaan {
|
||||
dateCreated := time.Now().Format("2006-01-02 15:04:05")
|
||||
objectID := primitive.NewObjectID()
|
||||
var fhirpekerjaan = mongomaster.Job{
|
||||
ResourceType: "Job",
|
||||
ID: objectID,
|
||||
}
|
||||
fhirpekerjaan.Identifier = []_struct.Identifier{
|
||||
{
|
||||
Use: "usual",
|
||||
System: "",
|
||||
Value: pekerjaan.IDPekerjaan,
|
||||
Type: _struct.CodeableConcept{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "idxpekerjaan",
|
||||
Display: "ID m_pekerjaan Simrs 3.0",
|
||||
UserSelected: true,
|
||||
},
|
||||
},
|
||||
Text: "ID m_pekerjaan Simrs 3.0",
|
||||
},
|
||||
Period: _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
},
|
||||
Assigner: _struct.Reference{
|
||||
Reference: "",
|
||||
Display: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fhirpekerjaan.Status = "active"
|
||||
fhirpekerjaan.Name = pekerjaan.NamaPekerjaan
|
||||
fhirpekerjaan.Description = ""
|
||||
fhirpekerjaan.Period = _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
}
|
||||
fhirpekerjaan.CreatedAt = dateCreated
|
||||
fhirpekerjaan.UpdatedAt = dateCreated
|
||||
|
||||
err := mongoDB.Insertjob(fhirpekerjaan)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Gagal migrasi data pekerjaan %s: %v", pekerjaan.IDPekerjaan, err)
|
||||
failedCount++
|
||||
continue
|
||||
}
|
||||
|
||||
migratedIDs = append(migratedIDs, objectID.Hex())
|
||||
migratedCount++
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "success",
|
||||
"message": "Migrasi data pekerjaan ke FHIR berhasil",
|
||||
"total": len(datapekerjaan),
|
||||
"migrated": migratedCount,
|
||||
"failed": failedCount,
|
||||
"migrated_ids": migratedIDs,
|
||||
"timestamp": time.Now().Format(time.RFC3339),
|
||||
})
|
||||
}
|
||||
|
||||
func Migrasipernikahan(c *gin.Context) {
|
||||
db := database.New().GetDB("simrs")
|
||||
simrs := connDatabase.NewDatabaseService(db)
|
||||
|
||||
datapernikahan := simrs.Getstatus()
|
||||
if datapernikahan == nil || len(datapernikahan) == 0 {
|
||||
c.JSON(http.StatusNotFound, gin.H{
|
||||
"status": "error",
|
||||
"message": "Tidak ada data pasien untuk dimigrasi",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
mongoDBConn := database.New(local).GetMongoDB()
|
||||
if mongoDBConn == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"status": "error",
|
||||
"message": "Koneksi database MongoDB gagal",
|
||||
})
|
||||
return
|
||||
}
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(mongoDBConn)
|
||||
|
||||
migratedCount := 0
|
||||
failedCount := 0
|
||||
var migratedIDs []string
|
||||
|
||||
for _, pernikahan := range datapernikahan {
|
||||
dateCreated := time.Now().Format("2006-01-02 15:04:05")
|
||||
objectID := primitive.NewObjectID()
|
||||
var fhirpernikahan = mongomaster.MartialStatus{
|
||||
ResourceType: "Martial Status",
|
||||
ID: objectID,
|
||||
}
|
||||
fhirpernikahan.Identifier = []_struct.Identifier{
|
||||
{
|
||||
Use: "usual",
|
||||
System: "",
|
||||
Value: pernikahan.IDStatus,
|
||||
Type: _struct.CodeableConcept{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "idxstatus",
|
||||
Display: "ID m_status_pasien Simrs 3.0",
|
||||
UserSelected: true,
|
||||
},
|
||||
},
|
||||
Text: "ID m_status_pasien Simrs 3.0",
|
||||
},
|
||||
Period: _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
},
|
||||
Assigner: _struct.Reference{
|
||||
Reference: "",
|
||||
Display: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fhirpernikahan.Status = "active"
|
||||
fhirpernikahan.Name = pernikahan.NamaStatus
|
||||
fhirpernikahan.Description = ""
|
||||
fhirpernikahan.Period = _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
}
|
||||
fhirpernikahan.CreatedAt = dateCreated
|
||||
fhirpernikahan.UpdatedAt = dateCreated
|
||||
|
||||
err := mongoDB.Insertmartial(fhirpernikahan)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Gagal migrasi data pernikahan %s: %v", pernikahan.IDStatus, err)
|
||||
failedCount++
|
||||
continue
|
||||
}
|
||||
|
||||
migratedIDs = append(migratedIDs, objectID.Hex())
|
||||
migratedCount++
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "success",
|
||||
"message": "Migrasi data pernikahan ke FHIR berhasil",
|
||||
"total": len(datapernikahan),
|
||||
"migrated": migratedCount,
|
||||
"failed": failedCount,
|
||||
"migrated_ids": migratedIDs,
|
||||
"timestamp": time.Now().Format(time.RFC3339),
|
||||
})
|
||||
}
|
||||
|
||||
func Migrasiagama(c *gin.Context) {
|
||||
db := database.New().GetDB("simrs")
|
||||
simrs := connDatabase.NewDatabaseService(db)
|
||||
|
||||
dataagama := simrs.Getagama()
|
||||
if dataagama == nil || len(dataagama) == 0 {
|
||||
c.JSON(http.StatusNotFound, gin.H{
|
||||
"status": "error",
|
||||
"message": "Tidak ada data pasien untuk dimigrasi",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
mongoDBConn := database.New(local).GetMongoDB()
|
||||
if mongoDBConn == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"status": "error",
|
||||
"message": "Koneksi database MongoDB gagal",
|
||||
})
|
||||
return
|
||||
}
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(mongoDBConn)
|
||||
|
||||
migratedCount := 0
|
||||
failedCount := 0
|
||||
var migratedIDs []string
|
||||
|
||||
for _, agama := range dataagama {
|
||||
dateCreated := time.Now().Format("2006-01-02 15:04:05")
|
||||
objectID := primitive.NewObjectID()
|
||||
var fhiragama = mongomaster.Religion{
|
||||
ResourceType: "Religion",
|
||||
ID: objectID,
|
||||
}
|
||||
fhiragama.Identifier = []_struct.Identifier{
|
||||
{
|
||||
Use: "usual",
|
||||
System: "",
|
||||
Value: agama.IDAgama,
|
||||
Type: _struct.CodeableConcept{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "idagama",
|
||||
Display: "ID m_agama_pasien Simrs 3.0",
|
||||
UserSelected: true,
|
||||
},
|
||||
},
|
||||
Text: "ID m_agama_pasien Simrs 3.0",
|
||||
},
|
||||
Period: _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
},
|
||||
Assigner: _struct.Reference{
|
||||
Reference: "",
|
||||
Display: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fhiragama.Status = "active"
|
||||
fhiragama.Name = agama.NamaAgama
|
||||
fhiragama.Description = ""
|
||||
fhiragama.Period = _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
}
|
||||
fhiragama.CreatedAt = dateCreated
|
||||
fhiragama.UpdatedAt = dateCreated
|
||||
|
||||
err := mongoDB.Insertreligion(fhiragama)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Gagal migrasi data agama %s: %v", agama.IDAgama, err)
|
||||
failedCount++
|
||||
continue
|
||||
}
|
||||
|
||||
migratedIDs = append(migratedIDs, objectID.Hex())
|
||||
migratedCount++
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "success",
|
||||
"message": "Migrasi data agama ke FHIR berhasil",
|
||||
"total": len(dataagama),
|
||||
"migrated": migratedCount,
|
||||
"failed": failedCount,
|
||||
"migrated_ids": migratedIDs,
|
||||
"timestamp": time.Now().Format(time.RFC3339),
|
||||
})
|
||||
}
|
||||
|
||||
func Migrasisuku(c *gin.Context) {
|
||||
db := database.New().GetDB("simrs")
|
||||
simrs := connDatabase.NewDatabaseService(db)
|
||||
|
||||
datasuku := simrs.Getsuku()
|
||||
if datasuku == nil || len(datasuku) == 0 {
|
||||
c.JSON(http.StatusNotFound, gin.H{
|
||||
"status": "error",
|
||||
"message": "Tidak ada data pasien untuk dimigrasi",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
local := os.Getenv("MONGODB_DEV_MASTER")
|
||||
mongoDBConn := database.New(local).GetMongoDB()
|
||||
if mongoDBConn == nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"status": "error",
|
||||
"message": "Koneksi database MongoDB gagal",
|
||||
})
|
||||
return
|
||||
}
|
||||
mongoDB := mongo.NewDatabaseServiceMongo(mongoDBConn)
|
||||
|
||||
migratedCount := 0
|
||||
failedCount := 0
|
||||
var migratedIDs []string
|
||||
|
||||
for _, suku := range datasuku {
|
||||
dateCreated := time.Now().Format("2006-01-02 15:04:05")
|
||||
objectID := primitive.NewObjectID()
|
||||
var fhirsuku = mongomaster.Tribe{
|
||||
ResourceType: "Tribe",
|
||||
ID: objectID,
|
||||
}
|
||||
fhirsuku.Identifier = []_struct.Identifier{
|
||||
{
|
||||
Use: "usual",
|
||||
System: "",
|
||||
Value: suku.IDSuku,
|
||||
Type: _struct.CodeableConcept{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "idxsuku",
|
||||
Display: "ID m_suku Simrs 3.0",
|
||||
UserSelected: true,
|
||||
},
|
||||
},
|
||||
Text: "ID m_suku Simrs 3.0",
|
||||
},
|
||||
Period: _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
},
|
||||
Assigner: _struct.Reference{
|
||||
Reference: "",
|
||||
Display: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fhirsuku.Status = "active"
|
||||
fhirsuku.Name = suku.NamaSuku
|
||||
fhirsuku.Description = ""
|
||||
fhirsuku.Period = _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
}
|
||||
fhirsuku.CreatedAt = dateCreated
|
||||
fhirsuku.UpdatedAt = dateCreated
|
||||
|
||||
err := mongoDB.Inserttribe(fhirsuku)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Gagal migrasi data suku %s: %v", suku.IDSuku, err)
|
||||
failedCount++
|
||||
continue
|
||||
}
|
||||
|
||||
migratedIDs = append(migratedIDs, objectID.Hex())
|
||||
migratedCount++
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "success",
|
||||
"message": "Migrasi data suku ke FHIR berhasil",
|
||||
"total": len(datasuku),
|
||||
"migrated": migratedCount,
|
||||
"failed": failedCount,
|
||||
"migrated_ids": migratedIDs,
|
||||
|
||||
@@ -1,401 +1,501 @@
|
||||
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: "",
|
||||
//},
|
||||
//}
|
||||
import (
|
||||
"api-poliklinik/internal/database"
|
||||
"api-poliklinik/pkg/database/mongo"
|
||||
connDatabase "api-poliklinik/pkg/database/satu_data"
|
||||
"api-poliklinik/pkg/models/mongo/location"
|
||||
_struct "api-poliklinik/pkg/models/struct"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Migrasilokasi(c *gin.Context) {
|
||||
|
||||
db := database.New().GetDB("simrs")
|
||||
simrs := connDatabase.NewDatabaseService(db)
|
||||
|
||||
dataLokasi := simrs.Getruang()
|
||||
if dataLokasi == nil || len(dataLokasi) == 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 _, lokasi := range dataLokasi {
|
||||
objectID := primitive.NewObjectID()
|
||||
dateCreated := time.Now().Format("2006-01-02 15:04:05")
|
||||
var code, display, text string
|
||||
|
||||
// Menentukan jenis subsistem berdasarkan dua kata pertama saja
|
||||
if strings.HasPrefix(lokasi.Subsistem, "RAWAT INAP") {
|
||||
code = "IRNA"
|
||||
display = "Instalasi Rawat Inap"
|
||||
text = "Rawat Inap"
|
||||
} else if strings.HasPrefix(lokasi.Subsistem, "RAWAT JALAN") {
|
||||
code = "IRJA"
|
||||
display = "Instalasi Rawat Jalan"
|
||||
text = "Rawat Jalan"
|
||||
} else {
|
||||
// Untuk kasus lain yang tidak teridentifikasi
|
||||
code = "UNKNOWN"
|
||||
display = "Tidak Diketahui"
|
||||
text = lokasi.Subsistem
|
||||
}
|
||||
var fhirLokasi = location.Location{
|
||||
ResourceType: "Location",
|
||||
ID: objectID,
|
||||
Status: true,
|
||||
}
|
||||
fhirLokasi.Identifier = []_struct.Identifier{
|
||||
{
|
||||
Use: "official",
|
||||
System: "",
|
||||
Value: lokasi.IDRuang,
|
||||
Type: _struct.CodeableConcept{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "ID",
|
||||
Display: "ID m_ruang SIMRS",
|
||||
},
|
||||
},
|
||||
Text: "ID m_ruang SIMRS",
|
||||
},
|
||||
Period: _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
},
|
||||
Assigner: _struct.Reference{
|
||||
Reference: "",
|
||||
Display: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
Use: "official",
|
||||
System: "",
|
||||
Value: lokasi.Kdruang,
|
||||
Type: _struct.CodeableConcept{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "",
|
||||
Display: "Kode Ruang",
|
||||
},
|
||||
},
|
||||
Text: "Kode Ruang",
|
||||
},
|
||||
Period: _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
},
|
||||
Assigner: _struct.Reference{
|
||||
Reference: "",
|
||||
Display: "",
|
||||
},
|
||||
}, {
|
||||
Use: "official",
|
||||
System: "",
|
||||
Value: lokasi.Kdunit,
|
||||
Type: _struct.CodeableConcept{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "",
|
||||
Display: "Kode Unit",
|
||||
},
|
||||
},
|
||||
Text: "Kode Unit",
|
||||
},
|
||||
Period: _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
},
|
||||
Assigner: _struct.Reference{
|
||||
Reference: "",
|
||||
Display: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
fhirLokasi.OperationalStatus = _struct.Coding{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "",
|
||||
Display: "",
|
||||
UserSelected: false,
|
||||
}
|
||||
fhirLokasi.Name = lokasi.NamaRuang
|
||||
fhirLokasi.Alias = []string{lokasi.NamaRuang}
|
||||
fhirLokasi.Description = lokasi.DesRuang
|
||||
fhirLokasi.Mode = "instance"
|
||||
fhirLokasi.Type = []_struct.CodeableConcept{
|
||||
{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "http://terminology.hl7.org/CodeSystem/v3-RoleCode",
|
||||
Version: "",
|
||||
Code: lokasi.Kelas,
|
||||
Display: lokasi.KelompokRuang,
|
||||
UserSelected: true,
|
||||
},
|
||||
},
|
||||
Text: "Poliklinik " + text,
|
||||
},
|
||||
{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: code,
|
||||
Display: display,
|
||||
UserSelected: true,
|
||||
},
|
||||
},
|
||||
Text: "Instalasi " + text,
|
||||
},
|
||||
{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "SUBSISTEM",
|
||||
Display: lokasi.Subsistem,
|
||||
UserSelected: true,
|
||||
},
|
||||
},
|
||||
Text: lokasi.Subsistem,
|
||||
},
|
||||
{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "PARTIAL",
|
||||
Display: lokasi.Partial,
|
||||
UserSelected: true,
|
||||
},
|
||||
},
|
||||
Text: lokasi.Partial,
|
||||
},
|
||||
}
|
||||
fhirLokasi.Contact = _struct.ExtendedContactDetail{
|
||||
|
||||
Purpose: _struct.Purpose{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "http://terminology.hl7.org/CodeSystem/contactentity-type",
|
||||
Version: "",
|
||||
Code: "PATINF",
|
||||
Display: "Patient",
|
||||
UserSelected: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
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: "",
|
||||
},
|
||||
}
|
||||
|
||||
fhirLokasi.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, Klojen, Kec. Klojen, Kota Malang, Jawa Timur 65112"},
|
||||
Village: "Klojen",
|
||||
District: "Klojen",
|
||||
City: "Malang",
|
||||
State: "Jawa Timur",
|
||||
PostalCode: "65112",
|
||||
Country: "Indonesia",
|
||||
Period: _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
},
|
||||
}
|
||||
fhirLokasi.Form = _struct.CodeableConcept{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "",
|
||||
Display: "",
|
||||
UserSelected: false,
|
||||
},
|
||||
},
|
||||
Text: "",
|
||||
}
|
||||
fhirLokasi.Position = _struct.Position{
|
||||
Latitude: 112.630348,
|
||||
Longitude: -7.981894,
|
||||
Altitude: 0,
|
||||
}
|
||||
|
||||
fhirLokasi.ManagingOrganization = _struct.Reference{
|
||||
Reference: "Organization/1",
|
||||
Display: "RSUD dr. Saiful Anwar Jatim Prov",
|
||||
}
|
||||
fhirLokasi.PartOf = _struct.Reference{
|
||||
Reference: "",
|
||||
Display: "",
|
||||
}
|
||||
fhirLokasi.Characteristic = []_struct.CodeableConcept{
|
||||
{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "",
|
||||
Display: "",
|
||||
UserSelected: false,
|
||||
},
|
||||
},
|
||||
Text: "",
|
||||
},
|
||||
}
|
||||
|
||||
fhirLokasi.HoursOfOperation = []_struct.Availability{
|
||||
{
|
||||
AvailableTime: []_struct.AvailabilityAvailableTime{
|
||||
{
|
||||
DaysOfWeek: []string{"mon", "tue", "wed", "thu", "fri"},
|
||||
AllDay: false,
|
||||
AvailableStartTime: "07:00",
|
||||
AvailableEndTime: "15:00",
|
||||
},
|
||||
},
|
||||
NotAvailableTime: []_struct.AvailabilityNotAvailable{
|
||||
{
|
||||
Description: "",
|
||||
During: _struct.Period{
|
||||
Start: "",
|
||||
End: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fhirLokasi.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: "",
|
||||
},
|
||||
},
|
||||
AddressExtendedContact: _struct.ExtendedContactDetail{
|
||||
Purpose: _struct.Purpose{
|
||||
Coding: []_struct.Coding{
|
||||
{
|
||||
System: "",
|
||||
Version: "",
|
||||
Code: "",
|
||||
Display: "",
|
||||
UserSelected: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
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: "",
|
||||
},
|
||||
}
|
||||
fhirLokasi.Endpoint = _struct.Reference{
|
||||
Reference: "",
|
||||
Display: "",
|
||||
}
|
||||
fhirLokasi.CreatedAt = dateCreated
|
||||
fhirLokasi.UpdatedAt = dateCreated
|
||||
fhirLokasi.Extension = []_struct.Extension{
|
||||
{
|
||||
URL: "",
|
||||
Extension: []_struct.ExtensionDetail{
|
||||
{
|
||||
URL: "",
|
||||
ValueDisplay: "",
|
||||
ValueCode: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
err := mongoDB.Insertlokasi(fhirLokasi)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Gagal migrasi data praktisi %s: %v", lokasi.IDRuang, 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(dataLokasi),
|
||||
"migrated": migratedCount,
|
||||
"failed": failedCount,
|
||||
"migrated_ids": migratedIDs,
|
||||
"timestamp": time.Now().Format(time.RFC3339),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import (
|
||||
"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"
|
||||
@@ -17,149 +15,6 @@ import (
|
||||
"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")
|
||||
|
||||
Reference in New Issue
Block a user