working getResourceBySourceId query and api.

This commit is contained in:
Jason Kulatunga 2022-09-25 16:57:30 -07:00
parent 498e4e6191
commit cd6a0fb68f
8 changed files with 35 additions and 313 deletions

View File

@ -16,7 +16,7 @@ type DatabaseRepository interface {
GetSummary(ctx context.Context) (*models.Summary, error)
UpsertResource(context.Context, *models.ResourceFhir) error
GetResource(context.Context, string) (*models.ResourceFhir, error)
GetResourceBySourceType(context.Context, string, string) (*models.ResourceFhir, error)
GetResourceBySourceId(context.Context, string, string) (*models.ResourceFhir, error)
ListResources(context.Context, models.ListResourceQueryOptions) ([]models.ResourceFhir, error)
GetPatientForSources(ctx context.Context) ([]models.ResourceFhir, error)

View File

@ -204,7 +204,7 @@ func (sr *sqliteRepository) ListResources(ctx context.Context, queryOptions mode
return wrappedResourceModels, results.Error
}
func (sr *sqliteRepository) GetResourceBySourceId(ctx context.Context, sourceResourceType string, sourceResourceId string) (*models.ResourceFhir, error) {
func (sr *sqliteRepository) GetResourceBySourceType(ctx context.Context, sourceResourceType string, sourceResourceId string) (*models.ResourceFhir, error) {
queryParam := models.ResourceFhir{
OriginBase: models.OriginBase{
UserID: sr.GetCurrentUser(ctx).ID,
@ -221,18 +221,17 @@ func (sr *sqliteRepository) GetResourceBySourceId(ctx context.Context, sourceRes
return &wrappedResourceModel, results.Error
}
func (sr *sqliteRepository) GetResource(ctx context.Context, resourceId string) (*models.ResourceFhir, error) {
resourceUUID, err := uuid.Parse(resourceId)
func (sr *sqliteRepository) GetResourceBySourceId(ctx context.Context, sourceId string, sourceResourceId string) (*models.ResourceFhir, error) {
sourceIdUUID, err := uuid.Parse(sourceId)
if err != nil {
return nil, err
}
queryParam := models.ResourceFhir{
OriginBase: models.OriginBase{
ModelBase: models.ModelBase{
ID: resourceUUID,
},
UserID: sr.GetCurrentUser(ctx).ID,
UserID: sr.GetCurrentUser(ctx).ID,
SourceID: sourceIdUUID,
SourceResourceID: sourceResourceId,
},
}

View File

@ -38,7 +38,8 @@ func GetResourceFhir(c *gin.Context) {
databaseRepo := c.MustGet("REPOSITORY").(database.DatabaseRepository)
resourceId := strings.Trim(c.Param("resourceId"), "/")
wrappedResourceModel, err := databaseRepo.GetResource(c, resourceId)
sourceId := strings.Trim(c.Param("sourceId"), "/")
wrappedResourceModel, err := databaseRepo.GetResourceBySourceId(c, sourceId, resourceId)
if err != nil {
logger.Errorln("An error occurred while retrieving resource", err)

View File

@ -54,7 +54,7 @@ func (ae *AppEngine) Setup(logger *logrus.Entry) *gin.Engine {
secure.POST("/source/:sourceId/sync", handler.SourceSync)
secure.GET("/source/:sourceId/summary", handler.GetSourceSummary)
secure.GET("/resource/fhir", handler.ListResourceFhir) //
secure.GET("/resource/fhir/:resourceId", handler.GetResourceFhir)
secure.GET("/resource/fhir/:sourceId/:resourceId", handler.GetResourceFhir)
}
api.GET("/metadata/source", handler.GetMetadataSource)

View File

@ -81,7 +81,7 @@ export class ListGenericResourceComponent implements OnInit, ResourceListCompone
onSelect({ selected }) {
console.log('Select Event', selected);
this.router.navigateByUrl(`/source/${selected.source_id}/resource/${selected.source_resource_id}`);
this.router.navigateByUrl(`/source/${selected[0].source_id}/resource/${selected[0].source_resource_id}`);
}
}

View File

@ -1,307 +1,7 @@
<div class="az-content az-content-app pd-b-0">
<div class="container">
<div class="az-content-left az-content-left-invoice">
<div class="az-content-breadcrumb lh-1 mg-b-10">
<span>Apps &amp; Pages</span>
<span>Invoice</span>
</div>
<h2 class="az-content-title tx-24 mg-b-20">My Invoices</h2>
<div class="az-content-body">
<div id="azInvoiceList" class="az-invoice-list ps ps--active-y">
<div class="media">
<div class="media-icon"><i class="far fa-file-alt"></i></div>
<div class="media-body">
<h6>
<span>Invoice002300</span>
<span>$25</span>
</h6>
<div>
<p><span>Date:</span> Oct 25</p>
<p><span>Product:</span> 921021</p>
</div>
</div><!-- media-body -->
</div><!-- media -->
<div class="media selected">
<div class="media-icon"><i class="far fa-file-alt"></i></div>
<div class="media-body">
<h6>
<span>Invoice002299</span>
<span>$16</span>
</h6>
<div>
<p><span>Date:</span> Oct 25</p>
<p><span>Product:</span> 435423</p>
</div>
</div><!-- media-body -->
</div><!-- media -->
<div class="media">
<div class="media-icon"><i class="far fa-file-alt"></i></div>
<div class="media-body">
<h6>
<span>Invoice002300</span>
<span>$32</span>
</h6>
<div>
<p><span>Date:</span> Oct 25</p>
<p><span>Product:</span> 921021</p>
</div>
</div><!-- media-body -->
</div><!-- media -->
<div class="media">
<div class="media-icon"><i class="far fa-file-alt"></i></div>
<div class="media-body">
<h6>
<span>Invoice002300</span>
<span>$18</span>
</h6>
<div>
<p><span>Date:</span> Oct 25</p>
<p><span>Product:</span> 921021</p>
</div>
</div><!-- media-body -->
</div><!-- media -->
<div class="media">
<div class="media-icon"><i class="far fa-file-alt"></i></div>
<div class="media-body">
<h6>
<span>Invoice002300</span>
<span>$25</span>
</h6>
<div>
<p><span>Date:</span> Oct 25</p>
<p><span>Product:</span> 921021</p>
</div>
</div><!-- media-body -->
</div><!-- media -->
<div class="media">
<div class="media-icon"><i class="far fa-file-alt"></i></div>
<div class="media-body">
<h6>
<span>Invoice002299</span>
<span>$16</span>
</h6>
<div>
<p><span>Date:</span> Oct 25</p>
<p><span>Product:</span> 435423</p>
</div>
</div><!-- media-body -->
</div><!-- media -->
<div class="media">
<div class="media-icon"><i class="far fa-file-alt"></i></div>
<div class="media-body">
<h6>
<span>Invoice002300</span>
<span>$32</span>
</h6>
<div>
<p><span>Date:</span> Oct 25</p>
<p><span>Product:</span> 921021</p>
</div>
</div><!-- media-body -->
</div><!-- media -->
<div class="media">
<div class="media-icon"><i class="far fa-file-alt"></i></div>
<div class="media-body">
<h6>
<span>Invoice002300</span>
<span>$18</span>
</h6>
<div>
<p><span>Date:</span> Oct 25</p>
<p><span>Product:</span> 921021</p>
</div>
</div><!-- media-body -->
</div><!-- media -->
<div class="media">
<div class="media-icon"><i class="far fa-file-alt"></i></div>
<div class="media-body">
<h6>
<span>Invoice002300</span>
<span>$25</span>
</h6>
<div>
<p><span>Date:</span> Oct 25</p>
<p><span>Product:</span> 921021</p>
</div>
</div><!-- media-body -->
</div><!-- media -->
<div class="media">
<div class="media-icon"><i class="far fa-file-alt"></i></div>
<div class="media-body">
<h6>
<span>Invoice002299</span>
<span>$16</span>
</h6>
<div>
<p><span>Date:</span> Oct 25</p>
<p><span>Product:</span> 435423</p>
</div>
</div><!-- media-body -->
</div><!-- media -->
<div class="media">
<div class="media-icon"><i class="far fa-file-alt"></i></div>
<div class="media-body">
<h6>
<span>Invoice002300</span>
<span>$32</span>
</h6>
<div>
<p><span>Date:</span> Oct 25</p>
<p><span>Product:</span> 921021</p>
</div>
</div><!-- media-body -->
</div><!-- media -->
<div class="media">
<div class="media-icon"><i class="far fa-file-alt"></i></div>
<div class="media-body">
<h6>
<span>Invoice002300</span>
<span>$18</span>
</h6>
<div>
<p><span>Date:</span> Oct 25</p>
<p><span>Product:</span> 921021</p>
</div>
</div><!-- media-body -->
</div><!-- media -->
<div class="ps__rail-x" style="left: 0px; top: 0px;">
<div class="ps__thumb-x" tabindex="0" style="left: 0px; width: 0px;"></div>
</div>
<div class="ps__rail-y" style="top: 0px; height: 689px; right: 0px;">
<div class="ps__thumb-y" tabindex="0" style="top: 0px; height: 647px;"></div>
</div>
</div><!-- az-invoice-list -->
</div><!-- az-content-left -->
<div class="az-content-body az-content-body-invoice ps ps--active-y">
<div class="card card-invoice">
<div class="card-body">
<div class="invoice-header">
<h1 class="invoice-title">Invoice</h1>
<div class="billed-from">
<h6>BootstrapDash, Inc.</h6>
<p>201 Something St., Something Town, YT 242, Country 6546<br>
Tel No: 324 445-4544<br>
Email: youremail@companyname.com</p>
</div><!-- billed-from -->
</div><!-- invoice-header -->
<div class="row mg-t-20">
<div class="col-md">
<label class="tx-gray-600">Billed To</label>
<div class="billed-to">
<h6>Juan Dela Cruz</h6>
<p>4033 Patterson Road, Staten Island, NY 10301 <br>
Tel No: 324 445-4544<br>
Email: youremail@companyname.com</p>
</div>
</div><!-- col -->
<div class="col-md">
<label class="tx-gray-600">Invoice Information</label>
<p class="invoice-info-row">
<span>Invoice No</span>
<span>GHT-673-00</span>
</p>
<p class="invoice-info-row">
<span>Project ID</span>
<span>32334300</span>
</p>
<p class="invoice-info-row">
<span>Issue Date:</span>
<span>November 21, 2017</span>
</p>
<p class="invoice-info-row">
<span>Due Date:</span>
<span>November 30, 2017</span>
</p>
</div><!-- col -->
</div><!-- row -->
<div class="table-responsive mg-t-40">
<table class="table table-invoice">
<thead>
<tr>
<th class="wd-20p">Type</th>
<th class="wd-40p">Description</th>
<th class="tx-center">QNTY</th>
<th class="tx-right">Unit Price</th>
<th class="tx-right">Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>Website Design</td>
<td class="tx-12">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque
laudantium, totam rem aperiam...
</td>
<td class="tx-center">2</td>
<td class="tx-right">$150.00</td>
<td class="tx-right">$300.00</td>
</tr>
<tr>
<td>Firefox Plugin</td>
<td class="tx-12">At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium
voluptatum deleniti atque...
</td>
<td class="tx-center">1</td>
<td class="tx-right">$1,200.00</td>
<td class="tx-right">$1,200.00</td>
</tr>
<tr>
<td>iPhone App</td>
<td class="tx-12">Et harum quidem rerum facilis est et expedita distinctio</td>
<td class="tx-center">2</td>
<td class="tx-right">$850.00</td>
<td class="tx-right">$1,700.00</td>
</tr>
<tr>
<td>Android App</td>
<td class="tx-12">Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
velit, sed quia non numquam eius modi tempora incidunt ut
</td>
<td class="tx-center">3</td>
<td class="tx-right">$850.00</td>
<td class="tx-right">$2,550.00</td>
</tr>
<tr>
<td colspan="2" rowspan="4" class="valign-middle">
<div class="invoice-notes">
<label class="az-content-label tx-13">Notes</label>
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium,
totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae
dicta sunt explicabo. </p>
</div><!-- invoice-notes -->
</td>
<td class="tx-right">Sub-Total</td>
<td colspan="2" class="tx-right">$5,750.00</td>
</tr>
<tr>
<td class="tx-right">Tax (5%)</td>
<td colspan="2" class="tx-right">$287.50</td>
</tr>
<tr>
<td class="tx-right">Discount</td>
<td colspan="2" class="tx-right">-$50.00</td>
</tr>
<tr>
<td class="tx-right tx-uppercase tx-bold tx-inverse">Total Due</td>
<td colspan="2" class="tx-right"><h4 class="tx-primary tx-bold">$5,987.50</h4></td>
</tr>
</tbody>
</table>
</div><!-- table-responsive -->
<hr class="mg-b-40">
<a href="" class="btn btn-primary btn-block">Pay Now</a>
</div><!-- card-body -->
</div><!-- card -->
<div class="ps__rail-x" style="left: 0px; top: 0px;">
<div class="ps__thumb-x" tabindex="0" style="left: 0px; width: 0px;"></div>
</div>
<div class="ps__rail-y" style="top: 0px; height: 278px; right: 0px;">
<div class="ps__thumb-y" tabindex="0" style="top: 0px; height: 82px;"></div>
</div>
</div><!-- az-content-body -->
</div>
</div>

View File

@ -1,4 +1,8 @@
import { Component, OnInit } from '@angular/core';
import {FastenApiService} from '../../services/fasten-api.service';
import {ActivatedRoute, Router} from '@angular/router';
import {Source} from '../../models/fasten/source';
import {ResourceFhir} from '../../models/fasten/resource_fhir';
@Component({
selector: 'app-resource-detail',
@ -7,9 +11,16 @@ import { Component, OnInit } from '@angular/core';
})
export class ResourceDetailComponent implements OnInit {
constructor() { }
resource: ResourceFhir = null
constructor(private fastenApi: FastenApiService, private router: Router, private route: ActivatedRoute) {
}
ngOnInit(): void {
//always request the resource by id
this.fastenApi.getResourceBySourceId(this.route.snapshot.paramMap.get('source_id'), this.route.snapshot.paramMap.get('resource_id')).subscribe((resourceFhir) => {
this.resource = resourceFhir;
});
}
}

View File

@ -160,6 +160,17 @@ export class FastenApiService {
);
}
getResourceBySourceId(sourceId: string, resourceId: string): Observable<ResourceFhir> {
return this._httpClient.get<any>(`${this.getBasePath()}/api/secure/resource/fhir/${sourceId}/${resourceId}`)
.pipe(
map((response: ResponseWrapper) => {
console.log("RESPONSE", response)
return response.data as ResourceFhir
})
);
}
getMetadataSources(): Observable<{[name: string]: MetadataSource}> {
return this._httpClient.get<any>(`${this.getBasePath()}/api/metadata/source`)
.pipe(