Advertisement
Guest User

Untitled

a guest
Jul 11th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 65.07 KB | None | 0 0
  1. function columnHTML(name, last, input3, input4, input5) {
  2. return `<a href="" class="aRow" ><div class="row"><span class="cell name"><span class="inCell">${name}</span></span><span class="cell"><span class="inCell">${last}</span></span><span class="cell"><span class="inCell">${input3}</span></span><span class="cell"><span class="inCell">${input4}</span></span><span class="cell"><span class="inCell">${input5}</span></span></div></a>`
  3. }
  4. function teethHTML(numberTeeth) {
  5. return (
  6. `<div class="teeth">
  7. <div class="pointerdown pointer">
  8. <div class="containerPointer">
  9. <input type="text" class="teethPriceSingle" placeholder="Price">
  10. <select class="selectTreatment" name="">
  11. <option value="">treatment</option>
  12. <option value="shetel">shetel</option>
  13. <option value="ikor">ikor</option>
  14. <option value="whatever">whatever</option>
  15. </select>
  16. <button type="button" name="button" class="pointersub">submit</button>
  17. </div>
  18. <div class="arrowdown"></div>
  19. </div>
  20. <div class="teethNumber">` +
  21. numberTeeth +
  22. `</div>
  23. <img class="imgTeeth" src="media/teethdown.png" alt="">
  24. </div>`
  25. )
  26. }
  27.  
  28. function medecineScript() {
  29. $('.medicine').click(function() {
  30. let nameDoc = $('#nameOfDoc').text()
  31. let medicineName = $(this).text()
  32. let medicine = {
  33. medicine: medicineName,
  34. nameDoc: nameDoc,
  35. patientName: $('#nameOfPatientDetails').text()
  36. }
  37. let medicineJSON = JSON.stringify(medicine)
  38. $.ajax({
  39. url: '/medicine',
  40. type: 'POST',
  41. dataType: 'json',
  42. data: medicineJSON,
  43. success: function(data) {
  44. console.log(data)
  45. $('#patientMedicine').append(
  46. '<span class=`medicineNameSelected>`' +
  47. medicineName +
  48. '</span></br>'
  49. )
  50. localStorage.setItem(
  51. 'medicine ' + medicine.patientName + ' of ' + nameDoc,
  52. JSON.stringify(data)
  53. )
  54. }
  55. })
  56. })
  57. }
  58.  
  59. $(window).on('load', function() {
  60. let username = localStorage.getItem('nameOfDoc')
  61. let clinic = localStorage.getItem('nameOfClinic')
  62. localStorage.clear()
  63. localStorage.setItem('nameOfDoc', username)
  64. localStorage.setItem('nameOfClinic', clinic)
  65. })
  66. $('#clinicFormSignUp').hide()
  67. $('#docFormSignUp').hide()
  68. $('#docFormSignIn').hide()
  69. $('#clinicFormSignIn').hide()
  70.  
  71. $('#doctorSignUp').click(function(e) {
  72. e.preventDefault()
  73. $('#docFormSignIn').hide()
  74. $('#clinicFormSignIn').hide()
  75. $('#clinicFormSignUp').hide()
  76. $('#docFormSignUp').show()
  77. })
  78.  
  79. $('#clinicSignUp').click(function(e) {
  80. e.preventDefault()
  81. $('#docFormSignIn').hide()
  82. $('#clinicFormSignIn').hide()
  83. $('#docFormSignUp').hide()
  84. $('#clinicFormSignUp').show()
  85. })
  86. //
  87. $('#doctorSignIn').click(function(e) {
  88. e.preventDefault()
  89. $('#clinicFormSignIn').hide()
  90. $('#docFormSignUp').hide()
  91. $('#clinicFormSignUp').hide()
  92. $('#docFormSignIn').show()
  93. })
  94.  
  95. $('#clinicSignIn').click(function(e) {
  96. e.preventDefault()
  97. $('#docFormSignUp').hide()
  98. $('#clinicFormSignUp').hide()
  99. $('#docFormSignIn').hide()
  100. $('#clinicFormSignIn').show()
  101. })
  102.  
  103. // function getLocalStorage(kind, patientClicked, nameOfDoc) {
  104. // localStorage.getItem(kind + " " + patientClicked.firstName + " " + patientClicked.SubName + "of" + JSON.parse(localStorage.getItem("nameOfDoc")).nameOfDoc)
  105. // }
  106.  
  107. function hideExaptButtons() {
  108. $('#char_cont').hide()
  109. $('#calendar_cont').hide()
  110. $('#content').hide()
  111. }
  112.  
  113. function openCity(evt, cityName) {
  114. let i, tabcontent, tablinks
  115. tabcontent = document.getElementsByClassName('tabcontent')
  116. for (i = 0; i < tabcontent.length; i++) {
  117. tabcontent[i].style.display = 'none'
  118. }
  119. tablinks = document.getElementsByClassName('tablinks')
  120. for (i = 0; i < tablinks.length; i++) {
  121. tablinks[i].className = tablinks[i].className.replace(' active', '')
  122. }
  123. document.getElementById(cityName).style.display = 'block'
  124. evt.currentTarget.className += ' active'
  125. }
  126.  
  127. // Chenge Languege
  128. $('.he').hide()
  129. $('.heInput').hide()
  130.  
  131. $('#en').click(function(e) {
  132. e.preventDefault()
  133. $('.he').hide()
  134. $('.en').show()
  135. $('.heInput').hide()
  136. $('.enInput').show()
  137. })
  138.  
  139. $('#he').click(function(e) {
  140. e.preventDefault()
  141. $('.en').hide()
  142. $('.he').show()
  143. $('.enInput').hide()
  144. $('.heInput').show()
  145. })
  146.  
  147. // SEARCH ENGINE:
  148.  
  149. $('#searchB').click(function() {
  150. let inputVal = $('#box').val()
  151. $('.name').each(function() {
  152. let isContains =
  153. $(this)
  154. .text()
  155. .indexOf(inputVal) > -1
  156. if (!isContains) {
  157. $(this)
  158. .parent()
  159. .hide()
  160. } else {
  161. $(this)
  162. .parent()
  163. .show()
  164. }
  165. })
  166. })
  167.  
  168. $('#bringThemOn').click(function() {
  169. $('.row').show()
  170. })
  171.  
  172. //Menu clicks
  173.  
  174. $('.menu_bts').click(function() {
  175. $(this)
  176. .siblings()
  177. .css('transform', 'translate(0px, -500px)')
  178. $('.menu_bts').css('opacity', '0')
  179. setTimeout(function() {
  180. $('#homeb').css('display', 'flex')
  181. $('#conteiner').hide()
  182. $('#homeb').css('opacity', '1')
  183. }, 1000)
  184. if ($(this).hasClass('left')) {
  185. setTimeout(function() {
  186. $('#content').show()
  187. $('#content').addClass('animated')
  188.  
  189. $('#content').addClass('bounceIn')
  190. }, 1500)
  191. } else if ($(this).hasClass('right')) {
  192. setTimeout(function() {
  193. $('#char_cont').show()
  194. $('#char_cont').addClass('animated')
  195. $('#char_cont').addClass('bounceIn')
  196. }, 1500)
  197. } else {
  198. setTimeout(function() {
  199. $('#calendar_cont').show()
  200. $('#calendar_cont').addClass('animated')
  201. $('#calendar_cont').addClass('bounceIn')
  202. }, 1500)
  203. }
  204. })
  205.  
  206. $('#homeb').click(function() {
  207. $(this).hide()
  208. $('#conteiner').show()
  209. $('.menu_bts').css('transform', 'translate(0px, 0px)')
  210. $('.menu_bts').css('opacity', '1')
  211. hideExaptButtons()
  212. })
  213.  
  214. $('#cancleb').click(function(e) {
  215. e.preventDefault()
  216. $('#homeb').click()
  217. })
  218.  
  219. $('#createNewAccount').hide()
  220. $('#createNewClinic').hide()
  221. $('#loginFormDiv').hide()
  222. $('.createNewAccoutSuggestion').click(function(e) {
  223. e.preventDefault()
  224. $('#createNewAccount').show()
  225. $('#loginFormDiv').hide()
  226. $('#createNewClinic').hide()
  227. })
  228. $('.createNewClinicSuggestion').click(function(e) {
  229. e.preventDefault()
  230. $('#createNewClinic').show()
  231. $('#createNewAccount').hide()
  232. $('#loginFormDiv').hide()
  233. })
  234. $('.createNewClinicSuggestion').click(function(e) {
  235. e.preventDefault()
  236. $('#login').show()
  237. })
  238. $('#loginClinic').click(function() {})
  239.  
  240. $('.newClinicForm').submit(function(e) {
  241. e.preventDefault()
  242.  
  243. $( "#clinicSignUp" ).removeClass( "active" )
  244. $( "#clinicSignIn" ).addClass( "active" )
  245. $('#docFormSignUp').hide()
  246. $('#clinicFormSignUp').hide()
  247. $('#docFormSignIn').hide()
  248. $('#clinicFormSignIn').show()
  249.  
  250. let nameOfNewClinic = $('#nameOfNewClinic').val()
  251. let addressOfNewClinic = $('#addressOfNewClinic').val()
  252. let managerOfClinic = $('#ManagerOfClinic').val()
  253. let passwordOfNewClinic = $('#passwordOfNewClinic').val()
  254. let cityOfClinic = $('#cityOfClinic').val()
  255. let phoneNumberOfNewClinic = $('#phoneNumberOfNewClinic').val()
  256. let emailAddressOfNewClinic = $('#emailAddressOfNewClinic').val()
  257.  
  258. let data = {
  259. nameOfNewClinic: nameOfNewClinic,
  260. password: passwordOfNewClinic,
  261. address: addressOfNewClinic + ' ' + cityOfClinic,
  262. managerOfClinic: managerOfClinic,
  263. emailAddress: emailAddressOfNewClinic,
  264. phoneNumber: phoneNumberOfNewClinic,
  265. doctors: [],
  266. patients: []
  267. }
  268.  
  269. let datajson = JSON.stringify(data)
  270. $.ajax({
  271. url: '/createNewClinic',
  272. type: 'POST',
  273. dataType: 'json',
  274. data: datajson,
  275. success: function(data) {
  276. console.log(data)
  277. console.log('w')
  278. }
  279. })
  280. alert("A mail was sent to your Emmail, confirm it in order to create your account")
  281. })
  282. $("#favMedicinesOption #prescriptionTab").click(function(e) {
  283. e.preventDefault()
  284. $(".favMedicine").click(function() {
  285. console.log($(this));
  286. })
  287. })
  288.  
  289. $('.loginClinic').submit(function(e) {
  290. e.preventDefault()
  291. let emailOfClinic = $('.emailOfClinicSign').val()
  292. let password = $('#passwordOfClinic').val()
  293. let data = {
  294. emailOfClinic: emailOfClinic,
  295. password: password
  296. }
  297. let dataJson = JSON.stringify(data)
  298. $.ajax({
  299. url: '/loginClinic',
  300. type: 'POST',
  301. dataType: 'json',
  302. data: dataJson,
  303. success: function(data) {
  304. let datafromServer = data
  305. let clinicsDetails = {
  306. nameOfClinic: datafromServer.nameOfClinic,
  307. idOfClinic: datafromServer.idUser,
  308. doctorsOfClinic: datafromServer.doctorsOfClinic
  309. }
  310. console.log(clinicsDetails)
  311. let clinicsJSON = JSON.stringify(clinicsDetails)
  312. localStorage.setItem('nameOfClinic', clinicsJSON)
  313.  
  314. $('#ID').html(datafromServer.idUser)
  315. if (datafromServer.bool) {
  316. window.open('http://ct-doc.tk/clinic.html', '_self')
  317. }
  318. }
  319. })
  320. })
  321.  
  322. // handling routes
  323. $('#cnaform').submit(function(e) {
  324. e.preventDefault()
  325.  
  326. $( "#doctorSignUp" ).removeClass( "active" )
  327. $( "#doctorSignIn" ).addClass( "active" )
  328. $('#clinicFormSignIn').hide()
  329. $('#docFormSignUp').hide()
  330. $('#clinicFormSignUp').hide()
  331. $('#docFormSignIn').show()
  332.  
  333. let data = {
  334. username:
  335. $('#nameOfNewAccountFirst').val() +
  336. ' ' +
  337. $('#nameOfNewAccountLast').val(),
  338. password: $('#passwordOfNewAccount').val(),
  339. address: $('#addressOfNewDoctor').val(),
  340. emailAddress: $('#emailAddressOfDoc').val(),
  341. patients: [],
  342. FavMedicines: [],
  343. confirm: "pending"
  344. }
  345. let json = JSON.stringify(data)
  346. console.log(data)
  347.  
  348. $.ajax({
  349. url: '/createDoc',
  350. type: 'POST',
  351. dataType: 'json',
  352. data: json
  353. })
  354. alert("A mail was sent to your Emmail, confirm it in order to create your account")
  355.  
  356. })
  357.  
  358. $('#green').click(function(e) {
  359. e.preventDefault()
  360. console.log('green')
  361. let backgroundName = {
  362. background: 'green',
  363. nameDoc: JSON.parse(localStorage.getItem('nameOfDoc')).nameOfDoc
  364. }
  365. let JSONbackground = JSON.stringify(backgroundName)
  366. $.ajax({
  367. url: '/green',
  368. type: 'POST',
  369. dataType: 'json',
  370. data: JSONbackground,
  371. success: function(data) {
  372. console.log(data)
  373. console.log('w')
  374. $('.body').css('background-image', `url('media/NEXT_green.jpg')`)
  375. localStorage.setItem('theme', 'green')
  376. }
  377. })
  378. })
  379.  
  380. // $(".fileupload").submit(function() {
  381. // let data = {
  382. // nmeOfDoc: $("#nameOfDoc").text(),
  383. // nameOfPtient: $(".nameOfPatientDetails").text()
  384. // }
  385. // let jsonData = JSON.stringify(data)
  386. // $.ajax({
  387. // url: '/upload',
  388. // type: 'POST',
  389. // dataType: 'json',
  390. // data: jsonData,
  391. // success: function(data) {
  392. //
  393. // }
  394. // })
  395. // })
  396. //set new meeting
  397. $('#submitSetNewMteetingBox').click(function(e) {
  398. e.preventDefault()
  399. let startMeetingHour = $('.startHour').val()
  400. let startMeetingMinutes = $('.startMinutes').val()
  401. let endMeetingHour = $('#endHour').val()
  402. let endMeetingMinutes = $('.endMinutes').val()
  403. let dateMeetingStart = $('#dateInputStart').val()
  404. let dateMeetingEnd = $('#dateInputEnd').val()
  405. let colorMeeting = $('#colorMeeting').val()
  406.  
  407. if (startMeetingHour.length === 1) {
  408. let hourAccepted = '0' + startMeetingHour
  409. startMeetingHour = hourAccepted
  410. console.log('Passed')
  411. }
  412. if (startMeetingMinutes.length === 1) {
  413. let minutesAccepted = '0' + startMeetingMinutes
  414. startMeetingMinutes = minutesAccepted
  415. }
  416. if (endMeetingHour.length === 1) {
  417. let hourAcceptedEnd = '0' + endMeetingHour
  418. endMeetingHour = hourAcceptedEnd
  419. console.log('Passed')
  420. }
  421. if (endMeetingMinutes.length === 1) {
  422. let minutesAccepted = '0' + endMeetingMinutes
  423. endMeetingMinutes = minutesAccepted
  424. console.log('Passed')
  425. }
  426. if (dateMeetingEnd.length === 0) {
  427. dateMeetingEnd = dateMeetingStart
  428. }
  429. console.log(dateMeetingEnd)
  430. let meeting = {
  431. newMeeting: {
  432. title: 'Meeting',
  433. start:
  434. dateMeetingStart + 'T' + startMeetingHour + ':' + startMeetingMinutes,
  435. color: colorMeeting,
  436. end: dateMeetingEnd + 'T' + endMeetingHour + ':' + endMeetingMinutes
  437. },
  438. patientName: $('#nameOfPatientDetails').text(),
  439. nameDoc: $('#nameOfDoc').text()
  440. }
  441. $('#calenderMeeting').fullCalendar('addEventSource', [meeting.newMeeting])
  442. let meetingJson = JSON.stringify(meeting)
  443. $.ajax({
  444. url: 'newMeeting',
  445. type: 'POST',
  446. dataType: 'json',
  447. data: meetingJson,
  448. success: function(data) {
  449. console.log(data)
  450. localStorage.setItem(
  451. meeting.nameDoc + ' of patient ' + meeting.patientName + ' meetings',
  452. JSON.stringify(data)
  453. )
  454. }
  455. })
  456. })
  457.  
  458. $('#orange').click(function(e) {
  459. e.preventDefault()
  460. console.log('orange')
  461. let backgroundName = {
  462. background: 'orange',
  463. nameDoc: JSON.parse(localStorage.getItem('nameOfDoc')).nameOfDoc
  464. }
  465. let JSONbackground = JSON.stringify(backgroundName)
  466. $.ajax({
  467. url: '/orange',
  468. type: 'POST',
  469. dataType: 'json',
  470. data: JSONbackground,
  471. success: function(data) {
  472. console.log('SAD')
  473. $('.body').css('background-image', `url('media/NEXT_orange.jpg')`)
  474. localStorage.setItem('theme', 'orange')
  475. }
  476. })
  477. })
  478.  
  479. $('#blue').click(function(e) {
  480. e.preventDefault()
  481. console.log('blue')
  482. let backgroundName = {
  483. background: 'blue',
  484. nameDoc: JSON.parse(localStorage.getItem('nameOfDoc')).nameOfDoc
  485. }
  486. let JSONbackground = JSON.stringify(backgroundName)
  487. $.ajax({
  488. url: '/blue',
  489. type: 'POST',
  490. dataType: 'json',
  491. data: JSONbackground,
  492. success: function(data) {
  493. console.log('SAD')
  494. $('.body').css('background-image', `url('media/NEXT_blue.jpg')`)
  495. localStorage.setItem('theme', 'blue')
  496. }
  497. })
  498. })
  499.  
  500. if (localStorage.getItem('theme') == 'grey') {
  501. $('.body').css('background-image', `url('media/NEXT_grey.jpg')`)
  502. } else if (localStorage.getItem('theme') == 'orange') {
  503. $('.body').css('background-image', `url('media/NEXT_orange.jpg')`)
  504. } else if (localStorage.getItem('theme') == 'orange') {
  505. $('.body').css('background-image', `url('media/NEXT_blue.jpg')`)
  506. } else {
  507. $('.body').css('background-image', `url('media/NEXT_green.jpg')`)
  508. }
  509.  
  510. $('#grey').click(function(e) {
  511. e.preventDefault()
  512. console.log('grey')
  513. let backgroundName = {
  514. background: 'grey',
  515. nameDoc: JSON.parse(localStorage.getItem('nameOfDoc')).nameOfDoc
  516. }
  517. let JSONbackground = JSON.stringify(backgroundName)
  518. $.ajax({
  519. url: '/grey',
  520. type: 'POST',
  521. dataType: 'json',
  522. data: JSONbackground,
  523. success: function(data) {
  524. localStorage.setItem('theme', 'grey')
  525. $('.body').css('background-image', `url('media/NEXT_grey.jpg')`)
  526. }
  527. })
  528. })
  529.  
  530. //$("#logB").click()
  531. $('#nameOfPatient').hide()
  532. $('#createNewPat-Form').submit(function(e) {
  533. e.preventDefault()
  534. let firstName = $('#patientFirstName').val()
  535. let subname = $('#subname').val()
  536. let pn = $('#pn').val()
  537. let emc = $('#emc').val()
  538. let fd = $('#FD').val()
  539. let address = $('#address').val()
  540. let job = $('#job').val()
  541. let homenumber = $('#homeNumber').val()
  542. let IDinput = $('#IDinput').val()
  543. let insurance = $('#insurance').val()
  544. let fax = $('#fax').val()
  545. let cameFrom = $('#cameFrom').val()
  546. let caseNumber = $('#caseNumber').val()
  547. let doctor = $('#doctor').val()
  548. let date = $('#date').val()
  549. let email = $('#email').val()
  550. let selectedGender = $('#gender option:selected')
  551. let gender = selectedGender[0].innerHTML
  552. let selectedStatus = $('#status option:selected')
  553. let status = selectedStatus[0].innerHTML
  554. let validity = $('#validity').val()
  555.  
  556. let dataPatient = {
  557. nameDoc: $('#nameOfDoc').text(),
  558. docID: $('#ID').text(),
  559. data: {
  560. firstName: firstName,
  561. SubName: subname,
  562. fullName: firstName + ' ' + subname,
  563. phoneNumber: pn,
  564. emergencyNumber: emc,
  565. familyDoctor: fd,
  566. address: address,
  567. IDinput: IDinput,
  568. date: date,
  569. email: email,
  570. gender: gender,
  571. status: status,
  572. meetings: [],
  573. teethArage: {teeth: {}, price: ''},
  574. cameFrom: cameFrom,
  575. caseNumber: caseNumber,
  576. insurance: insurance,
  577. fax: fax,
  578. homenumber: homenumber,
  579. job: job,
  580. doctor: doctor,
  581. validity: validity,
  582. medicines: [],
  583. archive: false,
  584. nameOfFiles: [],
  585. infoComments: "",
  586. treatmentComments: "",
  587. prescriptionsComment: ""
  588. }
  589. }
  590. let jsonDataPatient = JSON.stringify(dataPatient)
  591. console.log(dataPatient)
  592. console.log(jsonDataPatient)
  593. $.ajax({
  594. url: '/PatientDetails',
  595. type: 'POST',
  596. dataType: 'json',
  597. data: jsonDataPatient,
  598. success: function(data) {
  599. let lol = data
  600. console.log(lol)
  601. console.log("asdasd");
  602. }
  603. })
  604. })
  605.  
  606. $('#login-form').submit(function(e) {
  607. e.preventDefault()
  608. $('#nameOfPatient').show()
  609. $('#incorrect').html(
  610. 'Password or Username is incorrect! </br> <code>TIP</code>:Make sure the caps lock isnt locked on! :)'
  611. )
  612. let object = {
  613. username: $('#logUser').val(),
  614. password: $('#logPass').val(),
  615. patients: []
  616. }
  617. let objectJSON = JSON.stringify(object)
  618.  
  619. $.ajax({
  620. url: '/loginReq',
  621. type: 'POST',
  622. dataType: 'json',
  623. data: objectJSON,
  624. success: function(data) {
  625. let lol = data
  626. let doctorsDetails = {
  627. nameOfDoc: lol.username,
  628. idOfDoc: lol.idUser
  629. }
  630. // console.log(lol.bool);
  631. let doctorsJSON = JSON.stringify(doctorsDetails)
  632. localStorage.setItem('nameOfDoc', doctorsJSON)
  633.  
  634. $('#ID').html(lol.idUser)
  635. if (lol.bool) {
  636. window.open('http://ct-doc.tk/singleDoc.html', '_self')
  637. }
  638. }
  639. })
  640. })
  641.  
  642. $('#char').click(function(e) {
  643. e.preventDefault()
  644. let nameDoc = $('#nameOfDoc').text()
  645. let nameDocObject = {
  646. nameDoc: nameDoc
  647. }
  648. let nameDocObjectJson = JSON.stringify(nameDocObject)
  649. $.ajax({
  650. url: '/reqPatientsDetails',
  651. type: 'POST',
  652. dataType: 'json',
  653. data: nameDocObjectJson,
  654. success: function(data1) {
  655. $('#patRow').html('')
  656. let data = data1.patients
  657. for (let i = 0; i < data.length; i++) {
  658. console.log(data[i].archive === true);
  659. if (data[i].archive === true) {
  660. $("#namesArchiveTable").append(`<tr class="row100 body">
  661. <td class="cell100 column1">` + data[i].fullName + `</td>
  662. </tr>`)
  663. $('#patRowArchive').append(
  664. `<tr class="row100 body">
  665. <td class="cell100 column2">` + data[i].IDinput + `</td>
  666. <td class="cell100 column3">` + data[i].phoneNumber + `</td>
  667. <td class="cell100 column4">` + data[i].gender + `</td>
  668. <td class="cell100 column5">` + data[i].email + `</td>
  669. <td class="cell100 column6">` + data[i].date + `</td>
  670. <td class="cell100 column7">` + data[i].address + `</td>
  671. <td class="cell100 column8"><button class="searchTools bringBackFromArchive"><span class="nameOfPatientHiddenArchive">` + data[i].fullName + `</span>Bring Back</button></td>
  672. </tr>`
  673. )
  674. } else {
  675. $('#patRow').append(
  676. columnHTML(
  677. data[i].firstName + ' ' + data[i].SubName,
  678. data[i].phoneNumber,
  679. data[i].familyDoctor,
  680. data[i].date,
  681. data[i].gender
  682. )
  683. )
  684. }
  685. }
  686.  
  687. $(".deletePatient").click(function(e) {
  688. e.preventDefault()
  689. let nameOfPatient = $(this).parent().parent().parent().find(".name").children().text()
  690. let nameOfDoctor = $("#nameOfDoc").text()
  691. let data = {
  692. nameOfPatient: nameOfPatient,
  693. nameOfDoctor: nameOfDoctor
  694. }
  695. let jsonData = JSON.stringify(data)
  696. console.log(jsonData);
  697. let confirm = prompt("ARE YOU SURE YOU WANT TO DELETE PATIENT " + nameOfPatient + "? if you do, write the full name of the patient")
  698. if (confirm.toLowerCase() === nameOfPatient.toLowerCase()) {
  699. $.ajax({
  700. url: '/patientDeleted',
  701. type: 'POST',
  702. dataType: 'json',
  703. data: jsonData,
  704. success: function(data1) {
  705. alert(data1)
  706. }
  707. })
  708. location.reload()
  709. } else {
  710. alert("patient not deleted")
  711. }
  712. })
  713.  
  714. $(".bringBackFromArchive").click(function(e) {
  715. e.preventDefault()
  716. let nameOfPatient = $(this).children().text()
  717. let nameOfDoc = $("#nameOfDoc").text()
  718. let data = {
  719. nameOfPatient: nameOfPatient,
  720. nameDoc: nameOfDoc
  721. }
  722. let JSONdata = JSON.stringify(data)
  723. $.ajax({
  724. url: '/backFromArchive',
  725. type: 'POST',
  726. dataType: 'json',
  727. data: JSONdata,
  728. success: function(data) {
  729. console.log(data);
  730. }
  731. })
  732. location.reload()
  733. })
  734. $("#archiveTable").click(function(e) {
  735. e.preventDefault()
  736. $(".limiter").show()
  737. $("#archiveTableClose").click(function(e) {
  738. $(".limiter").hide()
  739. })
  740. })
  741. $('.aRow').click(function(e) {
  742. e.preventDefault()
  743.  
  744. let nameOfPatient = {
  745. nameOfDoc: $('#nameOfDoc').text(),
  746. nameOfPatient1: $(this)
  747. .find('.name')
  748. .children()
  749. .text()
  750. }
  751. for (let z = 0; z < data.length; z++) {
  752. if (
  753. data[z].firstName + ' ' + data[z].SubName ===
  754. nameOfPatient.nameOfPatient1
  755. ) {
  756. console.log(data[z])
  757. let patientClicked = data[z]
  758. $(".nameOfDocInput").val($("#nameOfDoc").text())
  759. $(".nameOfPatientInput").val($("#nameOfPatientDetails").text())
  760. $('#patientDetails').css('display', 'flex')
  761. $('#darkBackground').show()
  762. $('#darkBackground').css('height', $(document).height() + 'px')
  763. $('#closePatientdetails').click(function() {
  764. $('#patientDetails').hide()
  765. $('#darkBackground').hide()
  766. $('#meetingsUL').html('')
  767. })
  768. $(".nameOfPatientInput").val(patientClicked.firstName + ' ' + patientClicked.SubName)
  769. $('#nameOfPatientDetails').html(
  770. patientClicked.firstName + ' ' + patientClicked.SubName
  771. )
  772. $('#firstName').html(patientClicked.firstName)
  773. $('#SubName').html(patientClicked.SubName)
  774. $('#phoneNumberPatient').html(patientClicked.phoneNumber)
  775. $('#fax').html(patientClicked.fax)
  776. $("#info_box").val("")
  777. $('#doctor').html(patientClicked.doctor)
  778. $('#homenumber').html(patientClicked.homenumber)
  779. $('#validity').html(patientClicked.validity)
  780. $('#insurance').html(patientClicked.insurance)
  781. $('#job').html(patientClicked.job)
  782. $('#caseNumber').html(patientClicked.caseNumber)
  783. $('#cameFrom').html(patientClicked.cameFrom)
  784. $('#genderPatient').html(patientClicked.gender)
  785. $('#addressPatient').html(patientClicked.address)
  786. $('#emailPatient').html(patientClicked.email)
  787. $('#statusPatient').html(patientClicked.status)
  788. $('#famDocPatient').html(patientClicked.familyDoctor)
  789. $('#emargancyNumberPatient').html(patientClicked.emergencyNumber)
  790. $('#birthDayPatient').html(patientClicked.date)
  791. $('#calenderMeeting').fullCalendar('removeEventSources')
  792. $('#allTreatments').html(''),
  793. $("#textareaPayment").val("")
  794. if (localStorage.getItem("textareaPayment " + patientClicked.fullName)) {
  795. $("#textareaPayment").val(localStorage.getItem("textareaPayment " + patientClicked.fullName))
  796. } else {
  797. $("#textareaPayment").val(patientClicked.commentPayment)
  798. }
  799. if (localStorage.getItem("treatmentComment " + patientClicked.fullName)) {
  800. $("#textareaTreatment").val(localStorage.getItem("treatmentComment " + patientClicked.fullName))
  801. } else {
  802. $("#textareaTreatment").val(patientClicked.treatmentComments)
  803. }
  804. if (localStorage.getItem("prescriptionsComment " + patientClicked.fullName)) {
  805. $("#prescriptions_box").val(localStorage.getItem("prescriptionsComment " + patientClicked.fullName))
  806. } else {
  807. $("#prescriptions_box").val(patientClicked.prescriptionsComment)
  808. }
  809. //prescriptionsComment
  810. if (localStorage.getItem("infoComments " + patientClicked.fullName)) {
  811. $("#info_box").val(localStorage.getItem("infoComments " + patientClicked.fullName))
  812. } else {
  813. $("#info_box").val(patientClicked.infoComments)
  814. }
  815. for (var i = 0; i < patientClicked.nameOfFiles.length; i++) {
  816. $(".listOfFiles").append(`<img src=media/usersMedia/` + $("#nameOfDoc").text().split(' ').join('_') + `/` + patientClicked.fullName.split(' ').join('_') + `/` + patientClicked.nameOfFiles[i] + `>`)
  817. }
  818. $("#submitPayment").click(function() {
  819. let comment = $("#textareaPayment").val()
  820. let nameOfDoc = $("#nameOfDoc").text()
  821. let nameOfPatient = patientClicked.fullName
  822. let data = {
  823. comment: comment,
  824. nameDoc: nameOfDoc,
  825. namePatient: nameOfPatient
  826. }
  827. let JSONData = JSON.stringify(data)
  828. $.ajax({
  829. url: '/commentPayment',
  830. type: 'POST',
  831. dataType: 'json',
  832. data: JSONData,
  833. success: function(data) {
  834. console.log(data);
  835. localStorage.setItem("textareaPayment " + patientClicked.fullName, data.message)
  836. }
  837. })
  838. })
  839. $("#submitTreatmentComments").click(function() {
  840. let comment = $("#textareaTreatment").val()
  841. let nameOfDoc = $("#nameOfDoc").text()
  842. let nameOfPatient = patientClicked.fullName
  843. let data = {
  844. comment: comment,
  845. nameDoc: nameOfDoc,
  846. namePatient: nameOfPatient
  847. }
  848. let JSONData = JSON.stringify(data)
  849. $.ajax({
  850. url: '/treatmentComment',
  851. type: 'POST',
  852. dataType: 'json',
  853. data: JSONData,
  854. success: function(data) {
  855. console.log(data);
  856. localStorage.setItem("textareaTreatment " + patientClicked.fullName, data.message)
  857. }
  858. })
  859. })
  860. $("#submitPrescriptions").click(function() {
  861. let comment = $("#prescriptions_box").val()
  862. let nameOfDoc = $("#nameOfDoc").text()
  863. let nameOfPatient = patientClicked.fullName
  864. let data = {
  865. comment: comment,
  866. nameDoc: nameOfDoc,
  867. namePatient: nameOfPatient
  868. }
  869. let JSONData = JSON.stringify(data)
  870. $.ajax({
  871. url: '/prescriptionsComment',
  872. type: 'POST',
  873. dataType: 'json',
  874. data: JSONData,
  875. success: function(data) {
  876. console.log(data);
  877. localStorage.setItem("prescriptionsComment " + patientClicked.fullName, data.message)
  878. }
  879. })
  880. })
  881. $('#totalPriceOfTeeth').html('')
  882. $("#moveToArchive").click(function(e) {
  883. e.preventDefault()
  884. // let prompt = prompt("are you sure you wnna delete patient " + $("#nameOfPatientDetails").text() + "? if you do, type the full name of the patient")
  885. // if (prompt == $("#nameOfPatientDetails").text()) {
  886. let data = {
  887. namePatient: $("#nameOfPatientDetails").text(),
  888. }
  889. console.log(data);
  890. let jsonData = JSON.stringify(data)
  891. $.ajax({
  892. url: '/archivePatient',
  893. type: 'POST',
  894. dataType: 'json',
  895. data: jsonData,
  896. success: function(data) {
  897. console.log(data);
  898. location.reload()
  899. }
  900. })
  901. // } else {
  902. // alert("Wrong name")
  903. // }
  904. })
  905. let numberPatient = data.indexOf(patientClicked)
  906. let totalPrice = 0
  907. $('#favMedicines').html('')
  908. $("#saveBtnTextareaInfoTab").click(function(e) {
  909. e.preventDefault()
  910. let nameOfDoc = $("#nameOfDoc").text()
  911. let nameOfPatient = $("#nameOfPatientDetails").text()
  912. let comments = $("#info_box").val()
  913. let data = {
  914. nameDoc: nameOfDoc,
  915. namePatient: nameOfPatient,
  916. infoComments: comments
  917. }
  918. console.log(data);
  919. let jsonData = JSON.stringify(data)
  920. $.ajax({
  921. url: '/infoComments',
  922. type: 'POST',
  923. dataType: 'json',
  924. data: jsonData,
  925. success: function(data) {
  926. console.log(data);
  927. localStorage.setItem("infoComments " + patientClicked.fullName, data.message)
  928. }
  929. })
  930. })
  931. if (localStorage.getItem('favMedicine:')) {
  932. let favMedicines = JSON.parse(
  933. localStorage.getItem('favMedicine:')
  934. )
  935. for (let i = 0; i < favMedicines.length; i++) {
  936. //2003
  937. $('#favMedicines').append(
  938. `<a href=""class="aMedicine">
  939. <div class="medicine favMedicine">` +
  940. favMedicines[i] +
  941. `<span class="removeFavMedicine">&#10005</span>
  942. </div>
  943. </a>`
  944. )
  945. }
  946. } else {
  947. for (let i = 0; i < data1.FavMedicines.length; i++) {
  948. $('#favMedicines').append(
  949. `<a href=""class="aMedicine">
  950. <div class="medicine favMedicine">` +
  951. data1.FavMedicines[i] +
  952. `<span class="removeFavMedicine">&#10005</span>
  953. </div>
  954. </a>`
  955. )
  956. }
  957. $('.favMedicinesNewMedicine').click(function(e) {
  958. e.preventDefault()
  959. let favMedicine = {
  960. nameDoc: $('#nameOfDoc').text(),
  961. medicine: $(this).text()
  962. }
  963. let favMedicineJSON = JSON.stringify(favMedicine)
  964. $.ajax({
  965. url: '/medicineFav',
  966. type: 'POST',
  967. dataType: 'json',
  968. data: favMedicineJSON,
  969. success: function(data) {
  970. console.log(Object.values(data))
  971. $('#favMedicines').append(
  972. `<a href=""class="aMedicine">
  973. <div class="medicine favMedicine medicine` + $(".favMedicine").length + `">` +
  974. favMedicine.medicine +
  975. `<span class="removeFavMedicine">&#10005</span>
  976. </div>
  977. </a>`
  978. )
  979. let num = $(".favMedicine").length -1
  980. $('.medicine' + num).click(function() {
  981. console.log("new thing clicked " + $(".favMedicine").length + 1);
  982. let nameDoc = $('#nameOfDoc').text()
  983. let medicineName = $(this).text()
  984. let medicine = {
  985. medicine: medicineName,
  986. nameDoc: nameDoc,
  987. patientName: $('#nameOfPatientDetails').text()
  988. }
  989. let medicineJSON = JSON.stringify(medicine)
  990. $.ajax({
  991. url: '/medicine',
  992. type: 'POST',
  993. dataType: 'json',
  994. data: medicineJSON,
  995. success: function(data) {
  996. console.log(data)
  997. $('#patientMedicine').append(
  998. '<span class=`medicineNameSelected>`' +
  999. medicineName +
  1000. '</span></br>'
  1001. )
  1002. localStorage.setItem(
  1003. 'medicine ' + medicine.patientName + ' of ' + nameDoc,
  1004. JSON.stringify(data)
  1005. )
  1006. }
  1007. })
  1008. })
  1009. localStorage.setItem('favMedicine:', JSON.stringify(data))
  1010. $('.aMedicine').click(function(e) {
  1011. e.preventDefault()
  1012. })
  1013. }
  1014. })
  1015. })
  1016. $('.medicine').click(function() {
  1017. console.log($(this));
  1018. let nameDoc = $('#nameOfDoc').text()
  1019. let medicineName = $(this).text()
  1020. let medicine = {
  1021. medicine: medicineName,
  1022. nameDoc: nameDoc,
  1023. patientName: $('#nameOfPatientDetails').text()
  1024. }
  1025. let medicineJSON = JSON.stringify(medicine)
  1026. $.ajax({
  1027. url: '/medicine',
  1028. type: 'POST',
  1029. dataType: 'json',
  1030. data: medicineJSON,
  1031. success: function(data) {
  1032. console.log(data)
  1033. $('#patientMedicine').append(
  1034. '<span class=`medicineNameSelected>`' +
  1035. medicineName +
  1036. '</span></br>'
  1037. )
  1038. localStorage.setItem(
  1039. 'medicine ' + medicine.patientName + ' of ' + nameDoc,
  1040. JSON.stringify(data)
  1041. )
  1042. }
  1043. })
  1044. })
  1045. }
  1046.  
  1047.  
  1048. if (
  1049.  
  1050. localStorage.getItem(
  1051. 'doctor ' +
  1052. $('#nameOfDoc').text() +
  1053. ' teeth: ' +
  1054. patientClicked.firstName +
  1055. ' ' +
  1056. patientClicked.SubName
  1057. )
  1058. ) {
  1059. let Teeth = JSON.parse(
  1060. localStorage.getItem(
  1061. 'doctor ' +
  1062. $('#nameOfDoc').text() +
  1063. ' teeth: ' +
  1064. patientClicked.firstName +
  1065. ' ' +
  1066. patientClicked.SubName
  1067. )
  1068. )
  1069. if (
  1070. Teeth.patient ==
  1071. patientClicked.firstName + ' ' + patientClicked.SubName
  1072. ) {
  1073. for (let i = 0; i < Object.keys(Teeth.teeth).length; i++) {
  1074. // $("#allTreatments").append(`<div class="teethInfo">teethNumber` + Object.keys(Teeth.teeth)[i][0] + ` , treatment` + Object.values(Teeth.teeth)[0] + `, price1`+ Object.values(patientClicked.teethArage.teeth[i])[0][0]+`</div>`)
  1075. $('#allTreatments').append(
  1076. '<div class=`teethInfo`>teethNumber: ' +
  1077. Object.keys(Teeth.teeth)[i] +
  1078. ' , treatment: ' +
  1079. Object.values(Teeth.teeth)[i][1] +
  1080. ' price: ' +
  1081. Object.values(Teeth.teeth)[i][0] +
  1082. '</br></div>'
  1083. )
  1084. }
  1085. for (let i = 0; i < Object.keys(Teeth.teeth).length; i++) {
  1086. console.log(Object.values(Object.values(Teeth.teeth)[i])[0])
  1087. totalPrice += parseInt(Object.values(Teeth.teeth)[i][0])
  1088. }
  1089. }
  1090. } else {
  1091. for (
  1092. var SomeThing = 0;
  1093. SomeThing < Object.keys(patientClicked.teethArage.teeth).length;
  1094. SomeThing++
  1095. ) {
  1096. console.log(
  1097. Object.keys(patientClicked.teethArage.teeth)[SomeThing]
  1098. )
  1099. $('#allTreatments').append(
  1100. '<div class=`teethInfo`>teethNumber ' +
  1101. Object.keys(patientClicked.teethArage.teeth)[SomeThing] +
  1102. ' , treatment ' +
  1103. Object.values(patientClicked.teethArage.teeth)[
  1104. SomeThing
  1105. ][1] +
  1106. ' price: ' +
  1107. Object.values(patientClicked.teethArage.teeth)[
  1108. SomeThing
  1109. ][0] +
  1110. '</br></div>'
  1111. )
  1112. }
  1113. for (
  1114. let i = 0;
  1115. i < Object.keys(patientClicked.teethArage.teeth).length;
  1116. i++
  1117. ) {
  1118. console.log(
  1119. Object.values(
  1120. Object.values(patientClicked.teethArage.teeth)[i]
  1121. )[0]
  1122. )
  1123. totalPrice += parseInt(
  1124. Object.values(patientClicked.teethArage.teeth)[i][0]
  1125. )
  1126. }
  1127. }
  1128. $('#totalPriceOfTeeth').append(
  1129. "<div>The Price Is in totall: <span id='totaltreatmentprice'>" +
  1130. totalPrice +
  1131. '</span>'
  1132. )
  1133. if (
  1134. localStorage.getItem(
  1135. 'meetings ' +
  1136. patientClicked.firstName +
  1137. ' ' +
  1138. patientClicked.SubName
  1139. )
  1140. ) {
  1141. let meetings = localStorage.getItem(
  1142. 'meetings ' +
  1143. patientClicked.firstName +
  1144. ' ' +
  1145. patientClicked.SubName
  1146. )
  1147. $('#meetings').html(meetings)
  1148. } else {
  1149. for (let i = 0; i < patientClicked.meetings.length; i++) {
  1150. $('#meetingsUL').append(
  1151. '<li>' + patientClicked.meetings[i] + '</li>'
  1152. )
  1153. }
  1154. }
  1155. if (
  1156. localStorage.getItem(
  1157. 'medicine ' +
  1158. patientClicked.firstName +
  1159. ' ' +
  1160. patientClicked.SubName +
  1161. ' of ' +
  1162. nameOfPatient.nameOfDoc
  1163. )
  1164. ) {
  1165. let medicines = JSON.parse(
  1166. localStorage.getItem(
  1167. 'medicine ' +
  1168. patientClicked.firstName +
  1169. ' ' +
  1170. patientClicked.SubName +
  1171. ' of ' +
  1172. nameOfPatient.nameOfDoc
  1173. )
  1174. )
  1175. $('#patientMedicine').html('')
  1176. for (let i = 0; i < medicines.length; i++) {
  1177. $('#patientMedicine').append(medicines[i] + '<br>')
  1178. }
  1179. } else {
  1180. let medicines = patientClicked.medicines
  1181. $('#patientMedicine').html('')
  1182. for (let i = 0; i < medicines.length; i++) {
  1183. $('#patientMedicine').append(medicines[i] + '<br>')
  1184. }
  1185. }
  1186. let today = new Date()
  1187. let date =
  1188. today.getFullYear() +
  1189. '-' +
  1190. (today.getMonth() + 1) +
  1191. '-' +
  1192. today.getDate()
  1193. $('#paycheckDate').html(date)
  1194. $('#nameOfPatientPaycheck').html($('#nameOfPatientDetails').text())
  1195. $('#teethPricePaycheck').html($('#allTreatments').html())
  1196. $('#nameOfDocPaycheck').html($('#nameOfDoc').text())
  1197.  
  1198. if (
  1199. localStorage.getItem(
  1200. $('#nameOfDoc').text() +
  1201. ' of patient ' +
  1202. $('#nameOfPatientDetails').text() +
  1203. ' meetings'
  1204. )
  1205. ) {
  1206. let meetings = JSON.parse(
  1207. localStorage.getItem(
  1208. $('#nameOfDoc').text() +
  1209. ' of patient ' +
  1210. $('#nameOfPatientDetails').text() +
  1211.  
  1212. ' meetings'
  1213. )
  1214. )
  1215. $('#calenderMeeting').fullCalendar('addEventSource', meetings)
  1216. } else {
  1217. for (let i = 0; i < patientClicked.meetings.length; i++) {
  1218. $('#calenderMeeting').fullCalendar('addEventSource', [
  1219. patientClicked.meetings[i]
  1220. ])
  1221. }
  1222. }
  1223. $('.aMedicine').click(function(e) {
  1224. e.preventDefault()
  1225. })
  1226.  
  1227.  
  1228. break
  1229. }
  1230. }
  1231. })
  1232. }
  1233. })
  1234. })
  1235. $(".nameOfDocInput").val($("#nameOfDoc").text())
  1236. $('#mettings_all').click(function() {
  1237. $('#calendar4').fullCalendar('today');
  1238. $("#calendar4 .fc-agendaDay-button").click()
  1239. let toServer = {
  1240. docName: $('#nameOfDoc').text()
  1241. }
  1242. let toServer_Json = JSON.stringify(toServer)
  1243. $.ajax({
  1244. url: '/info_meeting',
  1245. type: 'POST',
  1246. dataType: 'json',
  1247. data: toServer_Json,
  1248. success: function(data) {
  1249. for (let j = 0; j < Object.values(data).length; j++) {
  1250. for (let i = 0; i < Object.values(data)[j].length; i++) {
  1251. Object.values(data)[j][i].title = Object.keys(data)[j]
  1252. $('#calendar4').fullCalendar('addEventSource', [
  1253. Object.values(data)[j][i]
  1254. ])
  1255. }
  1256. }
  1257. console.log(Object.values(data))
  1258. }
  1259. })
  1260. })
  1261.  
  1262. $('#addToFavMedicines').click(function(e) {
  1263. e.preventDefault()
  1264. $('#favMedicinesNew').show()
  1265. $('#backgroundFavMedicinesNew').show()
  1266. $('#closeFavMedicinesNew').click(function(e) {
  1267. e.preventDefault()
  1268. console.log('WORKING')
  1269. $('#favMedicinesNew').hide()
  1270. $('#backgroundFavMedicinesNew').hide()
  1271. })
  1272. })
  1273.  
  1274. let nameDoc = $('#nameOfDoc').text()
  1275.  
  1276. $('#backgroundFavMedicinesNew').click(function() {
  1277. $(this).hide()
  1278. })
  1279.  
  1280.  
  1281. $('#querterJaw1').html('')
  1282. $('#querterJaw2').html('')
  1283. $('#querterJaw3').html('')
  1284. $('#querterJaw4').html('')
  1285.  
  1286. let T = 10
  1287. let imageSRC
  1288.  
  1289. for (var i = 1; i < 5; i++) {
  1290. for (var t = 1; t < 9; t++) {
  1291. if (i === 1) {
  1292. T = 10 + t
  1293. imageSRC = "media/teethdown.png"
  1294. } else if (i === 2) {
  1295. T = 40 + t
  1296. imageSRC = "media/teeth.png"
  1297. } else if (i === 3) {
  1298. T = 20 + t
  1299. imageSRC = "media/teethdown.png"
  1300. } else if (i === 4) {
  1301. T = 30 + t
  1302. imageSRC = "media/teeth.png"
  1303. }
  1304. $('#querterJaw' + i).append(
  1305. `<div class="teeth">
  1306. <div class="pointerdown pointer">
  1307. <div class="containerPointer">
  1308. <input type="text" class="teethPriceSingle" placeholder="Price">
  1309. <select class="selectTreatment" name="">
  1310. <option value="">treatment</option>
  1311. <option value="shetel">shetel</option>
  1312. <option value="ikor">ikor</option>
  1313. <option value="whatever">whatever</option>
  1314. </select>
  1315. <button type="button" name="button" class="pointersub">submit</button>
  1316. </div>
  1317. <div class="arrowdown"></div>
  1318. </div>
  1319. <div class="teethNumber">` +
  1320. T
  1321. +
  1322. `</div>
  1323. <img class="imgTeeth" src="${imageSRC}" alt="">
  1324. </div>`
  1325. )
  1326. }
  1327. }
  1328.  
  1329. let jack = {}
  1330.  
  1331. $('.teethNumber').click(function(e) {
  1332. e.preventDefault()
  1333. $(this)
  1334. .parent()
  1335. .toggleClass('selectedTeeth')
  1336. $(this)
  1337. .parents()
  1338. .find('.pointer')
  1339. .toggle()
  1340. if (
  1341. $(this)
  1342. .parents()
  1343. .hasClass('selectedTeeth') === false
  1344. ) {
  1345. $(this)
  1346. .parents()
  1347. .find('.pointer')
  1348. .hide()
  1349. } else {
  1350. $(this)
  1351. .parents()
  1352. .siblings()
  1353. .find('.pointer')
  1354. .hide()
  1355. $(this)
  1356. .parents()
  1357. .parents()
  1358. .siblings()
  1359. .find('.pointer')
  1360. .hide()
  1361. }
  1362. })
  1363.  
  1364. $('#submitSpansPriceForm').submit(function(e) {
  1365. e.preventDefault()
  1366. let teethSelected = []
  1367. let count = 0
  1368. let data = {}
  1369. for (let i = 0; i < '.selectedTeeth'.find('.teethNumber').length; i++) {
  1370. teethSelected.push(
  1371. $('.selectedTeeth')
  1372. .find('.teethNumber')
  1373. .text()[i]
  1374. )
  1375. data[teethSelected[i]] = []
  1376. }
  1377. })
  1378.  
  1379. $('.imgTeeth').click(function(e) {
  1380. e.preventDefault()
  1381. $(this)
  1382. .parent()
  1383. .toggleClass('selectedTeeth')
  1384. $(this)
  1385. .parents()
  1386. .find('.pointer')
  1387. .toggle()
  1388. if (
  1389. $(this)
  1390. .parents()
  1391. .hasClass('selectedTeeth') === false
  1392. ) {
  1393. $(this)
  1394. .parents()
  1395. .find('.pointer')
  1396. .hide()
  1397. } else {
  1398. $(this)
  1399. .parents()
  1400. .siblings()
  1401. .find('.pointer')
  1402. .hide()
  1403. $(this)
  1404. .parents()
  1405. .parents()
  1406. .siblings()
  1407. .find('.pointer')
  1408. .hide()
  1409. }
  1410. })
  1411.  
  1412. $('.pointersub').click(function(e) {
  1413. e.preventDefault()
  1414. let numberTeeth = $(this)
  1415. .parent()
  1416. .parent()
  1417. .parent()
  1418. .find('.teethNumber')
  1419. .text()
  1420. let valuePrice = $(this)
  1421. .siblings('.teethPriceSingle')
  1422. .val()
  1423. let treatment = $(this)
  1424. .siblings('.selectTreatment')
  1425. .val()
  1426. let price = $('#teethPrice').val()
  1427. let docName = JSON.parse(localStorage.getItem('nameOfDoc')).nameOfDoc
  1428. // teethObject.teeth[parseInt(numberTeeth)].push(valuePrice)
  1429. // teethObject.teeth[parseInt(numberTeeth)].push(treatment)
  1430. if (isNaN(valuePrice)) {
  1431. alert('price in Numbers')
  1432. } else {
  1433. jack[parseInt(numberTeeth)] = [valuePrice, treatment]
  1434. $('#allTreatments').append(
  1435. 'Teeth number:<span class=`teethNumberAfter`> ' +
  1436. numberTeeth +
  1437. '</span> , The price is: <span class=`priceAfter`>' +
  1438. valuePrice +
  1439. '</span> treatment: <span class=`treatmentAfter`>' +
  1440. treatment +
  1441. '</span>'
  1442. )
  1443. $('#totaltreatmentprice').html(
  1444. parseInt($('#totaltreatmentprice').text()) + parseInt(valuePrice)
  1445. )
  1446. let teethObject = {
  1447. docName: docName,
  1448. patientName: $('#nameOfPatientDetails').text(),
  1449. teeth: jack,
  1450. price: $('#teethPrice').val()
  1451. }
  1452. console.log(jack)
  1453. let jsonObject = JSON.stringify(teethObject)
  1454. $.ajax({
  1455. url: '/patientsTeeth',
  1456. type: 'POST',
  1457. dataType: 'json',
  1458. data: jsonObject,
  1459. success: function(data) {
  1460. let PatientAndTeeth = {
  1461. patient: teethObject.patientName,
  1462. teeth: data
  1463. }
  1464. let jsonPatientTeeth = JSON.stringify(PatientAndTeeth.teeth)
  1465. localStorage.setItem(
  1466. 'doctor ' +
  1467. $('#nameOfDoc').text() +
  1468. ' teeth: ' +
  1469. teethObject.patientName,
  1470. JSON.stringify(PatientAndTeeth)
  1471. )
  1472. }
  1473. })
  1474. }
  1475. })
  1476.  
  1477. // Payment print section
  1478.  
  1479. function printDiv() {
  1480. var divToPrint = document.getElementById('paymentTab')
  1481. var newWin = window.open('', 'Print-Window')
  1482.  
  1483. newWin.document.open()
  1484.  
  1485. newWin.document.write(
  1486. '<html><body onload="window.print()">' +
  1487. divToPrint.innerHTML +
  1488. '</body></html>'
  1489. )
  1490.  
  1491. newWin.document.close()
  1492.  
  1493. setTimeout(function() {
  1494. newWin.close()
  1495. }, 10)
  1496. }
  1497.  
  1498. $('.form')
  1499. .find('input, textarea')
  1500. .on('keyup blur focus', function(e) {
  1501. var $this = $(this),
  1502. label = $this.prev('label')
  1503.  
  1504. if (e.type === 'keyup') {
  1505. if ($this.val() === '') {
  1506. label.removeClass('active highlight')
  1507. } else {
  1508. label.addClass('active highlight')
  1509. }
  1510. } else if (e.type === 'blur') {
  1511. if ($this.val() === '') {
  1512. label.removeClass('active highlight')
  1513. } else {
  1514. label.removeClass('highlight')
  1515. }
  1516. } else if (e.type === 'focus') {
  1517. if ($this.val() === '') {
  1518. label.removeClass('highlight')
  1519. } else if ($this.val() !== '') {
  1520. label.addClass('highlight')
  1521. }
  1522. }
  1523. })
  1524.  
  1525. $('.tab a').on('click', function(e) {
  1526. e.preventDefault()
  1527.  
  1528. $(this)
  1529. .parent()
  1530. .addClass('active')
  1531. $(this)
  1532. .parent()
  1533. .siblings()
  1534. .removeClass('active')
  1535.  
  1536. target = $(this).attr('href')
  1537.  
  1538. $('.tab-content > div')
  1539. .not(target)
  1540. .hide()
  1541.  
  1542. $(target).fadeIn(600)
  1543. })
  1544. //calendar
  1545. // let ll = {
  1546. // username: JSON.parse(localStorage.getItem("nameOfDoc")).nameOfDoc
  1547. // }
  1548. // let jsonObject = JSON.stringify(ll)
  1549. // $.ajax({
  1550. // url: "/meetingToday",
  1551. // type: "POST",
  1552. // dataType: "json",
  1553. // data: jsonObject,
  1554. // success: function(data) {
  1555. // if (data.length === 0) {
  1556. //
  1557. // } else {
  1558. // console.log();
  1559. //
  1560. // for (var i = 0; i < data.length; i++) {
  1561. // console.log(Object.values(data[i])[0][0].slice(0,3));
  1562. // console.log(Object.values(data[i])[0][0]);
  1563. $('.calendar1').fullCalendar({
  1564. header: {
  1565. left: 'prev,next today',
  1566. center: 'title',
  1567. right: 'month,agendaWeek,agendaDay,listMonth'
  1568. },
  1569. navLinks: true, // can click day/week names to navigate views
  1570. businessHours: true, // display business hours
  1571. editable: true,
  1572. eventClick: function(calEvent, jsEvent, view) {
  1573. console.log(calEvent);
  1574. let namePatient = calEvent.title.slice(calEvent.title.indexOf("(")+1, calEvent.title.indexOf(")"))
  1575. $("#homeb").click()
  1576. $("#char").click()
  1577. setTimeout(function() {
  1578. let nameOfPatient = {
  1579. nameOfClinic: $("#nameOfClinic").text(),
  1580. nameOfDoc: $('#nameOfDoc').text(),
  1581. nameOfPatient: $(this)
  1582. .find('.name')
  1583. .children()
  1584. .text()
  1585. }
  1586. console.log(nameOfPatient);
  1587. $('#patientDetails').css('display', 'flex')
  1588. $('#darkBackground').show()
  1589. $('#darkBackground').css('height', $(document).height() + 'px')
  1590. $('#closePatientdetails').click(function() {
  1591. $('#patientDetails').hide()
  1592. $('#darkBackground').hide()
  1593. $('#meetingsUL').html('')
  1594. })
  1595. let jsonData = JSON.stringify(nameOfPatient)
  1596. $.ajax({
  1597. url: '/getPatientClickedClinic',
  1598. dataType: 'json',
  1599. data: jsonData,
  1600. type: 'POST',
  1601. success: function(data) {
  1602. let patient = data
  1603. let totalPrice = 0
  1604. console.log(patient);
  1605. $('#nameOfPatientDetails').html(
  1606. patient.firstName + ' ' + patient.SubName
  1607. )
  1608. $('#firstName').html(patient.firstName)
  1609. $('#SubName').html(patient.SubName)
  1610. $('#phoneNumberPatient').html(patient.phoneNumber)
  1611. $('#fax').html(patient.fax)
  1612.  
  1613. $('#doctor').html(patient.doctor)
  1614. $('#homenumber').html(patient.homenumber)
  1615. $('#validity').html(patient.validity)
  1616. $('#insurance').html(patient.insurance)
  1617. $('#job').html(patient.job)
  1618. $('#caseNumber').html(patient.caseNumber)
  1619. $('#cameFrom').html(patient.cameFrom)
  1620. $('#genderPatient').html(patient.gender)
  1621. $('#addressPatient').html(patient.address)
  1622. $('#emailPatient').html(patient.email)
  1623. $('#statusPatient').html(patient.status)
  1624. $('#famDocPatient').html(patient.familyDoctor)
  1625. $('#emargancyNumberPatient').html(patient.emergencyNumber)
  1626. $('#birthDayPatient').html(patient.date)
  1627. $('#allTreatments').html('')
  1628. $('#totalPriceOfTeeth').html('')
  1629. $('.calendar1').fullCalendar('removeEventSources')
  1630. $('.calendar1').fullCalendar('today');
  1631.  
  1632. $("#moveToArchive").click(function(e) {
  1633. e.preventDefault()
  1634. console.log("button clicked");
  1635. $.ajax({
  1636. url: '/archiveClinic',
  1637. type: 'GET',
  1638. dataType: 'json',
  1639. success: function(data) {
  1640. console.log(data);
  1641. }
  1642. })
  1643. // location.reload()
  1644. })
  1645. setMeeting()
  1646.  
  1647.  
  1648. if (localStorage.getItem("doctor of patient ${patient.fullName} meetings")) {
  1649. $('#calenderMeeting').fullCalendar('addEventSource', [JSON.parse(localStorage.getItem("doctor of patient ${patient.fullName} meetings"))])
  1650. } else {
  1651. $('#calenderMeeting').fullCalendar('addEventSource', patient.meetings)
  1652. }
  1653.  
  1654. if (
  1655. localStorage.getItem(
  1656. 'doctor ' +
  1657. $('#nameOfDoc').text() +
  1658. ' teeth: ' + patient.fullName
  1659. )
  1660. ) {
  1661. let Teeth = JSON.parse(
  1662. localStorage.getItem(
  1663. 'doctor ' +
  1664. $('#nameOfDoc').text() +
  1665. ' teeth: ' +
  1666. patient.firstName +
  1667. ' ' +
  1668. patient.SubName
  1669. )
  1670. )
  1671. if (
  1672. Teeth.patient ==
  1673. patient.firstName + ' ' + patient.SubName
  1674. ) {
  1675. for (let i = 0; i < Object.keys(Teeth.teeth).length; i++) {
  1676. // $("#allTreatments").append(`<div class="teethInfo">teethNumber` + Object.keys(Teeth.teeth)[i][0] + ` , treatment` + Object.values(Teeth.teeth)[0] + `, price1`+ Object.values(patientClicked.teethArage.teeth[i])[0][0]+`</div>`)
  1677. $('#allTreatments').append(
  1678. '<div class=`teethInfo`>teethNumber: ' +
  1679. Object.keys(Teeth.teeth)[i] +
  1680. ' , treatment: ' +
  1681. Object.values(Teeth.teeth)[i][1] +
  1682. ' price: ' +
  1683. Object.values(Teeth.teeth)[i][0] +
  1684. '</br></div>'
  1685. )
  1686. }
  1687. for (let i = 0; i < Object.keys(Teeth.teeth).length; i++) {
  1688. console.log(Object.values(Object.values(Teeth.teeth)[i])[0])
  1689. totalPrice += parseInt(Object.values(Teeth.teeth)[i][0])
  1690. }
  1691. }
  1692. } else {
  1693. for (
  1694. var SomeThing = 0;
  1695. SomeThing < Object.keys(patient.teethArage.teeth).length;
  1696. SomeThing++
  1697. ) {
  1698. console.log(
  1699. Object.keys(patient.teethArage.teeth)[SomeThing]
  1700. )
  1701. $('#allTreatments').append(
  1702. '<div class=`teethInfo`>teethNumber ' +
  1703. Object.keys(patient.teethArage.teeth)[SomeThing] +
  1704. ' , treatment ' +
  1705. Object.values(patient.teethArage.teeth)[
  1706. SomeThing
  1707. ][1] +
  1708. ' price: ' +
  1709. Object.values(patient.teethArage.teeth)[
  1710. SomeThing
  1711. ][0] +
  1712. '</br></div>'
  1713. )
  1714. }
  1715. for (
  1716. let i = 0;
  1717. i < Object.keys(patient.teethArage.teeth).length;
  1718. i++
  1719. ) {
  1720. console.log(
  1721. Object.values(
  1722. Object.values(patient.teethArage.teeth)[i]
  1723. )[0]
  1724. )
  1725. totalPrice += parseInt(
  1726. Object.values(patient.teethArage.teeth)[i][0]
  1727. )
  1728. }
  1729. }
  1730. $("#info_box").val("")
  1731. $("#textareaPayment").val("")
  1732. $("#textareaTreatment").val("")
  1733. $("#textareaMedicines").val("")
  1734. if (localStorage.getItem("infoComments " + patient.fullName)) {
  1735. $("#info_box").val(localStorage.getItem("infoComments " + patient.fullName))
  1736. } else {
  1737. $("#info_box").val(patient.infoComments)
  1738. }
  1739. if (localStorage.getItem("prescriptionsComment " + patient.fullName)) {
  1740. $("#textareaMedicines").val(localStorage.getItem("prescriptionsComment " + patient.fullName))
  1741. } else {
  1742. $("#textareaMedicines").val(patient.prescriptionsComment)
  1743. }
  1744. if (localStorage.getItem("treatmentComment " + patient.fullName)) {
  1745. $("#textareaTreatment").val(localStorage.getItem("treatmentComment " + patient.fullName))
  1746. } else {
  1747. $("#textareaTreatment").val(patient.treatmentComments)
  1748. }
  1749. if (localStorage.getItem("textareaPayment " + patient.fullName)) {
  1750. $("#textareaPayment").val(localStorage.getItem("textareaPayment " + patient.fullName))
  1751. } else {
  1752. $("#textareaPayment").val(patient.prescriptionsComment)
  1753. }
  1754. $("#submitPaymentComments").click(function() {
  1755. let comment = $("#textareaPayment").val()
  1756. let data = {
  1757. comment: comment
  1758. }
  1759. let JSONData = JSON.stringify(data)
  1760. $.ajax({
  1761. url: '/commentPaymentClinic',
  1762. type: 'POST',
  1763. dataType: 'json',
  1764. data: JSONData,
  1765. success: function(data) {
  1766. console.log(data);
  1767. localStorage.setItem("textareaPayment " + patient.fullName, data.message)
  1768. }
  1769. })
  1770. })
  1771. $("#submitMedicinesComments").click(function() {
  1772. let comment = $("#textareaMedicines").val()
  1773. let data = {
  1774. comment: comment
  1775. }
  1776. let JSONData = JSON.stringify(data)
  1777. $.ajax({
  1778. url: '/prescriptionsCommentClinic',
  1779. type: 'POST',
  1780. dataType: 'json',
  1781. data: JSONData,
  1782. success: function(data) {
  1783. console.log(data);
  1784. localStorage.setItem("prescriptionsComment " + patient.fullName, data.message)
  1785. }
  1786. })
  1787. })
  1788. $("#submitTreatmentComments").click(function() {
  1789. let comment = $("#textareaTreatment").val()
  1790. let data = {
  1791. comment: comment
  1792. }
  1793. let JSONData = JSON.stringify(data)
  1794. $.ajax({
  1795. url: '/treatmentCommentClinic',
  1796. type: 'POST',
  1797. dataType: 'json',
  1798. data: JSONData,
  1799. success: function(data) {
  1800. console.log(data);
  1801. localStorage.setItem("treatmentComment " + patient.fullName, data.message)
  1802. }
  1803. })
  1804. })
  1805. $("#saveBtnTextareaInfoTab").click(function(e) {
  1806. e.preventDefault()
  1807. let comments = $("#info_box").val()
  1808. let data = {
  1809. infoComments: comments
  1810. }
  1811. let jsonData = JSON.stringify(data)
  1812. $.ajax({
  1813. url: '/infoCommentsClinic',
  1814. type: 'POST',
  1815. dataType: 'json',
  1816. data: jsonData,
  1817. success: function(data) {
  1818. console.log(data);
  1819. localStorage.setItem("infoComments " + patient.fullName, data.message)
  1820. }
  1821. })
  1822. })
  1823.  
  1824. $("#submitPayment").click(function() {
  1825. let comment = $("#textareaPayment").val()
  1826. let data = {
  1827. comment: comment
  1828. }
  1829. let JSONData = JSON.stringify(data)
  1830. $.ajax({
  1831. url: '/commentPaymentClinic',
  1832. type: 'POST',
  1833. dataType: 'json',
  1834. data: JSONData,
  1835. success: function(data) {
  1836. console.log(data);
  1837. localStorage.setItem("textareaPayment " + patient.fullName, data.message)
  1838. }
  1839. })
  1840. })
  1841. $(".newFormMeeting").click(function(e) {
  1842. let cloneForm = $(this).parent().clone()
  1843. $("#meetingsForm").append(cloneForm)
  1844. setMeeting()
  1845. })
  1846. }
  1847. })
  1848. console.log($("#patRow").find(namePatient));
  1849. // for (var i = 0; i < $(".aRow").length; i++) {
  1850. // if ($(".aRow").get([i]).find(".name") == namePatient) {
  1851. // $(".aRow").get([i]).click()
  1852. // break;
  1853. // }
  1854. // }
  1855. }, 3000)
  1856. console.log(jsEvent);
  1857. console.log(view);
  1858. },
  1859. events:[
  1860. // {
  1861. // title: 'Business Lunch',
  1862. // start: '2017-11-03T13:00:00',
  1863. // constraint: 'businessHours'
  1864. // },
  1865. // {
  1866. // title: 'Meeting',
  1867. // start: '2017-11-13T11:00:00',
  1868. // constraint: 'availableForMeeting', // defined below
  1869. // color: '#257e4a'
  1870. // },
  1871. // {
  1872. // title: 'Conference',
  1873. // start: '2017-11-18',
  1874. // end: '2017-11-20'
  1875. // },
  1876. // {
  1877. // title: 'Party',
  1878. // start: '2017-11-29T20:00:00'
  1879. // },
  1880. //
  1881. // // areas where "Meeting" must be dropped
  1882. // {
  1883. // id: 'availableForMeeting',
  1884. // start: '2017-11-11T10:00:00',
  1885. // end: '2017-11-11T16:00:00',
  1886. // rendering: 'background'
  1887. // },
  1888. // {
  1889. // id: 'availableForMeeting',
  1890. // start: '2017-11-13T10:00:00',
  1891. // end: '2017-11-13T16:00:00',
  1892. // rendering: 'background'
  1893. // },
  1894.  
  1895. // red areas where no events can be dropped
  1896. // {
  1897. // start: '2017-11-24',
  1898. // end: '2017-11-28',
  1899. // overlap: false,
  1900. // rendering: 'background',
  1901. // color: '#ff9f89'
  1902. // },
  1903. // {
  1904. // start: '2017-11-06',
  1905. // end: '2017-11-08',
  1906. // overlap: false,
  1907. // rendering: 'background',
  1908. // color: '#ff9f89'
  1909. // }
  1910. ]
  1911. });
  1912. // }
  1913. // }
  1914. // }
  1915. // })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement