Add files via upload

This commit is contained in:
gopi17701 2018-09-28 12:41:16 -04:00 committed by GitHub
parent bc42292d2c
commit b7d7dc48c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,368 +1,423 @@
import {HttpClient, HttpHeaders} from '@angular/common/http'; import {HttpClient, HttpHeaders} from '@angular/common/http';
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
@Injectable() @Injectable()
export class AstuteClientService { export class AstuteClientService {
headers = { headers = {
headers: new HttpHeaders().set('Content-Type', 'application/json'), headers: new HttpHeaders().set('Content-Type', 'application/json'),
}; };
private authUrl = 'http://localhost:8080/astutesystem/auth'; private authUrl = 'http://localhost:8080/astutesystem/auth';
private customerUrl = 'http://localhost:8080/astutesystem/customer'; private customerUrl = 'http://localhost:8080/astutesystem/customer';
private POUrl = 'http://localhost:8080/astutesystem/po'; private POUrl = 'http://localhost:8080/astutesystem/po';
private POServiceTypesUrl = 'http://localhost:8080/astutesystem/po/serviceTypes'; private POServiceTypesUrl = 'http://localhost:8080/astutesystem/po/serviceTypes';
private PODetailUrl = 'http://localhost:8080/astutesystem/po/detail'; private PODetailUrl = 'http://localhost:8080/astutesystem/po/detail';
private invoiceUrl = 'http://localhost:8080/astutesystem/invoice'; private invoiceUrl = 'http://localhost:8080/astutesystem/invoice';
private invoiceDetailUrl = 'http://localhost:8080/astutesystem/invoice/detail'; private invoiceDetailUrl = 'http://localhost:8080/astutesystem/invoice/detail';
private invoiceGenUrl = 'http://localhost:8080/astutesystem/invoice/generatedInvoice'; private invoiceGenUrl = 'http://localhost:8080/astutesystem/invoice/generatedInvoice';
private sessionId; private invoicePaymentUrl = 'http://localhost:8080/astutesystem/invoicePayment';
private sessionId;
constructor(private http: HttpClient) { }
constructor(private http: HttpClient) { }
// **************************************** AUTH Service methods
// **************************************** AUTH Service methods
public login(username: string, password: string): Promise<string> {
const data = { public login(username: string, password: string): Promise<string> {
'username': username, const data = {
'password': password 'username': username,
}; 'password': password
};
return this.http
.post(this.authUrl, data, this.headers) return this.http
.toPromise() .post(this.authUrl, data, this.headers)
.then(response => { .toPromise()
console.log(response['entity']); .then(response => {
const sessionId = response['entity']; console.log(response['entity']);
if (sessionId != null) { const sessionId = response['entity'];
localStorage.setItem('SESSION_ID', sessionId); if (sessionId != null) {
return sessionId; localStorage.setItem('SESSION_ID', sessionId);
} else { return sessionId;
return null; } else {
} return null;
}); }
} });
}
private getSessionId(): string {
console.log(localStorage.getItem('SESSION_ID')); private getSessionId(): string {
return localStorage.getItem('SESSION_ID'); console.log(localStorage.getItem('SESSION_ID'));
} return localStorage.getItem('SESSION_ID');
}
// **************************************** Customer Service methods
// **************************************** Customer Service methods
public getCustomers(): Promise<any> {
console.log("*** In getCustomers()"); public getCustomers(): Promise<any> {
const url = `${this.customerUrl}`; console.log("*** In getCustomers()");
return this.http.get(url) const url = `${this.customerUrl}`;
.toPromise() return this.http.get(url)
.then(response => { .toPromise()
console.log(response['entity']); .then(response => {
return response['entity']; console.log(response['entity']);
}); return response['entity'];
} });
}
public updateCustomer(customerId: number, data: any): Promise<any> {
console.log("*** In updateCustomer()"); public updateCustomer(customerId: number, data: any): Promise<any> {
const url = `${this.customerUrl}/${customerId}`; //TODO send sessionId console.log("*** In updateCustomer()");
return this.http.put(url, data) const url = `${this.customerUrl}/${customerId}`; //TODO send sessionId
.toPromise() return this.http.put(url, data)
.then(response => response['entity']); .toPromise()
} .then(response => response['entity']);
}
public createCustomer(data: any): Promise<any> {
console.log("*** In createCustomer()"); public createCustomer(data: any): Promise<any> {
const url = `${this.customerUrl}`; //TODO send sessionId console.log("*** In createCustomer()");
return this.http.post(url, data) const url = `${this.customerUrl}`; //TODO send sessionId
.toPromise() return this.http.post(url, data)
.then(response => response['entity']); .toPromise()
} .then(response => response['entity']);
}
// **************************************** PO Service methods
// **************************************** PO Service methods
public getPOs(): Promise<any> {
console.log("*** In getPOs()"); public getPOs(): Promise<any> {
const url = `${this.POUrl}`; console.log("*** In getPOs()");
return this.http.get(url) const url = `${this.POUrl}`;
.toPromise() return this.http.get(url)
.then(response => { .toPromise()
console.log(response['entity']); .then(response => {
return response['entity']; console.log(response['entity']);
}); return response['entity'];
} });
}
public getServiceTypes(): Promise<any> {
console.log("*** In getPOServiceTypes()"); public getServiceTypes(): Promise<any> {
const url = `${this.POServiceTypesUrl}`; console.log("*** In getPOServiceTypes()");
return this.http.get(url) const url = `${this.POServiceTypesUrl}`;
.toPromise() return this.http.get(url)
.then(response => { .toPromise()
console.log(response['entity']); .then(response => {
return response['entity']; console.log(response['entity']);
}); return response['entity'];
} });
}
public getPODetail(ponum): Promise<any> {
console.log("*** In getPODetails()"); public getPODetail(ponum): Promise<any> {
const url = `${this.PODetailUrl}?PONum=${ponum}`; console.log("*** In getPODetails()");
console.log(url); const url = `${this.PODetailUrl}?PONum=${ponum}`;
return this.http.get(url) console.log(url);
.toPromise() return this.http.get(url)
.then(response => { .toPromise()
console.log(response['entity']); .then(response => {
return response['entity']; console.log(response['entity']);
}); return response['entity'];
} });
}
public updatePO(ponum: string, data: any): Promise<any> {
console.log("*** In updatePO()"); public updatePO(ponum: string, data: any): Promise<any> {
const url = `${this.POUrl}/${ponum}`; //TODO send sessionId console.log("*** In updatePO()");
return this.http.put(url, data) const url = `${this.POUrl}/${ponum}`; //TODO send sessionId
.toPromise() return this.http.put(url, data)
.then(response => response['entity']); .toPromise()
} .then(response => response['entity']);
}
public createPO(data: any): Promise<any> {
console.log("*** In createPO()"); public createPO(data: any): Promise<any> {
const url = `${this.POUrl}`; //TODO send sessionId console.log("*** In createPO()");
return this.http.post(url, data) const url = `${this.POUrl}`; //TODO send sessionId
.toPromise() return this.http.post(url, data)
.then(response => response['entity']); .toPromise()
} .then(response => response['entity']);
}
// String serviceDesc;
// int feeTypeId; // String serviceDesc;
// Double qty; // int feeTypeId;
// int serviceTypeId; // Double qty;
// String schedule; // int serviceTypeId;
// Date deliverBy; // String schedule;
public updatePODetail(ponum, lineItemNo, data) { // Date deliverBy;
console.log("*** In updatePODetail()"); public updatePODetail(ponum, lineItemNo, data) {
const url = `${this.POUrl}/detail/${ponum}/${lineItemNo}`; //TODO send sessionId console.log("*** In updatePODetail()");
return this.http.put(url, data) const url = `${this.POUrl}/detail/${ponum}/${lineItemNo}`; //TODO send sessionId
.toPromise() return this.http.put(url, data)
.then(response => response['entity']); .toPromise()
} .then(response => response['entity']);
}
public createPODetail(data) {
console.log("*** In createPODetail()"); public createPODetail(data) {
const url = `${this.POUrl}/detail`; //TODO send sessionId console.log("*** In createPODetail()");
return this.http.post(url, data) const url = `${this.POUrl}/detail`; //TODO send sessionId
.toPromise() return this.http.post(url, data)
.then(response => response['entity']); .toPromise()
} .then(response => response['entity']);
}
// **************************************** Invoice Service methods
// **************************************** Invoice Service methods
// /{InvoiceNumber}/void
public submitInvoice (invoiceNumber) { // /{InvoiceNumber}/void
console.log("*** In submitInvoice(), invoiceNumber" + invoiceNumber); public submitInvoice (invoiceNumber) {
const url = `${this.invoiceUrl}/${invoiceNumber}/submit`; console.log("*** In submitInvoice(), invoiceNumber" + invoiceNumber);
return this.http.put(url, {}) const url = `${this.invoiceUrl}/${invoiceNumber}/submit`;
.toPromise() return this.http.put(url, {})
.then(response => { .toPromise()
console.log (response['entity']); .then(response => {
return response['entity']; console.log (response['entity']);
}); return response['entity'];
} });
}
public voidInvoice (invoiceNumber) {
console.log("*** In voidInvoice(), invoiceNumber" + invoiceNumber); public voidInvoice (invoiceNumber) {
const url = `${this.invoiceUrl}/${invoiceNumber}/void`; console.log("*** In voidInvoice(), invoiceNumber" + invoiceNumber);
return this.http.put(url, {}) const url = `${this.invoiceUrl}/${invoiceNumber}/void`;
.toPromise() return this.http.put(url, {})
.then(response => { .toPromise()
console.log (response['entity']); .then(response => {
return response['entity']; console.log (response['entity']);
}); return response['entity'];
} });
}
public deleteInvoice (invoiceNumber) {
console.log("*** In deleteInvoice(), invoiceNumber" + invoiceNumber); public deleteInvoice (invoiceNumber) {
const url = `${this.invoiceUrl}/${invoiceNumber}/delete`; console.log("*** In deleteInvoice(), invoiceNumber" + invoiceNumber);
return this.http.put(url, {}) const url = `${this.invoiceUrl}/${invoiceNumber}/delete`;
.toPromise() return this.http.put(url, {})
.then(response => { .toPromise()
console.log (response['entity']); .then(response => {
return response['entity']; console.log (response['entity']);
}); return response['entity'];
} });
}
public generateInvoiceNumber (ponum) {
console.log("*** In generateInvoiceNumber()"); public generateInvoiceNumber (ponum) {
const url = `${this.invoiceUrl}/generateInvoiceNumber/${ponum}`; console.log("*** In generateInvoiceNumber()");
return this.http.get(url) const url = `${this.invoiceUrl}/generateInvoiceNumber/${ponum}`;
.toPromise() return this.http.get(url)
.then(response => { .toPromise()
console.log (response['entity']) .then(response => {
return response['entity']; console.log (response['entity'])
}); return response['entity'];
} });
}
public getInvoices(): Promise<any> {
console.log("*** In getInvoices()"); public getInvoices(): Promise<any> {
const url = `${this.invoiceUrl}`; console.log("*** In getInvoices()");
return this.http.get(url) const url = `${this.invoiceUrl}`;
.toPromise() return this.http.get(url)
.then(response => { .toPromise()
console.log(response['entity']); .then(response => {
return response['entity']; console.log(response['entity']);
}); return response['entity'];
} });
}
public getInvoiceDetail(invoiceId: string): Promise<any> {
console.log("*** In getInvoiceDetail()"); public getInvoiceDetail(invoiceId: string): Promise<any> {
const url = `${this.invoiceDetailUrl}?invoiceNumber=${invoiceId}`; console.log("*** In getInvoiceDetail()");
return this.http.get(url) const url = `${this.invoiceDetailUrl}?invoiceNumber=${invoiceId}`;
.toPromise() return this.http.get(url)
.then(response => { .toPromise()
console.log(response['entity']); .then(response => {
return response['entity']; console.log(response['entity']);
}); return response['entity'];
} });
}
public getInvoiceGen (invoiceId: string): Promise<any> {
console.log("*** In getInvoiceGen()"); public getInvoiceGen (invoiceId: string): Promise<any> {
const url = `${this.invoiceGenUrl}/${invoiceId}`; console.log("*** In getInvoiceGen()");
return this.http.get(url) const url = `${this.invoiceGenUrl}/${invoiceId}`;
.toPromise() return this.http.get(url)
.then(response => { .toPromise()
console.log(response['entity']); .then(response => {
return response['entity']; console.log(response['entity']);
}); return response['entity'];
} });
}
public updateInvoice(invoiceNumber: string, data: any): Promise<any> {
console.log("*** In updateInvoice()"); public updateInvoice(invoiceNumber: string, data: any): Promise<any> {
const url = `${this.invoiceUrl}/${invoiceNumber}`; //TODO send sessionId console.log("*** In updateInvoice()");
return this.http.put(url, data) const url = `${this.invoiceUrl}/${invoiceNumber}`; //TODO send sessionId
.toPromise() return this.http.put(url, data)
.then(response => response['entity']); .toPromise()
} .then(response => response['entity']);
}
public createInvoice(data: any): Promise<any> {
console.log("*** In createInvoice()"); public createInvoice(data: any): Promise<any> {
const url = `${this.invoiceUrl}`; //TODO send sessionId console.log("*** In createInvoice()");
return this.http.post(url, data) const url = `${this.invoiceUrl}`; //TODO send sessionId
.toPromise() return this.http.post(url, data)
.then(response => response['entity']); .toPromise()
} .then(response => response['entity']);
}
public updateInvoiceDetail(invNum, lineItemNo, data) {
console.log("*** In updateInvoiceDetail()"); public updateInvoiceDetail(invNum, lineItemNo, data) {
const url = `${this.invoiceUrl}/detail/${invNum}/${lineItemNo}`; //TODO send sessionId console.log("*** In updateInvoiceDetail()");
return this.http.put(url, data) const url = `${this.invoiceUrl}/detail/${invNum}/${lineItemNo}`; //TODO send sessionId
.toPromise() return this.http.put(url, data)
.then(response => response['entity']); .toPromise()
} .then(response => response['entity']);
}
public createInvoiceDetail(data) {
console.log("*** In createInvoiceDetail()"); public createInvoiceDetail(data) {
const url = `${this.invoiceUrl}/detail`; //TODO send sessionId console.log("*** In createInvoiceDetail()");
return this.http.post(url, data) const url = `${this.invoiceUrl}/detail`; //TODO send sessionId
.toPromise() return this.http.post(url, data)
.then(response => response['entity']); .toPromise()
} .then(response => response['entity']);
}
// public getRecord(patientId: number): Promise<any> {
// const url = `${this.recordsUrl}/${patientId}?sessionId=${this.getSessionId()}`; // **************************************** Invoice Payment Service methods
// return this.http.get(url)
// .toPromise() public getSumittedInvoices(): Promise<any> {
// .then(response => { console.log("*** In getSumittedInvoices()");
// console.log(response); const url = `${this.invoiceUrl}/submitted`;
// }); return this.http.get(url)
// } .toPromise()
// .then(response => {
// public getInfo(patientId: number): Promise<any> { console.log(response['entity']);
// const url = `${this.recordsUrl}/${patientId}?sessionId=${this.getSessionId()}`; return response['entity'];
// return this.http.get(url) });
// .toPromise() }
// .then(response => {
// return response['entity']; public getInvoiceTypes(): Promise<any> {
// }); const url = `${this.invoicePaymentUrl}/paymentTypes`;
// } console.log("*** In getInvoiceTypes() ... calling " + url);
// return this.http.get(url)
// public getVisits(patientId: number): Promise<any> { .toPromise()
// const url = `${this.recordsUrl}/${patientId}/visits?sessionId=${this.getSessionId()}`; .then(response => {
// return this.http.get(url) console.log(response['entity']);
// .toPromise() return response['entity'];
// .then(response => { });
// return response['entity']; }
// });
// } public getInvoicePayments(): Promise<any> {
// console.log("*** In getInvoicePayments()");
// public getAllVisits(): Promise<any> { const url = `${this.invoicePaymentUrl}`;
// const url = `${this.recordsUrl}/visits?sessionId=${this.getSessionId()}`; return this.http.get(url)
// return this.http.get(url) .toPromise()
// .toPromise() .then(response => {
// .then(response => { console.log(response['entity']);
// return response['entity']; return response['entity'];
// }); });
// } }
//
// public getVitals(visitId: number): Promise<any> { public updateInvoicePayment(invoiceNumber: string, invoicePaymentId: string, data: any): Promise<any> {
// const url = `${this.visitsUrl}/${visitId}/vitals?sessionId=${this.getSessionId()}`; console.log("*** In updateInvoicePayment()");
// return this.http.get(url) const url = `${this.invoicePaymentUrl}/${invoiceNumber}/${invoicePaymentId}`; //TODO send sessionId
// .toPromise() console.log("*** invoicePaymentUrl is " + url);
// .then(response => { return this.http.put(url, data)
// return response['entity']; .toPromise()
// }); .then(response => response['entity']);
// } }
//
// public getLatestVitals(patientId: number): Promise<any> { public addInvoicePayment(data: any): Promise<any> {
// const url = `${this.recordsUrl}/${patientId}/vitals?sessionId=${this.getSessionId()}`; console.log("*** In addInvoicePayment()");
// return this.http.get(url) const url = `${this.invoicePaymentUrl}`; //TODO send sessionId
// .toPromise() return this.http.post(url, data)
// .then(response => { .toPromise()
// return response['entity']; .then(response => response['entity']);
// }); }
// }
// // public getRecord(patientId: number): Promise<any> {
// public updateInfo(patientId: number, data: any): Promise<any> { // const url = `${this.recordsUrl}/${patientId}?sessionId=${this.getSessionId()}`;
// const url = `${this.recordsUrl}/${patientId}?sessionId=${this.getSessionId()}`; // return this.http.get(url)
// return this.http.put(url, data) // .toPromise()
// .toPromise() // .then(response => {
// .then(response => response['entity']); // console.log(response);
// } // });
// public updateVisit(patientId: number, visit: any): Promise<any> { // }
// console.log(visit); //
// // public getInfo(patientId: number): Promise<any> {
// const url = `${this.recordsUrl}/${patientId}/visits/${visit.visitId}?sessionId=${this.getSessionId()}`; // const url = `${this.recordsUrl}/${patientId}?sessionId=${this.getSessionId()}`;
// return this.http.put(url, visit) // return this.http.get(url)
// .toPromise() // .toPromise()
// .then(response => { // .then(response => {
// console.log(response['entity']); // return response['entity'];
// return response['entity']; // });
// }); // }
// } //
// // public getVisits(patientId: number): Promise<any> {
// public getSessionPatientId(): Promise<number> { // const url = `${this.recordsUrl}/${patientId}/visits?sessionId=${this.getSessionId()}`;
// const url = `${this.sessionsUrl}/${this.getSessionId()}`; // return this.http.get(url)
// console.log(url); // .toPromise()
// return this.http.get(url) // .then(response => {
// .toPromise() // return response['entity'];
// .then(response => { // });
// console.log(response); // }
// return response['entity'].patientId; //
// }); // public getAllVisits(): Promise<any> {
// } // const url = `${this.recordsUrl}/visits?sessionId=${this.getSessionId()}`;
// // return this.http.get(url)
// public startVisit(patientId: number): Promise<any> { // .toPromise()
// const url = `${this.recordsUrl}/${patientId}/visits?${this.getSessionId()}`; // .then(response => {
// return this.http.post(url, null) // return response['entity'];
// .toPromise() // });
// .then(response => { // }
// console.log(response); //
// return response['entity']; // public getVitals(visitId: number): Promise<any> {
// }); // const url = `${this.visitsUrl}/${visitId}/vitals?sessionId=${this.getSessionId()}`;
// } // return this.http.get(url)
// // .toPromise()
// getMedications() { // .then(response => {
// const url = `${this.medsUrl}?${this.getSessionId()}`; // return response['entity'];
// return this.http.get(url) // });
// .toPromise() // }
// .then(response => { //
// console.log(response); // public getLatestVitals(patientId: number): Promise<any> {
// return response['entity']; // const url = `${this.recordsUrl}/${patientId}/vitals?sessionId=${this.getSessionId()}`;
// }); // return this.http.get(url)
// } // .toPromise()
} // .then(response => {
// return response['entity'];
// });
// }
//
// public updateInfo(patientId: number, data: any): Promise<any> {
// const url = `${this.recordsUrl}/${patientId}?sessionId=${this.getSessionId()}`;
// return this.http.put(url, data)
// .toPromise()
// .then(response => response['entity']);
// }
// public updateVisit(patientId: number, visit: any): Promise<any> {
// console.log(visit);
//
// const url = `${this.recordsUrl}/${patientId}/visits/${visit.visitId}?sessionId=${this.getSessionId()}`;
// return this.http.put(url, visit)
// .toPromise()
// .then(response => {
// console.log(response['entity']);
// return response['entity'];
// });
// }
//
// public getSessionPatientId(): Promise<number> {
// const url = `${this.sessionsUrl}/${this.getSessionId()}`;
// console.log(url);
// return this.http.get(url)
// .toPromise()
// .then(response => {
// console.log(response);
// return response['entity'].patientId;
// });
// }
//
// public startVisit(patientId: number): Promise<any> {
// const url = `${this.recordsUrl}/${patientId}/visits?${this.getSessionId()}`;
// return this.http.post(url, null)
// .toPromise()
// .then(response => {
// console.log(response);
// return response['entity'];
// });
// }
//
// getMedications() {
// const url = `${this.medsUrl}?${this.getSessionId()}`;
// return this.http.get(url)
// .toPromise()
// .then(response => {
// console.log(response);
// return response['entity'];
// });
// }
}