fixing issue optimasi
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
"satusehat-rssa/pkg/common"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -22,7 +21,6 @@ func (s *SpecimenHandler) CreateSpecimen(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
req.Identifier = append(req.Identifier, common.GetIdentifier("specimen"))
|
||||
res, err := s.Specimen.CreateSpecimen(req)
|
||||
if err != nil {
|
||||
if res != nil {
|
||||
@@ -63,7 +61,6 @@ func (s *SpecimenHandler) UpdateSpecimen(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
req.Id = c.Param("id")
|
||||
req.Identifier = append(req.Identifier, common.GetIdentifier("specimen"))
|
||||
res, err := s.Specimen.UpdateSpecimen(req)
|
||||
if err != nil {
|
||||
if res != nil {
|
||||
|
||||
@@ -86,6 +86,10 @@ func (c *CompositionRepository) CreateComposition(req model.CompositionRequest)
|
||||
},
|
||||
},
|
||||
},
|
||||
Text: &model.SectionText{
|
||||
Status: "additional",
|
||||
Div: "statis",
|
||||
},
|
||||
}
|
||||
if allergyId != "" {
|
||||
section.Entry = []model.Reference{
|
||||
@@ -344,6 +348,10 @@ func (c *CompositionRepository) CreateComposition(req model.CompositionRequest)
|
||||
},
|
||||
},
|
||||
},
|
||||
Text: &model.SectionText{
|
||||
Status: "additional",
|
||||
Div: "statis",
|
||||
},
|
||||
Entry: entryCondition,
|
||||
},
|
||||
},
|
||||
@@ -365,6 +373,10 @@ func (c *CompositionRepository) CreateComposition(req model.CompositionRequest)
|
||||
},
|
||||
},
|
||||
},
|
||||
Text: &model.SectionText{
|
||||
Status: "additional",
|
||||
Div: "statis",
|
||||
},
|
||||
Entry: entryProcedure,
|
||||
})
|
||||
var medication []model.Reference
|
||||
@@ -562,7 +574,7 @@ func (c *CompositionRepository) setupEncounter(req *model.CompositionRequest, pa
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if encounterExist {
|
||||
if encounterExist && encounterId != "" {
|
||||
req.Encounter.Reference = "Encounter/" + encounterId
|
||||
} else {
|
||||
//Buat dulu encounter
|
||||
@@ -601,7 +613,7 @@ func (c *CompositionRepository) setupAllergyIntollerance(patient string) string
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if allergyExist {
|
||||
if allergyExist && len(allergyId) > 0 {
|
||||
return allergyId[0]
|
||||
}
|
||||
return ""
|
||||
@@ -616,7 +628,7 @@ func (c *CompositionRepository) setupObservation(patient string) []model.Referen
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
if observationExist {
|
||||
if observationExist && len(observationId) > 0 {
|
||||
var references []model.Reference
|
||||
|
||||
for _, id := range observationId {
|
||||
@@ -636,7 +648,7 @@ func (c *CompositionRepository) setupClinicalImpression(patient string) string {
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if clinicalExist {
|
||||
if clinicalExist && len(clinicalId) > 0 {
|
||||
return clinicalId[0]
|
||||
}
|
||||
return ""
|
||||
@@ -651,7 +663,7 @@ func (c *CompositionRepository) setupGoal(patient string) string {
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if goalExist {
|
||||
if goalExist && len(goalId) > 0 {
|
||||
return goalId[0]
|
||||
}
|
||||
return ""
|
||||
@@ -666,7 +678,7 @@ func (c *CompositionRepository) setupCarePlan(patient string) string {
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if careplanExist {
|
||||
if careplanExist && len(careplanId) > 0 {
|
||||
return careplanId[0]
|
||||
}
|
||||
return ""
|
||||
@@ -686,7 +698,7 @@ func (c *CompositionRepository) setupServiceRequestCategory(patient string, cate
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if serviceRequestExist {
|
||||
if serviceRequestExist && len(serviceRequestId) > 0 {
|
||||
return serviceRequestId[0]
|
||||
}
|
||||
return ""
|
||||
@@ -702,7 +714,7 @@ func (c *CompositionRepository) setupSpecimenCategory(patient string) string {
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if specimenExist {
|
||||
if specimenExist && len(specimenId) > 0 {
|
||||
return specimenId[0]
|
||||
}
|
||||
return ""
|
||||
@@ -718,7 +730,7 @@ func (c *CompositionRepository) setupImagingStudy(patient string) string {
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if imagingExist {
|
||||
if imagingExist && len(imagingId) > 0 {
|
||||
return imagingId[0]
|
||||
}
|
||||
return ""
|
||||
@@ -738,7 +750,7 @@ func (c *CompositionRepository) setupObservationCategory(patient string, categor
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if observationExist {
|
||||
if observationExist && len(observationId) > 0 {
|
||||
return observationId[0]
|
||||
}
|
||||
return ""
|
||||
@@ -758,7 +770,7 @@ func (c *CompositionRepository) setupDiagnosticCategory(patient string, category
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if observationExist {
|
||||
if observationExist && len(observationId) > 0 {
|
||||
return observationId[0]
|
||||
}
|
||||
return ""
|
||||
@@ -774,7 +786,7 @@ func (c *CompositionRepository) setupCondition(patient string) string {
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if conditionExist {
|
||||
if conditionExist && len(conditionId) > 0 {
|
||||
return conditionId
|
||||
}
|
||||
return ""
|
||||
@@ -790,7 +802,7 @@ func (c *CompositionRepository) setupProcedure(patient string) string {
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if procedureExist {
|
||||
if procedureExist && len(procedureId) > 0 {
|
||||
return procedureId[0]
|
||||
}
|
||||
return ""
|
||||
@@ -806,7 +818,7 @@ func (c *CompositionRepository) setupMedicationRequest(patient string) string {
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if medicationRequestExist {
|
||||
if medicationRequestExist && len(medicationRequestId) > 0 {
|
||||
return medicationRequestId[0]
|
||||
}
|
||||
return ""
|
||||
@@ -822,7 +834,7 @@ func (c *CompositionRepository) setupMedicationDispense(patient string) string {
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if medicationDispenseExist {
|
||||
if medicationDispenseExist && len(medicationDispenseId) > 0 {
|
||||
return medicationDispenseId[0]
|
||||
}
|
||||
return ""
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"satusehat-rssa/internal/constant"
|
||||
"satusehat-rssa/internal/model"
|
||||
"satusehat-rssa/pkg/httputil"
|
||||
@@ -93,6 +94,12 @@ func (s *SpecimenRepository) CreateSpecimen(req model.SpecimenRequest) (map[stri
|
||||
var data map[string]interface{}
|
||||
|
||||
req.ResourceType = constant.SpecimenResourceType
|
||||
req.Identifier = []model.IdentifierSpecimen{}
|
||||
req.Identifier = append(req.Identifier, model.IdentifierSpecimen{
|
||||
System: "http://sys-ids.kemkes.go.id/specimen/" + os.Getenv("ORGANIZATION_ID"), // Set this if needed, or remove if not present in IdentifierObject
|
||||
Value: "00001",
|
||||
Assigner: model.AssignerSpecimen{Reference: "Organization/" + os.Getenv("ORGANIZATION_ID")},
|
||||
})
|
||||
// Setup Patient
|
||||
var patient string
|
||||
if req.Subject.Reference != "" {
|
||||
@@ -287,6 +294,12 @@ func (s *SpecimenRepository) HandleCheckSpecimen(id string) ([]string, bool, err
|
||||
|
||||
func (s *SpecimenRepository) UpdateSpecimen(req model.SpecimenRequest) (map[string]interface{}, error) {
|
||||
req.ResourceType = constant.SpecimenResourceType
|
||||
req.Identifier = []model.IdentifierSpecimen{}
|
||||
req.Identifier = append(req.Identifier, model.IdentifierSpecimen{
|
||||
System: "http://sys-ids.kemkes.go.id/specimen/" + os.Getenv("ORGANIZATION_ID"), // Set this if needed, or remove if not present in IdentifierObject
|
||||
Value: "00001",
|
||||
Assigner: model.AssignerSpecimen{Reference: "Organization/" + os.Getenv("ORGANIZATION_ID")},
|
||||
})
|
||||
// Setup Patient
|
||||
var patient string
|
||||
if req.Subject.Reference != "" {
|
||||
|
||||
+20
-10
@@ -1,16 +1,16 @@
|
||||
package model
|
||||
|
||||
type SpecimenRequest struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
ResourceType string `json:"resourceType"`
|
||||
Identifier []Identifier `json:"identifier"`
|
||||
Status string `json:"status"`
|
||||
Type SpecimenType `json:"type"`
|
||||
Collection SpecimenCollection `json:"collection"`
|
||||
Subject Reference `json:"subject"`
|
||||
Request []Reference `json:"request"`
|
||||
ReceivedTime string `json:"receivedTime"`
|
||||
Extension []SpecimenExtension `json:"extension"`
|
||||
Id string `json:"id,omitempty"`
|
||||
ResourceType string `json:"resourceType"`
|
||||
Identifier []IdentifierSpecimen `json:"identifier"`
|
||||
Status string `json:"status"`
|
||||
Type SpecimenType `json:"type"`
|
||||
Collection SpecimenCollection `json:"collection"`
|
||||
Subject Reference `json:"subject"`
|
||||
Request []Reference `json:"request"`
|
||||
ReceivedTime string `json:"receivedTime"`
|
||||
Extension []SpecimenExtension `json:"extension"`
|
||||
}
|
||||
|
||||
type SpecimenType struct {
|
||||
@@ -31,3 +31,13 @@ type SpecimenExtension struct {
|
||||
URL string `json:"url"`
|
||||
ValueDateTime string `json:"valueDateTime,omitempty"`
|
||||
}
|
||||
|
||||
type IdentifierSpecimen struct {
|
||||
Value string `json:"value,omitempty"`
|
||||
System string `json:"system,omitempty"`
|
||||
Assigner AssignerSpecimen `json:"assigner"`
|
||||
}
|
||||
|
||||
type AssignerSpecimen struct {
|
||||
Reference string `json:"reference"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user