Skip to content

Commit 27268f2

Browse files
committed
Cleanup
1 parent 17ed7df commit 27268f2

File tree

2 files changed

+2
-213
lines changed

2 files changed

+2
-213
lines changed

frontend/src/app/pages/medical-sources/medical-sources.component.html

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<div class="az-content">
22
<div class="container">
3-
<app-medical-sources-filter [categories]="resultLimits.categoryBuckets" [platformTypes]="resultLimits.platformTypesBuckets"></app-medical-sources-filter>
4-
<div class="az-content-body pd-lg-l-40 d-flex flex-column">
3+
<div class="az-content-body d-flex flex-column">
54
<div class="az-content-breadcrumb">
65
<span>Medical Sources</span>
76
</div>
@@ -46,56 +45,6 @@ <h2 class="az-content-title mg-t-40">Medical Record Sources</h2>
4645
</div><!-- col -->
4746
</div><!-- row -->
4847

49-
<hr class="mg-y-30">
50-
51-
<div class="az-content-label mg-b-5">Healthcare Companies</div>
52-
<p class="mg-b-20">The following medical companies have API's which Fasten can use to retrieve your medical history.
53-
Please click the logos below to initiate the connection.</p>
54-
55-
<!-- Search -->
56-
<div class="row row-sm sticky-top pt-2" style="position:sticky;">
57-
<div class="col-lg-8">
58-
<div class="input-group mb-3">
59-
<div class="input-group-prepend">
60-
<span class="input-group-text" id="search-prefix">Search</span>
61-
</div>
62-
<input [ngModel]="searchTermUpdate | async" (keyup)="searchTermUpdate.next($event.target.value)" type="text" class="form-control" placeholder="Search Term">
63-
<div class="input-group-append">
64-
<span class="input-group-text">{{this.availableLighthouseBrandList.length}} of {{this.resultLimits.totalItems}} results</span>
65-
</div>
66-
67-
</div><!-- input-group -->
68-
</div><!-- col -->
69-
</div>
70-
71-
72-
<div *ngIf="!loading || availableLighthouseBrandList.length > 0 else isLoadingTemplate" class="row row-sm"
73-
infiniteScroll
74-
[infiniteScrollDistance]="2"
75-
[infiniteScrollThrottle]="50"
76-
(scrolled)="onScroll()"
77-
>
78-
79-
<app-medical-sources-card class="col-sm-3 mg-b-20 px-3"
80-
81-
*ngFor="let lighthouseBrand of availableLighthouseBrandList"
82-
[sourceInfo]="lighthouseBrand"
83-
[status]="status[lighthouseBrand.brand.id]"
84-
(onClick)="connectModalHandler(contentModalRef, $event)"
85-
></app-medical-sources-card>
86-
87-
<div *ngIf="availableLighthouseBrandList.length == 0" class="mg-b-60 w-100">
88-
<div class="card card-body bg-gray-200 bd-0">
89-
<p class="card-text">
90-
<strong>No results</strong> Try another search term or <a (click)="showRequestHealthSystemModal()" class="link">request this health system</a>.
91-
</p>
92-
</div>
93-
</div>
94-
95-
</div><!-- row -->
96-
97-
<div class="ht-40"></div>
98-
9948
</div><!-- az-content-body -->
10049
</div><!-- container -->
10150
</div><!-- az-content -->

frontend/src/app/pages/medical-sources/medical-sources.component.ts

Lines changed: 1 addition & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export class MedicalSourcesComponent implements OnInit {
4242
uploadedFile: File[] = []
4343
uploadErrorMsg: string = ""
4444

45-
availableLighthouseBrandList: SourceListItem[] = []
4645
searchTermUpdate = new BehaviorSubject<string>("");
4746
status: { [name: string]: undefined | "token" | "authorize" } = {}
4847

@@ -54,18 +53,7 @@ export class MedicalSourcesComponent implements OnInit {
5453
// aggregations: undefined,
5554
}
5655

57-
//limits that are tied to the current result set.
58-
resultLimits: {
59-
totalItems: number,
60-
scrollComplete: boolean,
61-
platformTypesBuckets: LighthouseSourceSearchAggregation,
62-
categoryBuckets: LighthouseSourceSearchAggregation,
63-
} = {
64-
totalItems: 0,
65-
scrollComplete: false,
66-
platformTypesBuckets: undefined,
67-
categoryBuckets: undefined
68-
}
56+
6957

7058

7159
//source of truth for current state
@@ -89,148 +77,13 @@ export class MedicalSourcesComponent implements OnInit {
8977
private modalService: NgbModal,
9078

9179
) {
92-
this.filterService.filterChanges.subscribe((filterInfo) => {
93-
94-
//this function should only trigger when there's a change to the filter values -- which requires a new query
95-
this.availableLighthouseBrandList = []
96-
this.resultLimits.totalItems = 0
97-
this.resultLimits.scrollComplete = false
98-
99-
//update the form with data from route (don't emit a new patch event), then submit query
100-
this.querySources(filterInfo?.filter).subscribe(null, null, () => {})
101-
})
10280
}
10381

10482
ngOnInit(): void {
10583

106-
107-
// TODO: handle Callbacks from the source connect window
108-
const callbackState = this.activatedRoute.snapshot.paramMap.get('state')
109-
if(callbackState){
110-
111-
//get the source state information from localstorage
112-
let sourceStateInfo = this.lighthouseApi.getSourceState(callbackState)
113-
114-
//move this source from available to connected (with a progress bar)
115-
//remove item from available sources list, add to connected sources.
116-
let inProgressAvailableIndex = this.availableLighthouseBrandList.findIndex((item) => item.brand.id == sourceStateInfo.brand_id)
117-
if(inProgressAvailableIndex > -1){
118-
let sourcesInProgress = this.availableLighthouseBrandList.splice(inProgressAvailableIndex, 1);
119-
}
120-
}
121-
//we're not in a callback redirect, lets load the sources
122-
if(this.activatedRoute.snapshot.queryParams['query']){
123-
this.searchTermUpdate.next(this.activatedRoute.snapshot.queryParams['query'])
124-
}
125-
126-
127-
//register a callback for when the search box content changes
128-
this.searchTermUpdate
129-
.pipe(
130-
debounceTime(200),
131-
distinctUntilChanged(),
132-
)
133-
.subscribe(value => {
134-
let currentQuery = this.filterService.filterForm.value.query || ""
135-
if(value != null && currentQuery != value){
136-
this.filterService.filterForm.patchValue({query: value})
137-
}
138-
});
139-
140-
}
141-
142-
private querySources(filter?: MedicalSourcesFilter): Observable<LighthouseSourceSearch> {
143-
if(this.loading){
144-
return of(null)
145-
}
146-
//TODO: pass filter to function.
147-
// this.location.replaceState('/dashboard','', this.filter)
148-
149-
if(!filter){
150-
filter = this.filterService.toMedicalSourcesFilter(this.filterForm.value)
151-
}
152-
153-
154-
filter.fields = ["*"];
155-
this.loading = true
156-
var searchObservable = this.lighthouseApi.searchLighthouseSources(filter);
157-
searchObservable.subscribe(wrapper => {
158-
// this.searchResults = wrapper.hits.hits;
159-
this.resultLimits.totalItems = wrapper.hits.total.value;
160-
161-
this.availableLighthouseBrandList = this.availableLighthouseBrandList.concat(wrapper.hits.hits.map((result) => {
162-
return {
163-
brand: result._source,
164-
searchHighlights: result?.highlight?.aliases || []
165-
}
166-
}))
167-
168-
//check if scroll is complete.
169-
if(!wrapper?.hits || !wrapper?.hits?.hits || wrapper?.hits?.hits?.length == 0 || wrapper?.hits?.total?.value == wrapper?.hits?.hits?.length){
170-
this.resultLimits.scrollComplete = true;
171-
} else {
172-
//change the current Page (but don't cause a new query)
173-
this.filterService.filterForm.patchValue({searchAfter: wrapper.hits.hits[wrapper.hits.hits.length - 1].sort.join(",")}, {emitEvent: false})
174-
}
175-
176-
// .filter((item) => {
177-
// return !this.connectedSourceList.find((connectedItem) => connectedItem.metadata.source_type == item.metadata.source_type)
178-
// }))
179-
180-
181-
if(wrapper.aggregations){
182-
this.resultLimits.platformTypesBuckets = wrapper.aggregations.by_platform_type;
183-
this.resultLimits.categoryBuckets = wrapper.aggregations.by_category;
184-
var currentCategories = this.filterForm.get('categories').value;
185-
this.resultLimits.categoryBuckets.buckets.forEach((bucketData) => {
186-
if(!currentCategories.hasOwnProperty(bucketData.key)){
187-
(this.filterForm.get('categories') as FormGroup).addControl(bucketData.key, new FormControl(false))
188-
}
189-
})
190-
191-
var currentPlatformTypes = this.filterForm.get('platformTypes').value;
192-
this.resultLimits.platformTypesBuckets.buckets.forEach((bucketData) => {
193-
if(!currentPlatformTypes.hasOwnProperty(bucketData.key)){
194-
(this.filterForm.get('platformTypes') as FormGroup).addControl(bucketData.key, new FormControl(false))
195-
}
196-
})
197-
198-
//
199-
// this.resultLimits.categoryBuckets.forEach((bucketData) => {
200-
// if(!this.globalLimits.categories.some((category) => { return category.id === bucketData.key})){
201-
// this.globalLimits.categories.push({
202-
// id: bucketData.key,
203-
// name: bucketData.key,
204-
// group: 'custom'
205-
// })
206-
// }
207-
// })
208-
209-
// const fileTypes = <FormGroup>this.filterForm.get('fileTypes');
210-
// fileTypes.forEach((option: any) => {
211-
// checkboxes.addControl(option.title, new FormControl(true));
212-
// });
213-
}
214-
215-
this.loading = false
216-
},
217-
error => {
218-
this.loading = false
219-
console.error("sources FAILED", error)
220-
},
221-
() => {
222-
this.loading = false
223-
}
224-
);
225-
return searchObservable;
22684
}
22785

22886

229-
public onScroll(): void {
230-
if(!this.resultLimits.scrollComplete) {
231-
this.querySources()
232-
}
233-
}
23487

23588
//OLD FUNCTIONS
23689
//
@@ -367,17 +220,4 @@ export class MedicalSourcesComponent implements OnInit {
367220
})
368221
}
369222

370-
showRequestHealthSystemModal(): Promise<boolean> {
371-
return this.modalService.open(FormRequestHealthSystemComponent).result.then<boolean>(
372-
(result) => {
373-
//convert button clicked, .close()
374-
return true
375-
}
376-
).catch((reason) => {
377-
// x or cancel button clicked, .dismiss()
378-
return false
379-
})
380-
}
381-
382-
383223
}

0 commit comments

Comments
 (0)