@jonatandor35
import wixData from ‘wix-data’ ;
export function Consultations_afterQuery(item, context) {
item.ConsultID = item._id.slice( 0 , 8 ).toUpperCase();
item.consultCode = item.patientID + “-” + item.ConsultID;
const eyes = item.gcsEyes;
const verbal = item.gcsVerbal;
const motor = item.gcsMotor;
item.gcs = Number(eyes) + Number(verbal) + Number(motor);
return item;
}
// …
export function Contacts_afterQuery(item, context) {
//item.Geolocation = item.latitude +“,”+ item.longitude;
//firstName==================================
const fstr = item.firstName;
const lstr = item.lastName;
function capitalize(string) {
return string.charAt( 0 ).toUpperCase() + string.slice( 1 );
}
const capsfname = fstr.split( ’ ’ ).map(capitalize).join( ’ ’ );
const capslname = lstr.split( ’ ’ ).map(capitalize).join( ’ ’ );
item.firstName = capsfname;
item.lastName = capslname;
item.fileName = capslname + “, " + capsfname + " (” + item.title + “)” ;
item.PatientID = item._id.slice( 0 , 4 ).toUpperCase();
item.fileNo = item.lastName + " [" + item.PatientID+ “]” ;
item.PtID = item._id;
//==========================================
var appTime = item.appTime;
var appDate = item.appDate- 1 ;
var DOB = item.DOB;
const days = [
‘Domingo’ ,
‘Lunes’ ,
‘Martes’ ,
‘Miércoles’ ,
‘Jueves’ ,
‘Viernes’ ,
‘Sábado’
]
const months = {
0 : ‘Enero’ ,
1 : ‘Febrero’ ,
2 : ‘Marzo’ ,
3 : ‘Abril’ ,
4 : ‘Mayo’ ,
5 : ‘Junio’ ,
6 : ‘Julio’ ,
7 : ‘Agosto’ ,
8 : ‘Septiembre’ ,
9 : ‘Octubre’ ,
10 : ‘Noviembre’ ,
11 : ‘Diciembre’
}
const n = (DOB) //Math.round(DOB);
const d = new Date(appDate);
//const y = Math.round(((((Date.now() - new Date(n))/1000)/60)/60)/24/365).toFixed(1);
const y = (((((Date.now() - new Date(n))/1000)/ 60 )/60)/ 24 / 365 ).toFixed( 1 );
const yyyy = d.getFullYear(appDate);
const dayName = days[d.getDay(appDate)]
const dd = d.getDate(appDate);
const monthIndex = d.getMonth(appDate);
const monthName = months[monthIndex];
const today = Date.now();
const yesterday = Date.now()- 1 ;
item.years = y;
item.dayName = dayName;
item.appSlot = dd + " " + monthName + " " + yyyy + " @ " + appTime
if (appDate > yesterday) {
item.validApp = “Yes” ;
}
if (appDate < today) {
item.validApp = “No” ;
}
return item;
}