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