import { BillingConstants } from '../constants/billing.constants'; import { getLabShareConfiguration } from './common'; const conf = getLabShareConfiguration(); export class QueryBuilder { public date = new Date(); public month = this.date.getUTCMonth() + 1; public day = this.date.getUTCDate(); public year = this.date.getUTCFullYear(); public queryDate = `${this.year}-${this.month}-${this.day}`; public rtbQuery: any = { internalName: BillingConstants.STATUS, value: BillingConstants.RTB, operator: 'like' }; public billedQuery: any = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: this.queryDate, operator: 'lte' } ] }; public buildRTBQuery(sectionNames, listName, endDate) { const listNames = listName.toLowerCase(); const sectionName = sectionNames.toLowerCase(); if (listNames === BillingConstants.RESERVATIONS) { this.rtbQuery = { and: [ { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'neq' }, { internalName: BillingConstants.STATUS, value: BillingConstants.CANCELLED, operator: 'neq' } ] }, { internalName: BillingConstants.EVENT_DATE, value: endDate, operator: 'lte' } ] }; return this.rtbQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_BIS) { if (listNames === BillingConstants.POSTER_PRINTER) { this.rtbQuery = { and: [ { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'neq' }, { internalName: BillingConstants.STATUS, value: BillingConstants.CANCELLED, operator: 'neq' } ] }, { internalName: BillingConstants.EVENT_DATE, value: endDate, operator: 'lte' } ] }; } return this.rtbQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_FCS || sectionName === conf.billing.facilityID + BillingConstants.MYRTB_MICRO_ARRAY) { this.rtbQuery = { internalName: BillingConstants.STATUS, value: BillingConstants.RTB, operator: 'like' }; return this.rtbQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_ANTIBODY) { if (listNames === BillingConstants.REQUESTS) { this.rtbQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.RTB, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; } return this.rtbQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_PNCHEM) { switch (listNames) { case BillingConstants.PROTEIN_ID_REQUESTS: case BillingConstants.INTACT_MASS_REQUESTS: this.rtbQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.COMPLETED, operator: 'like' }, { internalName: BillingConstants.COMPLETED_DATE, value: endDate, operator: 'lte' } ] }; break; case BillingConstants.PEPTIDE_REQUESTS: this.rtbQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.RTB, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; break; case BillingConstants.PROTEIN_SEQ_REQUESTS: this.rtbQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.COMPLETED, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; break; default: this.rtbQuery = { internalName: BillingConstants.STATUS, value: BillingConstants.RTB, operator: 'like' }; } return this.rtbQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_RML_GENOMICS) { switch (listNames) { case BillingConstants.DNA_SEQ_REQUESTS: case BillingConstants.CUSTOM_PCR_REQUESTS: case BillingConstants.MICROARRAY_REQUESTS: this.rtbQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.RTB, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; break; case BillingConstants.PROJECT_CHARGES: case BillingConstants.QPCR_EXPERIMENTS: case BillingConstants.EXPRESSION_EXPERIMENTS: this.rtbQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.RTB, operator: 'like' }, { internalName: BillingConstants.SUBMITTED_DATE, value: endDate, operator: 'lte' } ] }; break; default: this.rtbQuery = { internalName: BillingConstants.STATUS, value: BillingConstants.RTB, operator: 'like' }; } return this.rtbQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_RML_EM) { if (listNames === BillingConstants.PROJECT_SUBSETS) { this.rtbQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.RTB, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; } return this.rtbQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_STRUCTURALBIO) { if (listNames === BillingConstants.PROJECT_CHARGES) { this.rtbQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.RTB, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; } return this.rtbQuery; } return this.rtbQuery; } public buildBilledQuery(sectionNames, listName, endDate) { const listNames = listName.toLowerCase(); const sectionName = sectionNames.toLowerCase(); if (listNames === BillingConstants.RESERVATIONS) { this.billedQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'like' }, { internalName: BillingConstants.EVENT_DATE, value: endDate, operator: 'lte' } ] }; return this.billedQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_BIS) { if (listNames === BillingConstants.POSTER_PRINTER) { this.billedQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'like' }, { internalName: BillingConstants.EVENT_DATE, value: endDate, operator: 'lte' } ] }; } return this.billedQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_FCS) { this.billedQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; return this.billedQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_MICRO_ARRAY) { this.billedQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILLING_STATUS, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; return this.billedQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_ANTIBODY) { if (listNames === BillingConstants.REQUESTS) { this.billedQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; } return this.billedQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_PNCHEM) { switch (listNames) { case BillingConstants.PROTEIN_ID_REQUESTS: case BillingConstants.INTACT_MASS_REQUESTS: this.billedQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'like' }, { internalName: BillingConstants.COMPLETED_DATE, value: endDate, operator: 'lte' } ] }; break; case BillingConstants.PEPTIDE_REQUESTS: case BillingConstants.PROTEIN_SEQ_REQUESTS: this.billedQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; break; default: this.billedQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; } return this.billedQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_RML_GENOMICS) { switch (listNames) { case BillingConstants.DNA_SEQ_REQUESTS: case BillingConstants.CUSTOM_PCR_REQUESTS: case BillingConstants.MICROARRAY_REQUESTS: case BillingConstants.QPCR_EXPERIMENTS: case BillingConstants.EXPRESSION_EXPERIMENTS: this.billedQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; break; case BillingConstants.PROJECT_CHARGES: this.billedQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'like' }, { internalName: BillingConstants.SUBMITTED_DATE, value: endDate, operator: 'lte' } ] }; break; default: this.billedQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; } return this.billedQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_RML_EM) { if (listNames === BillingConstants.PROJECT_SUBSETS) { this.billedQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; } return this.billedQuery; } if (sectionName === conf.billing.facilityID + BillingConstants.MYRTB_STRUCTURALBIO) { if (listNames === BillingConstants.PROJECT_CHARGES) { this.billedQuery = { and: [ { internalName: BillingConstants.STATUS, value: BillingConstants.BILL, operator: 'like' }, { internalName: BillingConstants.REQUEST_DATE, value: endDate, operator: 'lte' } ] }; } return this.billedQuery; } return this.billedQuery; } }