Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using metriport fhir converter #486

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,4 @@ I'd also like to thank the following Corporate Sponsors:

<a href="https://depot.dev/"><img src="https://raw.githubusercontent.com/fastenhealth/docs/main/img/sponsors/depot.png" height="100px" /></a>
<a style="padding-left:5px" href="https://www.macminivault.com/"><img src="https://raw.githubusercontent.com/fastenhealth/docs/main/img/sponsors/macminivault.png" height="100px" /></a>
<a style="padding-left:5px" href="https://www.health-samurai.io/"><img src="https://raw.githubusercontent.com/fastenhealth/docs/main/img/sponsors/health-samurai-logo.png" height="100px" /></a>
<a style="padding-left:5px" href="https://www.browserstack.com/"><img src="https://raw.githubusercontent.com/fastenhealth/docs/main/img/sponsors/browserstack.png" height="100px" /></a>
46 changes: 46 additions & 0 deletions backend/pkg/web/handler/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,49 @@ func (suite *SourceHandlerTestSuite) TestCreateManualSourceHandler() {
}, summary.ResourceTypeCounts[3])

}

// bug: https://github.com/fastenhealth/fasten-onprem/pull/486
func (suite *SourceHandlerTestSuite) TestCreateManualSourceHandler_ShouldExtractPatientIdFromConvertedCCDA() {
//setup
w := httptest.NewRecorder()
ctx, _ := gin.CreateTestContext(w)
ctx.Set(pkg.ContextKeyTypeLogger, logrus.WithField("test", suite.T().Name()))
ctx.Set(pkg.ContextKeyTypeDatabase, suite.AppRepository)
ctx.Set(pkg.ContextKeyTypeConfig, suite.AppConfig)
ctx.Set(pkg.ContextKeyTypeEventBusServer, suite.AppEventBus)
ctx.Set(pkg.ContextKeyTypeAuthUsername, "test_username")

//test
req, err := CreateManualSourceHttpRequestFromFile("testdata/ccda_to_fhir_converted_C-CDA_R2-1_CCD.xml.json")
require.NoError(suite.T(), err)
ctx.Request = req

CreateManualSource(ctx)

//assert
require.Equal(suite.T(), http.StatusOK, w.Code)

type ResponseWrapper struct {
Data struct {
UpdatedResources []string `json:"UpdatedResources"`
TotalResources int `json:"TotalResources"`
} `json:"data"`
Success bool `json:"success"`
Source models.SourceCredential `json:"source"`
}
var respWrapper ResponseWrapper
err = json.Unmarshal(w.Body.Bytes(), &respWrapper)
require.NoError(suite.T(), err)

require.Equal(suite.T(), true, respWrapper.Success)
require.Equal(suite.T(), "manual", string(respWrapper.Source.PlatformType))
require.Equal(suite.T(), 65, respWrapper.Data.TotalResources)
summary, err := suite.AppRepository.GetSourceSummary(ctx, respWrapper.Source.ID.String())
require.NoError(suite.T(), err)
require.Equal(suite.T(), map[string]interface{}{
"count": int64(1),
"resource_type": "Consent",
"source_id": respWrapper.Source.ID.String(),
}, summary.ResourceTypeCounts[3])

}
Loading
Loading