1/*************************************************************************************** 2 * @author Sachin Ranvirkar 3 * @date 08/08/2016 4 * @description filter logic of location, category, appointment type and practitioner. 5 ****************************************************************************************/ 6var app = app || {}; 7 8app.criteriaSelection = function(dropDownData){ 9 10 this.dropDownData = dropDownData; 11 12 // Data objects according to dynamic conditions. 13 this.FilteredObj = {}; // If nothing is selected 14 this.getCommonTimeSlot = []; //variable to store common time slot for grp of SP 15 this.commonTimeSlot = ''; //common time slot string 16 /* this.FilteredObj= {}; // If Location is selected 17 this.FilteredObj = {}; // If Location and Category is selected 18 this.FilteredObj = {}; // If Location and Doctor is selected 19 this.FilteredObj= {}; // If all selected. 20 this.FilteredObj= {}; // If category is selected. 21 this.FilteredObj= {}; // If category and doctor is selected. 22 this.FilteredObj= {}; // If doctor is selected. 23 this.FilteredObj= {};// If appoinmenttype is Selected 24 this.FilteredObj= {}; // If appoinmenttype, Location and category are selected 25 this.FilteredObj= {};// If category appoinmenttype doctor are selected 26 this.FilteredObj= {}; //If location category appoinmenttype doctor are selected */ 27 28 /*this.selectedLocation= "a083600000EhnciAAB"; 29 this.selectedCategory= ''; 30 this.selectedPractitioner= '';*/ 31 32 this.removeEmptyCategories = function(){ 33 var that = this; 34 for(var key in that.FilteredObj){ 35 var tempCategories = []; 36 for(var i=0, catLen=that.FilteredObj[key].categories.length; i<catLen; i++){ 37 if(that.FilteredObj[key].categories[i]){ 38 tempCategories.push(that.FilteredObj[key].categories[i]); 39 } 40 }; 41 that.FilteredObj[key].categories = tempCategories; 42 } 43 }; 44 45 this.getFilteredCategories = function(locationId){ 46 var that = this; 47 var locationSpecificArr = that.dropDownData.displayData.filter(function(elm){ 48 return elm.locationId == locationId; 49 }); 50 var categories = that.findUniqueCategories(locationSpecificArr); 51 return categories; 52 }; 53 54 this.getFilteredLocation = function(){ 55 var that = this; 56 var uniqueLocations = that.findUniqueLocation(that.dropDownData.displayData); 57 return uniqueLocations; 58 }; 59 60 this.findLocations= function(selectedCategory){ 61 62 var tempArr = []; 63 var uniqueLocations = []; 64 for(var i=0, catLen=selectedCategory.length; i<catLen; i++){ 65 if(tempArr.indexOf(selectedCategory[i].locationId) == -1){ 66 tempArr.push(selectedCategory[i].locationId); 67 uniqueLocations.push({locationId:selectedCategory[i].locationId,locationName:selectedCategory[i].locationName,locationAddress:selectedCategory[i].locationAddress}); 68 } 69 } 70 return uniqueLocations; 71 }; 72 73 this.findUniqueLocation = function(locationList){ 74 var uniqueLocations = []; 75 var temp = []; 76 if(locationList.length){ 77 for(var i=0, locLength=locationList.length; i<locLength; i++ ){ 78 if(temp.indexOf(locationList[i].locationId) === -1){ 79 temp.push(locationList[i].locationId); 80 uniqueLocations.push(locationList[i]); 81 } 82 } 83 } 84 return uniqueLocations; 85 }; 86 87 this.findDoctor= function(selectedCategory){ 88 var tempArr = []; 89 var uniqueDoctor = []; 90 for(var i=0, catLen=selectedCategory.length; i<catLen; i++){ 91 if(tempArr.indexOf(selectedCategory[i].serviceProviderId) == -1){ 92 tempArr.push(selectedCategory[i].serviceProviderId); 93 uniqueDoctor.push({id:selectedCategory[i].serviceProviderId, name:selectedCategory[i].serviceProviderName, profilePic:selectedCategory[i].profilePicUrl}); 94 } 95 } 96 return uniqueDoctor; 97 //console.log('uniqueDoctor',uniqueDoctor); 98 }; 99 100 101 this.findUniqueCategories = function(catArr){ 102 var tempArr = []; 103 var uniqueCategories = []; 104 for(var i=0, catLen=catArr.length; i<catLen; i++){ 105 if(tempArr.indexOf(catArr[i].categoryId) == -1){ 106 tempArr.push(catArr[i].categoryId); 107 uniqueCategories.push({categoryId:catArr[i].categoryId,categoryName:catArr[i].categoryName,mappingId:catArr[i].mappingId}); 108 } 109 } 110 return uniqueCategories; 111 }; 112 113 this.getAppTypesforLocCatAndPractitioner= function(locationSpecificArr,categorySpecificArr,practitionersArr){ 114 115 var tempArr = []; 116 var uniqueLocations = []; 117 var intersectionForLocAndCat= []; 118 var intersectionForUniqueCat= []; 119 for(var i=0, catLen=locationSpecificArr.length; i<catLen; i++){ 120 if(tempArr.indexOf(locationSpecificArr[i].categoryId) == -1){ 121 tempArr.push(locationSpecificArr[i].categoryId); 122 uniqueLocations.push({categoryId:locationSpecificArr[i].locationId,categoryName:locationSpecificArr[i].categoryName,mappingId:locationSpecificArr[i].mappingId}); 123 } 124 } 125 126 var tempArr1 = []; 127 var uniqueCategories = []; 128 for(var i=0, catLen=categorySpecificArr.length; i<catLen; i++){ 129 if(tempArr1.indexOf(categorySpecificArr[i].categoryId) == -1){ 130 tempArr1.push(categorySpecificArr[i].categoryId); 131 uniqueCategories.push({categoryId:categorySpecificArr[i].categoryId,categoryName:categorySpecificArr[i].categoryName,mappingId:categorySpecificArr[i].mappingId}); 132 } 133 } 134 135 _.each(uniqueLocations, function(elmUniqueCategoriesByLocation) { 136 var entry = _.find(uniqueLocations, function(elmUniqueCategories) {return elmUniqueCategoriesByLocation.categoryId == elmUniqueCategories.categoryId;}); 137 if (entry) intersectionForLocAndCat.push(entry); 138 }); 139 140 //console.log('intersectionForLocAndCat',intersectionForLocAndCat); 141 var tempArr2 = []; 142 var practitioners = []; 143 for(var i=0, catLen=practitionersArr.length; i<catLen; i++){ 144 if(tempArr2.indexOf(practitionersArr[i].serviceProviderID) == -1){ 145 tempArr2.push(practitionersArr[i].categoryId); 146 practitioners.push({categoryId:practitionersArr[i].categoryId,categoryName:practitionersArr[i].categoryName,mappingId:practitionersArr[i].mappingId}); 147 } 148 } 149 150 _.each(intersectionForLocAndCat, function(elmUniqueCategoriesByIntersection) { 151 var entry = _.find(intersectionForLocAndCat, function(practitioners) {return elmUniqueCategoriesByIntersection.categoryId == practitioners.categoryId;}); 152 if (entry) intersectionForUniqueCat.push(entry); 153 }); 154 //console.log('intersectionForUniqueCat',intersectionForUniqueCat); 155 return intersectionForUniqueCat; 156 }; 157
158 this.findUniqueCategoriesForLocAndDoc = function(locaionArr,doctor){ 159 var tempArr = []; 160 var tempArr1 = []; 161 var uniqueCategories = []; 162 var uniqueCategoriesByLocation = []; 163 var uniqueCategoriesByDoctor = []; 164 165 for(var i=0, catLen=locaionArr.length; i<catLen; i++){ 166 if(tempArr.indexOf(locaionArr[i].categoryId) == -1){ 167 tempArr.push(locaionArr[i].categoryId); 168 uniqueCategoriesByLocation.push({categoryId:locaionArr[i].categoryId,categoryName:locaionArr[i].categoryName}); 169 } 170 } 171 172 for(var i=0, doctorLen=doctor.length; i<doctorLen; i++){ 173 if(tempArr1.indexOf(doctor[i].categoryId) == -1){ 174 tempArr1.push(doctor[i].categoryId); 175 uniqueCategoriesByDoctor.push({categoryId:doctor[i].categoryId,categoryName:doctor[i].categoryName}); 176 } 177 } 178 _.each(uniqueCategoriesByLocation, function(elmUniqueCategoriesByLocation) { 179 var entry = _.find(uniqueCategoriesByDoctor, function(elmuniqueCategoriesByDoctor) {return elmUniqueCategoriesByLocation.categoryId == elmuniqueCategoriesByDoctor.categoryId;}); 180 if (entry) uniqueCategories.push(entry); 181 }); 182 return uniqueCategories; 183 }; 184 185 this.startsWith003 = function(arr){ 186 var obj = { 187 result:false, 188 serviceProviderId:[] 189 }; 190 for(var i=0, arrLen=arr.length; i<arrLen; i++){ 191 if(arr[i].substr(0,3) == '003'){ 192 obj.result = true; 193 obj.serviceProviderId.push(arr[i]); 194 } 195 } 196 return obj; 197 }; 198 199 this.startWith003ForLCD= function(cheackStr){ 200 if(cheackStr.substr(0,3) == '003'){ 201 return true; 202 }else{ 203 return false; 204 } 205 206 } 207 208 this.getFilteredAppointmentType = function(catId){ 209 var that = this; 210 var appointmentType = that.dropDownData.categoryAppTypWrapperMap[catId] || []; 211 return appointmentType; 212 }; 213 this.getFilteredAppointmentTypeBasedOnLocCatSp = function(selectedAppId, selectedLocation, catId){ 214 var that = this; 215 var appointmentType = that.dropDownData.categoryAppTypWrapperMap[catId] || []; 216 if(appointmentType && appointmentType.length > 0){ 217 appointmentType = appointmentType.filter(item=>{ 218 if(item.RecordId == selectedAppId && item.locationArr && item.locationArr.includes(selectedLocation) && item.locationSPArr[selectedLocation]){ 219 return item; 220 } 221 }); 222 } 223 return appointmentType; 224 }; 225 226 //function to get the common time slot for grp of SP by kunal 227 // Time-slot preference for a practitioner card. A named practitioner always 228 // keeps their own Availability Time Slots. commonTimeSlot (the intersection 229 // across every provider of the type at this location) is only meaningful 230 // when nobody has been named: appTypResourceTyp lists every service 231 // provider with a schedule for the type, not the resources one booking 232 // needs, so on any org with more than one provider it would otherwise 233 // collapse a named agent's slots to the narrowest setting in the state. 234 this.getPractitionerTimeSlot = function(practitioner){ 235 return (practitioner && practitioner.serviceProviderTimeSlot) || ""; 236 }; 237 238 // First Available ("Any") books whichever provider is free, so its calendar 239 // filter is the intersection of every provider's Availability Time Slots at 240 // the location and category. Applies only to "Any"; a named practitioner 241 // keeps what getPractitionerTimeSlot gave their card. Returns true when the 242 // selection was changed. 243 this.applyCommonTimeSlotForAny = function(appointmentDetail){ 244 var that = this; 245 if(!appointmentDetail || !appointmentDetail.practitioner || appointmentDetail.practitioner.id != "Any"){ 246 return false; 247 } 248 var appointmentTypeId = appointmentDetail.appointmentType && appointmentDetail.appointmentType.id; 249 var providers = that.dropDownData.appTypResourceTyp && that.dropDownData.appTypResourceTyp[appointmentTypeId]; 250 if(!providers || providers.length <= 1){ 251 return false; 252 } 253 that.getFilteredPractitioner(appointmentTypeId, appointmentDetail.location.id, appointmentDetail.category.id); 254 appointmentDetail.practitioner.timeSlot = that.commonTimeSlot; 255 return true; 256 }; 257 258 this.getCommonTimeSlotF = function(gspID, locationId, categoryId){ 259 var that = this; 260 var spTimeSlotArry = []; 261 var spTimeSlotArryFirstAvial = []; 262 that.getCommonTimeSlot = []; 263 spTimeSlotArry = that.dropDownData.displayData.filter(function(elm){ 264 return ((gspID.indexOf(elm.serviceProviderId) != -1) && elm.categoryId == categoryId && elm.locationId == locationId); 265 }); 266 //if there is no first available selected 267 if(spTimeSlotArry.length !== gspID.length){ 268 spTimeSlotArryFirstAvial = that.dropDownData.displayData.filter(function(elm){ 269 return ((gspID.indexOf(elm.resourceTypeId) != -1) && elm.categoryId == categoryId && elm.locationId == locationId); 270 }); 271 } 272 273 spTimeSlotArry = spTimeSlotArry.concat(spTimeSlotArryFirstAvial); 274 // console.log('all time slot SP data',spTimeSlotArry); 275 for(var i=0, timeScount=spTimeSlotArry.length; i<timeScount; i++){ 276 if(spTimeSlotArry[i].serviceProviderTimeSlot != null){ 277 that.getCommonTimeSlot.push(spTimeSlotArry[i].serviceProviderTimeSlot.split(';')); 278 } 279 } 280 // console.log('common time slot of all',that.getCommonTimeSlot); 281 var result = []; 282 if(that.getCommonTimeSlot.length > 0){ 283 result = that.getCommonTimeSlot.shift().reduce(function(res, v) { 284 if (res.indexOf(v) === -1 && that.getCommonTimeSlot.every(function(a) { 285 return a.indexOf(v) !== -1; 286 })) res.push(v); 287 return res; 288 }, []); 289 } 290 291 // console.log('final common time array', result.join(';')); 292 return result.join(';'); 293 }; 294 //code end 295 296 this.getFilteredPractitioner = function(appointmentTypeId, locationId, categoryId){ 297 var that = this; 298 //added by darshan 299 if(that.dropDownData && that.dropDownData.categoryAppTypWrapperMap && that.dropDownData.categoryAppTypWrapperMap[categoryId]){ 300 that.dropDownData.categoryAppTypWrapperMap[categoryId].map(it=>{ 301 if(it && it.IsFiveMinAppt){ 302 if(that.dropDownData.displayData){ 303 that.dropDownData.displayData.map(item=>{ 304 if(item && item.categoryId == categoryId){ 305 item.serviceProviderTimeSlot = '00:00;00:15;00:30;00:45;00:05;00:10;00:20;00:25;00:35;00:40;00:50;00:55'; 306 } 307 return item; 308 }) 309 } 310 } 311 }) 312 } 313 //end 314 315 if(that.dropDownData.appTypResourceTyp[appointmentTypeId]){ 316 that.dropDownData.appTypPrimaryResourceTyp = that.dropDownData.appTypPrimaryResourceTyp || {}; 317 /*if(that.dropDownData.appTypResourceTyp[appointmentTypeId].length > 1){ 318 let spIds = []; 319 for(let h = 0; h < that.dropDownData.appTypResourceTyp[appointmentTypeId].length; h++) { 320 for(let d = 0; d < that.dropDownData.displayData.length; d++) { 321 if(that.dropDownData.displayData[d].locationId == locationId) { 322 spIds.push(that.dropDownData.appTypResourceTyp[appointmentTypeId][h]); 323 } 324 } 325 } 326 if(spIds.length > 0) { 327 that.dropDownData.appTypResourceTyp[appointmentTypeId] = spIds; 328 } 329 }*/ 330 //code for scenarion when more than one SP will be conducting appointment 331 if(that.dropDownData.appTypResourceTyp[appointmentTypeId].length > 1){ 332 that.commonTimeSlot = that.getCommonTimeSlotF(that.dropDownData.appTypResourceTyp[appointmentTypeId], locationId, categoryId); 333 } 334 //code end 335 var resourceTypeIdArr = (that.dropDownData.appTypPrimaryResourceTyp[appointmentTypeId] ? that.dropDownData.appTypPrimaryResourceTyp[appointmentTypeId].split(",") : that.dropDownData.appTypResourceTyp[appointmentTypeId]); 336 var resultData = that.startsWith003(resourceTypeIdArr); 337 var categoryAppointmentSpecificPractitioner = []; 338 if(resultData.result){ 339 categoryAppointmentSpecificPractitioner = that.dropDownData.displayData.filter(function(elm){ 340 return ((resultData.serviceProviderId.indexOf(elm.serviceProviderId) != -1) && elm.categoryId == categoryId && elm.locationId == locationId); 341 }); 342 }else{ 343 for(var i=0, resLen=resourceTypeIdArr.length; i<resLen; i++){ 344 var tempArr = that.dropDownData.displayData.filter(function(elm){ 345 return (elm.resourceTypeId == resourceTypeIdArr[i] && elm.categoryId == categoryId && elm.locationId == locationId); 346 }); 347 categoryAppointmentSpecificPractitioner = categoryAppointmentSpecificPractitioner.concat(tempArr); 348 //console.log('categoryAppointmentSpecificPractitioner',categoryAppointmentSpecificPractitioner); 349 } 350 } 351 return categoryAppointmentSpecificPractitioner; 352 }else{ 353 return []; 354 } 355 }; 356 357 // Main flow start 358 this.getFilteredData = function(selectedLocation, selectedCategory, selectedPractitioner,selectedAppId){ 359 360 var that = this; 361 var FilteredObj ={}; 362 363 //If Nothing is selected 364 if(!selectedLocation && !selectedCategory && !selectedPractitioner && !selectedAppId){ 365 var locations = that.getFilteredLocation(); 366 for(var i=0,locLen=locations.length; i<locLen; i++){ 367 var categories = that.getFilteredCategories(locations[i].locationId); 368 for(var j=0, catLen=categories.length; j<catLen; j++){ 369 var appTypes = that.getFilteredAppointmentType(categories[j].categoryId); 370 for(var k=0, appTypLen=appTypes.length; k<appTypLen; k++){ 371 var practitioners = that.getFilteredPractitioner(appTypes[k].RecordId, locations[i].locationId, categories[j].categoryId); 372 if(practitioners){ 373 if(practitioners.length){ 374 375 var practitionersArr = []; 376 for(var l=0, practLen=practitioners.length; l<practLen; l++){ 377 if(appTypes[k].locationSPArr && appTypes[k].locationSPArr != null && appTypes[k].locationSPArr[locations[i].locationId] && appTypes[k].locationSPArr[locations[i].locationId].includes(practitioners[l].serviceProviderId)) {
378 practitionersArr.push({ 379 id: practitioners[l].serviceProviderId, 380 appointivBookingFormDescription: practitioners[l].AppointivBookingFormDescription ? practitioners[l].AppointivBookingFormDescription : '', 381 name: practitioners[l].serviceProviderName, 382 profilePic: practitioners[l].profilePicUrl, 383 timeSlot: that.getPractitionerTimeSlot(practitioners[l]) 384 }); 385 }else if(appTypes[k].locationSPArr == undefined) { 386 practitionersArr.push({ 387 id: practitioners[l].serviceProviderId, 388 appointivBookingFormDescription: practitioners[l].AppointivBookingFormDescription ? practitioners[l].AppointivBookingFormDescription : '', 389 name: practitioners[l].serviceProviderName, 390 profilePic: practitioners[l].profilePicUrl, 391 timeSlot: that.getPractitionerTimeSlot(practitioners[l]) 392 }); 393 } 394 } 395 396 if(!that.FilteredObj[locations[i].locationId]){ 397 that.FilteredObj[locations[i].locationId] = { 398 id:'', 399 name:'', 400 address:'', 401 timeZoneKey:'', 402 categories:[] 403 } 404 } 405 that.FilteredObj[locations[i].locationId].id = locations[i].locationId; 406 that.FilteredObj[locations[i].locationId].name = locations[i].locationName; 407 that.FilteredObj[locations[i].locationId].address = locations[i].locationAddress; 408 that.FilteredObj[locations[i].locationId].timeZoneKey = locations[i].locationTimeZoneKey; 409 410 if(!that.FilteredObj[locations[i].locationId].categories[j]){ 411 that.FilteredObj[locations[i].locationId].categories[j] = { 412 id:categories[j].categoryId, 413 mappingId:categories[j].mappingId, 414 name:categories[j].categoryName, 415 appointmentTypes:[], 416 isWebformServiceAvail: false 417 }; 418 } 419 420 /*Auther: Kunal Fule 421 Description: Check if services available for category then show the category if null the hide Category also 422 */ 423 if(appTypes[k].IsAvailableOnWebform){ 424 that.FilteredObj[locations[i].locationId].categories[j].isWebformServiceAvail = true; 425 } 426 //var fCatLen = that.FilteredObj[locations[i].locationId].categories.length; 427 //console.log('locationArr >>'+ JSON.stringify(appTypes[k].locationArr)); 428 if(appTypes[k].locationArr && appTypes[k].locationArr != null && appTypes[k].locationArr.includes(locations[i].locationId)) { 429 that.FilteredObj[locations[i].locationId].categories[j].appointmentTypes.push({ 430 id: appTypes[k].RecordId, 431 maxparticipant: appTypes[k].MaximumParticipant, 432 timeslotduration: appTypes[k].DefaultTime, 433 name: appTypes[k].Name, 434 description: appTypes[k].Description || '', 435 price: appTypes[k].Price || '', 436 practitioners:practitionersArr, 437 allowToBookWithMultipleCustomers: appTypes[k].IsAllowToBookWithMultipleCustomers, 438 first_Available_Counsellor: appTypes[k].First_Available_Counsellor ? appTypes[k].First_Available_Counsellor : false, 439 allowAttachment: appTypes[k].IsAllowAttachment, 440 appTypeSpecificFieldsetName: appTypes[k].WebformFieldSetName, 441 appTypeSpecificEventFieldsetName: appTypes[k].appointmentWebFieldSet, 442 isClassAppointive:appTypes[k].IsClassAppointment, 443 isAvailableOnWebform:appTypes[k].IsAvailableOnWebform, 444 leadTime:appTypes[k].LeadTime || 0, 445 isFiveMinAppt: appTypes[k].IsFiveMinAppt || false, 446 isSlotsBasedOnLocation: appTypes[k].IsSlotsBasedOnLocation ? appTypes[k].IsSlotsBasedOnLocation : false, 447 }); 448 } 449 if(appTypes[k].locationArr == undefined) { 450 that.FilteredObj[locations[i].locationId].categories[j].appointmentTypes.push({ 451 id: appTypes[k].RecordId, 452 maxparticipant: appTypes[k].MaximumParticipant, 453 timeslotduration: appTypes[k].DefaultTime, 454 name: appTypes[k].Name, 455 description: appTypes[k].Description || '', 456 price: appTypes[k].Price || '', 457 practitioners:practitionersArr, 458 allowToBookWithMultipleCustomers: appTypes[k].IsAllowToBookWithMultipleCustomers, 459 first_Available_Counsellor: appTypes[k].First_Available_Counsellor ? appTypes[k].First_Available_Counsellor : false, 460 allowAttachment: appTypes[k].IsAllowAttachment,
461 appTypeSpecificFieldsetName: appTypes[k].WebformFieldSetName, 462 appTypeSpecificEventFieldsetName: appTypes[k].appointmentWebFieldSet, 463 isClassAppointive:appTypes[k].IsClassAppointment, 464 isAvailableOnWebform:appTypes[k].IsAvailableOnWebform, 465 leadTime:appTypes[k].LeadTime || 0, 466 isFiveMinAppt: appTypes[k].IsFiveMinAppt || false, 467 isSlotsBasedOnLocation: appTypes[k].IsSlotsBasedOnLocation ? appTypes[k].IsSlotsBasedOnLocation : false, 468 }); 469 } 470 471 } 472 } 473 } 474 } 475 } 476 // console.log('If Nothing is selected',that.FilteredObj); 477 } 478 479 // If Location is selected 480 if(selectedLocation && !selectedCategory && !selectedPractitioner && !selectedAppId){ 481 // Get all locations with respect to 'selectedLocation' 482 var locationSpecificArr = that.dropDownData.displayData.filter(function(elm){ 483 return elm.locationId == selectedLocation; 484 }); 485 FilteredObj= { 486 id:locationSpecificArr[0].locationId, 487 name:locationSpecificArr[0].locationName, 488 address:locationSpecificArr[0].locationAddress, 489 timeZoneKey: locationSpecificArr[0].locationTimeZoneKey, 490 categories:[] 491 }; 492 493 var categories = this.findUniqueCategories(locationSpecificArr); 494 for(var i=0, catLen=categories.length; i<catLen; i++){ 495 var appTypes = that.getFilteredAppointmentType(categories[i].categoryId); 496 for(var j=0, appTypLen=appTypes.length; j<appTypLen; j++){ 497 var practitioners = that.getFilteredPractitioner(appTypes[j].RecordId, selectedLocation, categories[i].categoryId); 498 if(practitioners){ 499 if(practitioners.length){ 500 var practitionersArr = []; 501 for(var k=0, practLen=practitioners.length; k<practLen; k++){ 502 if(appTypes[j].locationSPArr && appTypes[j].locationSPArr[selectedLocation] && appTypes[j].locationSPArr[selectedLocation].includes(practitioners[k].serviceProviderId)) { 503 practitionersArr.push({ 504 id: practitioners[k].serviceProviderId, 505 appointivBookingFormDescription: practitioners[k].AppointivBookingFormDescription ? practitioners[k].AppointivBookingFormDescription : '', 506 name: practitioners[k].serviceProviderName, 507 profilePic: practitioners[k].profilePicUrl, 508 //timeSlot: practitioners[k].serviceProviderTimeSlot || "" 509 timeSlot: that.getPractitionerTimeSlot(practitioners[k]) 510 }); 511 } 512 513 if(FilteredObj.categories[i]){ 514 if(!FilteredObj.categories[i].appointmentTypes){ 515 FilteredObj.categories[i]["appointmentTypes"] = []; 516 } 517 }else{ 518 FilteredObj.categories[i] = { 519 id:categories[i].categoryId, 520 mappingId:categories[i].mappingId, 521 name:categories[i].categoryName, 522 appointmentTypes: [] 523 }; 524 } 525 526 527 resType = that.dropDownData.appTypResourceTyp[appTypes[j].RecordId]; 528 for(var l=0; l<resType.length; l++){ 529 if(that.startWith003ForLCD(resType[l])){ 530 if(!FilteredObj.categories[i].appointmentTypes[j]){ 531 if(appTypes[j].locationArr && appTypes[j].locationArr != null && appTypes[j].locationArr.includes(selectedLocation)) { 532 FilteredObj.categories[i].appointmentTypes.push({ 533 id: appTypes[j].RecordId, 534 maxparticipant: appTypes[j].MaximumParticipant, 535 timeslotduration: appTypes[j].DefaultTime, 536 name: appTypes[j].Name, 537 description: appTypes[j].Description || '', 538 price: appTypes[j].Price || '', 539 practitioners:practitionersArr, 540 allowToBookWithMultipleCustomers: appTypes[j].IsAllowToBookWithMultipleCustomers, 541 first_Available_Counsellor: appTypes[j].First_Available_Counsellor ? appTypes[j].First_Available_Counsellor : false, 542 allowAttachment: appTypes[j].IsAllowAttachment, 543 appTypeSpecificFieldsetName: appTypes[j].WebformFieldSetName, 544 appTypeSpecificEventFieldsetName: appTypes[j].appointmentWebFieldSet, 545 isClassAppointive:appTypes[j].IsClassAppointment, 546 isAvailableOnWebform:appTypes[j].IsAvailableOnWebform, 547 leadTime:appTypes[j].LeadTime || 0, 548 isFiveMinAppt: appTypes[j].IsFiveMinAppt || false, 549 isSlotsBasedOnLocation: appTypes[j].IsSlotsBasedOnLocation ? appTypes[j].IsSlotsBasedOnLocation : false, 550 }); 551 } 552 553 if(appTypes[j].locationArr == undefined) { 554 FilteredObj.categories[i].appointmentTypes.push({
555 id: appTypes[j].RecordId, 556 maxparticipant: appTypes[j].MaximumParticipant, 557 timeslotduration: appTypes[j].DefaultTime, 558 name: appTypes[j].Name, 559 description: appTypes[j].Description || '', 560 price: appTypes[j].Price || '', 561 practitioners:practitionersArr, 562 allowToBookWithMultipleCustomers: appTypes[j].IsAllowToBookWithMultipleCustomers, 563 first_Available_Counsellor: appTypes[j].First_Available_Counsellor ? appTypes[j].First_Available_Counsellor : false, 564 allowAttachment: appTypes[j].IsAllowAttachment, 565 appTypeSpecificFieldsetName: appTypes[j].WebformFieldSetName, 566 appTypeSpecificEventFieldsetName: appTypes[j].appointmentWebFieldSet, 567 isClassAppointive:appTypes[j].IsClassAppointment, 568 isAvailableOnWebform:appTypes[j].IsAvailableOnWebform, 569 leadTime:appTypes[j].LeadTime || 0, 570 isFiveMinAppt: appTypes[j].IsFiveMinAppt || false, 571 isSlotsBasedOnLocation: appTypes[j].IsSlotsBasedOnLocation ? appTypes[j].IsSlotsBasedOnLocation : false, 572 }); 573 } 574 } 575 }else{ 576 for(var m=0; m<locationSpecificArr.length; m++){ 577 if(locationSpecificArr[m].resourceTypeId == resType[l]){ 578 if(!FilteredObj.categories[i].appointmentTypes[j]){ 579 if(appTypes[j].locationArr && appTypes[j].locationArr != null && appTypes[j].locationArr.includes(selectedLocation)) { 580 FilteredObj.categories[i].appointmentTypes.push({ 581 id: appTypes[j].RecordId, 582 maxparticipant: appTypes[j].MaximumParticipant, 583 timeslotduration: appTypes[j].DefaultTime, 584 name: appTypes[j].Name, 585 description: appTypes[j].Description || '', 586 price: appTypes[j].Price || '', 587 practitioners:practitionersArr, 588 allowToBookWithMultipleCustomers: appTypes[j].IsAllowToBookWithMultipleCustomers, 589 first_Available_Counsellor: appTypes[j].First_Available_Counsellor ? appTypes[j].First_Available_Counsellor : false, 590 allowAttachment: appTypes[j].IsAllowAttachment, 591 appTypeSpecificFieldsetName: appTypes[j].WebformFieldSetName, 592 appTypeSpecificEventFieldsetName: appTypes[j].appointmentWebFieldSet, 593 isClassAppointive:appTypes[j].IsClassAppointment, 594 isAvailableOnWebform:appTypes[j].IsAvailableOnWebform, 595 leadTime:appTypes[j].LeadTime || 0, 596 isFiveMinAppt: appTypes[j].IsFiveMinAppt || false, 597 isSlotsBasedOnLocation: appTypes[j].IsSlotsBasedOnLocation ? appTypes[j].IsSlotsBasedOnLocation : false, 598 }); 599 } 600 if(appTypes[j].locationArr == undefined) { 601 FilteredObj.categories[i].appointmentTypes.push({ 602 id: appTypes[j].RecordId, 603 maxparticipant: appTypes[j].MaximumParticipant, 604 timeslotduration: appTypes[j].DefaultTime, 605 name: appTypes[j].Name, 606 description: appTypes[j].Description || '', 607 price: appTypes[j].Price || '', 608 practitioners:practitionersArr, 609 allowToBookWithMultipleCustomers: appTypes[j].IsAllowToBookWithMultipleCustomers, 610 first_Available_Counsellor: appTypes[j].First_Available_Counsellor ? appTypes[j].First_Available_Counsellor : false, 611 allowAttachment: appTypes[j].IsAllowAttachment, 612 appTypeSpecificFieldsetName: appTypes[j].WebformFieldSetName, 613 appTypeSpecificEventFieldsetName: appTypes[j].appointmentWebFieldSet, 614 isClassAppointive:appTypes[j].IsClassAppointment, 615 isAvailableOnWebform:appTypes[j].IsAvailableOnWebform, 616 leadTime:appTypes[j].LeadTime || 0, 617 isFiveMinAppt: appTypes[j].IsFiveMinAppt || false, 618 isSlotsBasedOnLocation: appTypes[j].IsSlotsBasedOnLocation ? appTypes[j].IsSlotsBasedOnLocation : false, 619 }); 620 } 621 break; 622 } 623 } 624 } 625 } 626 } 627 } 628 } 629 } 630 } 631 } 632 that.FilteredObj = FilteredObj; 633 console.log("If Location is selected",that.FilteredObj); 634 } 635 636 // If Location and category is selected 637 if(selectedLocation && selectedCategory && !selectedPractitioner && !selectedAppId){ 638 // Get all locations with respect to 'selectedLocation' 639 var locationSpecificArr = that.dropDownData.displayData.filter(function(elm){ 640 return elm.locationId == selectedLocation; 641 }); 642 643 // Get all category with respect to 'selectedCategory' 644 var categorySpecificArr = that.dropDownData.displayData.filter(function(elm){ 645 return elm.categoryId == selectedCategory; 646 }); 647 648 var categoryArr = [{ 649 id:categorySpecificArr[0].categoryId, 650 mappingId:categorySpecificArr[0].mappingId, 651 name:categorySpecificArr[0].categoryName, 652 appointmentTypes:[] 653 }]; 654 655 FilteredObj = { 656 id:locationSpecificArr[0].locationId, 657 name:locationSpecificArr[0].locationName, 658 address:locationSpecificArr[0].locationAddress, 659 timeZoneKey: locationSpecificArr[0].locationTimeZoneKey, 660 categories: categoryArr 661 }; 662 663 var appTypes = that.getFilteredAppointmentType(selectedCategory); 664 for(var j=0, appTypLen=appTypes.length; j<appTypLen; j++){ 665 var practitioners = that.getFilteredPractitioner(appTypes[j].RecordId, selectedLocation, selectedCategory); 666 if(practitioners){ 667 if(practitioners.length){ 668 var practitionersArr = []; 669 for(var k=0, practLen=practitioners.length; k<practLen; k++){ 670 if(appTypes[j].locationSPArr && appTypes[j].locationSPArr[selectedLocation] && appTypes[j].locationSPArr[selectedLocation].includes(practitioners[k].serviceProviderId)) {
671 practitionersArr.push({ 672 id: practitioners[k].serviceProviderId, 673 appointivBookingFormDescription: practitioners[k].AppointivBookingFormDescription ? practitioners[k].AppointivBookingFormDescription : '', 674 name: practitioners[k].serviceProviderName, 675 profilePic: practitioners[k].profilePicUrl, 676 //timeSlot: practitioners[k].serviceProviderTimeSlot || "" 677 timeSlot: that.getPractitionerTimeSlot(practitioners[k]) 678 }); 679 } 680 } 681 } 682 var resType = that.dropDownData.appTypResourceTyp[appTypes[j].RecordId] || []; 683 for(var i=0; i<resType.length; i++){ 684 if(that.startWith003ForLCD(resType[i])){ 685 if(!FilteredObj.categories[0].appointmentTypes[j]){ 686 if(appTypes[j].locationArr && appTypes[j].locationArr != null && appTypes[j].locationArr.includes(selectedLocation)) { 687 FilteredObj.categories[0].appointmentTypes.push({ 688 id: appTypes[j].RecordId, 689 maxparticipant: appTypes[j].MaximumParticipant, 690 timeslotduration: appTypes[j].DefaultTime, 691 name: appTypes[j].Name, 692 description: appTypes[j].Description || '', 693 price: appTypes[j].Price || '', 694 practitioners:practitionersArr || [], 695 allowToBookWithMultipleCustomers: appTypes[j].IsAllowToBookWithMultipleCustomers, 696 first_Available_Counsellor: appTypes[j].First_Available_Counsellor ? appTypes[j].First_Available_Counsellor : false, 697 allowAttachment: appTypes[j].IsAllowAttachment, 698 appTypeSpecificFieldsetName: appTypes[j].WebformFieldSetName, 699 appTypeSpecificEventFieldsetName: appTypes[j].appointmentWebFieldSet, 700 isClassAppointive:appTypes[j].IsClassAppointment, 701 isAvailableOnWebform:appTypes[j].IsAvailableOnWebform, 702 leadTime:appTypes[j].LeadTime || 0, 703 isFiveMinAppt: appTypes[j].IsFiveMinAppt || false, 704 isSlotsBasedOnLocation: appTypes[j].IsSlotsBasedOnLocation ? appTypes[j].IsSlotsBasedOnLocation : false, 705 }); 706 } 707 if(appTypes[j].locationArr == undefined) { 708 FilteredObj.categories[0].appointmentTypes.push({ 709 id: appTypes[j].RecordId, 710 maxparticipant: appTypes[j].MaximumParticipant, 711 timeslotduration: appTypes[j].DefaultTime, 712 name: appTypes[j].Name, 713 description: appTypes[j].Description || '', 714 price: appTypes[j].Price || '', 715 practitioners:practitionersArr || [], 716 allowToBookWithMultipleCustomers: appTypes[j].IsAllowToBookWithMultipleCustomers, 717 first_Available_Counsellor: appTypes[j].First_Available_Counsellor ? appTypes[j].First_Available_Counsellor : false, 718 allowAttachment: appTypes[j].IsAllowAttachment, 719 appTypeSpecificFieldsetName: appTypes[j].WebformFieldSetName, 720 appTypeSpecificEventFieldsetName: appTypes[j].appointmentWebFieldSet, 721 isClassAppointive:appTypes[j].IsClassAppointment, 722 isAvailableOnWebform:appTypes[j].IsAvailableOnWebform, 723 leadTime:appTypes[j].LeadTime || 0, 724 isFiveMinAppt: appTypes[j].IsFiveMinAppt || false, 725 isSlotsBasedOnLocation: appTypes[j].IsSlotsBasedOnLocation ? appTypes[j].IsSlotsBasedOnLocation : false, 726 }); 727 } 728 } 729 }else{ 730 for(var k=0; k<categorySpecificArr.length; k++){ 731 if(categorySpecificArr[k].resourceTypeId == resType[i]){ 732 if(!FilteredObj.categories[0].appointmentTypes[j]){ 733 if(appTypes[j].locationArr && appTypes[j].locationArr != null && appTypes[j].locationArr.includes(selectedLocation)) { 734 FilteredObj.categories[0].appointmentTypes.push({ 735 id: appTypes[j].RecordId, 736 maxparticipant: appTypes[j].MaximumParticipant, 737 timeslotduration: appTypes[j].DefaultTime, 738 name: appTypes[j].Name, 739 description: appTypes[j].Description || '', 740 price: appTypes[j].Price || '', 741 practitioners:practitionersArr || [], 742 allowToBookWithMultipleCustomers: appTypes[j].IsAllowToBookWithMultipleCustomers, 743 first_Available_Counsellor: appTypes[j].First_Available_Counsellor ? appTypes[j].First_Available_Counsellor : false, 744 allowAttachment: appTypes[j].IsAllowAttachment,
745 appTypeSpecificFieldsetName: appTypes[j].WebformFieldSetName, 746 appTypeSpecificEventFieldsetName: appTypes[j].appointmentWebFieldSet, 747 isClassAppointive:appTypes[j].IsClassAppointment, 748 isAvailableOnWebform:appTypes[j].IsAvailableOnWebform, 749 leadTime:appTypes[j].LeadTime || 0, 750 isFiveMinAppt: appTypes[j].IsFiveMinAppt || false, 751 isSlotsBasedOnLocation: appTypes[j].IsSlotsBasedOnLocation ? appTypes[j].IsSlotsBasedOnLocation : false, 752 }); 753 } 754 if(appTypes[j].locationArr == undefined) { 755 FilteredObj.categories[0].appointmentTypes.push({ 756 id: appTypes[j].RecordId, 757 maxparticipant: appTypes[j].MaximumParticipant, 758 timeslotduration: appTypes[j].DefaultTime, 759 name: appTypes[j].Name, 760 description: appTypes[j].Description || '', 761 price: appTypes[j].Price || '', 762 practitioners:practitionersArr || [], 763 allowToBookWithMultipleCustomers: appTypes[j].IsAllowToBookWithMultipleCustomers, 764 first_Available_Counsellor: appTypes[j].First_Available_Counsellor ? appTypes[j].First_Available_Counsellor : false, 765 allowAttachment: appTypes[j].IsAllowAttachment, 766 appTypeSpecificFieldsetName: appTypes[j].WebformFieldSetName, 767 appTypeSpecificEventFieldsetName: appTypes[j].appointmentWebFieldSet, 768 isClassAppointive:appTypes[j].IsClassAppointment, 769 isAvailableOnWebform:appTypes[j].IsAvailableOnWebform, 770 leadTime:appTypes[j].LeadTime || 0, 771 isFiveMinAppt: appTypes[j].IsFiveMinAppt || false, 772 isSlotsBasedOnLocation: appTypes[j].IsSlotsBasedOnLocation ? appTypes[j].IsSlotsBasedOnLocation : false, 773 }); 774 } 775 } 776 } 777 } 778 } 779 } 780 } 781 } 782 that.FilteredObj=FilteredObj 783 console.log("If Location and Category is selected",that.FilteredObj); 784 } 785 /* test common time slot condition in below scenario */ 786 // If Location and Doctor is selected 787 if(selectedLocation && !selectedCategory && selectedPractitioner && !selectedAppId){ 788 var locationSpecificArr = that.dropDownData.displayData.filter(function(elm){ 789 return elm.locationId == selectedLocation && elm.serviceProviderId == selectedPractitioner; 790 }); 791 var uniqueCategory = this.findUniqueCategories(locationSpecificArr); 792 var selectedPractitionerObj = { 793 id: locationSpecificArr[0].serviceProviderId, 794 name: locationSpecificArr[0].serviceProviderName, 795 profilePic: locationSpecificArr[0].profilePicUrl, 796 timeSlot: that.getPractitionerTimeSlot(locationSpecificArr[0]) 797 }; 798 FilteredObj= { 799 id:locationSpecificArr[0].locationId, 800 name:locationSpecificArr[0].locationName, 801 address:locationSpecificArr[0].locationAddress, 802 timeZoneKey: locationSpecificArr[0].locationTimeZoneKey, 803 categories:[] 804 }; 805 if(uniqueCategory){ 806 for(var i=0, catLen=uniqueCategory.length; i<catLen; i++){ 807 var appTypes = that.getFilteredAppointmentType(uniqueCategory[i].categoryId); 808 FilteredObj.categories[i] = { 809 id:uniqueCategory[i].categoryId, 810 name:uniqueCategory[i].categoryName, 811 appointmentTypes:[] 812 }; 813 for(var j=0, appTypLen=appTypes.length; j<appTypLen; j++){ 814 /* Auther: Kunal, Description: TO check common time slot if 2 SP are available in appointment */ 815 console.log('that.dropDownData.appTypResourceTyp[appTypes[j].RecordId]' + that.dropDownData.appTypResourceTyp[appTypes[j].RecordId]); 816 if(that.dropDownData.appTypResourceTyp[appTypes[j].RecordId] != undefined){ 817 if((that.dropDownData.appTypResourceTyp[appTypes[j].RecordId].length > 1)){ 818 var multiPractitioners = that.getFilteredPractitioner(appTypes[j].RecordId, selectedLocation, uniqueCategory[i].categoryId); 819 if(multiPractitioners.length && that.commonTimeSlot){ 820 var selectedPractitionerObjArr = [{ 821 id: locationSpecificArr[0].serviceProviderId, 822 name: locationSpecificArr[0].serviceProviderName, 823 profilePic: locationSpecificArr[0].profilePicUrl, 824 timeSlot: that.getPractitionerTimeSlot(locationSpecificArr[0]) 825 }]; 826 } 827 } 828 } 829 /* code end */ 830 if(appTypes[j].locationArr && appTypes[j].locationArr != null && appTypes[j].locationArr.includes(selectedLocation)) { 831 FilteredObj.categories[i].appointmentTypes.push({
832 id: appTypes[j].RecordId, 833 maxparticipant: appTypes[j].MaximumParticipant, 834 timeslotduration: appTypes[j].DefaultTime, 835 name: appTypes[j].Name, 836 description: appTypes[j].Description || '', 837 price: appTypes[j].Price || '', 838 // practitioners:selectedPractitionerObj, 839 practitioners: ((that.dropDownData.appTypResourceTyp[appTypes[j].RecordId] != undefined)? (((that.dropDownData.appTypResourceTyp[appTypes[j].RecordId].length > 1) && (that.commonTimeSlot))? selectedPractitionerObjArr : selectedPractitionerObj) : selectedPractitionerObj), 840 allowToBookWithMultipleCustomers: appTypes[j].IsAllowToBookWithMultipleCustomers, 841 first_Available_Counsellor: appTypes[j].First_Available_Counsellor ? appTypes[j].First_Available_Counsellor : false, 842 allowAttachment: appTypes[j].IsAllowAttachment, 843 appTypeSpecificFieldsetName: appTypes[j].WebformFieldSetName, 844 appTypeSpecificEventFieldsetName: appTypes[j].appointmentWebFieldSet, 845 isClassAppointive:appTypes[j].IsClassAppointment, 846 isAvailableOnWebform:appTypes[j].IsAvailableOnWebform, 847 leadTime:appTypes[j].LeadTime || 0, 848 isFiveMinAppt: appTypes[j].IsFiveMinAppt || false, 849 isSlotsBasedOnLocation: appTypes[j].IsSlotsBasedOnLocation ? appTypes[j].IsSlotsBasedOnLocation : false, 850 }); 851 } 852 if(appTypes[j].locationArr == undefined) { 853 FilteredObj.categories[i].appointmentTypes.push({ 854 id: appTypes[j].RecordId, 855 maxparticipant: appTypes[j].MaximumParticipant, 856 timeslotduration: appTypes[j].DefaultTime, 857 name: appTypes[j].Name, 858 description: appTypes[j].Description || '', 859 price: appTypes[j].Price || '', 860 // practitioners:selectedPractitionerObj, 861 practitioners: ((that.dropDownData.appTypResourceTyp[appTypes[j].RecordId] != undefined)? (((that.dropDownData.appTypResourceTyp[appTypes[j].RecordId].length > 1) && (that.commonTimeSlot))? selectedPractitionerObjArr : selectedPractitionerObj) : selectedPractitionerObj), 862 allowToBookWithMultipleCustomers: appTypes[j].IsAllowToBookWithMultipleCustomers, 863 first_Available_Counsellor: appTypes[j].First_Available_Counsellor ? appTypes[j].First_Available_Counsellor : false, 864 allowAttachment: appTypes[j].IsAllowAttachment, 865 appTypeSpecificFieldsetName: appTypes[j].WebformFieldSetName, 866 appTypeSpecificEventFieldsetName: appTypes[j].appointmentWebFieldSet, 867 isClassAppointive:appTypes[j].IsClassAppointment, 868 isAvailableOnWebform:appTypes[j].IsAvailableOnWebform, 869 leadTime:appTypes[j].LeadTime || 0, 870 isFiveMinAppt: appTypes[j].IsFiveMinAppt || false, 871 isSlotsBasedOnLocation: appTypes[j].IsSlotsBasedOnLocation ? appTypes[j].IsSlotsBasedOnLocation : false, 872 }); 873 } 874 } 875 } 876 } 877 that.FilteredObj = FilteredObj; 878 console.log("If Location and Doctor is selected",that.FilteredObj); 879 } 880 /* test the common time slot in below code */ 881 // If Location, Category and Doctor is selected 882 if(selectedLocation && selectedCategory && selectedPractitioner && !selectedAppId){ 883 var tempArray= [], 884 tempArray1= [], 885 appointmentTypes =[], 886 appointmentTypes1 = [], 887 categoryArr = [], 888 practitionersArr = []; 889 890 var locCatAndDocSpecificArr= that.dropDownData.displayData.filter(function(elm){ 891 return elm.locationId == selectedLocation && elm.categoryId == selectedCategory && elm.serviceProviderId == selectedPractitioner; 892 }); 893 894 for(catId in that.dropDownData.categoryAppTypWrapperMap){ 895 if(locCatAndDocSpecificArr[0].categoryId == catId){ 896 tempArray.push(that.dropDownData.categoryAppTypWrapperMap[catId]); 897 } 898 } 899 tempArray1= tempArray[0]; 900 for(var i= 0; i< tempArray1.length; i++){ 901 if(that.dropDownData.appTypResourceTyp[tempArray1[i].RecordId]){ 902 var serviceProviderIdArr = that.dropDownData.appTypResourceTyp[tempArray1[i].RecordId]; 903 for(var j= 0; j<serviceProviderIdArr.length; j++){ 904 if(that.startWith003ForLCD(serviceProviderIdArr[j])){ 905 if(serviceProviderIdArr[j] == locCatAndDocSpecificArr[0].serviceProviderId){ 906 appointmentTypes.push(tempArray1[i]); 907 } 908 }else{ 909 if(serviceProviderIdArr[j] == locCatAndDocSpecificArr[0].resourceTypeId){ 910 appointmentTypes.push(tempArray1[i]); 911 } 912 } 913 } 914 } 915 } 916
917 practitionersArr.push({ 918 id: locCatAndDocSpecificArr[0].serviceProviderId, 919 name: locCatAndDocSpecificArr[0].serviceProviderName, 920 profilePic: locCatAndDocSpecificArr[0].profilePicUrl 921 }); 922 923 categoryArr.push({ 924 id:locCatAndDocSpecificArr[0].categoryId, 925 mappingId:locCatAndDocSpecificArr[0].mappingId, 926 name:locCatAndDocSpecificArr[0].categoryName, 927 appointmentTypes:[] 928 }); 929 930 FilteredObj= { 931 id:locCatAndDocSpecificArr[0].locationId, 932 name:locCatAndDocSpecificArr[0].locationName, 933 address:locCatAndDocSpecificArr[0].locationAddress, 934 timeZoneKey: locCatAndDocSpecificArr[0].locationTimeZoneKey, 935 categories:categoryArr 936 }; 937 for(var i=0; i<appointmentTypes.length; i++){ 938 if(appointmentTypes[i].locationArr && appointmentTypes[i].locationArr != null && appointmentTypes[i].locationArr.includes(selectedLocation)) { 939 FilteredObj.categories[0].appointmentTypes.push({ 940 id: appointmentTypes[i].RecordId, 941 maxparticipant: appointmentTypes[i].MaximumParticipant, 942 timeslotduration: appointmentTypes[i].DefaultTime, 943 name: appointmentTypes[i].Name, 944 description: appointmentTypes[i].Description || '', 945 price: appointmentTypes[i].Price || '', 946 practitioners:practitionersArr, 947 allowToBookWithMultipleCustomers: appointmentTypes[i].IsAllowToBookWithMultipleCustomers, 948 first_Available_Counsellor: appointmentTypes[i].First_Available_Counsellor ? appointmentTypes[i].First_Available_Counsellor : false, 949 allowAttachment: appointmentTypes[i].IsAllowAttachment, 950 appTypeSpecificFieldsetName: appointmentTypes[i].WebformFieldSetName, 951 appTypeSpecificEventFieldsetName: appointmentTypes[i].appointmentWebFieldSet, 952 isClassAppointive:appointmentTypes[i].IsClassAppointment, 953 isAvailableOnWebform:appointmentTypes[i].IsAvailableOnWebform, 954 leadTime:appointmentTypes[i].LeadTime || 0, 955 isFiveMinAppt: appointmentTypes[i].IsFiveMinAppt || false, 956 isSlotsBasedOnLocation: appointmentTypes[i].IsSlotsBasedOnLocation ? appointmentTypes[i].IsSlotsBasedOnLocation : false, 957 }); 958 } 959 960 if(appointmentTypes[i].locationArr == undefined) { 961 FilteredObj.categories[0].appointmentTypes.push({ 962 id: appointmentTypes[i].RecordId, 963 maxparticipant: appointmentTypes[i].MaximumParticipant, 964 timeslotduration: appointmentTypes[i].DefaultTime, 965 name: appointmentTypes[i].Name, 966 description: appointmentTypes[i].Description || '', 967 price: appointmentTypes[i].Price || '', 968 practitioners:practitionersArr, 969 allowToBookWithMultipleCustomers: appointmentTypes[i].IsAllowToBookWithMultipleCustomers, 970 first_Available_Counsellor: appointmentTypes[i].First_Available_Counsellor ? appointmentTypes[i].First_Available_Counsellor : false, 971 allowAttachment: appointmentTypes[i].IsAllowAttachment, 972 appTypeSpecificFieldsetName: appointmentTypes[i].WebformFieldSetName, 973 appTypeSpecificEventFieldsetName: appointmentTypes[i].appointmentWebFieldSet, 974 isClassAppointive:appointmentTypes[i].IsClassAppointment, 975 isAvailableOnWebform:appointmentTypes[i].IsAvailableOnWebform, 976 leadTime:appointmentTypes[i].LeadTime || 0, 977 isFiveMinAppt: appointmentTypes[i].IsFiveMinAppt || false, 978 isSlotsBasedOnLocation: appointmentTypes[i].IsSlotsBasedOnLocation ? appointmentTypes[i].IsSlotsBasedOnLocation : false, 979 }); 980 } 981 } 982 that.FilteredObj = FilteredObj; 983 console.log('If Location, Category and Doctor is selected',that.FilteredObj); 984 } 985 986 //If category is selected. 987 if(selectedCategory && !selectedPractitioner && !selectedLocation && !selectedAppId){ 988 var locationArr = [] ,doctorArr = []; 989 var categorySpecificArr = that.dropDownData.displayData.filter(function(elm){ 990 return elm.categoryId == selectedCategory; 991 }); 992 console.log(categorySpecificArr); 993 994 var Location = that.findUniqueLocation(categorySpecificArr); 995 996 for(var i=0; i<Location.length;i++){ 997 locationArr.push({ 998 id:Location[i].locationId, 999 name:Location[i].locationName, 1000 address:Location[i].locationAddress, 1001 timeZoneKey: Location[i].locationTimeZoneKey 1002 }); 1003 } 1004 1005 //console.log('locationArr',locationArr); 1006 1007 FilteredObj={ 1008 id:categorySpecificArr[0].categoryId, 1009 mappingId:categorySpecificArr[0].mappingId, 1010 name:categorySpecificArr[0].categoryName, 1011 appointmentTypes:[] 1012 }; 1013 1014 var appTypes = that.getFilteredAppointmentType(selectedCategory);
1015 console.log('appTypes',appTypes); 1016 for(var i=0; i<appTypes.length; i++){ 1017 var practitioners=[]; 1018 var tempLocations = []; 1019 /* added by kunal for Wizard Covid appointment 1 and 2 */ 1020 if(appTypes[i].CategoryName == 'Covid Vaccinations' && document.location.origin == 'https://wizardpharmacy.appointiv.com'){ 1021 appTypes[i].IsAvailableOnWebform = true; 1022 } 1023 /* code end */ 1024 for(var k=0; k<locationArr.length; k++){ 1025 practitioners = that.getFilteredPractitioner(appTypes[i].RecordId, locationArr[k].id, selectedCategory); 1026 doctorArr = []; 1027 for(var j=0; j<practitioners.length; j++){ 1028 if(appTypes[i].locationSPArr && appTypes[i].locationSPArr[locationArr[k].id] && appTypes[i].locationSPArr[locationArr[k].id].includes(practitioners[j].serviceProviderId)) { 1029 doctorArr.push({ 1030 id:practitioners[j].serviceProviderId, 1031 name:practitioners[j].serviceProviderName, 1032 profilePic:practitioners[j].profilePicUrl, 1033 //timeSlot: practitioners[j].serviceProviderTimeSlot || "" 1034 timeSlot: that.getPractitionerTimeSlot(practitioners[j]) 1035 }); 1036 } 1037 } 1038 var loc = locationArr[k]; 1039 if(loc["doctorArr"]){ 1040 loc["doctorArr"] = loc["doctorArr"].concat(doctorArr); 1041 }else{ 1042 loc["doctorArr"] = doctorArr; 1043 } 1044 tempLocations.push(loc); 1045 } 1046 1047 FilteredObj.appointmentTypes.push({ 1048 id: appTypes[i].RecordId, 1049 maxparticipant: appTypes[i].MaximumParticipant, 1050 timeslotduration: appTypes[i].DefaultTime, 1051 name: appTypes[i].Name, 1052 description: appTypes[i].Description || '', 1053 price: appTypes[i].Price || '', 1054 location: tempLocations, 1055 allowToBookWithMultipleCustomers: appTypes[i].IsAllowToBookWithMultipleCustomers, 1056 first_Available_Counsellor: appTypes[i].First_Available_Counsellor ? appTypes[i].First_Available_Counsellor : false, 1057 allowAttachment: appTypes[i].IsAllowAttachment, 1058 appTypeSpecificFieldsetName: appTypes[i].WebformFieldSetName, 1059 appTypeSpecificEventFieldsetName: appTypes[i].appointmentWebFieldSet, 1060 isClassAppointive:appTypes[i].IsClassAppointment, 1061 isAvailableOnWebform:appTypes[i].IsAvailableOnWebform, 1062 leadTime:appTypes[i].LeadTime || 0, 1063 isFiveMinAppt: appTypes[i].IsFiveMinAppt || false, 1064 isSlotsBasedOnLocation: appTypes[i].IsSlotsBasedOnLocation ? appTypes[i].IsSlotsBasedOnLocation : false, 1065 }); 1066 } 1067 that.FilteredObj = FilteredObj; 1068 //console.log('this.FilteredObj.appointmentTypes.location.',Location[0].locationId); 1069 console.log('If category is selected',that.FilteredObj); 1070 } 1071 /* check the common time slot function in below code */ 1072 //If category and doctor is selected. 1073 if(selectedCategory && selectedPractitioner && !selectedLocation && !selectedAppId){ 1074 var locationArr= [], doctorArr= [], catArr= []; 1075 var categorySpecificArr = that.dropDownData.displayData.filter(function(elm){ 1076 return elm.categoryId == selectedCategory && elm.serviceProviderId == selectedPractitioner; 1077 }); 1078 1079 /*id:locationSpecificArr[0].locationId, 1080 name:locationSpecificArr[0].locationName, 1081 address:l*/ 1082 1083 //console.log("categorySpecificArr",categorySpecificArr); 1084 var Location = this.findUniqueLocation(categorySpecificArr); 1085 1086 //console.log("location",Location); 1087 1088 for(var i=0; i<Location.length;i++){ 1089 locationArr.push({ 1090 id:Location[i].locationId, 1091 name:Location[i].locationName, 1092 address:Location[i].locationAddress, 1093 timeZoneKey: Location[i].locationTimeZoneKey 1094 }); 1095 } 1096 1097 doctorArr.push({ 1098 id:categorySpecificArr[0].serviceProviderId, 1099 name:categorySpecificArr[0].serviceProviderName, 1100 profilePic:categorySpecificArr[0].profilePicUrl, 1101 location:locationArr 1102 }); 1103 1104 FilteredObj= { 1105 id:categorySpecificArr[0].categoryId, 1106 name:categorySpecificArr[0].categoryName, 1107 mappingId:categorySpecificArr[0].mappingId, 1108 appointmentTypes:[] 1109 }; 1110 1111 var appTypes = that.getFilteredAppointmentType(selectedCategory); 1112 console.log('appTypes',appTypes); 1113 var resType; 1114 for(var j=0, appTypLen=appTypes.length; j<appTypLen; j++){ 1115 var resType = that.dropDownData.appTypResourceTyp[appTypes[j].RecordId] || []; 1116 console.log("resType",resType); 1117 for(var i=0; i<resType.length; i++){ 1118 if(that.startWith003ForLCD(resType[i])){ 1119 if(selectedPractitioner == resType[i]){ 1120 FilteredObj.appointmentTypes.push({
1121 id: appTypes[j].RecordId, 1122 maxparticipant: appTypes[j].MaximumParticipant, 1123 timeslotduration: appTypes[j].DefaultTime, 1124 name: appTypes[j].Name, 1125 description: appTypes[j].Description || '', 1126 price: appTypes[j].Price || '', 1127 practitioners:doctorArr, 1128 allowToBookWithMultipleCustomers: appTypes[j].IsAllowToBookWithMultipleCustomers, 1129 first_Available_Counsellor: appTypes[j].First_Available_Counsellor ? appTypes[j].First_Available_Counsellor : false, 1130 allowAttachment: appTypes[j].IsAllowAttachment, 1131 appTypeSpecificFieldsetName: appTypes[j].WebformFieldSetName, 1132 appTypeSpecificEventFieldsetName: appTypes[j].appointmentWebFieldSet, 1133 isClassAppointive:appTypes[j].IsClassAppointment, 1134 isAvailableOnWebform:appTypes[j].IsAvailableOnWebform, 1135 leadTime:appTypes[j].LeadTime || 0, 1136 isFiveMinAppt: appTypes[j].IsFiveMinAppt || false, 1137 isSlotsBasedOnLocation: appTypes[j].IsSlotsBasedOnLocation ? appTypes[j].IsSlotsBasedOnLocation : false, 1138 }); 1139 } 1140 }else{ 1141 for(var i=0; i<categorySpecificArr.length; i++){ 1142 if(categorySpecificArr[i].resourceTypeId == resType[i]){ 1143 FilteredObj.appointmentTypes.push({ 1144 id: appTypes[j].RecordId, 1145 maxparticipant: appTypes[j].MaximumParticipant, 1146 timeslotduration: appTypes[j].DefaultTime, 1147 name: appTypes[j].Name, 1148 description: appTypes[j].Description || '', 1149 price: appTypes[j].Price || '', 1150 practitioners:doctorArr, 1151 allowToBookWithMultipleCustomers: appTypes[j].IsAllowToBookWithMultipleCustomers, 1152 first_Available_Counsellor: appTypes[j].First_Available_Counsellor ? appTypes[j].First_Available_Counsellor : false, 1153 allowAttachment: appTypes[j].IsAllowAttachment, 1154 appTypeSpecificFieldsetName: appTypes[j].WebformFieldSetName, 1155 appTypeSpecificEventFieldsetName: appTypes[j].appointmentWebFieldSet, 1156 isClassAppointive:appTypes[j].IsClassAppointment, 1157 isAvailableOnWebform:appTypes[j].IsAvailableOnWebform, 1158 leadTime:appTypes[j].LeadTime || 0, 1159 isFiveMinAppt: appTypes[j].IsFiveMinAppt || false, 1160 isSlotsBasedOnLocation: appTypes[j].IsSlotsBasedOnLocation ? appTypes[j].IsSlotsBasedOnLocation : false, 1161 }); 1162 } 1163 } 1164 } 1165 } 1166 // Final object gets create here 1167 1168 } 1169 that.FilteredObj = FilteredObj; 1170 console.log('If category and doctor is selected.',that.FilteredObj); 1171 } 1172 // If doctor is selected 1173 if(!selectedCategory && selectedPractitioner && !selectedLocation && !selectedAppId){ 1174 var locationArr= [],categoryArr= [], appTypeArr= []; 1175 1176 var doctorSpecificArr = that.dropDownData.displayData.filter(function(elm){ 1177 return elm.serviceProviderId == selectedPractitioner; 1178 }); 1179 //console.log('doctorSpecificArr',doctorSpecificArr); 1180 1181 FilteredObj={ 1182 id: doctorSpecificArr[0].serviceProviderId, 1183 name: doctorSpecificArr[0].serviceProviderName, 1184 profilePic: doctorSpecificArr[0].profilePicUrl, 1185 Location: [] 1186 } 1187 1188 var uniqueLocations= that.findUniqueLocation(doctorSpecificArr); 1189 //console.log('uniqueLocations',uniqueLocations); 1190 1191 //var Category= this.findUniqueCategories(doctorSpecificArr); 1192 for(var i=0; i<uniqueLocations.length; i++){ 1193 var categories = that.findUniqueCategories(doctorSpecificArr); 1194 console.log('categories',categories); 1195 FilteredObj.Location[i] = { 1196 id:uniqueLocations[i].locationId, 1197 name:uniqueLocations[i].locationName, 1198 address:uniqueLocations[i].locationAddress, 1199 timeZoneKey: uniqueLocations[i].locationTimeZoneKey, 1200 Category: [] 1201 }; 1202 for(var j=0, catLen=categories.length; j<catLen; j++){ 1203 var appTypes = that.getFilteredAppointmentType(categories[j].categoryId); 1204 console.log(appTypes); 1205 FilteredObj.Location[i].Category[j] = { 1206 id:categories[j].categoryId, 1207 mappingId:categories[j].mappingId, 1208 name:categories[j].categoryName, 1209 appointmentTypes:[] 1210 }; 1211 for(var k=0, appTypLen=appTypes.length; k<appTypLen; k++){ 1212 // Final object gets create here 1213 FilteredObj.Location[i].Category[j].appointmentTypes.push({
1214 id: appTypes[k].RecordId, 1215 maxparticipant: appTypes[k].MaximumParticipant, 1216 timeslotduration: appTypes[k].DefaultTime, 1217 name: appTypes[k].Name, 1218 description: appTypes[k].Description, 1219 price: appTypes[k].Price, 1220 allowToBookWithMultipleCustomers: appTypes[k].IsAllowToBookWithMultipleCustomers, 1221 first_Available_Counsellor: appTypes[k].First_Available_Counsellor ? appTypes[k].First_Available_Counsellor : false, 1222 allowAttachment: appTypes[k].IsAllowAttachment, 1223 appTypeSpecificFieldsetName: appTypes[k].WebformFieldSetName, 1224 appTypeSpecificEventFieldsetName: appTypes[k].appointmentWebFieldSet, 1225 isClassAppointive:appTypes[k].IsClassAppointment, 1226 isAvailableOnWebform:appTypes[k].IsAvailableOnWebform, 1227 leadTime:appTypes[k].LeadTime || 0, 1228 isFiveMinAppt: appTypes[k].IsFiveMinAppt || false, 1229 isSlotsBasedOnLocation: appTypes[k].IsSlotsBasedOnLocation ? appTypes[k].IsSlotsBasedOnLocation : false, 1230 1231 /* 1232 id: appTypes[j].RecordId, 1233 maxparticipant: appTypes[j].MaximumParticipant, 1234 timeslotduration: appTypes[j].DefaultTime, 1235 name: appTypes[j].Name, 1236 description: appTypes[j].Description || '', 1237 price: appTypes[j].Price || '', 1238 practitioners:practitionersArr 1239 */ 1240 }); 1241 } 1242 } 1243 } 1244 that.FilteredObj = FilteredObj; 1245 1246 console.log('If Doctor is selected',that.FilteredObj); 1247 1248 } 1249 1250 //If Appointmenttype & Category is selected 1251 if(!selectedLocation && selectedCategory && !selectedPractitioner && selectedAppId){ 1252 1253 var data=[],appType=[],appTypArr=[], locationArr= [], doctorArr=[]; 1254 1255 /* var categorySpecificArr = that.dropDownData.displayData.filter(function(elm){ 1256 return elm.categoryId == selectedCategory; 1257 }); 1258 //console.log('categorySpecificArr',categorySpecificArr); 1259 //var uniqueCategory= this.findUniqueCategories(categorySpecificArr); 1260 //console.log('uniqueCategory',uniqueCategory); 1261 var uniqueLocations= that.findUniqueLocation(categorySpecificArr); 1262 //console.log('uniqueLocations',uniqueLocations); 1263 1264 for(var i=0; i<uniqueLocations.length; i++){ 1265 locationArr.push({ 1266 id:uniqueLocations[i].locationId, 1267 name:uniqueLocations[i].locationName, 1268 address:uniqueLocations[i].locationAddress, 1269 practitioners: doctorArr 1270 }); 1271 } 1272 //console.log('locationArr',locationArr); 1273 var allAppType= that.dropDownData.categoryAppTypWrapperMap[selectedCategory]; 1274 //console.log("allAppType",allAppType); 1275 1276 for(var i=0; i<allAppType.length; i++){ 1277 data.push(allAppType[i]); 1278 } 1279 1280 for(var j=0; j<data.length; j++){ 1281 if(data[j].RecordId == selectedAppId) 1282 { 1283 appType.push(data[j]); 1284 } 1285 } 1286 1287 for(var j=0; j<appType.length; j++){ 1288 appTypArr.push({ 1289 id: appType[j].RecordId, 1290 maxparticipant: appType[j].MaximumParticipant, 1291 timeslotduration: appType[j].DefaultTime, 1292 name: appType[j].Name, 1293 description: appType[j].Description, 1294 price: appType[j].Price, 1295 Location: locationArr 1296 }); 1297 1298 } 1299 //console.log('appTypArr',appTypArr); //FilteredObj.a043600000DbTwjAAF.appointmentType[0].Location 1300 1301 for(var i=0; i<categorySpecificArr.length; i++){ 1302 FilteredObj[categorySpecificArr[i].categoryId]= { 1303 id:categorySpecificArr[i].categoryId, 1304 name:categorySpecificArr[i].categoryName, 1305 mappingId:categorySpecificArr[i].mappingId, 1306 appointmentType: appTypArr 1307 }; 1308 1309 for(var i= 0; i< allAppType.length; i++){ 1310 if(that.dropDownData.appTypResourceTyp[allAppType[i].RecordId]){ 1311 var serviceProviderIdArr = that.dropDownData.appTypResourceTyp[allAppType[i].RecordId]; 1312 //console.log("serviceProviderIdArr",serviceProviderIdArr); 1313 for(var j= 0; j<serviceProviderIdArr.length; j++){ 1314 1315 if(that.startWith003ForLCD(serviceProviderIdArr[j])){ 1316 //console.log(true); 1317 if(serviceProviderIdArr[j] == categorySpecificArr[i].serviceProviderId){ 1318 doctorArr.push({ 1319 id: categorySpecificArr[i].serviceProviderId, 1320 name: categorySpecificArr[i].serviceProviderName, 1321 profilePic: categorySpecificArr[i].profilePicUrl 1322 }); 1323 } 1324 }else{ 1325 1326 if(serviceProviderIdArr[j] == categorySpecificArr[i].resourceTypeId){ 1327 doctorArr.push({ 1328 id: categorySpecificArr[i].serviceProviderId, 1329 name: categorySpecificArr[i].serviceProviderName, 1330 profilePic: categorySpecificArr[i].profilePicUrl 1331 }); 1332 //console.log('doctorArr',doctorArr); 1333 } 1334 } 1335 } 1336 } 1337 } 1338 } */ 1339 that.FilteredObj = FilteredObj; 1340 console.log('If Appointmenttype & Category is selected',that.FilteredObj); 1341 } 1342 1343 // If Appointment type, Category and Location selected. 1344 if(selectedLocation && selectedCategory && !selectedPractitioner && selectedAppId){ 1345 var data=[],appType=[],appTypArr=[], locationArr= [], doctorArr=[], catArry= []; 1346 1347 var locAndCategorySpecificArr = that.dropDownData.displayData.filter(function(elm){ 1348 return elm.categoryId == selectedCategory && elm.locationId == selectedLocation; 1349 }); 1350 //console.log('locAndCategorySpecificArr',locAndCategorySpecificArr); 1351 1352 var uniqueLocations= that.findUniqueLocation(locAndCategorySpecificArr); 1353 //console.log('uniqueLocations',uniqueLocations); 1354 1355 var uniqueCategory= that.findUniqueCategories(locAndCategorySpecificArr); 1356 //console.log('uniqueCategory',uniqueCategory); 1357 1358 var allAppType= that.dropDownData.categoryAppTypWrapperMap[selectedCategory]; 1359 //console.log("allAppType",allAppType); 1360 1361 for(var i=0; i<allAppType.length; i++){ 1362 data.push(allAppType[i]); 1363 } 1364 1365 for(var j=0; j<data.length; j++){ 1366 if(data[j].RecordId == selectedAppId) 1367 {
1368 appType.push(data[j]); 1369 } 1370 } 1371 var selectedAppointmentType = {}; 1372 for(var j=0; j<appType.length; j++){ 1373 if(selectedAppId == appType[j].RecordId){ 1374 selectedAppointmentType = appType[j]; 1375 appTypArr.push({ 1376 id: appType[j].RecordId, 1377 maxparticipant: appType[j].MaximumParticipant, 1378 timeslotduration: appType[j].DefaultTime, 1379 name: appType[j].Name, 1380 description: appType[j].Description, 1381 price: appType[j].Price, 1382 practitioners:doctorArr, 1383 allowToBookWithMultipleCustomers: appType[j].IsAllowToBookWithMultipleCustomers, 1384 first_Available_Counsellor: appType[j].First_Available_Counsellor ? appType[j].First_Available_Counsellor : false, 1385 allowAttachment: appType[j].IsAllowAttachment, 1386 appTypeSpecificFieldsetName: appType[j].WebformFieldSetName, 1387 appTypeSpecificEventFieldsetName: appType[j].appointmentWebFieldSet, 1388 isClassAppointive:appType[j].IsClassAppointment, 1389 isAvailableOnWebform:appType[j].IsAvailableOnWebform, 1390 leadTime:appType[j].LeadTime || 0, 1391 }); 1392 } 1393 } 1394 1395 for(var i=0; i<uniqueCategory.length; i++){ 1396 catArry.push({ 1397 categoryId:uniqueCategory[i].categoryId, 1398 categoryName:uniqueCategory[i].categoryName, 1399 mappingId:uniqueCategory[i].mappingId, 1400 appointmentType: appTypArr 1401 }) 1402 } 1403 1404 for(var i=0; i<uniqueLocations.length; i++){ 1405 FilteredObj= { 1406 id:uniqueLocations[i].locationId, 1407 name:uniqueLocations[i].locationName, 1408 address:uniqueLocations[i].locationAddress, 1409 timeZoneKey: uniqueLocations[i].locationTimeZoneKey, 1410 categories:catArry 1411 }; 1412 } 1413 1414 if(selectedAppointmentType && selectedAppointmentType.locationSPArr && selectedAppointmentType.locationSPArr[selectedLocation] && selectedAppointmentType.locationSPArr[selectedLocation].length > 0){ 1415 var availableSPList = selectedAppointmentType.locationSPArr[selectedLocation] || []; 1416 var practitioners = that.getFilteredPractitioner(selectedAppId, selectedLocation, selectedCategory); 1417 if(practitioners){ 1418 if(practitioners.length){ 1419 for(var k=0, practLen=practitioners.length; k<practLen; k++){ 1420 if(availableSPList.includes(practitioners[k].serviceProviderId)){ 1421 doctorArr.push({ 1422 id: practitioners[k].serviceProviderId, 1423 appointivBookingFormDescription: practitioners[k].AppointivBookingFormDescription ? practitioners[k].AppointivBookingFormDescription : '', 1424 name: practitioners[k].serviceProviderName, 1425 profilePic: practitioners[k].profilePicUrl, 1426 //timeSlot: practitioners[k].serviceProviderTimeSlot || "" 1427 timeSlot: that.getPractitionerTimeSlot(practitioners[k]) 1428 }); 1429 } 1430 1431 } 1432 } 1433 } 1434 }else{ 1435 var practitioners = that.getFilteredPractitioner(selectedAppId, selectedLocation, selectedCategory); 1436 if(practitioners){ 1437 if(practitioners.length){ 1438 for(var k=0, practLen=practitioners.length; k<practLen; k++){ 1439 doctorArr.push({ 1440 id: practitioners[k].serviceProviderId, 1441 appointivBookingFormDescription: practitioners[k].AppointivBookingFormDescription ? practitioners[k].AppointivBookingFormDescription : '', 1442 name: practitioners[k].serviceProviderName, 1443 profilePic: practitioners[k].profilePicUrl, 1444 //timeSlot: practitioners[k].serviceProviderTimeSlot || "" 1445 timeSlot: that.getPractitionerTimeSlot(practitioners[k]) 1446 }); 1447 1448 } 1449 } 1450 } 1451 } 1452 that.FilteredObj= FilteredObj; 1453 1454 console.log('If Appointment type, Category and Location selected.',that.FilteredObj); 1455 } 1456 1457 //If Apptype, Category and Doctor is selected 1458 if(!selectedLocation && selectedCategory && selectedPractitioner && selectedAppId){ 1459 var data=[],appType=[],appTypArr=[], locationArr= [], doctorArr=[], catArry= []; 1460 var doctorAndCategorySpecificArr = that.dropDownData.displayData.filter(function(elm){ 1461 return elm.categoryId == selectedCategory && elm.serviceProviderId == selectedPractitioner; 1462 }); 1463 //console.log('doctorAndCategorySpecificArr',doctorAndCategorySpecificArr); 1464 1465 var uniqueLocations= that.findUniqueLocation(doctorAndCategorySpecificArr); 1466 1467 var uniqueCategory= that.findUniqueCategories(doctorAndCategorySpecificArr); 1468 //console.log('uniqueCategory',uniqueCategory); 1469 1470 var allAppType= that.dropDownData.categoryAppTypWrapperMap[selectedCategory]; 1471 //console.log("allAppType",allAppType); 1472 1473 for(var i=0; i<allAppType.length; i++){ 1474 data.push(allAppType[i]); 1475 } 1476 1477 for(var i=0; i<uniqueLocations.length; i++){ 1478 locationArr.push({ 1479 id:uniqueLocations[i].locationId, 1480 name:uniqueLocations[i].locationName, 1481 address:uniqueLocations[i].locationAddress, 1482 timeZoneKey: uniqueLocations[i].locationTimeZoneKey 1483 }); 1484 1485 var practitioners = that.getFilteredPractitioner(selectedAppId, uniqueLocations[i].locationId, selectedCategory); 1486 if(practitioners){ 1487 if(practitioners.length){ 1488 for(var k=0, practLen=practitioners.length; k<practLen; k++){ 1489 /*Auther: Kunal, Description: Code to check the selected Practitioner from the ID*/ 1490 if(practitioners[k].serviceProviderId == selectedPractitioner){ 1491 doctorArr.push({ 1492 id: practitioners[k].serviceProviderId, 1493 appointivBookingFormDescription: practitioners[k].AppointivBookingFormDescription ? practitioners[k].AppointivBookingFormDescription : '', 1494 name: practitioners[k].serviceProviderName, 1495 profilePic: practitioners[k].profilePicUrl, 1496 Location: locationArr, 1497 //timeSlot: practitioners[k].serviceProviderTimeSlot || "" 1498 timeSlot: that.getPractitionerTimeSlot(practitioners[k]) 1499 }); 1500 } 1501 } 1502 } 1503 } 1504 } 1505 1506 for(var j=0; j<data.length; j++){ 1507 if(data[j].RecordId == selectedAppId) 1508 {
1509 appType.push(data[j]); 1510 } 1511 } 1512 1513 for(var j=0; j<appType.length; j++){ 1514 appTypArr.push({ 1515 id: appType[j].RecordId, 1516 maxparticipant: appType[j].MaximumParticipant, 1517 timeslotduration: appType[j].DefaultTime, 1518 name: appType[j].Name, 1519 description: appType[j].Description, 1520 price: appType[j].Price, 1521 practitioners:doctorArr, 1522 allowToBookWithMultipleCustomers: appType[j].IsAllowToBookWithMultipleCustomers, 1523 first_Available_Counsellor: appType[j].First_Available_Counsellor ? appType[j].First_Available_Counsellor : false, 1524 allowAttachment: appType[j].IsAllowAttachment, 1525 appTypeSpecificFieldsetName: appType[j].WebformFieldSetName, 1526 appTypeSpecificEventFieldsetName: appType[j].appointmentWebFieldSet, 1527 isClassAppointive:appType[j].IsClassAppointment, 1528 isAvailableOnWebform:appType[j].IsAvailableOnWebform, 1529 leadTime:appType[j].LeadTime || 0, 1530 }); 1531 } 1532 1533 console.log(appTypArr); 1534 1535 for(var i=0; i<uniqueCategory.length; i++){ 1536 FilteredObj= { 1537 id:uniqueCategory[i].categoryId, 1538 name:uniqueCategory[i].categoryName, 1539 mappingId:uniqueCategory[i].mappingId, 1540 appointmentType: appTypArr 1541 } 1542 } 1543 that.FilteredObj = FilteredObj 1544 console.log('If Apptype, Category and Doctor is selected',that.FilteredObj); 1545 } 1546 1547 //If Location, Apptype, Category and Doctor is selected 1548 if(selectedLocation && selectedCategory && selectedPractitioner && selectedAppId){ 1549 var catArr =[],doctorArr =[],appTypArr =[]; 1550 var locationCatApptypDocSpecificArr = that.dropDownData.displayData.filter(function(elm){ 1551 return elm.categoryId == selectedCategory && elm.serviceProviderId == selectedPractitioner && elm.locationId == selectedLocation; 1552 }); 1553 //console.log('locationCatApptypDocSpecificArr',locationCatApptypDocSpecificArr); 1554 1555 var practitioners = that.getFilteredPractitioner(selectedAppId, selectedLocation, selectedCategory); 1556 //console.log('practitioners',practitioners); 1557 if(practitioners){ 1558 if(practitioners.length){ 1559 for(var k=0, practLen=practitioners.length; k<practLen; k++){ 1560 if(practitioners[k].serviceProviderId == selectedPractitioner){ 1561 doctorArr.push({ 1562 id: practitioners[k].serviceProviderId, 1563 appointivBookingFormDescription: practitioners[k].AppointivBookingFormDescription ? practitioners[k].AppointivBookingFormDescription : '', 1564 name: practitioners[k].serviceProviderName, 1565 profilePic: practitioners[k].profilePicUrl, 1566 //timeSlot: practitioners[k].serviceProviderTimeSlot || "" 1567 timeSlot: that.getPractitionerTimeSlot(practitioners[k]) 1568 }); 1569 } 1570 } 1571 } 1572 } 1573 1574 var appType = that.getFilteredAppointmentType(selectedCategory); 1575 1576 for(var j=0; j<appType.length; j++){ 1577 if(appType[j].RecordId == selectedAppId){ 1578 appTypArr.push({ 1579 id: appType[j].RecordId, 1580 maxparticipant: appType[j].MaximumParticipant, 1581 timeslotduration: appType[j].DefaultTime, 1582 name: appType[j].Name, 1583 description: appType[j].Description, 1584 price: appType[j].Price, 1585 practitioners:doctorArr, 1586 allowToBookWithMultipleCustomers: appType[j].IsAllowToBookWithMultipleCustomers, 1587 first_Available_Counsellor: appType[j].First_Available_Counsellor ? appType[j].First_Available_Counsellor : false, 1588 allowAttachment: appType[j].IsAllowAttachment, 1589 appTypeSpecificFieldsetName: appType[j].WebformFieldSetName, 1590 appTypeSpecificEventFieldsetName: appType[j].appointmentWebFieldSet, 1591 isClassAppointive:appType[j].IsClassAppointment, 1592 isAvailableOnWebform:appType[j].IsAvailableOnWebform, 1593 leadTime:appType[j].LeadTime || 0, 1594 isFiveMinAppt: appType[j].IsFiveMinAppt || false, 1595 isSlotsBasedOnLocation: appType[j].IsSlotsBasedOnLocation ? appType[j].IsSlotsBasedOnLocation : false, 1596 }); 1597 } 1598 } 1599 1600 catArr.push({ 1601 id:locationCatApptypDocSpecificArr[0].categoryId, 1602 name:locationCatApptypDocSpecificArr[0].categoryName, 1603 mappingId:locationCatApptypDocSpecificArr[0].mappingId, 1604 appointmentType: appTypArr 1605 }); 1606 1607 FilteredObj={ 1608 id:locationCatApptypDocSpecificArr[0].locationId, 1609 name:locationCatApptypDocSpecificArr[0].locationName, 1610 address:locationCatApptypDocSpecificArr[0].locationAddress, 1611 timeZoneKey:locationCatApptypDocSpecificArr[0].locationTimeZoneKey, 1612 Category: catArr 1613 } 1614 that.FilteredObj= FilteredObj 1615 console.log('If All selected',that.FilteredObj); 1616 } 1617 }; 1618};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.