From baa4958854304b64bbae5d40b98eeb19cbd43567 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Wed, 15 May 2024 15:57:03 -0700 Subject: [PATCH] adding ability to request health system if missing. --- backend/pkg/models/request_healthsystem.go | 8 ++ backend/pkg/web/handler/healthsystem.go | 53 ++++++++++ backend/pkg/web/server.go | 1 + .../form-request-health-system.component.html | 96 +++++++++++++++++++ .../form-request-health-system.component.scss | 0 ...rm-request-health-system.component.spec.ts | 23 +++++ .../form-request-health-system.component.ts | 55 +++++++++++ frontend/src/app/components/shared.module.ts | 2 + .../fasten/form-request-health-system.spec.ts | 7 ++ .../fasten/form-request-health-system.ts | 6 ++ .../medical-sources.component.html | 11 ++- .../medical-sources.component.ts | 12 +++ .../src/app/services/fasten-api.service.ts | 11 +++ 13 files changed, 284 insertions(+), 1 deletion(-) create mode 100644 backend/pkg/models/request_healthsystem.go create mode 100644 backend/pkg/web/handler/healthsystem.go create mode 100644 frontend/src/app/components/form-request-health-system/form-request-health-system.component.html create mode 100644 frontend/src/app/components/form-request-health-system/form-request-health-system.component.scss create mode 100644 frontend/src/app/components/form-request-health-system/form-request-health-system.component.spec.ts create mode 100644 frontend/src/app/components/form-request-health-system/form-request-health-system.component.ts create mode 100644 frontend/src/app/models/fasten/form-request-health-system.spec.ts create mode 100644 frontend/src/app/models/fasten/form-request-health-system.ts diff --git a/backend/pkg/models/request_healthsystem.go b/backend/pkg/models/request_healthsystem.go new file mode 100644 index 000000000..309fefa01 --- /dev/null +++ b/backend/pkg/models/request_healthsystem.go @@ -0,0 +1,8 @@ +package models + +type RequestHealthSystem struct { + Email string `json:"email"` + Name string `json:"name"` + Website string `json:"website"` + StreetAddress string `json:"street_address"` +} diff --git a/backend/pkg/web/handler/healthsystem.go b/backend/pkg/web/handler/healthsystem.go new file mode 100644 index 000000000..7c0c18198 --- /dev/null +++ b/backend/pkg/web/handler/healthsystem.go @@ -0,0 +1,53 @@ +package handler + +import ( + "fmt" + "github.com/fastenhealth/fasten-onprem/backend/pkg/models" + "github.com/gin-gonic/gin" + "io/ioutil" + "net/http" + "net/url" +) + +func HealthSystemRequest(c *gin.Context) { + + var healthSystemRequest models.RequestHealthSystem + if err := c.ShouldBindJSON(&healthSystemRequest); err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()}) + return + } + + //submit support request to Google Form + //https://medium.com/front-end-augustus-study-notes/custom-google-form-en-f7be4c27a98b + + //source: https://docs.google.com/forms/d/e/1FAIpQLScH77CFpd3XAuwlUASFDJkOR54pZmt4AHqHa4xtZMGLXb1JIA/viewform?usp=sf_link + formUrl := "https://docs.google.com/forms/u/0/d/e/1FAIpQLScH77CFpd3XAuwlUASFDJkOR54pZmt4AHqHa4xtZMGLXb1JIA/formResponse" + + supportRequestResponse, err := http.PostForm(formUrl, url.Values{ + "entry.583209151": {healthSystemRequest.Email}, + "entry.1753315374": {healthSystemRequest.Name}, + "entry.1863832106": {healthSystemRequest.Website}, + "entry.751017705": {healthSystemRequest.StreetAddress}, + }) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()}) + return + } + + defer supportRequestResponse.Body.Close() + body, err := ioutil.ReadAll(supportRequestResponse.Body) + + if err != nil { + //handle read response error + c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()}) + return + } else if supportRequestResponse.StatusCode != 200 { + //handle non 200 response + c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": fmt.Sprintf("status code error: %d %s", supportRequestResponse.StatusCode, supportRequestResponse.Status)}) + return + } + + fmt.Printf("%s\n", string(body)) + + c.JSON(http.StatusOK, gin.H{"success": true}) +} diff --git a/backend/pkg/web/server.go b/backend/pkg/web/server.go index 1d6eac818..e74a18660 100644 --- a/backend/pkg/web/server.go +++ b/backend/pkg/web/server.go @@ -94,6 +94,7 @@ func (ae *AppEngine) Setup() (*gin.RouterGroup, *gin.Engine) { api.GET("/glossary/code", handler.GlossarySearchByCode) api.POST("/support/request", handler.SupportRequest) + api.POST("/healthsystem/request", handler.HealthSystemRequest) secure := api.Group("/secure").Use(middleware.RequireAuth()) { diff --git a/frontend/src/app/components/form-request-health-system/form-request-health-system.component.html b/frontend/src/app/components/form-request-health-system/form-request-health-system.component.html new file mode 100644 index 000000000..e35327ffc --- /dev/null +++ b/frontend/src/app/components/form-request-health-system/form-request-health-system.component.html @@ -0,0 +1,96 @@ +
+ + + + + + +
+ + + +
+ +

Success!

+

Your request has been recorded.
Thanks!

+ +
+
diff --git a/frontend/src/app/components/form-request-health-system/form-request-health-system.component.scss b/frontend/src/app/components/form-request-health-system/form-request-health-system.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/frontend/src/app/components/form-request-health-system/form-request-health-system.component.spec.ts b/frontend/src/app/components/form-request-health-system/form-request-health-system.component.spec.ts new file mode 100644 index 000000000..596942e53 --- /dev/null +++ b/frontend/src/app/components/form-request-health-system/form-request-health-system.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FormRequestHealthSystemComponent } from './form-request-health-system.component'; + +describe('FormRequestHealthSystemComponent', () => { + let component: FormRequestHealthSystemComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ FormRequestHealthSystemComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(FormRequestHealthSystemComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/components/form-request-health-system/form-request-health-system.component.ts b/frontend/src/app/components/form-request-health-system/form-request-health-system.component.ts new file mode 100644 index 000000000..6dc49ee35 --- /dev/null +++ b/frontend/src/app/components/form-request-health-system/form-request-health-system.component.ts @@ -0,0 +1,55 @@ +import { Component, OnInit } from '@angular/core'; +import {NgbActiveModal, NgbModal} from '@ng-bootstrap/ng-bootstrap'; +import {SupportRequest} from '../../models/fasten/support-request'; +import {FormRequestHealthSystem} from '../../models/fasten/form-request-health-system'; +import {environment} from '../../../environments/environment'; +import {versionInfo} from '../../../environments/versions'; +import {FastenApiService} from '../../services/fasten-api.service'; + +@Component({ + selector: 'app-form-request-health-system', + templateUrl: './form-request-health-system.component.html', + styleUrls: ['./form-request-health-system.component.scss'] +}) +export class FormRequestHealthSystemComponent implements OnInit { + formRequestHealthSystem: FormRequestHealthSystem = null + + loading: boolean = false + submitSuccess: boolean = false + errorMsg: string = "" + + constructor( + private fastenApi: FastenApiService, + public activeModal: NgbActiveModal, + ) { } + + ngOnInit(): void { + this.resetForm() + } + + resetForm() { + this.submitSuccess = false + let requestForm = new FormRequestHealthSystem() + requestForm.email = '' + requestForm.name = '' + requestForm.street_address = '' + requestForm.website = '' + + this.formRequestHealthSystem = requestForm + } + + submitForm() { + this.loading = true + this.fastenApi.requestHealthSystem(this.formRequestHealthSystem).subscribe((resp: any) => { + this.loading = false + this.submitSuccess = true + //show success toast? close modal? + }, + (err)=>{ + this.loading = false + console.error("an error occurred during request submission",err) + this.errorMsg = err || "An error occurred while submitting your request. Please try again later." + }) + } + +} diff --git a/frontend/src/app/components/shared.module.ts b/frontend/src/app/components/shared.module.ts index a6dbfca49..69fc6a22c 100644 --- a/frontend/src/app/components/shared.module.ts +++ b/frontend/src/app/components/shared.module.ts @@ -36,6 +36,7 @@ import {FhirCardModule} from './fhir-card/fhir-card.module'; import {FhirDatatableModule} from './fhir-datatable/fhir-datatable.module'; import { MedicalRecordWizardAddEncounterComponent } from './medical-record-wizard-add-encounter/medical-record-wizard-add-encounter.component'; import { MedicalRecordWizardAddLabResultsComponent } from './medical-record-wizard-add-lab-results/medical-record-wizard-add-lab-results.component'; +import { FormRequestHealthSystemComponent } from './form-request-health-system/form-request-health-system.component'; @NgModule({ imports: [ @@ -87,6 +88,7 @@ import { MedicalRecordWizardAddLabResultsComponent } from './medical-record-wiza MedicalSourcesConnectedComponent, MedicalSourcesCategoryLookupPipe, MedicalSourcesCardComponent, + FormRequestHealthSystemComponent, ], exports: [ ComponentsSidebarComponent, diff --git a/frontend/src/app/models/fasten/form-request-health-system.spec.ts b/frontend/src/app/models/fasten/form-request-health-system.spec.ts new file mode 100644 index 000000000..efbc2c49f --- /dev/null +++ b/frontend/src/app/models/fasten/form-request-health-system.spec.ts @@ -0,0 +1,7 @@ +import { FormRequestHealthSystem } from './form-request-health-system'; + +describe('FormRequestHealthSystem', () => { + it('should create an instance', () => { + expect(new FormRequestHealthSystem()).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/models/fasten/form-request-health-system.ts b/frontend/src/app/models/fasten/form-request-health-system.ts new file mode 100644 index 000000000..b3824ea14 --- /dev/null +++ b/frontend/src/app/models/fasten/form-request-health-system.ts @@ -0,0 +1,6 @@ +export class FormRequestHealthSystem { + name: string + email: string + website: string + street_address: string +} diff --git a/frontend/src/app/pages/medical-sources/medical-sources.component.html b/frontend/src/app/pages/medical-sources/medical-sources.component.html index dcc3390ba..748be90bd 100644 --- a/frontend/src/app/pages/medical-sources/medical-sources.component.html +++ b/frontend/src/app/pages/medical-sources/medical-sources.component.html @@ -73,12 +73,21 @@

Medical Record Sources

> +
+
+

+ No results Try another search term or request this health system. +

+
+
+
@@ -144,7 +153,7 @@