diff --git a/health_portal/src/app/app-routing.module.ts b/health_portal/src/app/app-routing.module.ts
index 6690c67..7469c35 100644
--- a/health_portal/src/app/app-routing.module.ts
+++ b/health_portal/src/app/app-routing.module.ts
@@ -29,7 +29,7 @@ const routes: Routes = [
{ path: 'view-profile/:profileId', component: ViewProfileComponent },
{ path: 'update-profile/:profileId', component: UpdateProfileComponent },
{ path: 'list-prescription/:profileId', component: ListPrescriptionComponent },
- { path: 'create-prescription', component: CreatePrescriptionComponent },
+ { path: 'create-prescription/:profileId', component: CreatePrescriptionComponent },
{ path: 'view-prescription/:profileId/:prescriptionId', component: ViewPrescriptionComponent },
{ path: 'update-prescription/:profileId/:prescriptionId', component: UpdatePrescriptionComponent },
{ path: 'health-advice/:profileId', component: HealthAdviceComponent },
diff --git a/health_portal/src/app/components/prescription/create-prescription/create-prescription.component.html b/health_portal/src/app/components/prescription/create-prescription/create-prescription.component.html
index b27635e..04b3a55 100644
--- a/health_portal/src/app/components/prescription/create-prescription/create-prescription.component.html
+++ b/health_portal/src/app/components/prescription/create-prescription/create-prescription.component.html
@@ -1 +1,51 @@
-
create-prescription works!
+Create Prescription
+
+
+
+
+
+
+
You submitted successfully!
+
\ No newline at end of file
diff --git a/health_portal/src/app/components/prescription/create-prescription/create-prescription.component.ts b/health_portal/src/app/components/prescription/create-prescription/create-prescription.component.ts
index f27146a..3287750 100644
--- a/health_portal/src/app/components/prescription/create-prescription/create-prescription.component.ts
+++ b/health_portal/src/app/components/prescription/create-prescription/create-prescription.component.ts
@@ -1,4 +1,8 @@
import { Component } from '@angular/core';
+import { Prescription } from "./../../../documents/prescription";
+import { PrescriptionService } from "./../../../service/prescription.service";
+import { Router, ActivatedRoute } from '@angular/router';
+import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-create-prescription',
@@ -7,4 +11,44 @@ import { Component } from '@angular/core';
})
export class CreatePrescriptionComponent {
-}
+ prescription: Prescription = new Prescription();
+ submitted = false;
+ profileId: string;
+ prescriptionId: string;
+
+ constructor(
+ private route: ActivatedRoute,
+ private prescriptionService: PrescriptionService,
+ private router: Router,
+ private fb: FormBuilder
+ ) {
+ }
+
+ ngOnInit() {
+ this.profileId = this.route.snapshot.paramMap.get('profileId');
+ }
+
+ newProfile(): void {
+ this.submitted = false;
+ this.prescription = new Prescription();
+ }
+
+ save() {
+ this.prescription.profileId = this.profileId;
+ this.prescriptionService.createPrescription(this.prescription)
+ .subscribe(data => console.log(data), error => console.log(error));
+ this.prescription = new Prescription();
+ alert("Prescription created successfully!");
+ this.gotoList(this.profileId);
+ }
+
+ onSubmit() {
+ this.submitted = true;
+ this.save();
+ }
+
+ gotoList(profileId: String) {
+ this.router.navigate(['list-prescription', profileId]);
+ }
+
+}
\ No newline at end of file
diff --git a/health_portal/src/app/components/prescription/list-prescription/list-prescription.component.html b/health_portal/src/app/components/prescription/list-prescription/list-prescription.component.html
index 6d97f49..be49b0a 100644
--- a/health_portal/src/app/components/prescription/list-prescription/list-prescription.component.html
+++ b/health_portal/src/app/components/prescription/list-prescription/list-prescription.component.html
@@ -8,7 +8,7 @@ You're now viewing your prescription list
Prescription List
-
+
diff --git a/health_portal/src/app/components/prescription/list-prescription/list-prescription.component.ts b/health_portal/src/app/components/prescription/list-prescription/list-prescription.component.ts
index 8941326..07ee09c 100644
--- a/health_portal/src/app/components/prescription/list-prescription/list-prescription.component.ts
+++ b/health_portal/src/app/components/prescription/list-prescription/list-prescription.component.ts
@@ -45,6 +45,10 @@ export class ListPrescriptionComponent {
// this.router.navigate(['view-prescription', prescriptionId]);
// }
+ createPrescription() {
+ this.router.navigate(['create-prescription', this.profileId]);
+ }
+
updatePrescription(profileId: String, prescriptionId: String) {
this.router.navigate(['update-prescription', profileId, prescriptionId]);
}
diff --git a/health_portal/src/app/components/prescription/update-prescription/update-prescription.component.html b/health_portal/src/app/components/prescription/update-prescription/update-prescription.component.html
index b94077e..ec9ae91 100644
--- a/health_portal/src/app/components/prescription/update-prescription/update-prescription.component.html
+++ b/health_portal/src/app/components/prescription/update-prescription/update-prescription.component.html
@@ -1,4 +1,4 @@
-Update Profile
+Update Prescription