\r\n {Translate('Check your E-mail box to confirm registration and activate your account.')}\r\n
\r\n >\r\n\r\n const validConfirmCodeHtml =\r\n <>\r\n За да научите повече за това какво представляват бисквитките и как да ги управлявате, прочетете внимателно настоящата Политика за Бисквитки.
\r\n\r\n Бисквитката представлява малък файл, съдържащ данни, който се съхранява в уеб браузъра на Вашето устройство при посещаване на конкретни уебсайтове. Бисквитките могат да съдържат, но могат и да не съдържат лични данни за посетителя.
\r\n\r\n За да работи правилно, всеки съвременен уебсайт използва бисквитки.
\r\n Те имат различни задачи, които най-общо улесняват и правят по-интерактивно Вашето ползване на уебсайтовете ни.Например, чрез бисквитките събираме информация във връзка с Вашето посещение и поведение на сайта, така че не трябва да ни я предоставяте отново, и отново. По този начин, можем да Ви разпознаем при следващо посещение на уебсайтовете ни и да Ви покажем.
\r\n Бисквитките ни помагат и да разберем как използвате нашите услуги, за да можем непрекъснато да ги подобряваме, чрез персонализиране на съдържанието и предложенията към Вас, на база Вашите предпочитания и интереси.
\r\n\r\n В зависимост от това колко време се съхраняват на вашето устройство, бисквитките се категоризират на „постоянни” и „временни” („сесийни“) бисквитки.
\r\n Когато посещавате уебсайтa, вие можете да установите наличието на различни видове бисквитки, които се генерират. Ние използваме и четирите описани типа бисквитки.
\r\n Използваме и някои бисквитки на трети страни като част от нашите услуги. Тези бисквитки се управляват от съответните трети страни и не се контролират от нас.
\r\n\r\n Вие можете да контролирате и/или да изтривате бисквитките, в зависимост от вашето желание.
\r\n Може да изтриете всички инсталирани на Вашия компютър бисквитки, както и да настроите повечето браузъри така, че да предотвратите разполагането им във Вашия компютър.
\r\n В случай, че направите това, може да е необходимо да правите промени в настройките на някои предпочитания всеки път, когато посещавате уебсайтовете ни, а някои от услугите и функциите на уебсайтовете ни е възможно да не работят.
\r\n Как да изтриете всички бисквитки от даден браузър (показана е информация за най-популярните браузъри):
\r\n Ние си запазваме правото да променяме настоящата Политиката за бисквитки и поради това препоръчваме да преглеждате периодично съдържанието и. Всички бъдещи промени в нашата Политика за бисквитките ще бъдат публикувани на тази страница, от който момент промените ще се считат за влезли в сила, освен ако не е упоменато друго.
\r\n Настоящата политика е актуална към дата 18.09.2019 г.
\r\n\r\n Моля, изпращайте вашите въпроси и коментари относно бисквитките или поверителността на адрес: gdpr@icb.bg
\r\n\r\n >\r\n\r\nconst contentEn =\r\n <>\r\n To learn more about what cookies are and how to manage them, read this Cookie Policy carefully.
\r\n\r\n A cookie is a small file containing data that is stored in the web browser of your device when you visit specific websites. Cookies may or may not contain personally identifiable information about the visitor.
\r\n\r\n To function properly, any modern website uses cookies.
\r\n They have different tasks that generally facilitate and make your use of our websites more interactive. For example, cookies collect information about your visit and behavior on the site, so you do not have to provide it to us again and again. That way, we can recognize you the next time we visit our websites and show you.
\r\n Cookies also help us understand how you use our services so that we can continually improve them by customizing content and suggestions to you based on your preferences and interests.
\r\n\r\n Depending on how long they are stored on your device, cookies are categorized as \"permanent\" and \"temporary\" (\"session\") cookies.
\r\n When you visit a website, you may find that different types of cookies are generated. We use all four types of cookies described.
\r\n We also use some third-party cookies as part of our services. These cookies are managed by the respective third parties and are not controlled by us.
\r\n\r\n You can control and / or delete cookies, depending on your preference.
\r\n You can delete all cookies installed on your computer, and set up most browsers to prevent them from being installed on your computer.
\r\n If you do, you may need to make changes to your preferences settings each time you visit our websites, and some of our services and features may not work.
\r\n How to delete all cookies from a browser (shows information for the most popular browsers):
\r\n We reserve the right to change this Cookie Policy and therefore we recommend that you periodically review its content. Any future changes to our Cookie Policy will be posted on this page, from which time the changes will be considered effective unless is mentioned otherwise.
\r\n This policy is current as of 18.09.2019.
\r\n\r\n {\r\n constructor(props: IProps) {\r\n super(props);\r\n }\r\n\r\n public render() {\r\n let resultHtml;\r\n\r\n switch (this.props.lang) {\r\n case 'bg':\r\n resultHtml = contentBg;\r\n break;\r\n default:\r\n resultHtml = contentEn;\r\n }\r\n\r\n return (\r\n \r\n
\r\n {Translate('Cookies Policy')}\r\n
\r\n <>\r\n {resultHtml}\r\n >\r\n \r\n )\r\n }\r\n\r\n}\r\n\r\nconst mapsStateToProps = state => {\r\n return {\r\n lang: state.common.lang\r\n };\r\n}\r\n\r\nexport default connect(mapsStateToProps)(CookiePolicyComponent);","import * as React from 'react';\r\nimport Translate from '../../common/functions/translate';\r\nimport { connect } from 'react-redux';\r\n\r\nconst contentBg =\r\n <>\r\n\r\n Въведение
\r\n С представяне на настоящите правила имаме за цел да Ви разясним каква информация събираме за Вас, защо и как го правим, какви са правата Ви съгласно Закона за защита на личните данни (ЗЗЛД) и Общия регламент за защита на личните данни (РЕГЛАМЕНТ (ЕС) 2016/679 НА ЕВРОПЕЙСКИЯ ПАРЛАМЕНТ И НА СЪВЕТА от 27 април 2016 година - GDPR).
\r\n\r\n Защо е необходимо Вашето съгласие?
\r\n Наш изключителен приоритет е да защитаваме личните Ви данни и да получим Вашето свободно, информирано и недвусмислено съгласие за обработка на личните Ви данни от нас.
\r\n Ако маркирате „Потвърди политика за защита на линчите данни” Вие се съгласявате, че предоставяте личните си данни доброволно, че сте се запознали с правата си по ЗЗЛД и РЕГЛАМЕНТ (ЕС) 2016/679 НА ЕВРОПЕЙСКИЯ ПАРЛАМЕНТ И НА СЪВЕТА от 27 април 2016 година-GDPR и давате своето съгласие личните Ви данни да бъдат събирани, обработвани и съхранявани.
\r\n\r\n Определения
\r\n „Лични данни“ означава всяка информация, свързана с идентифицирано физическо лице или физическо лице, което може да бъде идентифицирано („субект на данни“ или “потребител”); физическо лице, което може да бъде идентифицирано, е лице, което може да бъде идентифицирано, пряко или непряко, по-специално чрез идентификатор като име, идентификационен номер, данни за местонахождение, онлайн идентификатор или по един или повече признаци, специфични за физическата, физиологичната, генетичната, психическата и умствената, икономическата, културната или социалната идентичност на това физическо лице;
\r\n „Администратор“ означава орган, който сам или съвместно с други органи определя целите и средствата за обработването на лични данни; когато целите и средствата за това обработване се определят от правото на Европейския съюз или правото на Република България, администраторът или специалните критерии за неговото определяне могат да бъдат установени в правото на Европейския съюз или в българското законодателство. В настоящия случай администраторът е „Интерконсулт България” ООД (наричано по-долу за краткост „ICB”), дружество надлежно регистрирано и действащо съгласно законите на Република България с ЕИК 121026857, със седалище и адрес на управление: гр. София 1309, район р-н Красна поляна, ж.к. ИЛИНДЕН, УЛ. ИНДЖЕ ВОЙВОДА No 7
\r\n „Обработващ лични данни“ означава физическо или юридическо лице, публичен орган, агенция или друга структура, която обработва лични данни от името на администратора;
\r\n „Обработване“ означава всяка операция или съвкупност от операции, извършвана с лични данни или набор от лични данни чрез автоматични или други средства като събиране, записване, организиране, структуриране, съхранение, адаптиране или промяна, извличане, консултиране, употреба, разкриване чрез предаване, разпространяване или друга форма на осигуряване на достъп до данните, подреждане или комбиниране, ограничаване, изтриване или унищожаване;
\r\n „Надзорен орган“ означава независим публичен орган от държава членка на Европейския съюз, отговорен за наблюдението на прилагането на правилата за защита на личните данни. За Република България надзорен орган е Комисията за защита на личните данни.
\r\n\r\n Цел на политиката
\r\n Тази политика за поверителност има за цел да гарантира, че Администраторът:
\r\n \r\n - спазва законодателството в областта на защитата на данните, а именно Закона за защита на личните данни (ЗЗЛД) и Общия регламент за защита на личните данни и останалото приложимо законодателство, и следва добрите практики;
\r\n - защитава потребителите, служителите, клиентите и партньорите;
\r\n - гарантира прозрачност за начините, по които се съхраняват и обработват личните данни на субектите;
\r\n - осигурява защита от рисковете, свързани с нарушаване на данните;
\r\n
\r\n\r\n Как събираме информация за Вас?
\r\n Ние можем да събираме информация за Вас по няколко начина:
\r\n Попълвани и изпращани от Вас форми, свързани с използваните услуги
\r\n Чрез изпращането им, Вие съзнателно споделяте лични данни.
\r\n За всяка форма, съдържаща изпращане на лични данни, ще посочим целите на използване, срок на съхранението им, трети страни, с които евентуално ще ги споделим, начините да упражните правата си по Регламента.
\r\n Ще минимизираме обема данни във формата спрямо според обявените цели.
\r\n Например: когато създавате профил, Вие ни предоставяте лична информация, включително имената си и електронна поща.
\r\n Данни, събирани чрез наблюдения
\r\n Понякога събираме информация за Вас наблюдавайки Вашето поведение на сайтовете ни и в мобилните ни апликации.
\r\n За целта използваме стандартни за Internet подходи за проследяване на потребителското поведение, напр. използване на мрежово оборудване, за проследяване на IP адреса Ви, анализиране на информацията налична като част от комуникацията в изпозлваните от нас протоколи за запис и обмен на идентификатори на Вас и устройството Ви, напр. HTTP GET/POST заявките, използване функционалностите на JavaScript и други стандартни и широко разпространени в WEB програмни езици за извличане на данни и информация за контекста Ви браузър, операционна система, резолюция на екрана, език и др.
\r\n Данни, получени от трети страни
\r\n Понякога, след Ваше изрично съгласие дадено през инструментите партньора, можем да получим данни от трети страни, напр. данни от профила Ви в социални мрежи, като Facebook.
\r\n Възможно е тези данни да бъдат обединени с други лични данни за Вас, с които вече разполагаме.
\r\n Бисквитки
\r\n Сайтът използва бисквитки за съхранение на настройки и идентификатори, необходими за предоставяне на посочните в сайта услуги. Някои от тези бисквитки са технически необходими за нормалното функциониране на сайтовете.
\r\n Повече информация за политиката ни по отношение на бисквитките може да намерите тук.
\r\n\r\n Каква информация събираме и обработваме, когато ползвате нашите услуги?
\r\n Попълвани и изпращани от Вас форми
\r\n Събираме следните данни:
\r\n \r\n - Вашите имена;
\r\n - Адрес на електронна поща;
\r\n - Парола;
\r\n - Лични данни: дата на рождене, пол, кръвна група, височина, тегло, непозволени храни и напитки, алергии;
\r\n - Лекарства;
\r\n - Заболявания;
\r\n - Лекарски предписания;
\r\n - Здравно състояние;
\r\n - Семейство;
\r\n - Резултати от изследвания;
\r\n
\r\n Данни, събирани чрез наблюдения
\r\n За всички посетители ние и доставчиците на използваните от нас инструменти, обичайно събираме следните данни за Вас:
\r\n \r\n - Идентификатор на браузъра Ви;
\r\n - Идентификатор на мобилното Ви устройството;
\r\n - Поведение спрямо съдържанието на сайта/мобилната апликация – навигация, използвани интерфейсни елементи, време на престой;
\r\n - Вашите търсения;
\r\n
\r\n Данни, получени от трети страни
\r\n В зависимост от източника на данни, това включва:\r\n Основна информация за профила, като име, имейл адрес, дата на раждане;\r\n Подробности, които решите да споделите според конкретните настройки за социални медийни акаунти;\r\n Вашият контакти и начина Ви на свързаност с тях.
\r\n\r\n За какви цели обработваме информацията?
\r\n Информацията, която събираме и обработваме за Вас може да се използва за следните цели:
\r\n Нормално функциониране на сайтове ни
\r\n Тези данни са стриктно необходими за нормалната работа на сайтовете и мобилните ни апликации. Чрез тях можем да удостоверим самоличността Ви като логнат потребители, да Ви покажем по-добре съдържанието, да заредим сайта по-бързо, да защитаваме сайтовете и Вас от посегателства.
\r\n Такива данни например са данните от сесията Ви – информация дали сте логнат, кеширано съдържание и други.
\r\n Тук попадат и данните, свързани с идентифицирането Ви във връзка с регистрация за използване на наша услуга.
\r\n За запазване и достъп до информация
\r\n Тази цел е спомагателна за изпълнение на други цели – чрез използването на различни технически механизми
\r\n Включва съхранение и достъп до информация, запазена на Вашето устройство, напр. идентификатори на устройство, идентификатори на потребител, бисквитки и други технологии.
\r\n Тази цел е помощна – чрез използването на описаните в нея технически механизми, ние ще можем да изпълним някоя от другите описани цели.
\r\n\r\n Какви са правата Ви във връзка с личните данни?
\r\n Наш приоритет е както да Ви информираме за Вашите законови права, така и да гарантираме тяхното спазване. Вие имате следните права, които следва да се съблюдават при обработване на личните Ви данни:
\r\n \r\n - Право във всеки един момент да оттеглите съгласието си за обработка на личните Ви данни;
\r\n - Да поискате коригиране или допълване на данните Ви при констатирана неточност чрез писмено заявление, отправено до нас;
\r\n - Право на достъп до личните Ви данни;
\r\n - Право на ограничаване обработването на личните Ви данни;
\r\n - Право на възражение срещу обработването на личните Ви данни;
\r\n - Правото на преносимост на данните;
\r\n - Право да поискате изтриване на личните Ви данни, които се обработват незаконосъобразно или с отпаднало правно основание (оттеглено съгласие, изпълнена първоначална цел, за която са били събрани и др.);
\r\n - Право да поискате от Администратора на личните Ви данни да уведомите третите лица, на които Администраторът е предоставил Вашите данни, по отношение на коригиране, изтриване или ограничаване на обработването на личните данни.
\r\n - Имате право на жалба до Комисия за защита на личните данни.
\r\n
\r\n\r\n Кога можем да ползваме данните Ви, за да се свърже с Вас?
\r\n Можем да използваме предоставената от Вас информация, за да се свържем с Вас относно различни въпроси като: да Ви уведомим за промени в политиките и настоящите правила;
\r\n Никога няма да се свържем с Вас, за да поискаме паролата от Вашия акаунт.
\r\n\r\n Как мога да получа, актуализирам и управлявам моите лични данни?
\r\n Вие можете лесно да актуализирате и управлявате Вашата информация, като отидете на „Профил / Моята информация”.
\r\n Нашите уебсайтове използват „бисквитки”. Ако искате да научите повече за използването за „бисквитките” на нашите уебсайтове и това как да ги управлявате, прочетете нашата „Политика за Бисквитки”.
\r\n\r\n Заключение
\r\n Настоящата политика за поверителност е актуална към дата 18.09.2019 г.
\r\n ICB запазва правото си по всяко време да променя и/или допълва настоящата Политика. Промените влизат в сила веднага след публикуването им на уебсайта, освен ако в актуализираната версия на Политиката не е предвидено друго. Трябва периодично да посещавате тази страница за преглед на Политиката. Политиката може да бъде актуализирани по всяко време без специално уведомяване на потребителите на Сайта. ICB не носи отговорност, ако даден потребител на уебсайтовете не се е запознал с последния актуален вариант на настоящата Политиката.
\r\n\r\n Моля, изпращайте вашите въпроси и коментари относно бисквитките или поверителността на адрес: gdpr@icb.bg
\r\n\r\n >\r\n\r\nconst contentEn =\r\n <>\r\n Introduction
\r\n By presenting these rules, we aim to explain to you what information we collect for you, why and how we do it, what your rights are under the Personal Data Protection Act (LPPD) and the General Data Protection Regulation (REGULATION (EU) 2016/679 OF THE EUROPEAN PARLIAMENT AND OF THE COUNCIL of 27 April 2016 - GDPR).
\r\n\r\n Why do you need your consent?
\r\n It is our utmost priority to protect your personal data and to obtain your free, informed and unequivocal consent to the processing of your personal data by us.
\r\n By tagging \"Confirm Privacy Policy\" you agree that you are submitting your personal data voluntarily, that you have become aware of your rights under the LPP and REGULATION (EU) 2016/679 OF THE EUROPEAN PARLIAMENT AND OF THE COUNCIL of 27 April 2016 -GDPR and you consent to your personal data being collected, processed and stored.
\r\n\r\n Definitions
\r\n \"Personal data\" means any information relating to an identified or identifiable natural person (\"data subject\" or \"user\"); identifiable natural person is an identifiable person, directly or indirectly, in particular by an identifier such as a name, identification number, location data, online identifier, or by one or more physical-specific attributes, the physiological, genetic, mental and mental, economic, cultural or social identity of that individual;
\r\n \"Controller\" means a body which alone or jointly with other bodies determines the purposes and means of the processing of personal data; where the purposes and means of such processing are determined by European Union law or by the law of the Republic of Bulgaria, the administrator or the specific criteria for determining it may be laid down in European Union law or in Bulgarian law. In the present case, the Administrator is Interconsult Bulgaria OOD (hereinafter ICB), a company duly registered and operating under the laws of the Republic of Bulgaria with UIC 121026857, with registered office and registered office: Sofia 1309, district p -n Krasna Polyana, residential building ILINDEN, INJJEVOD STREET No 7
\r\n \"Processor\" means a natural or legal person, public authority, agency or other entity who processes personal data on behalf of the controller;
\r\n \"Processing\" means any operation or set of operations performed with personal data or a set of personal data by automatic or other means such as the collection, recording, organization, structuring, storage, adaptation or modification, extraction, consultation, use, disclosure by transmission, dissemination or other form of providing access to the data, arranging or combining, limiting, deleting or destroying it;
\r\n \"Supervisory authority\" means an independent public authority from a Member State of the European Union responsible for monitoring the application of the rules on protection of personal data. For the Republic of Bulgaria the supervisory authority is the Commission for Personal Data Protection.
\r\n\r\n Aim of the policy
\r\n This privacy policy is intended to ensure that the Administrator:
\r\n \r\n - complies with data protection legislation, namely the Personal Data Protection Act (LPPD) and the General Regulation on personal data protection and other applicable legislation, and follows good practices;
\r\n - protects consumers, employees, customers and partners;
\r\n - guarantees transparency about the ways in which the personal data of the subjects are stored and processed;
\r\n - provides protection against data breach risks;
\r\n
\r\n\r\n How do we collect information about you?
\r\n We can collect information about you in several ways:
\r\n Completed and submitted forms related to the services used
\r\n By sending them, you knowingly share personal information.
\r\n For each form containing personal data, we will indicate the purposes of use, the storage period, the third parties with whom we may share, the ways to exercise your rights under the Regulation.
\r\n We will minimize the amount of data in the form relative to the announced goals.
\r\n For example, when you create an account, you provide us with personal information, including your names and email.
\r\n Data collected through observations
\r\n We sometimes collect information about you by observing your behavior on our sites and in our mobile applications.
\r\n To do this, we use standard Internet approaches to track user behavior, e.g. using network equipment to track your IP address, analyze information available as part of communication in the protocols we use to record and exchange identifiers for you and your device, e.g. HTTP GET / POST requests, use of JavaScript functionality and other standard and widely used WEB programming languages to retrieve data and context information for your browser, operating system, screen resolution, language, and more.
\r\n Data received from third parties
\r\n Sometimes, following your explicit consent through partner tools, we may receive third-party data, e.g. data from your social networking account, such as Facebook.
\r\n This information may be combined with other personal information we already have available to you.
\r\n Cookies
\r\n The site uses cookies to store the settings and identifiers required to provide the services specified on the site. Some of these cookies are technically necessary for the sites to function properly.
\r\n More information about our cookie policy can be found here.
\r\n\r\n What information do we collect and process when you use our services?
\r\n Completed and submitted forms
\r\n We collect the following data:
\r\n \r\n - Your names;
\r\n - Email Address;
\r\n - Password;
\r\n - Personal data: date of birth, gender, blood type, height, weight, illicit foods and drinks, allergies;
\r\n - Medicines;
\r\n - Diseases;
\r\n - Medical prescriptions;
\r\n - Health;
\r\n - Family;
\r\n - Research results;
\r\n
\r\n Data collected through observations
\r\n For all visitors, we and the vendors of the tools we use, we typically collect the following information for you:
\r\n \r\n - Your browser ID;
\r\n - Your mobile device ID;
\r\n - Behavior of site content / mobile application - navigation, interface elements used, downtime;
\r\n - Your searches;
\r\n
\r\n Data received from third parties
\r\n Depending on the data source, this includes: Basic account information such as name, email address, date of birth; Details that you choose to share according to your specific social media account settings; Your contacts and how you connect with them.
\r\n\r\n For what purposes do we process information?
\r\n The information we collect and process for you can be used for the following purposes:
\r\n The normal functioning of our sites
\r\n This data is strictly necessary for the normal operation of our sites and our mobile applications. With them, we can authenticate you by logging in to users, show you better content, load your site faster, protect your sites and you from harm.
\r\n Such data, for example, are data from your session - whether you are logged in, cached, and more.
\r\n This also includes your registration related information to use our service.
\r\n To save and access information
\r\n This objective is ancillary to the fulfillment of other objectives - through the use of various technical mechanisms
\r\n Includes storing and accessing information stored on your device, e.g. device IDs, user IDs, cookies and other technologies.
\r\n This purpose is ancillary - by using the technical mechanisms described therein, we will be able to fulfill any of the other objectives described.
\r\n\r\n What are your rights regarding personal data?
\r\n It is our priority to inform you of your legal rights and to ensure that they are respected. You have the following rights that should be respected when processing your personal data:
\r\n \r\n - The right at any time to withdraw your consent to the processing of your personal data;
\r\n - Request corrections or additions to your information in the case of inaccuracy found in a written application sent to us;
\r\n - Right of access to your personal data;
\r\n - The right to restrict the processing of your personal data;
\r\n - Right to object to the processing of your personal data;
\r\n - The right to data portability;
\r\n - The right to request the deletion of your personal data that is being processed illegally or with a lapsed legal basis (consent withdrawn, original purpose for which it was collected, etc.);
\r\n - The right to ask the Data Controller to notify third parties to whom the Data Controller has provided your data regarding the correction, deletion or restriction of the processing of personal data.
\r\n - You have the right to complain to the Data Protection Commission.
\r\n
\r\n\r\n When can we use your information to contact you?
\r\n We may use the information you provide to contact you about various issues such as: letting you know about changes in policies and current policies;
\r\n We will never contact you to request a password from your account.
\r\n\r\n How can I receive, update and manage my personal information?
\r\n You can easily update and manage your information by going to Profile / My Information.
\r\n Our websites use cookies. If you would like to learn more about the use of cookies on our websites and how to manage them, read our Cookie Policy.
\r\n\r\n Conclusion
\r\n This privacy policy is current as of 09/18/2019.
\r\n ICB reserves the right at any time to amend and / or supplement this Policy. Changes will take effect as soon as they are posted on the Website, unless otherwise provided in the updated version of the Policy. You must periodically visit this page to review the Policy. The Policy may be updated at any time without specific notice to users of the Site. ICB is not responsible if a website user is not familiar with the latest up-to-date version of this Policy.
\r\n Please send your questions or comments about cookies or privacy to: gdpr@icb.bg
\r\n >\r\n\r\ninterface IProps {\r\n lang: string\r\n}\r\n\r\ninterface IState {\r\n}\r\n\r\nclass PersonalDataPolicyComponent extends React.Component {\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n }\r\n\r\n public render() {\r\n\r\n let resultHtml;\r\n\r\n switch (this.props.lang) {\r\n case 'bg':\r\n resultHtml = contentBg;\r\n break;\r\n default:\r\n resultHtml = contentEn;\r\n }\r\n\r\n return (\r\n \r\n
\r\n {Translate('Personal Data Policy')}\r\n
\r\n <>\r\n {resultHtml}\r\n >\r\n \r\n )\r\n }\r\n\r\n}\r\n\r\nconst mapsStateToProps = state => {\r\n return {\r\n lang: state.common.lang\r\n };\r\n}\r\n\r\nexport default connect(mapsStateToProps)(PersonalDataPolicyComponent);","import axios from 'axios';\r\nimport * as Constants from '../common/constants';\r\nimport * as HelperFunctions from '../common/functions/helperFunctions';\r\nimport { UserModel } from '../models/user/userModel';\r\nimport { UserChangePasswordModel } from '../models/user/userChangePasswordModel';\r\nimport { UserDiseaseModel } from '../models/user/userDiseaseModel';\r\nimport { UserMedicineModel } from '../models/user/userMedicineModel';\r\nimport { UserPrescriptionModel } from '../models/user/userPrescriptionModel';\r\nimport { UserMedicineToUserDiseaseModel } from '../models/user/userMedicineToUserDiseaseModel';\r\nimport AuthService from './authService';\r\nimport { UserForGridModel } from '../models/user/userForGridModel';\r\nimport { UserMedicineHistoryModel } from '../models/user/userMedicineHistoryModel';\r\nimport { UserNotificationModel } from '../models/user/userNotificationModel';\r\nimport { UserDiseaseHistoryModel } from '../models/user/userDiseaseHistoryModel';\r\nimport { UserMedicineWithHistoryWrapper } from '../models/user/userMedicineWithHistoryWrapper';\r\nimport { UserDiseaseWithHistoryModel } from '../models/user/userDiseaseWithHistoryModel';\r\nimport { UserMedicineSettingsModel } from '../models/user/userMedicineSettingsModel';\r\nimport { UserDiseaseSettingsModel } from '../models/user/userDiseaseSettingsModel';\r\nclass UserService {\r\n\r\n lang: string = '';\r\n authService = new AuthService();\r\n\r\n constructor(lang?) {\r\n this.lang == lang;\r\n axios.defaults.headers = {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache',\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n }\r\n }\r\n\r\n getUser() {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/getById`,\r\n method: 'get'\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n updateUser(user: UserModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/update`,\r\n method: 'put',\r\n data: JSON.stringify(user)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n deleteAccountPermanently() {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/deleteAccountPermanently/`,\r\n method: 'delete'\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getAccountInfo(lang: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/getAccountInfo/`,\r\n method: 'get',\r\n headers: {\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n changePassword(user: UserChangePasswordModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/changePassword/`,\r\n method: 'put',\r\n data: JSON.stringify(user)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n //User diseases\r\n getAllUserDiseases() {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/userDiseases/`,\r\n method: 'get'\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getAllUserDiseasesWithHistoryCount(userId: number, from: number, numberOfRows: number, lang: string, settings: UserDiseaseSettingsModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/userDiseasesWithHistoryCount/${userId}/${from}/${numberOfRows}`,\r\n method: 'post',\r\n headers: {\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n },\r\n data: JSON.stringify(settings)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getUserDisease(userId: number, diseaseId: number, lang: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/userDisease/${userId}/${diseaseId}`,\r\n method: 'get',\r\n headers: {\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n addUserDisease(userDisease: UserDiseaseWithHistoryModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/addUserDisease/`,\r\n method: 'post',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userDisease)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n updateUserDisease(userDisease: UserDiseaseModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/updateUserDisease/`,\r\n method: 'put',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userDisease)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n deleteUserDisease(userId: number, diseaseId: number, historyId: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/deleteUserDisease/${userId}/${diseaseId}/${historyId}`,\r\n method: 'delete'\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n isDiseaseInserted(userId: number, diseaseId: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/isDiseaseInserted/${userId}/${diseaseId}`,\r\n method: 'get'\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n addDiseaseHistory(userId: number, diseaseId: number, userDiseaseHistoryModel: UserDiseaseHistoryModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/addDiseaseHistory/${userId}/${diseaseId}`,\r\n method: 'post',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userDiseaseHistoryModel)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n updateDiseaseHistory(userDiseaseHistoryModel: UserDiseaseHistoryModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/updateDiseaseHistory/`,\r\n method: 'put',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userDiseaseHistoryModel)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n deleteDiseaseHistory(userDiseaseHistoryId) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/deleteDiseaseHistory/${userDiseaseHistoryId}`,\r\n method: 'delete'\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n\r\n //User medicines\r\n getAllUserMedicines() {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/userMedicines/`,\r\n method: 'get'\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getUserMedicine(userId: number, medicineId: number, lang: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/userMedicine/${userId}/${medicineId}`,\r\n method: 'get',\r\n headers: {\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getAllUserMedicinesWithHistory(userId: number, from: number, numberOfRows: number, lang: string, medSettings: UserMedicineSettingsModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/userMedicinesWithHistory/${userId}/${from}/${numberOfRows}`,\r\n method: 'post',\r\n headers: {\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n },\r\n data: JSON.stringify(medSettings)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n addUserMedicine(userMedicine: UserMedicineWithHistoryWrapper) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/addUserMedicine/`,\r\n method: 'post',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userMedicine)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n updateUserMedicine(userMedicine: UserMedicineModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/updateUserMedicine/`,\r\n method: 'put',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userMedicine)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n deleteUserMedicine(userId: number, medicineId: number, medHistoryId: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/deleteUserMedicine/${userId}/${medicineId}/${medHistoryId}`,\r\n method: 'delete'\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n addMedicineHistory(userId: number, medicineId: number, userMedicineHistoryModel: UserMedicineHistoryModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/addUserMedicineHistory/${userId}/${medicineId}`,\r\n method: 'post',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userMedicineHistoryModel)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n updateMedicineHistory(userMedicineHistoryModel: UserMedicineHistoryModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/updateMedicineHistory`,\r\n method: 'put',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userMedicineHistoryModel)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n deleteMedicineHistory(userMedicineHistoryId) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/deleteMedicineHistory/${userMedicineHistoryId}`,\r\n method: 'delete',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n isMedicineInserted(userId: number, medicineId: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/isMedicineInserted/${userId}/${medicineId}`,\r\n method: 'get',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n // User Family\r\n getUserFamilyDropdownList() {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/myFamily/getDropdownList/`,\r\n method: 'get',\r\n headers: {\r\n Authorization: `Bearer ${this.authService.getToken()}`\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getMyFamily() {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/myFamily/getAll`,\r\n method: 'get'\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getUserFromMyFamily(childUserId: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/myFamily/get/${childUserId}`,\r\n method: 'get'\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n deleteUserFromFamily(childUserId: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/myFamily/delete/${childUserId}`,\r\n method: 'delete'\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n deleteCaretaker(childUserId: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/myFamily/deleteCaretaker/${childUserId}`,\r\n method: 'delete'\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n addMemberInMyFamily(user: UserForGridModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/myFamily/create`,\r\n method: 'post',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(user)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n addCaretaker(user: UserForGridModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/myFamily/addCaretaker`,\r\n method: 'post',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(user)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n updateMyMemberFromFamily(user: UserForGridModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/myFamily/update`,\r\n method: 'put',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(user)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n\r\n //user prescriptions\r\n getAllUserPrescriptions(from: number, numberOfRows: number, lang: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/userPrescriptions/${from}/${numberOfRows}/`,\r\n method: 'get',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache',\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n },\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getUserPrescription(userPrescriptionId: number, lang: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/userPrescription/${userPrescriptionId}`,\r\n method: 'get',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache',\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n },\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getUserPrescriptionFromLink(userPrescriptionId: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/prescription/${userPrescriptionId}`,\r\n method: 'get',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n addUserPrescription(userPrescription: UserPrescriptionModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/addUserPrescription/`,\r\n method: 'post',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userPrescription)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n updateUserPrescription(userPrescription: UserPrescriptionModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/updateUserPrescription/`,\r\n method: 'put',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userPrescription)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n deleteUserPrescription(userPrescriptionId: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/deleteUserPrescription/${userPrescriptionId}`,\r\n method: 'delete',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getPrescriptionMedicines(userPrescriptionId: number, lang: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/getPrescriptionMedicines/${userPrescriptionId}`,\r\n method: 'get',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache',\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n addPrescriptionMedicine(userPrescriptionId: number, userMedicine: UserMedicineHistoryModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/addPrescriptionMedicine/${userPrescriptionId}`,\r\n method: 'post',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userMedicine)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n updatePrescriptionMedicine(userPrescriptionId: number, userMedicine: UserMedicineHistoryModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/updatePrescriptionMedicine/${userPrescriptionId}`,\r\n method: 'put',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userMedicine)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n deletePrescriptionMedicine(userPrescriptionId: number, userMedicineHistoryId: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/deletePrescriptionMedicine/${userPrescriptionId}/${userMedicineHistoryId}`,\r\n method: 'delete',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getHistoryNotifications(userMedicineHistoryId: number, lang: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/getMedicineHistoryNotifications/${userMedicineHistoryId}`,\r\n method: 'get',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache',\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n },\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getMedicineNotifications(userMedicineId: number, lang: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/getMedicineNotifications/${userMedicineId}`,\r\n method: 'get',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache',\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n },\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n addNotification(userNotification: UserNotificationModel, lang: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/addNotification/`,\r\n method: 'post',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache',\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n },\r\n data: JSON.stringify(userNotification)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n updateNotification(userNotificationId: number, isActive: boolean) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/updateNotification/${userNotificationId}/${isActive}`,\r\n method: 'put',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n deleteNotification(userNotificationId: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/deleteNotification/${userNotificationId}`,\r\n method: 'delete',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getPrescriptionDiseases(userPrescriptionId: number, lang: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/getPrescriptionDiseases/${userPrescriptionId}`,\r\n method: 'get',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache',\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n addPrescriptionDisease(userPrescriptionId: number, userDisease: UserDiseaseHistoryModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/addPrescriptionDisease/${userPrescriptionId}`,\r\n method: 'post',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userDisease)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n updatePrescriptionDisease(userPrescriptionId: number, userDisease: UserDiseaseHistoryModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/updatePrescriptionDisease/${userPrescriptionId}`,\r\n method: 'put',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(userDisease)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n deletePrescriptionDisease(userPrescriptionId: number, userDiseaseId: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/deletePrescriptionDisease/${userPrescriptionId}/${userDiseaseId}`,\r\n method: 'delete',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n // Push subscriptions\r\n createPushSubscription(subscription) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/createSubscription/`,\r\n method: 'post',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(subscription)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n discardPushSubscription(subscription: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/discardSubscription/${subscription}`,\r\n method: 'delete',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getAllUserNotifications(lang: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/getUserNotifications/`,\r\n method: 'get',\r\n headers: {\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getNotSeenNotifications(lang: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/getNotSeenNotifications/`,\r\n method: 'get',\r\n headers: {\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n markAllAsSeen() {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/markAllAsSeen/`,\r\n method: 'get',\r\n headers: {\r\n Authorization: `Bearer ${this.authService.getToken()}`\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getNotificationScheduler(schedulerId: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/getNotificationScheduler/${schedulerId}/`,\r\n method: 'get',\r\n headers: {\r\n Authorization: `Bearer ${this.authService.getToken()}`\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n setTakenNotification(schedulerId: number, acceptanceType: number, acceptanceDate: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/setTakenNotification/${schedulerId}/${acceptanceType}/`,\r\n method: 'post',\r\n headers: {\r\n Authorization: `Bearer ${this.authService.getToken()}`\r\n },\r\n data: JSON.stringify(acceptanceDate)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n setSnoozedNotification(schedulerId: number, snoozeMinutes: number, snoozeDate: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/setSnoozedNotification/${schedulerId}/${snoozeMinutes}/`,\r\n method: 'post',\r\n headers: {\r\n Authorization: `Bearer ${this.authService.getToken()}`\r\n },\r\n data: JSON.stringify(snoozeDate)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getAllNotifications(first: number, rows: number, lang: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/getAllNotifications/${first}/${rows}`,\r\n method: 'get',\r\n headers: {\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n \"langId\": HelperFunctions.getLangId(lang)\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getAllCaretakers() {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/getAllCaretakers/`,\r\n method: 'get',\r\n headers: {\r\n Authorization: `Bearer ${this.authService.getToken()}`\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n getFilteredUsers(from: number, numberOfRows: number, email: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/getFilteredUsers/${from}/${numberOfRows}/${email}`,\r\n method: 'get',\r\n headers: {\r\n Authorization: `Bearer ${this.authService.getToken()}`\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n validateCaretaker(confirmCode: string) {\r\n return axios({\r\n url: `${Constants.apiUrl}/user/validateCaretaker/`,\r\n method: 'post',\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n Authorization: `Bearer ${this.authService.getToken()}`\r\n },\r\n data: JSON.stringify(confirmCode)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n}\r\n\r\n\r\nexport default UserService;","import * as React from \"react\";\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport Translate from '../../../common/functions/translate';\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport { UserModel } from '../../../models/user/userModel';\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport UserService from '../../../services/userService';\r\nimport AuthService from '../../../services/authService';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport { Checkbox } from 'primereact/checkbox';\r\nimport { PushNotificationSubscription } from \"../../../models/pushNotificationSubscription\";\r\nimport TextField from '@material-ui/core/TextField';\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes } from '@fortawesome/free-solid-svg-icons';\r\nimport * as Constants from '../../../common/constants';\r\n\r\ninterface IProps {\r\n history: any,\r\n onCancelClick: any;\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n user: UserModel;\r\n}\r\n\r\nclass UserAccountTab extends React.Component {\r\n\r\n userService = new UserService();\r\n authService = new AuthService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n user: new UserModel()\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n this.getUserData();\r\n }\r\n\r\n getUserData() {\r\n if (this.authService.isAuthenticated()) {\r\n\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n let id = this.authService.getUserId();\r\n\r\n this.userService.getUser().then(\r\n (data: any) => {\r\n if (data) {\r\n this.setState({\r\n isLoading: false,\r\n user: data\r\n });\r\n }\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n }\r\n\r\n handleChange = (key, value) => {\r\n const user: UserModel = { ...this.state.user };\r\n user[key] = value;\r\n this.setState({ user: { ...user } });\r\n };\r\n\r\n handleSaveButton = event => {\r\n event.preventDefault();\r\n\r\n if (!this.isValidAddEditForm()) return;\r\n\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n const user = this.state.user;\r\n\r\n this.userService.updateUser(user).then(\r\n (data: any) => {\r\n if (data) {\r\n this.setState({\r\n isLoading: false\r\n });\r\n this.growl.show({ severity: 'success', summary: Translate('You have successfully saved your data.') });\r\n }\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n\r\n }\r\n\r\n isValidAddEditForm() {\r\n let message = '';\r\n\r\n const { user } = this.state;\r\n\r\n if (!user.email || user.email.trim() == '') {\r\n message += Translate('Please enter Email');\r\n } else {\r\n if (!HelperFunctions.validateEmail(this.state.user.email)) {\r\n message += Translate('Please enter valid Email');\r\n }\r\n }\r\n\r\n if (!user.name || user.name.trim() == '') {\r\n message += Translate('Please enter Name');\r\n }\r\n\r\n message ? this.growl.show({ severity: 'error', summary: message }) : null;\r\n\r\n return message == '';\r\n }\r\n\r\n public render() {\r\n const { isLoading, user } = this.state;\r\n\r\n return (\r\n \r\n {isLoading ?
: null}\r\n
this.growl = el} />\r\n\r\n \r\n
\r\n\r\n
\r\n
\r\n this.handleChange('email', e.target['value'])}\r\n />\r\n
\r\n
\r\n this.handleChange('name', e.target['value'])}\r\n />\r\n
\r\n
\r\n
\r\n \r\n \r\n
\r\n
\r\n
\r\n \r\n )\r\n }\r\n}\r\n\r\nexport default UserAccountTab;","export class UserPersonalDataModel {\r\n public userPersonalDataId: number;\r\n public userId: number;\r\n public birthDate?: string;\r\n public weight: number;\r\n public height: number;\r\n public genderTypeId?: number;\r\n public bloodTypeId?: number;\r\n public pregnancyTypeId?: number;\r\n public professionTypeId?: number;\r\n public notAllowedFoods: string;\r\n public allergies: string;\r\n}","import axios from 'axios';\r\nimport * as Constants from '../common/constants';\r\nimport * as HelperFunctions from '../common/functions/helperFunctions';\r\nimport { UserPersonalDataModel } from '../models/user/userPersonalDataModel';\r\nimport AuthService from './authService';\r\n\r\nclass UserPersonalDataService {\r\n\r\n authService = new AuthService();\r\n\r\n constructor() {\r\n //axios.defaults.baseURL = `${Constants.apiUrl}`;\r\n axios.defaults.headers = {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n }\r\n }\r\n\r\n getUserPersonalData(id: number) {\r\n return axios({\r\n url: `${Constants.apiUrl}/userPersonalData/get/${id}`,\r\n method: 'get',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n }\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n updateUserPersonalData(user: UserPersonalDataModel) {\r\n return axios({\r\n url: `${Constants.apiUrl}/userPersonalData/update/`,\r\n method: 'put',\r\n headers: {\r\n \"Content-Type\": \"application/json; charset=utf-8\",\r\n Authorization: `Bearer ${this.authService.getToken()}`,\r\n Pragma: 'no-cache'\r\n },\r\n data: JSON.stringify(user)\r\n })\r\n .then(res => res.data.data)\r\n .catch(error =>\r\n Promise.reject(HelperFunctions.getErrorMessage(error))\r\n )\r\n }\r\n\r\n\r\n}\r\n\r\nexport default UserPersonalDataService;","import * as React from \"react\";\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport Translate from '../../../common/functions/translate';\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport { UserPersonalDataModel } from '../../../models/user/userPersonalDataModel';\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport UserPersonalDataService from '../../../services/userPersonalDataService';\r\nimport AuthService from '../../../services/authService';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport { ProfessionType, PregnancyType, BloodType, GenderType } from \"../../../common/enums\";\r\nimport { DropdownModel } from \"../../../models/dropdownModel\";\r\nimport { enumToDropdownArray } from '../../../common/functions/helperFunctions';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport Button from '@material-ui/core/Button';\r\nimport { MuiThemeProvider, createMuiTheme } from '@material-ui/core';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes, faTimesCircle } from '@fortawesome/free-solid-svg-icons';\r\nimport { DatePicker } from '@material-ui/pickers';\r\nimport { Checkbox } from '@material-ui/core';\r\nimport * as Constants from '../../../common/constants';\r\nimport Select from '@material-ui/core/Select';\r\nimport InputLabel from '@material-ui/core/InputLabel';\r\nimport MenuItem from '@material-ui/core/MenuItem';\r\nimport FormControl from '@material-ui/core/FormControl';\r\nimport { id } from \"date-fns/esm/locale\";\r\n\r\ninterface IProps {\r\n history: any;\r\n userId?: number;\r\n onCancelClick: any;\r\n onSave?: any;\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n userPersonalData: UserPersonalDataModel;\r\n professionTypeDropdown: Array;\r\n pregnancyTypeDropdown: Array;\r\n bloodTypeDropdown: Array;\r\n genderTypeDropdown: Array;\r\n //isBirtdateDisabled: boolean;\r\n}\r\n\r\nclass UserPersonalDataTab extends React.Component {\r\n\r\n userPersonalDataService = new UserPersonalDataService();\r\n authService = new AuthService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n userPersonalData: new UserPersonalDataModel(),\r\n professionTypeDropdown: new Array(0),\r\n pregnancyTypeDropdown: new Array(0),\r\n bloodTypeDropdown: new Array(0),\r\n genderTypeDropdown: new Array(0),\r\n //isBirtdateDisabled: true\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n let userId = this.props.userId ? this.props.userId : this.authService.getUserId();\r\n\r\n const professionTypeDropdown: Array = [{ label: Translate('Select'), value: 0 }];\r\n const pregnancyTypeDropdown: Array = [{ label: Translate('Select'), value: 0 }];\r\n const bloodTypeDropdown: Array = [{ label: Translate('Select'), value: 0 }];\r\n const genderTypeDropdown: Array = [{ label: Translate('Select'), value: 0 }];\r\n\r\n if (this.authService.isAuthenticated()) {\r\n\r\n this.setState({\r\n isLoading: true,\r\n professionTypeDropdown: professionTypeDropdown.concat(enumToDropdownArray(ProfessionType, true)),\r\n pregnancyTypeDropdown: pregnancyTypeDropdown.concat(enumToDropdownArray(PregnancyType, true)),\r\n bloodTypeDropdown: bloodTypeDropdown.concat(enumToDropdownArray(BloodType, true)),\r\n genderTypeDropdown: genderTypeDropdown.concat(enumToDropdownArray(GenderType, true))\r\n });\r\n\r\n this.userPersonalDataService.getUserPersonalData(userId).then(\r\n (data: UserPersonalDataModel) => {\r\n if (data) {\r\n this.setState({\r\n isLoading: false,\r\n userPersonalData: data,\r\n //isBirtdateDisabled: data.birthDate == undefined\r\n });\r\n }\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n }\r\n\r\n handleChange = (key, value) => {\r\n const userPersonalData: UserPersonalDataModel = { ...this.state.userPersonalData };\r\n if (key == \"genderTypeId\" && value == GenderType.Male) {\r\n userPersonalData.pregnancyTypeId = undefined;\r\n }\r\n userPersonalData[key] = value;\r\n this.setState({ userPersonalData: { ...userPersonalData } });\r\n };\r\n\r\n // handleBirtdateCheckbox = () => {\r\n // this.setState({\r\n // isBirtdateDisabled: !this.state.isBirtdateDisabled\r\n // });\r\n // if (this.state.isBirtdateDisabled) {\r\n // this.handleChange('birthDate', this.state.userPersonalData.birthDate ? this.state.userPersonalData.birthDate : new Date().toISOString());\r\n // }\r\n // }\r\n\r\n handleSaveButton = event => {\r\n event.preventDefault();\r\n\r\n //if (!this.isValidAddEditForm()) return;\r\n\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n const { userPersonalData } = this.state;\r\n\r\n // if (userPersonalData && userPersonalData.birthDate) {\r\n // userPersonalData.birthDate = !isBirtdateDisabled ? HelperFunctions.fomatDateAsString(new Date(userPersonalData.birthDate)) : undefined\r\n // }\r\n\r\n this.userPersonalDataService.updateUserPersonalData(userPersonalData).then(\r\n (data: any) => {\r\n if (data) {\r\n this.setState({\r\n isLoading: false\r\n });\r\n this.growl.show({ severity: 'success', summary: Translate('You have successfully saved your data.') });\r\n this.props.onSave();\r\n }\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n\r\n }\r\n\r\n isValidAddEditForm() {\r\n let message = '';\r\n\r\n const { userPersonalData } = this.state;\r\n\r\n // if (!user.email || user.email.trim() == '') {\r\n // message += Translate('Please enter Email') + '.
';\r\n // } else {\r\n // if (!HelperFunctions.validateEmail(this.state.user.email)) {\r\n // message += Translate('Please enter valid Email') + '.
';\r\n // }\r\n // }\r\n\r\n message ? this.growl.show({ severity: 'error', summary: message }) : null;\r\n\r\n return message == '';\r\n }\r\n\r\n clearDate = (e) => {\r\n if (e) {\r\n e.preventDefault();\r\n }\r\n let userPersonalData = { ...this.state.userPersonalData }\r\n userPersonalData.birthDate = undefined;\r\n this.setState({ userPersonalData: userPersonalData });\r\n }\r\n\r\n public render() {\r\n const { isLoading, userPersonalData,\r\n genderTypeDropdown, professionTypeDropdown, pregnancyTypeDropdown, bloodTypeDropdown } = this.state;\r\n\r\n return (\r\n \r\n {isLoading ?
: null}\r\n
this.growl = el} />\r\n\r\n \r\n
\r\n
\r\n
{Translate('Birthdate')}\r\n
\r\n
this.handleChange('birthDate', e)}\r\n placeholder={Translate('Enter birht date')}\r\n inputProps={{\r\n id: 'birth-label'\r\n }}\r\n />\r\n \r\n \r\n
\r\n\r\n
\r\n \r\n {Translate('Gender')}\r\n \r\n \r\n
\r\n\r\n
\r\n \r\n {Translate('Blood Type')}\r\n \r\n \r\n
\r\n\r\n
\r\n this.handleChange('height', e.target.value)}\r\n />\r\n
\r\n\r\n
\r\n this.handleChange('weight', e.target.value)}\r\n />\r\n
\r\n\r\n\r\n
\r\n \r\n {Translate('Profession')}\r\n \r\n \r\n
\r\n {userPersonalData.genderTypeId && userPersonalData.genderTypeId == GenderType.Female ?\r\n
\r\n \r\n {Translate('Pregnancy&Breastfeeding')}\r\n \r\n \r\n
: null}\r\n\r\n
\r\n this.handleChange('notAllowedFoods', e.target.value)}\r\n />\r\n
\r\n\r\n
\r\n this.handleChange('allergies', e.target.value)}\r\n />\r\n
\r\n\r\n
\r\n
\r\n \r\n \r\n
\r\n
\r\n \r\n )\r\n }\r\n}\r\n\r\nexport default UserPersonalDataTab;","import * as React from \"react\";\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport Translate from '../../../common/functions/translate';\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport { InputText } from 'primereact/inputtext';\r\nimport { Password } from 'primereact/password';\r\nimport { UserChangePasswordModel } from '../../../models/user/userChangePasswordModel';\r\nimport { Link } from \"react-router-dom\";\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport UserService from '../../../services/userService';\r\nimport AuthService from '../../../services/authService';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes } from '@fortawesome/free-solid-svg-icons';\r\n\r\ninterface IProps {\r\n history: any,\r\n onCancelClick: any;\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n user: UserChangePasswordModel;\r\n userId: number;\r\n}\r\n\r\nclass UserChangePasswordTab extends React.Component {\r\n\r\n userService = new UserService();\r\n authService = new AuthService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n let profile = this.authService.getProfile();\r\n let userId = profile ? profile['id'] : 0;\r\n\r\n this.state = {\r\n isLoading: false,\r\n user: new UserChangePasswordModel(),\r\n userId: userId\r\n };\r\n }\r\n\r\n handleChange = (key, value) => {\r\n const user: UserChangePasswordModel = { ...this.state.user };\r\n user[key] = value;\r\n this.setState({ user: { ...user } });\r\n };\r\n\r\n isValidAddEditForm() {\r\n let message = '';\r\n\r\n const { user } = this.state;\r\n\r\n if (!user.oldPassword || user.oldPassword.trim() == '') {\r\n message += Translate('Please enter Old Password') + \". \";\r\n }\r\n\r\n if (!user.newPassword || user.newPassword.trim() == '') {\r\n message += Translate('Please enter New Password') + \". \";\r\n }\r\n\r\n if (!user.confirmPassword || user.confirmPassword.trim() == '') {\r\n message += Translate('Please enter Confirm Password') + \". \";\r\n }\r\n\r\n if (user.newPassword && user.newPassword.trim() != '' &&\r\n user.confirmPassword && user.confirmPassword.trim() != '' &&\r\n user.newPassword != user.confirmPassword) {\r\n message += Translate('New Password and Confirm Password are different') + \". \";\r\n }\r\n\r\n message ? this.growl.show({ severity: 'error', summary: message }) : null;\r\n\r\n return message == '';\r\n }\r\n\r\n handleChangeButtonClick = event => {\r\n event.preventDefault();\r\n\r\n if (!this.isValidAddEditForm()) return;\r\n\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n const { user, userId } = this.state;\r\n\r\n user.userId = userId;\r\n\r\n this.userService.changePassword(user).then(\r\n (data: any) => {\r\n if (data) {\r\n let user = this.state.user;\r\n user.oldPassword = '';\r\n user.newPassword = '';\r\n user.confirmPassword = '';\r\n this.setState({\r\n isLoading: false,\r\n user: user\r\n });\r\n this.growl.show({ severity: 'success', summary: Translate('You have successfully changed your Password.') });\r\n }\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n\r\n }\r\n\r\n handleKeyPress = (e) => {\r\n if (e.key === 'Enter') {\r\n this.handleChangeButtonClick(e);\r\n }\r\n }\r\n\r\n public render() {\r\n const { isLoading, user } = this.state;\r\n\r\n return (\r\n \r\n {isLoading ?
: null}\r\n
this.growl = el} />\r\n\r\n \r\n
\r\n\r\n
\r\n
\r\n this.handleChange('oldPassword', e.target['value'])}\r\n value={user && user.oldPassword ? user.oldPassword : \"\"}\r\n />\r\n
\r\n
\r\n this.handleChange('newPassword', e.target['value'])}\r\n value={user && user.newPassword ? user.newPassword : \"\"}\r\n />\r\n
\r\n
\r\n this.handleChange('confirmPassword', e.target['value'])}\r\n value={user && user.confirmPassword ? user.confirmPassword : \"\"}\r\n />\r\n
\r\n
\r\n
\r\n \r\n \r\n {/* */}\r\n
\r\n
\r\n
\r\n \r\n )\r\n }\r\n}\r\n\r\nexport default UserChangePasswordTab;","import * as React from \"react\";\r\nimport { BrowserRouter, Route, Link, Switch, Redirect, withRouter } from \"react-router-dom\";\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport Translate from '../../../common/functions/translate';\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport { UserModel } from '../../../models/user/userModel';\r\nimport UserService from '../../../services/userService';\r\nimport AuthService from '../../../services/authService';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport ConfirmDialog from '../../../common/components/confirmDialog/confirmDialog';\r\nimport { connect } from 'react-redux';\r\nimport * as actionTypes from '../../../store/actionTypes';\r\nimport FileSaver from 'file-saver';\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes, faDownload, faFile } from '@fortawesome/free-solid-svg-icons';\r\nimport Card from '@material-ui/core/Card';\r\nimport CardActions from '@material-ui/core/CardActions';\r\nimport CardContent from '@material-ui/core/CardContent';\r\n\r\ninterface IProps {\r\n history: any,\r\n onUserLogout: any,\r\n lang: string\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n user: UserModel;\r\n isVisibleConfirmDialog: boolean;\r\n}\r\n\r\nclass UserInformationTab extends React.Component {\r\n\r\n userService = new UserService();\r\n authService = new AuthService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n user: new UserModel(),\r\n isVisibleConfirmDialog: false\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n }\r\n\r\n handleGetAccounInfoButton = (event, type) => {\r\n event.preventDefault();\r\n\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n this.userService.getAccountInfo(this.props.lang).then(\r\n (data: any) => {\r\n this.setState({\r\n isLoading: false\r\n });\r\n if (data) {\r\n let res = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });\r\n if (type == 'view') {\r\n if (window.navigator && window.navigator.msSaveOrOpenBlob) {\r\n window.navigator.msSaveOrOpenBlob(res);\r\n }\r\n else {\r\n var url = window.URL.createObjectURL(res);\r\n window.open(url);\r\n }\r\n } else {\r\n FileSaver.saveAs(res, \"UserInformation.json\");\r\n }\r\n }\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n handleDeleteAccountButton = event => {\r\n event.preventDefault();\r\n this.setState({\r\n isVisibleConfirmDialog: true\r\n });\r\n }\r\n\r\n deleleteAccount = () => {\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n this.userService.deleteAccountPermanently().then(\r\n (data: any) => {\r\n if (data) {\r\n this.setState({\r\n isLoading: false\r\n });\r\n this.authService.logout();\r\n setTimeout(() => {\r\n this.props.onUserLogout();\r\n this.props.history.push(`/`);\r\n });\r\n }\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n\r\n public render() {\r\n const { isLoading } = this.state;\r\n const userId = this.authService.getUserId();\r\n\r\n return (\r\n \r\n {isLoading ?
: null}\r\n\r\n
this.growl = el} />\r\n\r\n \r\n
\r\n
\r\n \r\n \r\n {Translate('Download Your Information')}\r\n
\r\n \r\n {Translate('DownloadYourInformationDescription')}\r\n
\r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n\r\n
\r\n\r\n
\r\n
\r\n \r\n \r\n {Translate('Permanently Delete Account')}\r\n
\r\n \r\n {Translate('DeleteAccountPermanentlyDescription')}\r\n
\r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n\r\n {/*
\r\n \r\n {Translate('DeleteAccountPermanentlyDescription')}\r\n
\r\n \r\n \r\n
\r\n */}\r\n
\r\n
\r\n\r\n { this.setState({ isVisibleConfirmDialog: false }); this.deleleteAccount() }}\r\n noClick={() => { this.setState({ isVisibleConfirmDialog: false }) }}>\r\n {Translate('Are you sure that you want to delete your Account permanently?')}\r\n \r\n\r\n \r\n )\r\n }\r\n}\r\n\r\nconst mapDispatchToProps = dispatch => {\r\n return {\r\n onUserLogout: () => dispatch({ type: actionTypes.USER_LOGOUT })\r\n }\r\n}\r\n\r\nconst mapsStateToProps = state => {\r\n return {\r\n lang: state.common.lang\r\n };\r\n}\r\n\r\nexport default withRouter(connect(mapsStateToProps, mapDispatchToProps)(UserInformationTab));","import * as React from \"react\";\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport Translate from '../../../common/functions/translate';\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport UserService from '../../../services/userService';\r\nimport AuthService from '../../../services/authService';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport UserAccountTab from './userAccountTab';\r\nimport UserPersonalDataTab from './userPersonalDataTab';\r\nimport UserChangePasswordTab from './userChangePasswordTab';\r\nimport UserInformationTab from './userInformationTab';\r\nimport { Accordion, AccordionTab } from 'primereact/accordion';\r\n\r\ninterface IProps {\r\n history: any\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n activeIndex: any;\r\n}\r\n\r\nclass UserProfileComponent extends React.Component {\r\n\r\n userService = new UserService();\r\n authService = new AuthService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n activeIndex: null\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n }\r\n\r\n handleTabMenuchange = (event, value) => {\r\n if (value != null) {\r\n this.setState({ activeIndex: value });\r\n } else {\r\n this.setState({ activeIndex: null });\r\n }\r\n }\r\n\r\n onCancelClick = () => {\r\n {\r\n this.setState({ activeIndex: null });\r\n }\r\n }\r\n\r\n onSave = () => {\r\n //Function is empty because we need props.onSave\r\n //in user family to close the popup, here we \r\n //don't need it but if is not iplemented there is a error\r\n }\r\n\r\n public render() {\r\n const { isLoading, activeIndex } = this.state;\r\n\r\n return (\r\n \r\n\r\n {isLoading ?
: null}\r\n
this.growl = el} />\r\n\r\n {Translate('Profile')}
\r\n\r\n \r\n
this.handleTabMenuchange(e, e.index)}>\r\n \r\n {activeIndex == 0 ?\r\n \r\n : null}\r\n \r\n \r\n {activeIndex == 1 ?\r\n \r\n : null}\r\n \r\n \r\n {activeIndex == 2 ?\r\n \r\n : null}\r\n \r\n \r\n {activeIndex == 3 ?\r\n \r\n : null}\r\n \r\n \r\n
\r\n \r\n )\r\n }\r\n}\r\n\r\nexport default UserProfileComponent;","import { MedicineForListModel } from '../medicineForListModel';\r\nimport { UserMedicineHistoryModel } from './userMedicineHistoryModel';\r\n\r\nexport class UserMedicineModel {\r\n public userId: number;\r\n public medicine: MedicineForListModel;\r\n public userMedicineHistory: Array;\r\n}","import { UserNotificationModel } from './userNotificationModel';\r\n\r\nexport class UserMedicineHistoryModel {\r\n public userMedicineHistoryId: number;\r\n public userMedicineId: number;\r\n public userId: number;\r\n public medicineId: number;\r\n public medicineName: string;\r\n public authorisationStatus: number;\r\n public startDate?: string;\r\n public endDate?: string;\r\n public singleDose: string;\r\n public frequencyOfIntake: string;\r\n public intakeConditions: string;\r\n public comments: string;\r\n public prescriptionName: string;\r\n public userNotifications: Array;\r\n public notificationsCount: number;\r\n public prescriptionDoctor: string;\r\n public prescriptionId: number;\r\n}","import * as React from 'react';\r\nimport { Button } from \"primereact/button\";\r\nimport { InputText } from 'primereact/inputtext';\r\nimport { Toolbar } from 'primereact/toolbar';\r\nimport { MedicineFilterSettings } from \"../../../models/medicineFilterSettings\";\r\nimport AlphabeticalFilter from '../../../common/components/alphabeticalFilter/alphabeticalFilter';\r\nimport Translate from '../../../common/functions/translate';\r\n\r\ninterface MedicinesFilterProps {\r\n onSearchClick: any,\r\n totalRecordsCount: number,\r\n lang: string\r\n onClearClick: any;\r\n}\r\n\r\ninterface MedicinesFilterState {\r\n medicineSettings: MedicineFilterSettings,\r\n selectedType: null,\r\n selectedGroup: null,\r\n filterText: string\r\n}\r\n\r\nexport class MedicineFilter extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n medicineSettings: new MedicineFilterSettings(),\r\n selectedType: null,\r\n selectedGroup: null,\r\n filterText: ''\r\n };\r\n }\r\n\r\n handleAlphaIndexChange = (e, letter: string) => {\r\n e.preventDefault();\r\n let currentSettings: MedicineFilterSettings = this.state.medicineSettings;\r\n currentSettings.name = '';\r\n currentSettings.alphaIndex = letter;\r\n const fiterText = this.generateFilterText(currentSettings);\r\n this.setState({\r\n medicineSettings: currentSettings,\r\n filterText: fiterText\r\n });\r\n this.handleSearchButtonClick();\r\n }\r\n\r\n handleChange = (event) => {\r\n const target = event.target;\r\n const value = target.type === 'checkbox' ? target.checked : target.value\r\n const name = target.name;\r\n\r\n const currentSettings: MedicineFilterSettings = { ...this.state.medicineSettings };\r\n currentSettings.name = value;\r\n currentSettings.alphaIndex = '';\r\n const fiterText = this.generateFilterText(currentSettings);\r\n this.setState({\r\n medicineSettings: { ...currentSettings },\r\n filterText: fiterText\r\n }, this.searchByName);\r\n }\r\n\r\n searchByName = () => {\r\n if (this.state.medicineSettings && this.state.medicineSettings.name && this.state.medicineSettings.name.length >= 3) {\r\n this.handleSearchButtonClick()\r\n }\r\n }\r\n\r\n generateFilterText = (settings) => {\r\n let result = '';\r\n\r\n if (settings.alphaIndex) {\r\n result += Translate(\"Start with\") + \" '\" + settings.alphaIndex + \"', \"\r\n }\r\n\r\n if (settings.name) {\r\n result += Translate(\"Name\") + \" '\" + settings.name + \"', \"\r\n }\r\n\r\n if (settings.title) {\r\n result += Translate(\"Title\") + \" '\" + settings.title + \"', \"\r\n }\r\n\r\n if (settings.number) {\r\n result += Translate(\"Number\") + \" '\" + settings.number + \"', \"\r\n }\r\n\r\n return result.substr(0, result.length - 2);\r\n }\r\n\r\n handleSearchButtonClick = () => {\r\n this.props.onSearchClick(this.state.medicineSettings);\r\n }\r\n\r\n handleClearButtonClick = () => {\r\n let currentSettings: MedicineFilterSettings = this.state.medicineSettings;\r\n currentSettings.name = '';\r\n currentSettings.alphaIndex = '';\r\n this.setState({\r\n medicineSettings: currentSettings,\r\n filterText: ''\r\n });\r\n this.props.onClearClick();\r\n }\r\n\r\n handleKeyPress = (e) => {\r\n if (e.key === 'Enter') {\r\n this.handleSearchButtonClick()\r\n }\r\n }\r\n\r\n render() {\r\n return (\r\n <>\r\n \r\n
\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n
{Translate('BrowseAlphabetically')}:\r\n
\r\n
\r\n \r\n
\r\n {Translate('Result')}: {this.props.totalRecordsCount}\r\n {this.state.filterText ? ', ' : ''}\r\n \r\n
\r\n
\r\n >\r\n )\r\n }\r\n}\r\n\r\nexport default MedicineFilter;\r\n","import * as React from 'react';\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faAngleLeft, faAngleRight, faAngleDoubleLeft, faAngleDoubleRight } from '@fortawesome/free-solid-svg-icons';\r\nimport * as Constants from '../../../common/constants';\r\nimport { MuiThemeProvider, createMuiTheme } from \"@material-ui/core\";\r\n\r\nconst pagingItems = (props) => {\r\n let pageItems = new Array();\r\n\r\n if (props.numberOfPages > 1) {\r\n for (let i = 1; i <= props.numberOfPages; i++) {\r\n pageItems.push(i);\r\n }\r\n }\r\n return pageItems;\r\n}\r\n\r\n\r\nconst paginator = (props) => {\r\n\r\n let items = pagingItems(props);\r\n\r\n if (items.length < 2) {\r\n return null;\r\n }\r\n\r\n let paginator: Array = new Array();\r\n if (props.onlyArrows) {\r\n let startEl: Array = [\r\n ,\r\n ]\r\n let endEl: Array = [\r\n ,\r\n \r\n ]\r\n\r\n paginator = [\r\n\r\n ];\r\n if (props.page == 1) {\r\n paginator.splice(0, 1);\r\n }\r\n if (props.page == items.length) {\r\n paginator.splice(2, 1);\r\n }\r\n\r\n paginator.splice(0, 0, ...endEl);\r\n paginator.push(...startEl)\r\n }\r\n\r\n else {\r\n if (items.length <= 5) {\r\n paginator = items.map(item => {\r\n return (\r\n \r\n )\r\n })\r\n }\r\n\r\n else {\r\n\r\n let startEl: Array = [\r\n ,\r\n ]\r\n let endEl: Array = [\r\n ,\r\n \r\n ]\r\n\r\n paginator = [\r\n ,\r\n ,\r\n \r\n ];\r\n if (props.page == 1) {\r\n paginator.splice(0, 1);\r\n paginator.push()\r\n }\r\n if (props.page == items.length) {\r\n paginator.splice(2, 1);\r\n paginator.splice(0, 0, );\r\n }\r\n\r\n paginator.splice(0, 0, ...startEl);\r\n paginator.push(...endEl)\r\n }\r\n }\r\n return (\r\n \r\n \r\n {paginator}\r\n \r\n
\r\n )\r\n}\r\n\r\nexport default paginator;","import * as React from \"react\";\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport Translate from '../../../common/functions/translate';\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport { MedicineForListModel, MedicineListModel } from \"../../../models\";\r\nimport { MedicineFilterSettings } from \"../../../models/medicineFilterSettings\";\r\nimport MedicineService from '../../../services/medicineService';\r\nimport UserService from '../../../services/userService';\r\nimport MedicineFilter from './medicineFilter';\r\nimport Radio from '@material-ui/core/Radio';\r\nimport { UserMedicineModel } from '../../../models/user/userMedicineModel';\r\nimport Paginator from '../../../common/components/paginator/paginator';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes } from '@fortawesome/free-solid-svg-icons';\r\n\r\ninterface IProps {\r\n isVisible: boolean\r\n addMedicineClick: any,\r\n cancelClick: any,\r\n dialogError: any,\r\n clearDialogError: any,\r\n userId: number,\r\n lang: string\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n medicines: Array;\r\n selectedMedicine: MedicineForListModel;\r\n from: number;\r\n numberOfRows: number;\r\n totalRecordsCount: number;\r\n medicineSettings: MedicineFilterSettings;\r\n searchText: string;\r\n page: number;\r\n numberOfPages: number;\r\n}\r\n\r\nclass MedicineSearchDialog extends React.Component {\r\n growl: any;\r\n medicineService = new MedicineService();\r\n userService = new UserService();\r\n initFrom = 0;\r\n numberOfRows = 10;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n medicines: new Array(0),\r\n selectedMedicine: new MedicineForListModel(),\r\n from: this.initFrom,\r\n numberOfRows: this.numberOfRows,\r\n totalRecordsCount: 0,\r\n medicineSettings: new MedicineFilterSettings(),\r\n searchText: '',\r\n page: 1,\r\n numberOfPages: 1\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n //this.getAllFilteredItems(this.state.page, this.state.numberOfRows, this.state.medicineSettings);\r\n }\r\n\r\n handleAddButton = (event) => {\r\n event.preventDefault();\r\n\r\n let usermedicine: UserMedicineModel = new UserMedicineModel();\r\n usermedicine.medicine = this.state.selectedMedicine;\r\n usermedicine.userMedicineHistory = [];\r\n usermedicine.userId = this.props.userId;\r\n this.props.addMedicineClick(usermedicine, true);\r\n }\r\n\r\n handleCancelButton = () => {\r\n this.props.cancelClick();\r\n }\r\n\r\n handleSelectionChange = (e) => {\r\n this.setState({\r\n selectedMedicine: e\r\n });\r\n }\r\n\r\n handleChange = (key, value) => {\r\n this.setState({ searchText: value });\r\n };\r\n\r\n getAllFilteredItems(page: number, numberOfRows: number, currentFilterSettings: MedicineFilterSettings) {\r\n let from = (page - 1) * this.state.numberOfRows;\r\n\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n this.medicineService.getAllMedicines(from, numberOfRows, currentFilterSettings, this.props.lang).then(\r\n (data: MedicineListModel) => {\r\n this.setState({\r\n isLoading: false,\r\n from: from,\r\n medicines: data.medicines,\r\n totalRecordsCount: data.totalRecordsCount,\r\n numberOfPages: (data.totalRecordsCount % this.state.numberOfRows > 0 ?\r\n data.totalRecordsCount / this.state.numberOfRows + 1 : data.totalRecordsCount / this.state.numberOfRows)\r\n });\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n handleSearchButtonClick = (settings) => {\r\n this.setState({\r\n isLoading: true,\r\n page: 1,\r\n medicineSettings: settings\r\n },\r\n () => this.getAllFilteredItems(this.state.page, this.state.numberOfRows, settings)\r\n );\r\n }\r\n\r\n handleClearClick = () => {\r\n this.setState({\r\n page: 1, medicineSettings: new MedicineFilterSettings(), medicines: [], totalRecordsCount: 0, numberOfPages: 0\r\n });\r\n }\r\n\r\n paginataorClick = (page) => {\r\n this.setState({ page: page }, () => this.getAllFilteredItems(page, this.state.numberOfRows, this.state.medicineSettings));\r\n }\r\n\r\n public render() {\r\n const { isLoading, medicines, selectedMedicine, page, numberOfPages, medicineSettings } = this.state;\r\n\r\n return (\r\n \r\n )\r\n }\r\n}\r\n\r\nexport default MedicineSearchDialog;","import * as React from \"react\";\r\nimport Translate from '../../../common/functions/translate';\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport { UserMedicineHistoryModel } from \"../../../models/user/userMedicineHistoryModel\";\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport { DatePicker } from '@material-ui/pickers';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes, faTimesCircle } from '@fortawesome/free-solid-svg-icons';\r\nimport MedicineSearchDialog from \"./medicineSearchDialog\";\r\nimport { UserMedicineModel } from \"../../../models/user/userMedicineModel\";\r\nimport { MedicineForListModel } from \"../../../models\";\r\nimport AddIcon from '@material-ui/icons/Add';\r\nimport Fab from '@material-ui/core/Fab';\r\nimport Growl from \"../../../common/components/alertMessage/growl\";\r\n\r\ninterface IProps {\r\n //history: any,\r\n addClick: any,\r\n updateClick: any,\r\n cancelClick: any,\r\n isVisible: boolean,\r\n currentUserMedicineHistory: UserMedicineHistoryModel,\r\n lang: string,\r\n userId: number,\r\n isAdd: boolean\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n validationMessage: string;\r\n currentUserMedicineHistory: UserMedicineHistoryModel,\r\n isVisibleSearchMedicineDialog: boolean,\r\n searchDialogError: any,\r\n userMedicine: UserMedicineModel\r\n}\r\n\r\nclass UserMedicineHistoryAddEditDialog extends React.Component {\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n validationMessage: '',\r\n isLoading: false,\r\n currentUserMedicineHistory: props.currentUserMedicineHistory,\r\n isVisibleSearchMedicineDialog: false,\r\n searchDialogError: null,\r\n userMedicine: new UserMedicineModel()\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n }\r\n\r\n handleSaveButton = (event) => {\r\n event.preventDefault();\r\n\r\n const currentUserMedicineHistory = this.state.currentUserMedicineHistory;\r\n\r\n if (currentUserMedicineHistory.startDate) {\r\n currentUserMedicineHistory.startDate = HelperFunctions.fomatDateAsString(new Date(currentUserMedicineHistory.startDate))\r\n } else {\r\n currentUserMedicineHistory.startDate = HelperFunctions.fomatDateAsString(new Date())\r\n }\r\n\r\n if (currentUserMedicineHistory.endDate) {\r\n currentUserMedicineHistory.endDate = HelperFunctions.fomatDateAsString(new Date(currentUserMedicineHistory.endDate))\r\n } else {\r\n currentUserMedicineHistory.endDate = HelperFunctions.fomatDateAsString(HelperFunctions.getDayslater(new Date().toString(), 7))\r\n }\r\n\r\n if (currentUserMedicineHistory.endDate && currentUserMedicineHistory.startDate) {\r\n if (currentUserMedicineHistory.endDate < currentUserMedicineHistory.startDate) {\r\n this.growl.show({ severity: 'error', summary: Translate(\"Start date is greater than end date\") });\r\n return;\r\n }\r\n }\r\n\r\n if (currentUserMedicineHistory && currentUserMedicineHistory.userMedicineHistoryId && currentUserMedicineHistory.userMedicineHistoryId > 0) {\r\n this.props.updateClick(currentUserMedicineHistory, close);\r\n }\r\n else {\r\n this.props.addClick(currentUserMedicineHistory, this.state.userMedicine, close);\r\n }\r\n }\r\n\r\n handleCancelButton = () => {\r\n this.props.cancelClick();\r\n }\r\n\r\n handleChange = (key, value) => {\r\n const currentUserMedicineHistory: UserMedicineHistoryModel = { ...this.state.currentUserMedicineHistory };\r\n currentUserMedicineHistory[key] = value;\r\n this.setState({ currentUserMedicineHistory: { ...currentUserMedicineHistory } });\r\n };\r\n\r\n handleMedicineSaveButton = (currentUserMedicine: UserMedicineModel, close: boolean) => {\r\n this.setState({\r\n isVisibleSearchMedicineDialog: false,\r\n userMedicine: currentUserMedicine\r\n });\r\n }\r\n\r\n handleCancelSearchMedicine = () => {\r\n this.setState({\r\n isVisibleSearchMedicineDialog: false,\r\n searchDialogError: null\r\n });\r\n }\r\n\r\n\r\n clearDialogError = () => {\r\n this.setState({\r\n searchDialogError: null\r\n });\r\n }\r\n\r\n handleMedicineRemoveClick(event) {\r\n event.preventDefault();\r\n this.setState({\r\n userMedicine: new UserMedicineModel()\r\n });\r\n }\r\n\r\n handleMedicineAddEditClick() {\r\n this.setState({\r\n isVisibleSearchMedicineDialog: true,\r\n validationMessage: ''\r\n });\r\n }\r\n\r\n public render() {\r\n const { isLoading, currentUserMedicineHistory, isVisibleSearchMedicineDialog, searchDialogError, userMedicine } = this.state;\r\n let medicineInputButton =\r\n \r\n
\r\n
\r\n {currentUserMedicineHistory.medicineName}\r\n
\r\n
;\r\n if (!currentUserMedicineHistory || !currentUserMedicineHistory.userMedicineHistoryId || currentUserMedicineHistory.userMedicineHistoryId == 0) {\r\n let classInput = 'float-left-full-width';\r\n if (!userMedicine || !userMedicine.medicine || !userMedicine.medicine.medicineId) {\r\n classInput = 'float-left-calculated-width';\r\n }\r\n medicineInputButton =\r\n \r\n
\r\n
\r\n
\r\n {userMedicine && userMedicine.medicine && userMedicine.medicine.medicineId ?\r\n <>\r\n
\r\n - \r\n
\r\n
\r\n {userMedicine.medicine.brandName ? userMedicine.medicine.brandName : ''}\r\n
\r\n
\r\n \r\n \r\n
\r\n >\r\n :
{Translate('No medicine selected')}
}\r\n
\r\n {!userMedicine || !userMedicine.medicine || !userMedicine.medicine.medicineId ?\r\n
\r\n
this.handleMedicineAddEditClick()}>\r\n \r\n \r\n
: null}\r\n
\r\n
;\r\n }\r\n\r\n return (\r\n <>\r\n \r\n\r\n {isVisibleSearchMedicineDialog ? (\r\n ) : null\r\n }\r\n >\r\n )\r\n }\r\n}\r\n\r\nexport default UserMedicineHistoryAddEditDialog;","export class UserNotificationModel {\r\n public userNotificationId: number;\r\n public userMedicineId?: number;\r\n public userMedicineHistoryId?: number;\r\n public userId?: number;\r\n public notificationScheduleTypeId: number;\r\n public notificationAlarmTypeId: number;\r\n public alarmTime: string;\r\n public description: string;\r\n public isActive: boolean;\r\n public oneTimeExecutionDate?: string;\r\n public notificationFrequencyId?: number;\r\n public notificationFrequencyCounter?: number;\r\n public isSingleDailyOccurance?: boolean;\r\n public startDate?: string;\r\n public endDate?: string;\r\n public dailyFrequencyCounter?: number;\r\n public startTime?: string;\r\n public endTime?: string;\r\n public canBeActivated: boolean;\r\n public minutesForIntake: number;\r\n public caretakerUserId: number;\r\n public timeZoneOffsetInMinutes: number;\r\n public cronExpression: string;\r\n public caretakerName: string;\r\n}","import 'babel-polyfill';\r\nimport * as React from 'react';\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes, faTimesCircle } from '@fortawesome/free-solid-svg-icons';\r\nimport MedicineService from '../../../services/medicineService';\r\nimport Translate from '../../../common/functions/translate';\r\nimport { UserNotificationModel } from \"../../../models/user/userNotificationModel\";\r\nimport { NotificationScheduleType, NotificationAlarmType, NotificationFrequency, MinutesForIntake, DayOfWeekOneLetterAbbr, DayOfWeekThreeLetterAbbr } from \"../../../common/enums\";\r\nimport { DropdownModel } from \"../../../models/dropdownModel\";\r\nimport { enumToDropdownArray, weekDayEnumToObjArray, getFrequencyCounterLabel, fomatDateAsString, fomatTimeAsString, fomatDateTimeAsString, getNotificationSummary, formatAlarmTime, fomatDateAsStringNotifications } from '../../../common/functions/helperFunctions';\r\nimport Select from '@material-ui/core/Select';\r\nimport MenuItem from '@material-ui/core/MenuItem';\r\nimport FormControl from '@material-ui/core/FormControl';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport { TimePicker, DatePicker } from '@material-ui/pickers';\r\nimport { Checkbox } from '@material-ui/core';\r\nimport { MuiThemeProvider, createMuiTheme } from '@material-ui/core';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport InputLabel from '@material-ui/core/InputLabel';\r\nimport * as Constants from '../../../common/constants';\r\nimport UserService from \"../../../services/userService\";\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\n\r\nimport Chip from '@material-ui/core/Chip';\r\nimport Avatar from '@material-ui/core/Avatar';\r\nimport Paper from '@material-ui/core/Paper';\r\nimport TagFacesIcon from '@material-ui/icons/TagFaces';\r\n\r\ninterface IProps {\r\n selectedUserNotification: UserNotificationModel,\r\n isVisible: boolean,\r\n cancelClick: any,\r\n saveClick: any,\r\n //userMedicineHistoryId: number,\r\n lang: string\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n currentUserNotification: UserNotificationModel,\r\n notificationScheduleTypeDropdown: Array;\r\n notificationAlarmTypeDropdown: Array;\r\n notificationFrequencyDropdown: Array;\r\n isFrequencyButtonDisabled: boolean;\r\n summaryContent: string;\r\n //isEndDateDisabled: boolean;\r\n caretakers: Array;\r\n minutesForIntake: Array;\r\n weekDayChips: Array;\r\n isWeekdaySelected: boolean;\r\n}\r\n\r\n\r\nclass UserNotificationAddEditDialog extends React.Component {\r\n medicineService = new MedicineService();\r\n growl: any;\r\n userService = new UserService();\r\n today = new Date();\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n currentUserNotification: props.selectedUserNotification,\r\n notificationScheduleTypeDropdown: new Array(0),\r\n notificationAlarmTypeDropdown: new Array(0),\r\n notificationFrequencyDropdown: new Array(0),\r\n isFrequencyButtonDisabled: false,\r\n //isEndDateDisabled: false,\r\n summaryContent: '',\r\n caretakers: new Array(0),\r\n minutesForIntake: new Array(0),\r\n weekDayChips: new Array(0),\r\n isWeekdaySelected: false\r\n }\r\n }\r\n\r\n componentDidMount() {\r\n this.setState({\r\n isLoading: true\r\n });\r\n this.userService.getAllCaretakers().then(\r\n (data: any) => {\r\n if (data) {\r\n let firstElement: Array = new Array(0);\r\n if (data && data.length > 0) {\r\n firstElement = [{ label: Translate('Select'), value: 0 }];\r\n }\r\n this.setState({ caretakers: firstElement.concat(data), isLoading: false }, () => this.initData());\r\n }\r\n })\r\n .catch(error => {\r\n this.setState({\r\n isLoading: false\r\n });\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n });\r\n }\r\n\r\n initData() {\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n const notificationAlarmTypeDropdown: Array = enumToDropdownArray(NotificationAlarmType, true);\r\n const notificationScheduleTypeDropdown: Array = enumToDropdownArray(NotificationScheduleType, true);\r\n const notificationFrequencyDropdown: Array = enumToDropdownArray(NotificationFrequency, true);\r\n const minutesForIntake: Array = enumToDropdownArray(MinutesForIntake, true);\r\n const weekDayObjArray: Array = weekDayEnumToObjArray(DayOfWeekOneLetterAbbr, true, false, false);\r\n\r\n\r\n this.setState({\r\n notificationAlarmTypeDropdown: notificationAlarmTypeDropdown,\r\n notificationScheduleTypeDropdown: notificationScheduleTypeDropdown,\r\n notificationFrequencyDropdown: notificationFrequencyDropdown,\r\n minutesForIntake: minutesForIntake,\r\n isLoading: false,\r\n isFrequencyButtonDisabled: (this.state.currentUserNotification.notificationScheduleTypeId === 1) ? true : false,\r\n weekDayChips: weekDayObjArray\r\n });\r\n\r\n this.handleSummaryContent(this.state.currentUserNotification);\r\n }\r\n\r\n handleSummaryContent(currentUserNotification: UserNotificationModel) {\r\n let summaryContent = getNotificationSummary(currentUserNotification, this.props.lang);\r\n\r\n this.setState({\r\n summaryContent: summaryContent\r\n });\r\n }\r\n\r\n handleChange = (key, value) => {\r\n const currentUserNotification: UserNotificationModel = { ...this.state.currentUserNotification };\r\n currentUserNotification[key] = value;\r\n\r\n if (key === \"notificationScheduleTypeId\" && value !== this.state.currentUserNotification.notificationScheduleTypeId) {\r\n let theNextHour: Date = new Date();\r\n theNextHour.setHours(theNextHour.getHours() + 1, 0)\r\n currentUserNotification.alarmTime = theNextHour.toUTCString();\r\n }\r\n\r\n if (key == \"caretakerUserId\" && !currentUserNotification.minutesForIntake) {\r\n currentUserNotification.minutesForIntake = 5;\r\n }\r\n\r\n if (key === \"alarmTime\") {\r\n if (this.state.currentUserNotification.notificationScheduleTypeId == NotificationScheduleType.OneTime) {\r\n let date = new Date(currentUserNotification && currentUserNotification.oneTimeExecutionDate ? currentUserNotification.oneTimeExecutionDate : new Date());\r\n currentUserNotification.oneTimeExecutionDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), value.getHours(), value.getMinutes()).toUTCString();\r\n }\r\n\r\n if (this.state.currentUserNotification.notificationScheduleTypeId == NotificationScheduleType.Recurring) {\r\n let startDate = new Date(currentUserNotification && currentUserNotification.startDate ? currentUserNotification.startDate : new Date());\r\n currentUserNotification.startDate = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate(), value.getHours(), value.getMinutes()).toUTCString();\r\n // if (!this.state.isEndDateDisabled) {\r\n // let endDate = new Date(currentUserNotification && currentUserNotification.endDate ? currentUserNotification.endDate : new Date());\r\n // currentUserNotification.endDate = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate(), value.getHours(), value.getMinutes()).toUTCString();\r\n // }\r\n }\r\n }\r\n\r\n if (key === \"notificationScheduleTypeId\") {\r\n if (value == NotificationScheduleType.OneTime) {\r\n currentUserNotification.startDate = undefined;\r\n currentUserNotification.endDate = undefined;\r\n }\r\n if (value == NotificationScheduleType.Recurring) {\r\n currentUserNotification.oneTimeExecutionDate = undefined;\r\n // if (this.state.isEndDateDisabled) {\r\n // currentUserNotification.endDate = undefined;\r\n // }\r\n }\r\n }\r\n\r\n this.setState({\r\n currentUserNotification: { ...currentUserNotification },\r\n isFrequencyButtonDisabled: (currentUserNotification.notificationScheduleTypeId === 1) ? true : false\r\n });\r\n\r\n this.handleSummaryContent(currentUserNotification);\r\n };\r\n\r\n handleDateTimeChange = (key, value) => {\r\n const currentUserNotification: UserNotificationModel = { ...this.state.currentUserNotification };\r\n\r\n let datePart = fomatDateAsString(value);\r\n let timePart = fomatTimeAsString(new Date(currentUserNotification[key]));\r\n\r\n let newValue = datePart;// + \" \" + timePart;\r\n value = new Date(newValue);\r\n\r\n currentUserNotification[key] = value;\r\n this.setState({\r\n currentUserNotification: { ...currentUserNotification },\r\n isFrequencyButtonDisabled: (currentUserNotification.notificationScheduleTypeId === 1) ? true : false\r\n });\r\n\r\n this.handleSummaryContent(currentUserNotification);\r\n };\r\n\r\n handleCancelButton = () => {\r\n this.props.cancelClick();\r\n }\r\n\r\n handleSaveButton = event => {\r\n let currentUserNotification = this.state.currentUserNotification;\r\n\r\n if (currentUserNotification.notificationScheduleTypeId == NotificationScheduleType.Recurring) {\r\n let startDate = new Date(currentUserNotification && currentUserNotification.startDate ? currentUserNotification.startDate : new Date());\r\n currentUserNotification.startDate = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate(), 0, 0, 0).toUTCString();\r\n\r\n // if (!this.state.isEndDateDisabled) {\r\n // let endDate = new Date(currentUserNotification && currentUserNotification.endDate ? currentUserNotification.endDate : new Date());\r\n // currentUserNotification.endDate = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate(), 23, 59, 59).toUTCString();\r\n // }\r\n }\r\n\r\n let result = this.hadleObjectValidation(JSON.parse(JSON.stringify(currentUserNotification)));\r\n\r\n this.growl.show({ severity: 'error', summary: result });\r\n\r\n if (!result) {\r\n //currentUserNotification.userMedicineHistoryId = this.props.userMedicineHistoryId;\r\n this.props.saveClick(currentUserNotification);\r\n }\r\n }\r\n\r\n setCurrentCronExpression(currentUserNotification: UserNotificationModel) {\r\n // cronExpression = \"* * * * * *\" => minute | hour | day | month | weekday | year\r\n\r\n let cronExpression: string;\r\n if (currentUserNotification.notificationScheduleTypeId === 1) {\r\n cronExpression: \"\"\r\n }\r\n }\r\n\r\n hadleObjectValidation(currentUserNotification: UserNotificationModel) {\r\n if (!currentUserNotification.alarmTime) {\r\n return Translate(\"Alarm time cannot be empty\");\r\n }\r\n\r\n let alarmTime = formatAlarmTime(currentUserNotification.alarmTime);\r\n\r\n if (currentUserNotification.notificationScheduleTypeId === 1) {\r\n if (!currentUserNotification.oneTimeExecutionDate) {\r\n return Translate(\"Date cannot be empty\");\r\n }\r\n\r\n let currentDateTime = fomatDateTimeAsString(new Date());\r\n let alarmDate = fomatDateAsStringNotifications(new Date(currentUserNotification.oneTimeExecutionDate));\r\n let alarmDateTime = alarmDate + \" \" + alarmTime;\r\n\r\n if (currentDateTime >= alarmDateTime) {\r\n return Translate(\"Alarm date and/or time\") + \" (\" + alarmDateTime + \") \" + Translate(\"are lesser than current time\")\r\n + \" (\" + currentDateTime + \")\" + \". \" + Translate(\"Alarm will never execute\");\r\n }\r\n\r\n currentUserNotification.oneTimeExecutionDate = alarmDateTime;\r\n currentUserNotification.alarmTime = alarmTime;\r\n currentUserNotification.notificationFrequencyId = undefined;\r\n currentUserNotification.notificationFrequencyCounter = undefined;\r\n currentUserNotification.isSingleDailyOccurance = undefined;\r\n currentUserNotification.startDate = undefined;\r\n currentUserNotification.endDate = undefined;\r\n currentUserNotification.dailyFrequencyCounter = undefined;\r\n currentUserNotification.startTime = undefined;\r\n currentUserNotification.endTime = undefined;\r\n\r\n return \"\";\r\n }\r\n else {\r\n if (!currentUserNotification.notificationFrequencyId || currentUserNotification.notificationFrequencyId === -1) {\r\n return Translate(\"Please choose frequency\");\r\n }\r\n\r\n if (!currentUserNotification.notificationFrequencyCounter || currentUserNotification.notificationFrequencyCounter < 1) {\r\n return Translate(\"Please choose counter\");\r\n }\r\n\r\n if (!currentUserNotification.startDate) {\r\n return Translate(\"Start date cannot be empty\");\r\n }\r\n\r\n currentUserNotification.startDate = fomatDateAsString(new Date(currentUserNotification.startDate));\r\n currentUserNotification.alarmTime = alarmTime;\r\n\r\n if (currentUserNotification.endDate) {\r\n currentUserNotification.endDate = fomatDateAsString(new Date(currentUserNotification.endDate));\r\n\r\n if (currentUserNotification.endDate < currentUserNotification.startDate) {\r\n return Translate(\"Start date is greater than end date\");\r\n }\r\n\r\n if (currentUserNotification.endDate < fomatDateAsString(new Date())) {\r\n return Translate(\"End date is lesser than today\") + \". \" + Translate(\"Alarm will never execute\");\r\n }\r\n }\r\n\r\n currentUserNotification.oneTimeExecutionDate = undefined;\r\n currentUserNotification.dailyFrequencyCounter = undefined;\r\n currentUserNotification.startTime = undefined;\r\n currentUserNotification.endTime = undefined;\r\n currentUserNotification.isSingleDailyOccurance = undefined;\r\n\r\n return \"\"\r\n }\r\n }\r\n\r\n\r\n\r\n handleWeekdayChipClick = (key) => {\r\n let weekDayChips: Array = this.state.weekDayChips;\r\n if (weekDayChips && weekDayChips.length > 0) {\r\n\r\n let clickedIndex = weekDayChips.findIndex(c => c.value === key);\r\n\r\n weekDayChips[clickedIndex].isSelected = !weekDayChips[clickedIndex].isSelected;\r\n this.setState({\r\n weekDayChips: weekDayChips\r\n });\r\n }\r\n }\r\n\r\n handleWeekDayCheckBox = (value) => {\r\n let weekDayChips: Array = this.state.weekDayChips;\r\n\r\n if (weekDayChips && weekDayChips.length > 0) {\r\n\r\n weekDayChips.map(c => c.isSelected = value);\r\n\r\n this.setState({\r\n weekDayChips: weekDayChips\r\n });\r\n }\r\n\r\n this.setState({\r\n isWeekdaySelected: value\r\n });\r\n }\r\n\r\n clearDate = (e) => {\r\n if (e) {\r\n e.preventDefault();\r\n }\r\n let currentUserNotification = { ...this.state.currentUserNotification }\r\n currentUserNotification.endDate = undefined;\r\n this.setState({ currentUserNotification: currentUserNotification });\r\n this.handleSummaryContent(currentUserNotification);\r\n }\r\n\r\n render() {\r\n let { currentUserNotification, notificationFrequencyDropdown, notificationScheduleTypeDropdown,\r\n notificationAlarmTypeDropdown, isFrequencyButtonDisabled, caretakers, minutesForIntake, isLoading, weekDayChips, isWeekdaySelected } = this.state;\r\n\r\n let FrequencyCounterLabel = getFrequencyCounterLabel(currentUserNotification.notificationFrequencyId, true);\r\n\r\n let oneTimeExecutionElement =\r\n <>\r\n \r\n this.handleChange('oneTimeExecutionDate', e)}\r\n />\r\n
\r\n \r\n this.handleChange('alarmTime', e)}\r\n />\r\n
\r\n >;\r\n\r\n let globalFrequencyElement =\r\n <>\r\n \r\n
\r\n \r\n {Translate('Frequency')}\r\n \r\n \r\n
\r\n
\r\n {/* */}\r\n {currentUserNotification.notificationFrequencyId && currentUserNotification.notificationFrequencyId === 3\r\n ?\r\n
\r\n
\r\n
\r\n this.handleWeekDayCheckBox(e.target['checked'])}\r\n color=\"primary\"\r\n inputProps={{\r\n name: 'selectAll',\r\n id: 'select-all'\r\n }} />\r\n \r\n {weekDayChips && weekDayChips.length > 0\r\n ?\r\n weekDayChips.map(m =>\r\n this.handleWeekdayChipClick(m.value)}\r\n //size=\"small\"\r\n //variant=\"outlined\"\r\n //className={classes.chip}\r\n />\r\n )\r\n :\r\n null}\r\n \r\n
\r\n
\r\n :\r\n
\r\n this.handleChange('notificationFrequencyCounter', e.target['value'])}\r\n margin=\"none\"\r\n />\r\n
}\r\n >;\r\n\r\n let dailyFrequencyContainer =\r\n
\r\n
\r\n this.handleDateTimeChange('startDate', e)}\r\n />\r\n
\r\n
\r\n
\r\n
\r\n\r\n {/*
*/}\r\n
this.handleChange('endDate', e)}\r\n />\r\n \r\n \r\n
\r\n
\r\n this.handleChange('alarmTime', e)}\r\n />\r\n
\r\n
\r\n ;\r\n\r\n return (\r\n
\r\n )\r\n }\r\n}\r\n\r\nexport default UserNotificationAddEditDialog;","import * as React from 'react';\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport { UserMedicineHistoryModel } from '../../../models/user/userMedicineHistoryModel';\r\nimport UserService from '../../../services/userService';\r\nimport Translate from '../../../common/functions/translate';\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport { UserNotificationModel } from \"../../../models/user/userNotificationModel\";\r\nimport UserNotificationAddEditDialog from './userNotificationAddEditDialog'\r\nimport { NotificationScheduleType, NotificationAlarmType } from \"../../../common/enums\";\r\nimport { fomatDateTimeAsString, getNotificationSummary, fomatDateAsString, fomatTimeAsString } from '../../../common/functions/helperFunctions';\r\nimport ConfirmDialog from '../../../common/components/confirmDialog/confirmDialog';\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faTimesCircle, faTimes } from '@fortawesome/free-solid-svg-icons';\r\nimport Switch from '@material-ui/core/Switch';\r\nimport { MuiThemeProvider, createMuiTheme } from '@material-ui/core';\r\nimport blue from '@material-ui/core/colors/blue';\r\nimport Button from '@material-ui/core/Button';\r\nimport * as Constants from '../../../common/constants'\r\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport Fab from '@material-ui/core/Fab';\r\nimport AddIcon from '@material-ui/icons/Add';\r\nimport { connect } from 'react-redux';\r\nimport * as actionTypes from '../../../store/actionTypes';\r\nimport { NotificationSchedulerModel } from '../../../models/notificationSchedulerModel';\r\n\r\nconst materialTheme = createMuiTheme({\r\n overrides: {\r\n MuiSwitch: {\r\n switchBase: {\r\n height: '26px'\r\n },\r\n },\r\n },\r\n palette: {\r\n primary: blue,\r\n },\r\n});\r\n\r\ninterface IProps {\r\n isVisible: boolean,\r\n closeClick: any,\r\n userMedicineHistoryId: number,\r\n lang: string\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n validationMessage: string;\r\n from: number;\r\n numberOfRows: number;\r\n totalRecordsCount: number;\r\n currentMedicineHistory: UserMedicineHistoryModel;\r\n isVisibleNotificationAddEditDDialog: boolean,\r\n currrentUserNotification: UserNotificationModel,\r\n isVisibleConfirmDialog: boolean;\r\n isActivePushNotifications: boolean,\r\n isVisibleNotificationConfirm: boolean,\r\n newUserNotification: UserNotificationModel\r\n}\r\n\r\nconst initFrom = 0;\r\nconst numberOfRows = 10;\r\n\r\nclass UserNotificationListDialog extends React.Component
{\r\n userService = new UserService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n validationMessage: '',\r\n from: initFrom,\r\n numberOfRows: numberOfRows,\r\n totalRecordsCount: 0,\r\n currentMedicineHistory: new UserMedicineHistoryModel(),\r\n isVisibleNotificationAddEditDDialog: false,\r\n currrentUserNotification: new UserNotificationModel(),\r\n isVisibleConfirmDialog: false,\r\n isActivePushNotifications: false,\r\n isVisibleNotificationConfirm: false,\r\n newUserNotification: new UserNotificationModel()\r\n }\r\n }\r\n\r\n componentDidMount() {\r\n this.getMedicineNotifications(this.props.userMedicineHistoryId)\r\n }\r\n\r\n setCurrentMedicineHistory(currentMedicineHistory: UserMedicineHistoryModel) {\r\n this.setState({ currentMedicineHistory: { ...currentMedicineHistory } });\r\n }\r\n\r\n getMedicineNotifications = (userMedicineHistoryId) => {\r\n if (!userMedicineHistoryId) {\r\n this.growl.show({ severity: 'error', summary: \"MedicneID not valid\" });\r\n } else {\r\n this.setState({\r\n isLoading: true\r\n });\r\n this.userService.getHistoryNotifications(userMedicineHistoryId, this.props.lang)\r\n .then(\r\n (data: UserMedicineHistoryModel) => {\r\n this.setCurrentMedicineHistory(data);\r\n this.setState({\r\n isLoading: false\r\n });\r\n this.userHasPushSubscription();\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n }\r\n }\r\n\r\n handleCloseButton = () => {\r\n this.props.closeClick();\r\n }\r\n\r\n showUserNotificationDialog = (show: boolean) => {\r\n this.setState({\r\n isVisibleNotificationAddEditDDialog: show\r\n });\r\n }\r\n\r\n handleUserNotificationAddClick = () => {\r\n let theNextHour: Date = new Date();\r\n theNextHour.setHours(theNextHour.getHours() + 1, 0)\r\n let newUserNotification = new UserNotificationModel();\r\n newUserNotification.isSingleDailyOccurance = true;\r\n newUserNotification.isActive = true;\r\n newUserNotification.notificationScheduleTypeId = 1;\r\n newUserNotification.notificationAlarmTypeId = 2;\r\n newUserNotification.notificationFrequencyId = 2;\r\n newUserNotification.notificationFrequencyCounter = 1;\r\n newUserNotification.userMedicineHistoryId = this.state.currentMedicineHistory.userMedicineHistoryId;\r\n newUserNotification.userId = this.state.currentMedicineHistory.userId;\r\n newUserNotification.timeZoneOffsetInMinutes = (new Date()).getTimezoneOffset();\r\n\r\n newUserNotification.alarmTime = theNextHour.toUTCString();\r\n newUserNotification.oneTimeExecutionDate = theNextHour.toUTCString();\r\n\r\n // let netificationStartDate = this.state.currentMedicineHistory.startDate;\r\n // if (netificationStartDate) {\r\n // newUserNotification.startDate = fomatDateTimeAsString(new Date(fomatDateAsString(new Date(netificationStartDate)) + \" \" + fomatTimeAsString(new Date())));\r\n // } else {\r\n // newUserNotification.startDate = new Date().toUTCString();\r\n // }\r\n\r\n // if (this.state.currentMedicineHistory.endDate) {\r\n // newUserNotification.endDate = new Date(this.state.currentMedicineHistory.endDate).toUTCString();\r\n // } else {\r\n // newUserNotification.endDate = new Date().toUTCString();\r\n // }\r\n\r\n // newUserNotification.startTime = fomatDateTimeAsString(new Date(fomatDateAsString(new Date(newUserNotification.startDate)) + \" 00:00:00\"));\r\n // newUserNotification.endTime = fomatDateTimeAsString(new Date(fomatDateAsString(new Date(newUserNotification.startDate)) + \" 23:59:59\"));\r\n\r\n this.setState({\r\n currrentUserNotification: newUserNotification,\r\n isVisibleNotificationAddEditDDialog: true\r\n });\r\n }\r\n\r\n handleUserNotificationDialogCancelButton = () => {\r\n this.setState({\r\n isVisibleNotificationAddEditDDialog: false\r\n });\r\n }\r\n\r\n userHasPushSubscription() {\r\n navigator.serviceWorker.getRegistration().then((registration: any) => {\r\n if (registration) {\r\n registration.pushManager.getSubscription()\r\n .then(subscription => {\r\n if (subscription) {\r\n this.setState({\r\n isActivePushNotifications: true\r\n });\r\n }\r\n });\r\n }\r\n });\r\n }\r\n\r\n subscribeForPushNotifications() {\r\n this.setState({ isVisibleNotificationConfirm: false });\r\n\r\n const pushIsSupported: boolean = 'serviceWorker' in navigator && 'PushManager' in window;\r\n\r\n if (!pushIsSupported)\r\n return;\r\n\r\n let applicationServerPublicKey = HelperFunctions.urlB64ToUint8Array(Constants.applicationServerPublicKey);\r\n navigator.serviceWorker.getRegistration()\r\n .then((registration: any) => {\r\n if (registration) {\r\n registration.pushManager.getSubscription()\r\n .then(subscription => {\r\n if (subscription) {\r\n // subscription present, no need to register subscription again\r\n this.growl.show({ severity: 'success', summary: Translate('You have already subscribed for Notifications.') });\r\n this.setState({\r\n isLoading: false\r\n });\r\n return;\r\n }\r\n\r\n registration.pushManager.subscribe({\r\n userVisibleOnly: true,\r\n applicationServerKey: applicationServerPublicKey\r\n })\r\n .then(subscription => {\r\n this.userService.createPushSubscription(subscription)\r\n .then((data: any) => {\r\n if (data) {\r\n this.setState({\r\n isActivePushNotifications: true,\r\n isLoading: false\r\n });\r\n this.growl.show({ severity: 'success', summary: Translate('You have successfully subscribed for Notifications.') });\r\n }\r\n })\r\n .catch(error => this.catchErrorFailedToSubscribe(error));\r\n })\r\n .catch(error => this.catchErrorFailedToSubscribe(error));\r\n })\r\n .catch(error => this.catchErrorFailedToSubscribe(error));\r\n } else {\r\n this.catchErrorFailedToSubscribe({ message: '' })\r\n }\r\n });\r\n }\r\n\r\n catchErrorFailedToSubscribe = (error) => {\r\n this.setState({\r\n isLoading: false\r\n });\r\n this.growl.show({ severity: 'error', summary: Translate('Failed to subscribe for Push Notifications:') + error.message });\r\n }\r\n\r\n handleUserNotificationAddDialogSaveButton = (userNotification: UserNotificationModel) => {\r\n this.showUserNotificationDialog(false);\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n const currentMedicineHistory: UserMedicineHistoryModel = { ...this.state.currentMedicineHistory };\r\n\r\n if (!userNotification.userNotificationId) {\r\n this.userService.addNotification(userNotification, this.props.lang)\r\n .then(\r\n (data) => {\r\n this.growl.show({ severity: 'success', summary: Translate('Data Saved Successfully') });\r\n this.getMedicineNotifications(currentMedicineHistory.userMedicineHistoryId);\r\n if (userNotification.notificationAlarmTypeId == NotificationAlarmType.PushNotification && !this.state.isActivePushNotifications) {\r\n this.setState({\r\n isVisibleNotificationConfirm: true,\r\n newUserNotification: { ...userNotification }\r\n });\r\n }\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n } else {\r\n this.growl.show({ severity: 'error', summary: \"EROR in save button\" });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n\r\n }\r\n\r\n handleNotificationActivationButton = (userNotification: UserNotificationModel, isActive: boolean) => {\r\n const currentMedicineHistory: UserMedicineHistoryModel = { ...this.state.currentMedicineHistory };\r\n\r\n if (userNotification && userNotification.userNotificationId > 0) {\r\n this.userService.updateNotification(userNotification.userNotificationId, isActive)\r\n .then(\r\n (data) => {\r\n this.growl.show({ severity: 'success', summary: Translate('Data Saved Successfully') });\r\n this.getMedicineNotifications(currentMedicineHistory.userMedicineHistoryId);\r\n if (userNotification.notificationAlarmTypeId == NotificationAlarmType.PushNotification && !this.state.isActivePushNotifications && isActive) {\r\n this.setState({\r\n isVisibleNotificationConfirm: true,\r\n newUserNotification: { ...userNotification }\r\n });\r\n }\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n } else {\r\n this.growl.show({ severity: 'error', summary: \"EROR in active/deactive button\" });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n this.showUserNotificationDialog(false);\r\n }\r\n\r\n handleNotificationDeleteClick = (event, userNotificationId) => {\r\n event.preventDefault();\r\n let userNotification = this.state.currentMedicineHistory.userNotifications.find(m => m.userNotificationId === userNotificationId);\r\n if (userNotification) {\r\n this.setState({\r\n currrentUserNotification: userNotification\r\n });\r\n }\r\n this.setState({\r\n isVisibleConfirmDialog: true\r\n });\r\n }\r\n\r\n deleteNotification = (userNotificationId) => {\r\n this.setState({\r\n isVisibleConfirmDialog: false,\r\n isLoading: true\r\n });\r\n\r\n if (userNotificationId) {\r\n this.userService.deleteNotification(userNotificationId)\r\n .then(\r\n (data) => {\r\n this.growl.show({ severity: 'success', summary: Translate('Deleted Successfully') });\r\n this.getMedicineNotifications(this.state.currentMedicineHistory.userMedicineHistoryId);\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n }\r\n else {\r\n this.growl.show({ severity: 'error', summary: \"Delete failed\" });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n }\r\n\r\n render() {\r\n const { currentMedicineHistory, currrentUserNotification, isLoading } = this.state;\r\n\r\n let dialogHeader: string = Translate('Alarms');\r\n let contentHeader = Translate('Alarms') + \" \" + Translate('for') + \" \" + Translate('medicine')\r\n + \" \" + ((currentMedicineHistory && currentMedicineHistory.medicineName) ? currentMedicineHistory.medicineName : \"\");\r\n\r\n return (\r\n <>\r\n \r\n {this.state.isVisibleNotificationAddEditDDialog ? (\r\n \r\n ) : null}\r\n\r\n { this.deleteNotification(currrentUserNotification.userNotificationId) }}\r\n noClick={() => { this.setState({ isVisibleConfirmDialog: false }) }}>\r\n {Translate(\"Are you sure that you want to delete this record\")}\r\n \r\n\r\n { this.subscribeForPushNotifications() }}\r\n noClick={() => { this.setState({ isVisibleNotificationConfirm: false }) }}>\r\n {Translate(\"Do you want to activate notification on this device\")}\r\n \r\n >\r\n )\r\n }\r\n}\r\n\r\nexport default UserNotificationListDialog;\r\n","import { UserMedicineHistoryModel } from './userMedicineHistoryModel';\r\nimport { UserMedicineModel } from './userMedicineModel';\r\n\r\nexport class UserMedicineWithHistoryWrapper {\r\n userMedicine: UserMedicineModel;\r\n userMedicineHistory: UserMedicineHistoryModel;\r\n}","export class UserMedicineSettingsModel {\r\n public medicineName: string;\r\n public startDate: string;\r\n public endDate: string;\r\n}","import * as React from 'react';\r\n\r\nconst expandedList = (props) => {\r\n return (\r\n \r\n\r\n )\r\n}\r\n\r\nexport default expandedList;\r\n","import * as React from \"react\";\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport Translate from '../../../common/functions/translate';\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport UserService from '../../../services/userService';\r\nimport AuthService from '../../../services/authService';\r\nimport { UserMedicineModel } from '../../../models/user/userMedicineModel';\r\n//import { UserMedicineGridModel } from '../../../models/user/userMedicineGridModel';\r\nimport UserMedicinesList from './userMedicinesList';\r\nimport UserMedicineHistoryDialog from './userMedicineHistoryDialog';\r\nimport ConfirmDialog from '../../../common/components/confirmDialog/confirmDialog';\r\nimport MedicineSearchDialog from './medicineSearchDialog';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faBell, faCheckCircle, faPills, faCalendarAlt, faPrescription, faChevronUp, faChevronDown } from '@fortawesome/free-solid-svg-icons';\r\nimport { connect } from 'react-redux';\r\nimport Fab from '@material-ui/core/Fab';\r\nimport AddIcon from '@material-ui/icons/Add';\r\nimport HistoryIcon from '@material-ui/icons/History';\r\nimport CSSTransition from 'react-transition-group/CSSTransition';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport Badge from '@material-ui/core/Badge';\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport { UserMedicineHistoryWrapperModel } from '../../../models/user/userMedicineHistoryWrapperModel';\r\nimport { UserMedicineHistoryModel } from '../../../models/user/userMedicineHistoryModel';\r\nimport UserMedicineHistoryAddEditDialog from './userMedicineHistoryAddEditDialog';\r\nimport UserNotificationListDialog from '../userNotification/userNotificationListDialog';\r\nimport { UserMedicineWithHistoryWrapper } from \"../../../models/user/userMedicineWithHistoryWrapper\";\r\nimport { UserMedicineSettingsModel } from '../../../models/user/userMedicineSettingsModel';\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport Button from '@material-ui/core/Button';\r\nimport { faTimes, faFilter } from '@fortawesome/free-solid-svg-icons';\r\nimport { MuiPickersUtilsProvider, DatePicker } from '@material-ui/pickers';\r\nimport DateFnsUtils from '@date-io/date-fns';\r\nimport Checkbox from '@material-ui/core/Checkbox';\r\nimport { MuiThemeProvider, createMuiTheme } from '@material-ui/core';\r\nimport * as Constants from '../../../common/constants';\r\nimport blue from '@material-ui/core/colors/blue';\r\nimport { DropdownModel } from \"../../../models/dropdownModel\";\r\nimport Select from '@material-ui/core/Select';\r\nimport FormControl from '@material-ui/core/FormControl';\r\nimport MenuItem from '@material-ui/core/MenuItem';\r\nimport InputLabel from '@material-ui/core/InputLabel';\r\nimport { TimePresetType } from \"../../../common/enums\";\r\nimport ExpandingList from '../../../common/components/expandingList/expandingList';\r\nimport { AuthorisationStatus } from '../../../common/enums';\r\n\r\nexport const smallDialogTheme = createMuiTheme({\r\n overrides: {\r\n MuiFormControl: {\r\n marginNormal: {\r\n marginTop: 5,\r\n marginBottom: 0,\r\n width: '90% !important'\r\n },\r\n root: {\r\n width: '100% !important'\r\n }\r\n },\r\n MuiDialog: {\r\n paper: {\r\n margin: 0,\r\n maxWidth: '350px !important',\r\n minWidth: '335px'\r\n }\r\n }\r\n },\r\n palette: {\r\n primary: blue\r\n },\r\n});\r\n\r\ninterface IProps {\r\n history: any;\r\n userId: number;\r\n lang: string;\r\n location: any;\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n validationMessage: string;\r\n userId: number;\r\n currentUserMedicine: UserMedicineModel;\r\n userMedicines: Array\r\n isVisibleConfirmDialog: boolean;\r\n deleteValidationMessage: string;\r\n isVisibleSearchMedicineDialog: boolean;\r\n searchDialogError: any;\r\n expandedMedicine: Array;\r\n first: number;\r\n rows: number;\r\n totalRecords: number;\r\n activeUserMedicineCount: number;\r\n userName: string;\r\n selectedMedicineHistory: UserMedicineHistoryModel;\r\n isVisibleUserNotificationListDialog: boolean;\r\n isVisibleUserMedicineHistoryAddEditDialog: boolean;\r\n isAddHistory: boolean;\r\n medicineSettings: UserMedicineSettingsModel,\r\n isVisiblefilters: boolean;\r\n currentFilterSettings: UserMedicineSettingsModel\r\n filterByDates: boolean;\r\n timeDropdown: Array;\r\n selectedTime: number;\r\n canChooseDates: boolean;\r\n isMyFamily: boolean;\r\n}\r\n\r\nclass UserMedicinesComponent extends React.Component {\r\n userService = new UserService();\r\n authService = new AuthService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n validationMessage: '',\r\n isLoading: false,\r\n userId: this.props.userId ? this.props.userId : 0,\r\n currentUserMedicine: new UserMedicineModel(),\r\n userMedicines: new Array(0),\r\n isVisibleConfirmDialog: false,\r\n deleteValidationMessage: '',\r\n isVisibleSearchMedicineDialog: false,\r\n searchDialogError: null,\r\n expandedMedicine: new Array(),\r\n first: 0,\r\n rows: 20,\r\n totalRecords: 0,\r\n activeUserMedicineCount: 0,\r\n userName: '',\r\n selectedMedicineHistory: new UserMedicineHistoryModel(),\r\n isVisibleUserNotificationListDialog: false,\r\n isVisibleUserMedicineHistoryAddEditDialog: false,\r\n isAddHistory: false,\r\n medicineSettings: new UserMedicineSettingsModel(),\r\n isVisiblefilters: false,\r\n currentFilterSettings: new UserMedicineSettingsModel(),\r\n filterByDates: false,\r\n timeDropdown: Array(0),\r\n selectedTime: 1,\r\n canChooseDates: false,\r\n isMyFamily: false\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n window.addEventListener('scroll', this.onScroll);\r\n\r\n let tabName = HelperFunctions.getURLParameter('tabName');\r\n\r\n if (tabName && tabName == 'Family' && (this.props.history.action === \"PUSH\" || this.props.history.action === \"POP\")) {\r\n let userId = HelperFunctions.getURLParameter('userId');\r\n let userName = HelperFunctions.getURLParameter('userName');\r\n\r\n let numUser: number = userId ? parseInt(userId + '') : 0;\r\n this.setState({ userId: numUser, userName: userName + '', isMyFamily: true }, () => this.getAllUserMedicines(true));\r\n }\r\n else {\r\n this.setState({ userId: this.authService.getUserId(), userName: '', first: 0, isMyFamily: false }, () => this.getAllUserMedicines(true));\r\n }\r\n }\r\n\r\n componentWillUnmount() {\r\n window.removeEventListener('scroll', this.onScroll);\r\n }\r\n\r\n\r\n componentDidUpdate(prevProps) {\r\n\r\n let tabName = HelperFunctions.getURLParameter('tabName');\r\n\r\n if (tabName && tabName == 'Family' && (this.props.history.action === \"PUSH\" || this.props.history.action === \"POP\") && !this.state.isMyFamily) {\r\n let userId = HelperFunctions.getURLParameter('userId');\r\n let userName = HelperFunctions.getURLParameter('userName');\r\n\r\n let numUser: number = userId ? parseInt(userId + '') : 0;\r\n this.setState({ userId: numUser, userName: userName + '', isMyFamily: true }, () => this.getAllUserMedicines(true));\r\n }\r\n if ((!tabName || tabName == '') && this.state.isMyFamily) {\r\n this.setState({ userId: this.authService.getUserId(), userName: '', first: 0, isMyFamily: false }, () => this.getAllUserMedicines(true));\r\n }\r\n\r\n }\r\n\r\n onScroll = () => {\r\n let scrollY = window.scrollY ? window.scrollY : window.pageYOffset;\r\n if (window.innerHeight + scrollY >= document.body.offsetHeight - 250 &&\r\n this.state.totalRecords > this.state.userMedicines.length && !this.state.isLoading) {\r\n this.paginatorClick({ first: this.state.first + this.state.rows }, false);\r\n }\r\n };\r\n\r\n paginatorClick = (e, isInit: boolean) => {\r\n this.setState({ first: e.first }, () => this.getAllUserMedicines(isInit));\r\n }\r\n\r\n getAllUserMedicines(isInit: boolean) {\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n if (this.authService.isAuthenticated()) {\r\n let userId = this.state.userId ? this.state.userId : this.authService.getUserId();\r\n let settings: UserMedicineSettingsModel = new UserMedicineSettingsModel();\r\n if (this.state.currentFilterSettings) {\r\n if (this.state.filterByDates && this.state.currentFilterSettings.startDate) {\r\n settings.startDate = HelperFunctions.fomatDateTimeAsString(new Date(this.state.currentFilterSettings.startDate));\r\n }\r\n\r\n if (this.state.filterByDates && this.state.currentFilterSettings.endDate) {\r\n settings.endDate = HelperFunctions.fomatDateTimeAsString(new Date(this.state.currentFilterSettings.endDate));\r\n }\r\n\r\n if (this.state.currentFilterSettings.medicineName && this.state.currentFilterSettings.medicineName.trim() != '') {\r\n settings.medicineName = this.state.currentFilterSettings.medicineName;\r\n }\r\n }\r\n this.userService.getAllUserMedicinesWithHistory(userId, this.state.first, this.state.rows, this.props.lang, settings).then(\r\n (data: any) => {\r\n if (data) {\r\n if (isInit) {\r\n this.setState({\r\n isLoading: false,\r\n userMedicines: [...data.userMedicineHistory],\r\n totalRecords: data.totalRecords,\r\n activeUserMedicineCount: data.activeUserMedicineCount,\r\n userId: userId\r\n });\r\n }\r\n else {\r\n this.setState({\r\n isLoading: false,\r\n userMedicines: [...this.state.userMedicines, ...data.userMedicineHistory],\r\n totalRecords: data.totalRecords,\r\n userId: userId\r\n });\r\n }\r\n }\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n }\r\n\r\n setCurrentUserMedicine(currentUserMedicine: UserMedicineModel) {\r\n this.setState({ currentUserMedicine: { ...currentUserMedicine } });\r\n }\r\n\r\n handleUserMedicineDeleteClick = (medHistory: UserMedicineHistoryModel) => {\r\n let message: string = Translate(\"Are you sure that you want to delete this record\");\r\n if (medHistory.prescriptionDoctor && medHistory.prescriptionDoctor.trim() != '') {\r\n message = Translate(\"This medicine is attached to prescription\") + \": \" +\r\n medHistory.prescriptionDoctor + '. ' + Translate(\"Are you sure that you want to delete this record\");\r\n }\r\n this.setState({\r\n isVisibleConfirmDialog: true,\r\n deleteValidationMessage: message,\r\n selectedMedicineHistory: medHistory\r\n });\r\n }\r\n\r\n deleteUserMedicine(medicineId: number, medhistoryId: number) {\r\n this.setState({\r\n isVisibleConfirmDialog: false,\r\n isLoading: true\r\n });\r\n\r\n this.userService.deleteUserMedicine(this.state.userId, medicineId, medhistoryId)\r\n .then(\r\n data => {\r\n this.growl.show({ severity: 'success', summary: Translate('Deleted Successfully') });\r\n this.setState({ first: 0, selectedMedicineHistory: new UserMedicineHistoryModel() }, () => this.getAllUserMedicines(true));\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: Translate(error.message) });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n handleUserMedicineHistoryClick = (medicineId, userMedHistory: UserMedicineHistoryModel) => {\r\n this.setState({\r\n isLoading: true\r\n });\r\n let userId = this.state.userId ? this.state.userId : this.authService.getUserId();\r\n this.userService.getUserMedicine(userId, medicineId, this.props.lang)\r\n .then(\r\n (data: UserMedicineModel) => {\r\n this.setCurrentUserMedicine(data);\r\n this.setState({\r\n isLoading: false,\r\n isVisibleUserMedicineHistoryAddEditDialog: true,\r\n validationMessage: '',\r\n selectedMedicineHistory: userMedHistory,\r\n isAddHistory: false\r\n });\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: Translate(error.message) });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n }\r\n\r\n handleUserMedicineInfoClick = (id) => {\r\n this.props.history.push(`${Constants.MedicinesUrl}/${id}`)\r\n }\r\n\r\n handleAddClick = () => {\r\n this.setState({\r\n isVisibleUserMedicineHistoryAddEditDialog: true,\r\n isAddHistory: true\r\n });\r\n }\r\n\r\n handleUserNotificationButtonClick = (userMedicineId) => {\r\n if (!userMedicineId) {\r\n this.growl.show({ severity: 'error', summary: \"UserMedicine ID is not valid\" });\r\n } else {\r\n let userMedicineHistory = this.state.userMedicines.find(d => d.userMedicineHistoryId === userMedicineId);\r\n if (userMedicineHistory) {\r\n this.setState({\r\n selectedMedicineHistory: userMedicineHistory\r\n }, () => this.showUserNotificationListDialog(true));\r\n } else {\r\n console.log(\"EROR\")\r\n }\r\n }\r\n }\r\n\r\n showUserNotificationListDialog = (show: boolean) => {\r\n this.setState({\r\n isVisibleUserNotificationListDialog: show\r\n });\r\n }\r\n\r\n handleUserNotificationListDialogCloseButton = () => {\r\n this.setState({\r\n first: 0,\r\n isVisibleUserNotificationListDialog: false,\r\n selectedMedicineHistory: new UserMedicineHistoryModel()\r\n }, () => this.getAllUserMedicines(true));\r\n }\r\n\r\n handleHistoryAddButton = (currentUserMedicineHistory: UserMedicineHistoryModel, userMedicine: UserMedicineModel, close: boolean) => {\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n let medWrapp: UserMedicineWithHistoryWrapper = new UserMedicineWithHistoryWrapper();\r\n medWrapp.userMedicine = userMedicine;\r\n medWrapp.userMedicineHistory = currentUserMedicineHistory;\r\n if (!medWrapp.userMedicine.userId || medWrapp.userMedicine.userId == 0) {\r\n medWrapp.userMedicine.userId = this.state.userId;\r\n }\r\n this.userService.addUserMedicine(medWrapp)\r\n .then(\r\n (data) => {\r\n this.growl.show({ severity: 'success', summary: Translate('Data Saved Successfully') });\r\n this.handleUserMedicineHistoryCancelClick();\r\n this.setState({ first: 0 }, () => this.getAllUserMedicines(true));\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: Translate(error.message) });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n handleHistoryUpdateButton = (currentUserMedicineHistory: UserMedicineHistoryModel, close: boolean) => {\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n this.userService.updateMedicineHistory(currentUserMedicineHistory)\r\n .then(\r\n (data) => {\r\n this.growl.show({ severity: 'success', summary: Translate('Data Saved Successfully') });\r\n this.setState({ first: 0 }, () => this.getAllUserMedicines(true));\r\n this.handleUserMedicineHistoryCancelClick();\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: Translate(error.message) });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n expanedData = (rowData: UserMedicineHistoryModel) => {\r\n return (\r\n {/* \r\n \r\n */}\r\n\r\n \r\n \r\n \r\n \r\n
)\r\n }\r\n\r\n rowExpansionTemplate = (rowData: UserMedicineHistoryModel) => {\r\n return (\r\n r.userMedicineHistoryId == rowData.userMedicineHistoryId)}\r\n timeout={300} classNames=\"list-slide\" mountOnEnter unmountOnExit>\r\n {this.expanedData(rowData)}\r\n \r\n );\r\n }\r\n\r\n expandData = (data: UserMedicineHistoryModel) => {\r\n if (!this.state.expandedMedicine.some(r => r.userMedicineHistoryId == data.userMedicineHistoryId) ||\r\n this.state.expandedMedicine.length == 0) {\r\n this.setState({ expandedMedicine: [...this.state.expandedMedicine, data] });\r\n } else {\r\n this.setState({ expandedMedicine: this.state.expandedMedicine.filter(r => r.userMedicineHistoryId != data.userMedicineHistoryId) });\r\n }\r\n }\r\n\r\n handleUserMedicineHistoryCancelClick = () => {\r\n this.setState({\r\n isVisibleUserMedicineHistoryAddEditDialog: false,\r\n selectedMedicineHistory: new UserMedicineHistoryModel()\r\n });\r\n }\r\n\r\n handleFilterChange = (key, value) => {\r\n const userFilter: UserMedicineSettingsModel = { ...this.state.medicineSettings };\r\n userFilter[key] = value;\r\n this.setState({ medicineSettings: { ...userFilter }, first: 0 })\r\n };\r\n\r\n clearFilters = (e) => {\r\n if (e) {\r\n e.preventDefault();\r\n }\r\n this.setState({\r\n isVisiblefilters: false, currentFilterSettings: new UserMedicineSettingsModel(),\r\n medicineSettings: new UserMedicineSettingsModel(), selectedTime: 1, filterByDates: false\r\n }, () => this.getAllUserMedicines(true));\r\n }\r\n\r\n handleFilter = (e) => {\r\n e.preventDefault();\r\n let filters = { ...this.state.medicineSettings };\r\n if (!filters.startDate) {\r\n filters.startDate = HelperFunctions.getDaysEarlier(new Date().toString(), 1).toISOString();\r\n }\r\n if (!filters.endDate) {\r\n filters.endDate = new Date().toISOString();\r\n }\r\n this.setState({ isVisiblefilters: false, currentFilterSettings: filters, filterByDates: true }, () => this.getAllUserMedicines(true));\r\n }\r\n\r\n getMonthEarlier = (currentDate: string) => {\r\n let d = new Date(currentDate);\r\n d.setMonth(d.getMonth() - 1);\r\n return d;\r\n }\r\n\r\n filterClick = () => {\r\n let currentSettings: UserMedicineSettingsModel = new UserMedicineSettingsModel();\r\n let startDate: boolean = false;\r\n let endDate: boolean = false;\r\n if (this.state.currentFilterSettings &&\r\n (this.state.currentFilterSettings.endDate || this.state.currentFilterSettings.startDate || this.state.currentFilterSettings.medicineName)) {\r\n currentSettings = { ...this.state.currentFilterSettings };\r\n }\r\n\r\n let timeDr = new Array(0);\r\n timeDr = HelperFunctions.enumToDropdownArray(TimePresetType, true);\r\n\r\n this.setState({ isVisiblefilters: true, medicineSettings: { ...currentSettings }, timeDropdown: timeDr });\r\n }\r\n\r\n getFiltersummary = () => {\r\n let nameSet: any = null;\r\n let startSet: any = null;\r\n let endSet: any = null;\r\n\r\n if (this.state.currentFilterSettings && this.state.currentFilterSettings.medicineName) {\r\n nameSet =\r\n <>\r\n {Translate('Medicine')}:\r\n {this.state.currentFilterSettings.medicineName} \r\n >\r\n }\r\n\r\n if (this.state.currentFilterSettings && this.state.currentFilterSettings.startDate) {\r\n startSet =\r\n <>\r\n {Translate('From')}:\r\n {HelperFunctions.fomatDateAsStringWithLang(new Date(this.state.currentFilterSettings.startDate), this.props.lang)} \r\n >\r\n }\r\n\r\n if (this.state.currentFilterSettings && this.state.currentFilterSettings.endDate) {\r\n endSet =\r\n <>\r\n {Translate('To')}:\r\n {HelperFunctions.fomatDateAsStringWithLang(new Date(this.state.currentFilterSettings.endDate), this.props.lang)} \r\n >\r\n }\r\n\r\n let summary =\r\n \r\n {nameSet}\r\n {startSet}\r\n {endSet}\r\n
\r\n\r\n return summary;\r\n }\r\n\r\n handleTimeDropdownChange = (id) => {\r\n let filters = { ...this.state.medicineSettings };\r\n let canChooseDates = false;\r\n switch (id) {\r\n case TimePresetType.OneDay:\r\n filters.startDate = HelperFunctions.getDaysEarlier(new Date().toString(), 1).toISOString();\r\n filters.endDate = new Date().toISOString();\r\n canChooseDates = false;\r\n break;\r\n case TimePresetType.OneWeek:\r\n filters.startDate = HelperFunctions.getDaysEarlier(new Date().toString(), 7).toISOString();\r\n filters.endDate = new Date().toISOString();\r\n canChooseDates = false;\r\n break;\r\n case TimePresetType.OneMonth:\r\n filters.startDate = HelperFunctions.getMonthsEarlier(new Date().toString(), 1).toISOString();\r\n filters.endDate = new Date().toISOString();\r\n canChooseDates = false;\r\n break;\r\n case TimePresetType.ThreeMonths:\r\n filters.startDate = HelperFunctions.getMonthsEarlier(new Date().toString(), 3).toISOString();\r\n filters.endDate = new Date().toISOString();\r\n canChooseDates = false;\r\n break;\r\n case TimePresetType.SixMonths:\r\n filters.startDate = HelperFunctions.getMonthsEarlier(new Date().toString(), 6).toISOString();\r\n filters.endDate = new Date().toISOString();\r\n canChooseDates = false;\r\n break;\r\n case TimePresetType.OneYear:\r\n filters.startDate = HelperFunctions.getMonthsEarlier(new Date().toString(), 12).toISOString();\r\n filters.endDate = new Date().toISOString();\r\n canChooseDates = false;\r\n break;\r\n case TimePresetType.Advanced:\r\n canChooseDates = true;\r\n }\r\n this.setState({ selectedTime: id, medicineSettings: filters, canChooseDates: canChooseDates });\r\n }\r\n\r\n goToPrescriptions = (e, perscriptionId) => {\r\n e.preventDefault();\r\n this.props.history.push(`${Constants.PrescriptionUrl}?perscriptionId=${perscriptionId}`);\r\n }\r\n\r\n keyItem = (item: UserMedicineHistoryModel) => {\r\n return item.userMedicineHistoryId + \"medId\";\r\n }\r\n\r\n itemName = (item: UserMedicineHistoryModel) => {\r\n let today = HelperFunctions.fomatDateAsString(new Date());\r\n return (\r\n <>\r\n {new Date(item.startDate ? item.startDate.substr(0, 10) : '') <= new Date(today) && new Date(item.endDate ? item.endDate.substr(0, 10) : '') >= new Date(today) ?\r\n : null}\r\n {item.medicineName ? item.medicineName : null}\r\n {item.authorisationStatus > 0 && item.authorisationStatus != AuthorisationStatus.Authorised ?\r\n - {HelperFunctions.getEnumLabel(item.authorisationStatus, AuthorisationStatus, true)} : null}\r\n >)\r\n }\r\n\r\n itemDesc = (item: UserMedicineHistoryModel) => {\r\n return (\r\n <>\r\n \r\n \r\n {HelperFunctions.fomatDatesStringWithLang(new Date(item.startDate ? item.startDate : ''), this.props.lang) + \" - \"}\r\n {HelperFunctions.fomatDatesStringWithLang(new Date(item.endDate ? item.endDate : ''), this.props.lang)}\r\n
\r\n \r\n
\r\n {Translate('Alarms')}\r\n
\r\n {item.notificationsCount ? item.notificationsCount : '0'}\r\n
\r\n
\r\n {item.prescriptionDoctor && item.prescriptionDoctor.trim() != '' ?\r\n : null}\r\n >\r\n )\r\n }\r\n\r\n itemActions = (item: UserMedicineHistoryModel) => {\r\n return (\r\n <>\r\n {window.innerWidth >= Constants.device.tablet ? this.expanedData(item) :\r\n\r\n this.state.expandedMedicine.some(r => r.userMedicineHistoryId == item.userMedicineHistoryId) ?\r\n \r\n : \r\n }\r\n >\r\n )\r\n }\r\n\r\n public render() {\r\n const { isLoading, userMedicines, totalRecords, activeUserMedicineCount, currentFilterSettings, selectedMedicineHistory, isVisibleSearchMedicineDialog,\r\n searchDialogError, expandedMedicine, timeDropdown, selectedTime, medicineSettings } = this.state;\r\n\r\n let userName = HelperFunctions.getURLParameter('userName');\r\n let showAllLink = false;\r\n if ((currentFilterSettings.medicineName && currentFilterSettings.medicineName.trim() != '') || currentFilterSettings.startDate || currentFilterSettings.endDate) {\r\n showAllLink = true\r\n }\r\n return (\r\n \r\n
this.growl = el} />\r\n\r\n <>\r\n {userName ?\r\n <>\r\n {Translate('Medicines of')}:
\r\n {userName}
\r\n >\r\n : {Translate('My Medicines')}
}\r\n this.handleAddClick()} className=\"floating-action-button\">\r\n \r\n \r\n this.filterClick()} className=\"floating-action-button-second\">\r\n \r\n \r\n\r\n {!isLoading && userMedicines && userMedicines.length > 0 ?\r\n \r\n {totalRecords} {Translate('total records.')}
\r\n {activeUserMedicineCount} {Translate('current medicine history.')}\r\n {activeUserMedicineCount > 0 ?\r\n \r\n : null}\r\n
: null}\r\n\r\n {currentFilterSettings && (currentFilterSettings.medicineName || currentFilterSettings.startDate || currentFilterSettings.endDate) ?\r\n <>\r\n {Translate('Filters') + \":\"}
\r\n {this.getFiltersummary()}\r\n >\r\n : null}\r\n\r\n {showAllLink ?\r\n : null}\r\n\r\n\r\n \r\n\r\n\r\n {/* */}\r\n {isLoading ? : null}\r\n {!isLoading && (!userMedicines || userMedicines.length == 0) ? Translate(\"No records found\") : null}\r\n >\r\n\r\n { this.deleteUserMedicine(selectedMedicineHistory.medicineId, selectedMedicineHistory.userMedicineHistoryId) }}\r\n noClick={() => { this.setState({ isVisibleConfirmDialog: false, deleteValidationMessage: '', selectedMedicineHistory: new UserMedicineHistoryModel() }) }}>\r\n {this.state.deleteValidationMessage}\r\n {/* Are you sure that you want to delete \r\n {currentUserMedicine.medicine\r\n ? [currentUserMedicine.medicine.brandName, currentUserMedicine.medicine.additionalTitle].filter(Boolean).join(' / ')\r\n : \"this record\"}? */}\r\n \r\n\r\n {this.state.isVisibleUserNotificationListDialog ? (\r\n ) : null}\r\n\r\n {this.state.isVisibleUserMedicineHistoryAddEditDialog ? (\r\n \r\n ) : null}\r\n\r\n \r\n \r\n )\r\n }\r\n}\r\n\r\nconst mapsStateToProps = state => {\r\n return {\r\n lang: state.common.lang\r\n };\r\n}\r\n\r\nexport default connect(mapsStateToProps)(UserMedicinesComponent);","import { DiseaseForGridModel } from '../diseaseForGridModel';\r\nimport { UserDiseaseHistoryModel } from './userDiseaseHistoryModel';\r\n\r\nexport class UserDiseaseModel {\r\n public userId: number;\r\n public disease: DiseaseForGridModel;\r\n public userDiseaseHistory: Array;\r\n}","export class UserDiseaseHistoryModel {\r\n public userDiseaseHistoryId: number;\r\n public userId: number;\r\n public diseaseId: number;\r\n public diseaseCode: string;\r\n public diseaseName: string;\r\n public startDate?: string;\r\n public endDate?: string;\r\n public diseaseTypeId?: number;\r\n public comments: string;\r\n public prescriptionName: string;\r\n public isActive: boolean;\r\n public prescriptionDoctor: string;\r\n public prescriptionId: number;\r\n}","import { UserDiseaseModel } from './userDiseaseModel';\r\nimport { UserDiseaseHistoryModel } from './userDiseaseHistoryModel';\r\n\r\nexport class UserDiseaseWithHistoryModel {\r\n public userDisease: UserDiseaseModel;\r\n public userDiseaseHistory: UserDiseaseHistoryModel;\r\n}","import axios from 'axios';\r\nimport * as Constants from \"../common/constants\";\r\nimport * as HelperFunctions from '../common/functions/helperFunctions';\r\nimport { DiseaseFilterSettingsModel } from \"../models/\";\r\n\r\nclass DiseaseService {\r\n\r\n\tlang: string = '';\r\n\r\n\tconstructor(lang?) {\r\n\t\tthis.lang = lang;\r\n\t\taxios.defaults.baseURL = `${Constants.apiUrl}/`;\r\n\t\taxios.defaults.headers = {\r\n\t\t\t\"Content-Type\": \"application/json; charset=utf-8\",\r\n\t\t\tPragma: 'no-cache',\r\n\t\t\t\"langId\": HelperFunctions.getLangId(lang)\r\n\t\t}\r\n\t}\r\n\r\n\tgetAllDiseases(from: number, numberOfRows: number, settings: DiseaseFilterSettingsModel, lang: string) {\r\n\t\treturn axios({\r\n\t\t\turl: `disease/getAll/${from}/${numberOfRows}`,\r\n\t\t\tmethod: 'post',\r\n\t\t\theaders: {\r\n\t\t\t\t\"Content-Type\": \"application/json; charset=utf-8\",\r\n\t\t\t\t\"langId\": HelperFunctions.getLangId(lang)\r\n\t\t\t},\r\n\t\t\tdata: JSON.stringify(settings)\r\n\t\t})\r\n\t\t\t.then(res => res.data.data)\r\n\t\t\t.catch(error =>\r\n\t\t\t\tPromise.reject(HelperFunctions.getErrorMessage(error))\r\n\t\t\t)\r\n\t}\r\n\r\n}\r\n\r\nexport default DiseaseService;\r\n","import * as React from 'react';\r\nimport { Button } from \"primereact/button\";\r\nimport { InputText } from 'primereact/inputtext';\r\nimport { Toolbar } from 'primereact/toolbar';\r\nimport { DiseaseFilterSettingsModel } from \"../../../models/diseaseFilterSettingsModel\";\r\nimport AlphabeticalFilter from '../../../common/components/alphabeticalFilter/alphabeticalFilter';\r\nimport Translate from '../../../common/functions/translate';\r\n\r\ninterface IProps {\r\n onSearchClick: any,\r\n totalRecordsCount: number,\r\n lang: string\r\n onClearClick: any;\r\n}\r\n\r\ninterface IState {\r\n diseaseSettings: DiseaseFilterSettingsModel,\r\n selectedType: null,\r\n selectedGroup: null,\r\n filterText: string\r\n}\r\n\r\nexport class DiseaseFilter extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n diseaseSettings: new DiseaseFilterSettingsModel(),\r\n selectedType: null,\r\n selectedGroup: null,\r\n filterText: ''\r\n };\r\n }\r\n\r\n handleAlphaIndexChange = (e, letter: string) => {\r\n e.preventDefault();\r\n const currentSettings: DiseaseFilterSettingsModel = { ...this.state.diseaseSettings };\r\n currentSettings.diseaseName = '';\r\n currentSettings.alphaIndex = letter;\r\n const fiterText = this.generateFilterText(currentSettings);\r\n this.setState({\r\n diseaseSettings: { ...currentSettings },\r\n filterText: fiterText\r\n });\r\n this.handleSearchButtonClick(currentSettings);\r\n }\r\n\r\n handleChange = (event) => {\r\n const target = event.target;\r\n const value = target.type === 'checkbox' ? target.checked : target.value\r\n const name = target.name;\r\n\r\n const currentSettings: DiseaseFilterSettingsModel = { ...this.state.diseaseSettings };\r\n currentSettings[name] = value;\r\n const fiterText = this.generateFilterText(currentSettings);\r\n this.setState({\r\n diseaseSettings: { ...currentSettings },\r\n filterText: fiterText\r\n }, this.searchByName);\r\n }\r\n\r\n searchByName = () => {\r\n if (this.state.diseaseSettings && this.state.diseaseSettings.diseaseName && this.state.diseaseSettings.diseaseName.length >= 3) {\r\n this.handleSearchButtonClick(this.state.diseaseSettings)\r\n }\r\n }\r\n\r\n generateFilterText = (settings: DiseaseFilterSettingsModel) => {\r\n let result = '';\r\n\r\n if (settings.alphaIndex) {\r\n result += Translate(\"Start with\") + \" '\" + settings.alphaIndex + \"', \"\r\n }\r\n if (settings.diseaseName) {\r\n result += Translate(\"Name\") + \" '\" + settings.diseaseName + \"', \"\r\n }\r\n\r\n return result.substr(0, result.length - 2);\r\n }\r\n\r\n handleSearchButtonClick = (settings) => {\r\n this.props.onSearchClick(settings);\r\n }\r\n\r\n handleClearButtonClick = () => {\r\n this.setState({\r\n diseaseSettings: new DiseaseFilterSettingsModel(),\r\n filterText: ''\r\n });\r\n this.props.onClearClick();\r\n }\r\n\r\n handleKeyPress = (e) => {\r\n if (e.key === 'Enter') {\r\n this.handleSearchButtonClick(this.state.diseaseSettings)\r\n }\r\n }\r\n\r\n render() {\r\n return (\r\n \r\n
\r\n
\r\n this.handleKeyPress(e)}\r\n style={{ width: '100%' }}\r\n name=\"diseaseName\"\r\n placeholder={Translate('EnterDiseaseName')}\r\n onChange={this.handleChange}\r\n value={this.state.diseaseSettings && this.state.diseaseSettings.diseaseName ? this.state.diseaseSettings.diseaseName : ''}\r\n />\r\n
\r\n
\r\n
\r\n
{Translate('BrowseAlphabetically')}:\r\n
\r\n
\r\n
\r\n
\r\n {Translate('Result')}: {this.props.totalRecordsCount}\r\n {this.state.filterText ? ', ' : ''}\r\n \r\n
\r\n
\r\n
\r\n )\r\n }\r\n}\r\n\r\nexport default DiseaseFilter;\r\n","import * as React from 'react';\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faTrash, faPlus, faCheck, faTimes } from '@fortawesome/free-solid-svg-icons';\r\nimport DiseaseService from '../../../services/diseaseService';\r\nimport { DiseaseGridModel, DiseaseForGridModel, DiseaseFilterSettingsModel } from \"../../../models\";\r\nimport Translate from '../../../common/functions/translate';\r\nimport UserService from '../../../services/userService';\r\nimport DiseaseFilter from './diseaseFilter';\r\nimport Radio from '@material-ui/core/Radio';\r\nimport Paginator from '../../../common/components/paginator/paginator';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport { connect } from 'react-redux';\r\nimport { UserDiseaseModel } from '../../../models/user/userDiseaseModel';\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\n\r\ninterface IProps {\r\n isVisible: boolean,\r\n cancelClick: any,\r\n addClick: any,\r\n selectedDisease: DiseaseForGridModel,\r\n userId: number,\r\n lang: string,\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n from: number;\r\n numberOfRows: number;\r\n totalRecordsCount: number;\r\n diseases: Array\r\n currentDisease: DiseaseForGridModel;\r\n currentFilterSettings: DiseaseFilterSettingsModel;\r\n page: number;\r\n numberOfPages: number;\r\n}\r\n\r\nconst initFrom = 0;\r\nconst numberOfRows = 10;\r\n\r\nclass DiseaseListDialog extends React.Component {\r\n diseaseService = new DiseaseService(this.props.lang);\r\n userService = new UserService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n from: initFrom,\r\n numberOfRows: numberOfRows,\r\n totalRecordsCount: 0,\r\n diseases: new Array(),\r\n currentDisease: this.props.selectedDisease,\r\n currentFilterSettings: new DiseaseFilterSettingsModel(),\r\n page: 1,\r\n numberOfPages: 1\r\n }\r\n }\r\n\r\n componentDidMount() {\r\n //this.getAllFilteredItems(this.state.page, this.state.numberOfRows, this.state.currentFilterSettings);\r\n }\r\n\r\n getAllFilteredItems(page: number, numberOfRows: number, currentFilterSettings: DiseaseFilterSettingsModel) {\r\n let from = (page - 1) * this.state.numberOfRows;\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n this.diseaseService.getAllDiseases(from, numberOfRows, currentFilterSettings, this.props.lang).then(\r\n (data: DiseaseGridModel) => {\r\n this.setState({\r\n isLoading: false,\r\n from: from,\r\n diseases: data.diseases,\r\n totalRecordsCount: data.totalRecordsCount,\r\n numberOfPages: (data.totalRecordsCount % this.state.numberOfRows > 0 ?\r\n data.totalRecordsCount / this.state.numberOfRows + 1 : data.totalRecordsCount / this.state.numberOfRows)\r\n });\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n handleAddButton = event => {\r\n event.preventDefault();\r\n let userdisease: UserDiseaseModel = new UserDiseaseModel();\r\n userdisease.disease = this.state.currentDisease;\r\n userdisease.userDiseaseHistory = [];\r\n this.props.addClick(userdisease, true);\r\n }\r\n\r\n handleCancelButton = () => {\r\n this.props.cancelClick();\r\n }\r\n\r\n handleFilterChange = (event) => {\r\n const target = event.target;\r\n const value = target.type === 'checkbox' ? target.checked : target.value\r\n const name = target.name;\r\n\r\n const currentFilterSettings: DiseaseFilterSettingsModel = { ...this.state.currentFilterSettings };\r\n currentFilterSettings[name] = value;\r\n this.setState({\r\n currentFilterSettings: { ...currentFilterSettings }\r\n });\r\n }\r\n\r\n handleFilterButtonClick = (settings) => {\r\n this.setState({ currentFilterSettings: { ...settings } }, () => this.getAllFilteredItems(this.state.page, this.state.numberOfRows, settings));\r\n }\r\n\r\n handleOnClearClick = () => {\r\n this.setState({ currentFilterSettings: new DiseaseFilterSettingsModel(), page: 1, numberOfPages: 0, diseases: [], totalRecordsCount: 0 });\r\n }\r\n\r\n handleClearButtonClick = () => {\r\n this.setState({\r\n currentFilterSettings: new DiseaseFilterSettingsModel()\r\n });\r\n\r\n this.handleFilterButtonClick(new DiseaseFilterSettingsModel());\r\n }\r\n\r\n displayHeaderSelection(currentDisease: DiseaseForGridModel | undefined) {\r\n if (!currentDisease || (currentDisease && !currentDisease.diseaseCode)) {\r\n return {Translate('No Selection')}
;\r\n }\r\n else {\r\n return {Translate('Disease')}: \r\n {[currentDisease.diseaseCode, currentDisease.diseaseName].filter(Boolean).join(' ')}\r\n
\r\n }\r\n }\r\n\r\n handleKeyPress = (e) => {\r\n if (e.key === 'Enter') {\r\n this.handleFilterButtonClick(this.state.currentFilterSettings)\r\n }\r\n }\r\n\r\n handleSelectionChange = (e) => {\r\n this.setState({\r\n currentDisease: e\r\n });\r\n }\r\n\r\n paginataorClick = (page) => {\r\n console.log(this.state.currentFilterSettings)\r\n this.setState({ page: page }, () => this.getAllFilteredItems(page, this.state.numberOfRows, this.state.currentFilterSettings));\r\n }\r\n\r\n render() {\r\n let { diseases, currentDisease, numberOfPages, numberOfRows, page, isLoading, currentFilterSettings } = this.state;\r\n\r\n return (\r\n \r\n )\r\n }\r\n\r\n}\r\n\r\nexport default DiseaseListDialog;\r\n","import * as React from \"react\";\r\nimport Translate from '../../../common/functions/translate';\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport { UserDiseaseHistoryModel } from \"../../../models/user/userDiseaseHistoryModel\";\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport { DatePicker } from '@material-ui/pickers';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport Growl from \"../../../common/components/alertMessage/growl\";\r\nimport { UserDiseaseModel } from \"../../../models/user/userDiseaseModel\";\r\nimport AddIcon from '@material-ui/icons/Add';\r\nimport Fab from '@material-ui/core/Fab';\r\nimport { faCheck, faTimes, faTimesCircle } from '@fortawesome/free-solid-svg-icons';\r\nimport DiseaseListDialog from \"./diseaseListDialog\";\r\nimport { DiseaseForGridModel } from \"../../../models\";\r\n\r\ninterface IProps {\r\n //history: any,\r\n addClick: any,\r\n updateClick: any,\r\n cancelClick: any,\r\n isVisible: boolean,\r\n currentUserDiseaseHistory: UserDiseaseHistoryModel,\r\n userId: number,\r\n lang: string\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n validationMessage: string;\r\n currentUserDiseaseHistory: UserDiseaseHistoryModel,\r\n userDisease: UserDiseaseModel,\r\n isVisibleSearchDiseaseDialog: boolean\r\n}\r\n\r\nclass UserDiseaseHistoryAddEditDialog extends React.Component {\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n validationMessage: '',\r\n isLoading: false,\r\n currentUserDiseaseHistory: props.currentUserDiseaseHistory,\r\n userDisease: new UserDiseaseModel(),\r\n isVisibleSearchDiseaseDialog: false\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n }\r\n\r\n handleAddButton = (event) => {\r\n event.preventDefault();\r\n\r\n const currentUserDiseaseHistory = this.state.currentUserDiseaseHistory;\r\n\r\n if (currentUserDiseaseHistory.startDate) {\r\n currentUserDiseaseHistory.startDate = HelperFunctions.fomatDateAsString(new Date(currentUserDiseaseHistory.startDate))\r\n } else {\r\n currentUserDiseaseHistory.startDate = HelperFunctions.fomatDateAsString(new Date())\r\n }\r\n\r\n if (currentUserDiseaseHistory.endDate) {\r\n currentUserDiseaseHistory.endDate = HelperFunctions.fomatDateAsString(new Date(currentUserDiseaseHistory.endDate))\r\n } else {\r\n currentUserDiseaseHistory.endDate = HelperFunctions.fomatDateAsString(HelperFunctions.getDayslater(new Date().toString(), 7))\r\n }\r\n\r\n if (currentUserDiseaseHistory && currentUserDiseaseHistory.userDiseaseHistoryId && currentUserDiseaseHistory.userDiseaseHistoryId > 0) {\r\n this.props.updateClick(currentUserDiseaseHistory, close);\r\n }\r\n else {\r\n this.props.addClick(currentUserDiseaseHistory, this.state.userDisease, close);\r\n }\r\n }\r\n\r\n handleCancelButton = () => {\r\n this.props.cancelClick();\r\n }\r\n\r\n handleChange = (key, value) => {\r\n const currentUserDiseaseHistory: UserDiseaseHistoryModel = { ...this.state.currentUserDiseaseHistory };\r\n currentUserDiseaseHistory[key] = value;\r\n this.setState({ currentUserDiseaseHistory: { ...currentUserDiseaseHistory } });\r\n };\r\n\r\n handleDiseaseRemoveClick(event) {\r\n event.preventDefault();\r\n this.setState({\r\n userDisease: new UserDiseaseModel()\r\n });\r\n }\r\n\r\n handleDiseaseAddEditClick() {\r\n this.setState({\r\n isVisibleSearchDiseaseDialog: true,\r\n validationMessage: ''\r\n });\r\n }\r\n\r\n handleAddSaveButton = (currentUserDisease: UserDiseaseModel, close: boolean) => {\r\n this.setState({\r\n isVisibleSearchDiseaseDialog: false,\r\n userDisease: currentUserDisease\r\n });\r\n }\r\n\r\n handleDiseaseListDialogCancelButton = () => {\r\n this.setState({\r\n isVisibleSearchDiseaseDialog: false,\r\n });\r\n }\r\n\r\n public render() {\r\n const { isLoading, currentUserDiseaseHistory, userDisease } = this.state;\r\n\r\n let diseaseInputButton =\r\n \r\n
\r\n
\r\n {currentUserDiseaseHistory.diseaseCode + currentUserDiseaseHistory.diseaseName ? currentUserDiseaseHistory.diseaseName : null}\r\n
\r\n
;\r\n if (!currentUserDiseaseHistory || !currentUserDiseaseHistory.userDiseaseHistoryId || currentUserDiseaseHistory.userDiseaseHistoryId == 0) {\r\n let classInput = 'float-left-full-width';\r\n if (!userDisease || !userDisease.disease || !userDisease.disease.diseaseId) {\r\n classInput = 'float-left-calculated-width';\r\n }\r\n diseaseInputButton =\r\n \r\n
\r\n
\r\n
\r\n {userDisease && userDisease.disease && userDisease.disease.diseaseId ?\r\n <>\r\n
\r\n - \r\n
\r\n
\r\n {userDisease.disease.diseaseCode + userDisease.disease.diseaseName ? userDisease.disease.diseaseName : ''}\r\n
\r\n
\r\n \r\n \r\n
\r\n >\r\n :
{Translate('No disease selected')}
}\r\n
\r\n {!userDisease || !userDisease.disease || !userDisease.disease.diseaseId ?\r\n
\r\n
this.handleDiseaseAddEditClick()}>\r\n \r\n \r\n
: null}\r\n
\r\n
;\r\n }\r\n\r\n\r\n return (\r\n <>\r\n \r\n {this.state.isVisibleSearchDiseaseDialog ? (\r\n \r\n ) : null}\r\n >\r\n )\r\n }\r\n}\r\n\r\nexport default UserDiseaseHistoryAddEditDialog;","export class UserDiseaseSettingsModel {\r\n public diseaseName: string;\r\n public startDate: string;\r\n public endDate: string;\r\n}","import * as React from \"react\";\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport Translate from '../../../common/functions/translate';\r\nimport UserService from '../../../services/userService';\r\nimport AuthService from '../../../services/authService';\r\nimport { UserDiseaseModel } from '../../../models/user/userDiseaseModel';\r\nimport UserDiseaseList from './userDiseaseList';\r\nimport ConfirmDialog from '../../../common/components/confirmDialog/confirmDialog';\r\nimport { DiseaseForGridModel } from '../../../models/diseaseForGridModel';\r\nimport Fab from '@material-ui/core/Fab';\r\nimport AddIcon from '@material-ui/icons/Add';\r\nimport { connect } from 'react-redux';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheckCircle, faNotesMedical } from '@fortawesome/free-solid-svg-icons';\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport { UserDiseaseHistoryModel } from \"../../../models/user/userDiseaseHistoryModel\";\r\nimport { UserDiseaseWithHistoryModel } from \"../../../models/user/userDiseaseWithHistoryModel\";\r\nimport UserDiseaseHistoryAddEditDialog from \"./userDiseaseHistoryAddEditDialog\";\r\nimport { UserDiseaseSettingsModel } from \"../../../models/user/userDiseaseSettingsModel\";\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport Button from '@material-ui/core/Button';\r\nimport { faCheck, faTimes, faFilter, faPrescription, faCalendarAlt, faChevronUp, faChevronDown } from '@fortawesome/free-solid-svg-icons';\r\nimport Search from '@material-ui/icons/Search';\r\nimport { MuiPickersUtilsProvider, DatePicker } from '@material-ui/pickers';\r\nimport DateFnsUtils from '@date-io/date-fns';\r\nimport Checkbox from '@material-ui/core/Checkbox';\r\nimport { MuiThemeProvider, createMuiTheme } from '@material-ui/core';\r\nimport * as Constants from '../../../common/constants'; import blue from '@material-ui/core/colors/blue';\r\nimport { DiseaseFilterSettingsModel } from \"../../../models\";\r\nimport { DropdownModel } from \"../../../models/dropdownModel\";\r\nimport Select from '@material-ui/core/Select';\r\nimport FormControl from '@material-ui/core/FormControl';\r\nimport MenuItem from '@material-ui/core/MenuItem';\r\nimport { TimePresetType } from \"../../../common/enums\";\r\nimport InputLabel from '@material-ui/core/InputLabel';\r\nimport CSSTransition from 'react-transition-group/CSSTransition';\r\nimport ExpandingList from '../../../common/components/expandingList/expandingList';\r\n\r\nexport const smallDialogTheme = createMuiTheme({\r\n overrides: {\r\n MuiFormControl: {\r\n marginNormal: {\r\n marginTop: 5,\r\n marginBottom: 0,\r\n width: '90% !important'\r\n },\r\n root: {\r\n width: '100% !important'\r\n }\r\n },\r\n MuiDialog: {\r\n paper: {\r\n margin: 0,\r\n maxWidth: '350px !important',\r\n minWidth: '335px'\r\n }\r\n }\r\n },\r\n palette: {\r\n primary: blue\r\n },\r\n});\r\n\r\ninterface IProps {\r\n history: any;\r\n userId: number;\r\n location: any;\r\n lang: string;\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n validationMessage: string;\r\n userId: number;\r\n currentUserDisease: UserDiseaseModel;\r\n userDiseases: Array;\r\n isVisibleConfirmDialog: boolean;\r\n deleteValidationMessage: string;\r\n userDisease: UserDiseaseHistoryModel;\r\n isVisibleDiseaseListDialog: boolean;\r\n expandedDiseases: Array;\r\n first: number;\r\n rows: number;\r\n totalRecords: number;\r\n activeUserDiseaseCount: number;\r\n userName: string;\r\n selectedUserDiseaseHistory: UserDiseaseHistoryModel,\r\n diseaseSettings: UserDiseaseSettingsModel,\r\n isVisiblefilters: boolean;\r\n filterByDates: boolean;\r\n currentFilterSettings: UserDiseaseSettingsModel;\r\n timeDropdown: Array;\r\n selectedTime: number;\r\n canChooseDates: boolean;\r\n isMyFamily: boolean;\r\n}\r\n\r\nclass UserDiseasesComponent extends React.Component {\r\n userService = new UserService(this.props.lang);\r\n authService = new AuthService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n validationMessage: '',\r\n isLoading: false,\r\n userId: this.props.userId ? this.props.userId : 0,\r\n currentUserDisease: new UserDiseaseModel(),\r\n userDiseases: new Array(),\r\n isVisibleConfirmDialog: false,\r\n deleteValidationMessage: '',\r\n userDisease: new UserDiseaseHistoryModel(),\r\n isVisibleDiseaseListDialog: false,\r\n first: 0,\r\n rows: 20,\r\n totalRecords: 0,\r\n activeUserDiseaseCount: 0,\r\n expandedDiseases: new Array(),\r\n userName: '',\r\n selectedUserDiseaseHistory: new UserDiseaseHistoryModel(),\r\n diseaseSettings: new UserDiseaseSettingsModel(),\r\n isVisiblefilters: false,\r\n currentFilterSettings: new UserDiseaseSettingsModel(),\r\n timeDropdown: Array(0),\r\n selectedTime: 1,\r\n canChooseDates: false,\r\n filterByDates: false,\r\n isMyFamily: false\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n window.addEventListener('scroll', this.onScroll);\r\n\r\n let tabName = HelperFunctions.getURLParameter('tabName');\r\n\r\n if (tabName && tabName == 'Family' && (this.props.history.action === \"PUSH\" || this.props.history.action === \"POP\")) {\r\n let userId = HelperFunctions.getURLParameter('userId');\r\n let userName = HelperFunctions.getURLParameter('userName');\r\n let numUser: number = userId ? parseInt(userId + '') : 0;\r\n this.setState({ userId: numUser, userName: userName + '', isMyFamily: true }, () => this.getAllUserDisease(true));\r\n }\r\n else {\r\n this.setState({ userId: this.authService.getUserId(), userName: '', isMyFamily: false }, () => this.getAllUserDisease(true));\r\n }\r\n }\r\n\r\n componentWillUnmount() {\r\n window.removeEventListener('scroll', this.onScroll);\r\n }\r\n\r\n\r\n componentDidUpdate(prevProps) {\r\n let tabName = HelperFunctions.getURLParameter('tabName');\r\n\r\n if (tabName && tabName == 'Family' && (this.props.history.action === \"PUSH\" || this.props.history.action === \"POP\") && !this.state.isMyFamily) {\r\n let userId = HelperFunctions.getURLParameter('userId');\r\n let userName = HelperFunctions.getURLParameter('userName');\r\n let numUser: number = userId ? parseInt(userId + '') : 0;\r\n this.setState({ userId: numUser, userName: userName + '', isMyFamily: true }, () => this.getAllUserDisease(true));\r\n }\r\n if ((!tabName || tabName == '') && this.state.isMyFamily) {\r\n this.setState({ userId: this.authService.getUserId(), userName: '', first: 0, isMyFamily: false }, () => this.getAllUserDisease(true));\r\n }\r\n }\r\n\r\n onScroll = () => {\r\n let scrollY = window.scrollY ? window.scrollY : window.pageYOffset;\r\n if (window.innerHeight + scrollY >= document.body.offsetHeight - 250 &&\r\n this.state.totalRecords > this.state.userDiseases.length && !this.state.isLoading) {\r\n this.paginatorClick({ first: this.state.first + this.state.rows }, false);\r\n }\r\n };\r\n\r\n paginatorClick = (e, isInit: boolean) => {\r\n this.setState({ first: e.first }, () => this.getAllUserDisease(isInit));\r\n }\r\n\r\n getAllUserDisease(isInit: boolean) {\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n if (this.authService.isAuthenticated()) {\r\n let userId = this.state.userId ? this.state.userId : this.authService.getUserId();\r\n let settings: UserDiseaseSettingsModel = new UserDiseaseSettingsModel();\r\n if (this.state.currentFilterSettings) {\r\n if (this.state.filterByDates && this.state.currentFilterSettings.startDate) {\r\n settings.startDate = HelperFunctions.fomatDateTimeAsString(new Date(this.state.currentFilterSettings.startDate));\r\n }\r\n\r\n if (this.state.filterByDates && this.state.currentFilterSettings.endDate) {\r\n settings.endDate = HelperFunctions.fomatDateTimeAsString(new Date(this.state.currentFilterSettings.endDate));\r\n }\r\n\r\n if (this.state.currentFilterSettings.diseaseName && this.state.currentFilterSettings.diseaseName.trim() != '') {\r\n settings.diseaseName = this.state.currentFilterSettings.diseaseName;\r\n }\r\n }\r\n this.userService.getAllUserDiseasesWithHistoryCount(userId, this.state.first, this.state.rows, this.props.lang, settings).then(\r\n (data: any) => {\r\n if (data) {\r\n if (isInit) {\r\n this.setState({\r\n isLoading: false,\r\n userDiseases: [...data.userDiseaseHistory],\r\n totalRecords: data.totalRecords,\r\n activeUserDiseaseCount: data.activeUserDiseaseCount,\r\n userId: userId\r\n });\r\n }\r\n else {\r\n this.setState({\r\n isLoading: false,\r\n userDiseases: [...this.state.userDiseases, ...data.userDiseaseHistory],\r\n totalRecords: data.totalRecords,\r\n userId: userId\r\n });\r\n }\r\n }\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n }\r\n\r\n handleHistoryAddButton = (currentUserDiseaseHistory: UserDiseaseHistoryModel, userDisease: UserDiseaseModel, close: boolean) => {\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n let wrapper: UserDiseaseWithHistoryModel = new UserDiseaseWithHistoryModel();\r\n wrapper.userDisease = userDisease;\r\n wrapper.userDiseaseHistory = currentUserDiseaseHistory;\r\n if (!wrapper.userDisease.userId || wrapper.userDisease.userId == 0) {\r\n wrapper.userDisease.userId = this.state.userId;\r\n }\r\n this.userService.addUserDisease(wrapper)\r\n .then(\r\n (data) => {\r\n this.growl.show({ severity: 'success', summary: Translate('Data Saved Successfully') });\r\n this.setState({ first: 0, isVisibleDiseaseListDialog: false }, () => this.getAllUserDisease(true));\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: Translate(error.message) });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n\r\n getUserDisease = (diseaseId) => {\r\n this.userService.getUserDisease(this.state.userId, diseaseId, this.props.lang)\r\n .then(\r\n (data: UserDiseaseModel) => {\r\n this.setCurrentUserDisease(data);\r\n this.setState({\r\n isLoading: false\r\n });\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: Translate(error.message) });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n handleUserDiseaseDeleteClick = (disease: UserDiseaseHistoryModel) => {\r\n let message: string = Translate(\"Are you sure that you want to delete this record\");\r\n if (disease.prescriptionDoctor && disease.prescriptionDoctor.trim() != '') {\r\n message = Translate(\"This medicine is attached to prescription\") + \": \" +\r\n disease.prescriptionDoctor + '. ' + Translate(\"Are you sure that you want to delete this record\");\r\n }\r\n this.setState({\r\n selectedUserDiseaseHistory: disease,\r\n isVisibleConfirmDialog: true,\r\n deleteValidationMessage: message\r\n });\r\n }\r\n\r\n deleteUserDisease(diseaseId, historyId) {\r\n this.setState({\r\n isVisibleConfirmDialog: false,\r\n isLoading: true,\r\n selectedUserDiseaseHistory: new UserDiseaseHistoryModel()\r\n });\r\n\r\n this.userService.deleteUserDisease(this.state.userId, diseaseId, historyId)\r\n .then(\r\n data => {\r\n this.growl.show({ severity: 'success', summary: Translate('Deleted Successfully') });\r\n this.setState({ first: 0 }, () => this.getAllUserDisease(true));\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: Translate(error.message) });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n setCurrentUserDisease(currentUserDisease: UserDiseaseModel) {\r\n this.setState({ currentUserDisease: { ...currentUserDisease } });\r\n }\r\n\r\n handleHistoryUpdateButton = (diseaseHistory: UserDiseaseHistoryModel) => {\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n this.userService.updateDiseaseHistory(diseaseHistory)\r\n .then(\r\n (data) => {\r\n this.growl.show({ severity: 'success', summary: Translate('Data Saved Successfully') });\r\n this.setState({ first: 0, isVisibleDiseaseListDialog: false, selectedUserDiseaseHistory: new UserDiseaseHistoryModel() }, () => this.getAllUserDisease(true));\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: Translate(error.message) });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n handleUserDiseaseHistoryClick = (diseaseId, userDisease: UserDiseaseHistoryModel) => {\r\n this.setState({\r\n isLoading: true\r\n });\r\n let userId = this.state.userId ? this.state.userId : this.authService.getUserId();\r\n this.userService.getUserDisease(userId, diseaseId, this.props.lang)\r\n .then(\r\n (data: UserDiseaseModel) => {\r\n this.setCurrentUserDisease(data);\r\n this.setState({\r\n isLoading: false,\r\n selectedUserDiseaseHistory: userDisease,\r\n isVisibleDiseaseListDialog: true\r\n });\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: Translate(error.message) });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n }\r\n\r\n handleDiseaseListDialogCancelButton = () => {\r\n this.setState({\r\n isVisibleDiseaseListDialog: false,\r\n selectedUserDiseaseHistory: new UserDiseaseHistoryModel()\r\n });\r\n };\r\n\r\n handleDiseaseAddEditClick() {\r\n this.setState({\r\n isVisibleDiseaseListDialog: true\r\n });\r\n }\r\n\r\n expanedData = (rowData: UserDiseaseHistoryModel) => {\r\n return (\r\n this.handleUserDiseaseHistoryClick(rowData.diseaseId, rowData)}\r\n > \r\n this.handleUserDiseaseDeleteClick(rowData)}\r\n >\r\n
)\r\n }\r\n\r\n rowExpansionTemplate = (rowData: UserDiseaseHistoryModel) => {\r\n return (\r\n r.userDiseaseHistoryId == rowData.userDiseaseHistoryId)}\r\n timeout={300} classNames=\"list-slide\" mountOnEnter unmountOnExit>\r\n {this.expanedData(rowData)}\r\n \r\n );\r\n }\r\n expandData = (data: UserDiseaseHistoryModel) => {\r\n if (!this.state.expandedDiseases.some(r => r.userDiseaseHistoryId == data.userDiseaseHistoryId)\r\n || this.state.expandedDiseases.length == 0) {\r\n this.setState({ expandedDiseases: [...this.state.expandedDiseases, data] });\r\n } else {\r\n this.setState({ expandedDiseases: this.state.expandedDiseases.filter(r => r.userDiseaseHistoryId != data.userDiseaseHistoryId) });\r\n }\r\n }\r\n\r\n handleFilterChange = (key, value) => {\r\n const userFilter: UserDiseaseSettingsModel = { ...this.state.diseaseSettings };\r\n userFilter[key] = value;\r\n this.setState({ diseaseSettings: { ...userFilter }, first: 0 })\r\n };\r\n\r\n clearFilters = (e) => {\r\n if (e) {\r\n e.preventDefault();\r\n }\r\n this.setState({\r\n isVisiblefilters: false, currentFilterSettings: new UserDiseaseSettingsModel(),\r\n diseaseSettings: new UserDiseaseSettingsModel(), selectedTime: 1, filterByDates: false\r\n }, () => this.getAllUserDisease(true));\r\n }\r\n\r\n handleFilter = (e) => {\r\n e.preventDefault();\r\n let filters = { ...this.state.diseaseSettings };\r\n if (!filters.startDate) {\r\n filters.startDate = HelperFunctions.getDaysEarlier(new Date().toString(), 1).toISOString();\r\n }\r\n if (!filters.endDate) {\r\n filters.endDate = new Date().toISOString();\r\n }\r\n this.setState({ isVisiblefilters: false, currentFilterSettings: filters, filterByDates: true }, () => this.getAllUserDisease(true));\r\n }\r\n\r\n filterClick = () => {\r\n let currentSettings: UserDiseaseSettingsModel = new UserDiseaseSettingsModel();\r\n\r\n if (this.state.currentFilterSettings &&\r\n (this.state.currentFilterSettings.endDate || this.state.currentFilterSettings.startDate || this.state.currentFilterSettings.diseaseName)) {\r\n currentSettings = { ...this.state.currentFilterSettings };\r\n }\r\n\r\n let timeDr = new Array(0);\r\n timeDr = HelperFunctions.enumToDropdownArray(TimePresetType, true);\r\n this.setState({ isVisiblefilters: true, diseaseSettings: { ...currentSettings }, timeDropdown: timeDr });\r\n }\r\n\r\n getFiltersummary = () => {\r\n let nameSet: any = null;\r\n let startSet: any = null;\r\n let endSet: any = null;\r\n\r\n if (this.state.currentFilterSettings && this.state.currentFilterSettings.diseaseName) {\r\n nameSet =\r\n <>\r\n {Translate('Medicine')}:\r\n {this.state.currentFilterSettings.diseaseName} \r\n >\r\n }\r\n\r\n if (this.state.currentFilterSettings && this.state.currentFilterSettings.startDate) {\r\n startSet =\r\n <>\r\n {Translate('From')}:\r\n {HelperFunctions.fomatDateAsStringWithLang(new Date(this.state.currentFilterSettings.startDate), this.props.lang)} \r\n >\r\n }\r\n\r\n if (this.state.currentFilterSettings && this.state.currentFilterSettings.endDate) {\r\n endSet =\r\n <>\r\n {Translate('To')}:\r\n {HelperFunctions.fomatDateAsStringWithLang(new Date(this.state.currentFilterSettings.endDate), this.props.lang)} \r\n >\r\n }\r\n\r\n let summary =\r\n \r\n {nameSet}\r\n {startSet}\r\n {endSet}\r\n
\r\n\r\n return summary;\r\n }\r\n\r\n goToPrescriptions = (e, perscriptionId) => {\r\n e.preventDefault();\r\n this.props.history.push(`${Constants.PrescriptionUrl}?perscriptionId=${perscriptionId}`);\r\n }\r\n\r\n handleTimeDropdownChange = (id) => {\r\n let filters = { ...this.state.diseaseSettings };\r\n let canChooseDates = false;\r\n switch (id) {\r\n case TimePresetType.OneDay:\r\n filters.startDate = HelperFunctions.getDaysEarlier(new Date().toString(), 1).toISOString();\r\n filters.endDate = new Date().toISOString();\r\n canChooseDates = false;\r\n break;\r\n case TimePresetType.OneWeek:\r\n filters.startDate = HelperFunctions.getDaysEarlier(new Date().toString(), 7).toISOString();\r\n filters.endDate = new Date().toISOString();\r\n canChooseDates = false;\r\n break;\r\n case TimePresetType.OneMonth:\r\n filters.startDate = HelperFunctions.getMonthsEarlier(new Date().toString(), 1).toISOString();\r\n filters.endDate = new Date().toISOString();\r\n canChooseDates = false;\r\n break;\r\n case TimePresetType.ThreeMonths:\r\n filters.startDate = HelperFunctions.getMonthsEarlier(new Date().toString(), 3).toISOString();\r\n filters.endDate = new Date().toISOString();\r\n canChooseDates = false;\r\n break;\r\n case TimePresetType.SixMonths:\r\n filters.startDate = HelperFunctions.getMonthsEarlier(new Date().toString(), 6).toISOString();\r\n filters.endDate = new Date().toISOString();\r\n canChooseDates = false;\r\n break;\r\n case TimePresetType.OneYear:\r\n filters.startDate = HelperFunctions.getMonthsEarlier(new Date().toString(), 12).toISOString();\r\n filters.endDate = new Date().toISOString();\r\n canChooseDates = false;\r\n break;\r\n case TimePresetType.Advanced:\r\n canChooseDates = true;\r\n }\r\n this.setState({ selectedTime: id, diseaseSettings: filters, canChooseDates: canChooseDates });\r\n }\r\n\r\n keyItem = (item: UserDiseaseHistoryModel) => {\r\n return item.userDiseaseHistoryId + 'disease';\r\n }\r\n\r\n itemName = (m: UserDiseaseHistoryModel) => {\r\n let today = HelperFunctions.fomatDateAsString(new Date());\r\n return (\r\n <>\r\n {new Date(m.startDate ? m.startDate.substr(0, 10) : '') <= new Date(today) && new Date(m.endDate ? m.endDate.substr(0, 10) : '') >= new Date(today) ?\r\n : null}\r\n {m.diseaseName ? [m.diseaseCode, m.diseaseName].join(\" \").trim() : m.diseaseCode}\r\n >)\r\n }\r\n\r\n itemDesc = (m: UserDiseaseHistoryModel) => {\r\n return (\r\n <>\r\n \r\n \r\n {HelperFunctions.fomatDatesStringWithLang(new Date(m.startDate ? m.startDate : ''), this.props.lang) + \" - \"}\r\n {HelperFunctions.fomatDatesStringWithLang(new Date(m.endDate ? m.endDate : ''), this.props.lang)}\r\n
\r\n {m.prescriptionDoctor && m.prescriptionDoctor.trim() != '' ?\r\n : null}\r\n >\r\n )\r\n }\r\n\r\n itemActions = (item: UserDiseaseHistoryModel) => {\r\n return (\r\n <>\r\n {window.innerWidth >= Constants.device.tablet ? this.expanedData(item) :\r\n\r\n this.state.expandedDiseases.some(r => r.userDiseaseHistoryId == item.userDiseaseHistoryId) ?\r\n \r\n : \r\n }\r\n >\r\n )\r\n }\r\n\r\n public render() {\r\n const { isLoading, userDiseases, totalRecords, activeUserDiseaseCount, expandedDiseases,\r\n diseaseSettings, selectedUserDiseaseHistory, currentFilterSettings, selectedTime, timeDropdown } = this.state;\r\n let disease = new DiseaseForGridModel();\r\n\r\n let userName = HelperFunctions.getURLParameter('userName');\r\n let showAllLink = false;\r\n if ((currentFilterSettings.diseaseName && currentFilterSettings.diseaseName.trim() != '') || currentFilterSettings.startDate || currentFilterSettings.endDate) {\r\n showAllLink = true\r\n }\r\n\r\n return (\r\n \r\n
this.growl = el} />\r\n\r\n\r\n <>\r\n {userName ?\r\n <>\r\n {Translate('Diseases of')}:
\r\n {userName}
\r\n > : {Translate('My Diseases')}
}\r\n this.handleDiseaseAddEditClick()} className=\"floating-action-button\">\r\n \r\n \r\n this.filterClick()} className=\"floating-action-button-second\">\r\n \r\n \r\n\r\n {!isLoading && userDiseases && userDiseases.length > 0 ?\r\n \r\n {totalRecords} {Translate('total records.')}
\r\n {activeUserDiseaseCount} {Translate('current disease count.')}\r\n {activeUserDiseaseCount > 0 ?\r\n \r\n : null}\r\n
: null}\r\n\r\n {currentFilterSettings && (currentFilterSettings.diseaseName || currentFilterSettings.startDate || currentFilterSettings.endDate) ?\r\n <>\r\n {Translate('Filters') + \":\"}
\r\n {this.getFiltersummary()}\r\n >\r\n : null}\r\n\r\n {showAllLink ?\r\n : null}\r\n\r\n < ExpandingList\r\n listItems={userDiseases}\r\n keyItem={this.keyItem}\r\n expandData={this.expandData}\r\n expandedPanel={this.rowExpansionTemplate}\r\n itemName={this.itemName}\r\n itemDesc={this.itemDesc}\r\n itemActions={this.itemActions}\r\n isExpandable={window.innerWidth < Constants.device.tablet}\r\n infoStyle={window.innerWidth < Constants.device.tablet ? {} : { width: 'unset' }}\r\n //actionsStyle={window.innerWidth < Constants.device.tablet ? {} : { width: 124 }}\r\n />\r\n\r\n {/* */}\r\n {isLoading ? : null}\r\n {!isLoading && (!userDiseases || userDiseases.length == 0) ? Translate(\"No records found\") : null}\r\n >\r\n\r\n {this.state.isVisibleDiseaseListDialog ? (\r\n \r\n ) : null}\r\n\r\n\r\n \r\n\r\n { this.deleteUserDisease(selectedUserDiseaseHistory.diseaseId, selectedUserDiseaseHistory.userDiseaseHistoryId) }}\r\n noClick={() => { this.setState({ isVisibleConfirmDialog: false, selectedUserDiseaseHistory: new UserDiseaseHistoryModel() }) }}>\r\n {this.state.deleteValidationMessage}\r\n \r\n \r\n )\r\n }\r\n}\r\n\r\nconst mapsStateToProps = state => {\r\n return {\r\n lang: state.common.lang\r\n };\r\n}\r\n\r\nexport default connect(mapsStateToProps)(UserDiseasesComponent);","import { UserDiseaseHistoryModel } from './userDiseaseHistoryModel';\r\nimport { UserMedicineHistoryModel } from './userMedicineHistoryModel';\r\n\r\nexport class UserPrescriptionModel {\r\n public userPrescriptionId: number;\r\n public userId: number;\r\n public startDate?: string;\r\n public endDate?: string;\r\n public prescription: string;\r\n public doctor: string;\r\n public hospital: string;\r\n public comments: string;\r\n public notAllowedFoods: string;\r\n public recommendedFoods: string;\r\n public recommendedTreatment: string;\r\n public isActive: boolean;\r\n public userMedicines: Array;\r\n public userDiseases: Array;\r\n}","import * as React from \"react\";\r\nimport { UserPrescriptionModel } from '../../../models/user/userPrescriptionModel';\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport Translate from '../../../common/functions/translate';\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport AuthService from '../../../services/authService';\r\nimport { enumToDropdownArray, getFrequencyCounterLabel, fomatDateAsString, fomatTimeAsString, fomatDateTimeAsString, getNotificationSummary, formatAlarmTime } from '../../../common/functions/helperFunctions';\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport { DatePicker } from '@material-ui/pickers';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes } from '@fortawesome/free-solid-svg-icons';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport Card from '@material-ui/core/Card';\r\nimport CardContent from '@material-ui/core/CardContent';\r\nimport CardActions from '@material-ui/core/CardActions';\r\nimport Typography from '@material-ui/core/Typography';\r\n\r\ninterface IProps {\r\n //history: any,\r\n saveClick: any,\r\n cancelClick: any,\r\n isVisible: boolean,\r\n currentUserPrescription: UserPrescriptionModel\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n validationMessage: string;\r\n userId: number;\r\n userPrescription: UserPrescriptionModel\r\n}\r\n\r\nclass UserPrescriptionAddEditDialog extends React.Component {\r\n authService = new AuthService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n validationMessage: '',\r\n isLoading: false,\r\n userId: props.currentUserPrescription.userId,\r\n userPrescription: props.currentUserPrescription\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n }\r\n\r\n handleSaveButton = (event, close) => {\r\n event.preventDefault();\r\n const userPrescription = this.state.userPrescription;\r\n\r\n if (userPrescription.startDate) {\r\n userPrescription.startDate = HelperFunctions.fomatDateAsString(new Date(userPrescription.startDate))\r\n } else {\r\n userPrescription.startDate = HelperFunctions.fomatDateAsString(new Date())\r\n }\r\n\r\n if (userPrescription.endDate) {\r\n userPrescription.endDate = HelperFunctions.fomatDateAsString(new Date(userPrescription.endDate))\r\n } else {\r\n userPrescription.endDate = HelperFunctions.fomatDateAsString(HelperFunctions.getDayslater(new Date().toString(), 7))\r\n }\r\n\r\n if (userPrescription.endDate) {\r\n userPrescription.endDate = fomatDateAsString(new Date(userPrescription.endDate));\r\n\r\n if (userPrescription.endDate < userPrescription.startDate) {\r\n this.growl.show({ severity: 'error', summary: Translate(\"Start date is greater than end date\") });\r\n return;\r\n }\r\n }\r\n\r\n this.props.saveClick(userPrescription, close);\r\n }\r\n\r\n handleCancelButton = () => {\r\n this.props.cancelClick();\r\n }\r\n\r\n handleChange = (key, value) => {\r\n const userPrescription: UserPrescriptionModel = { ...this.state.userPrescription };\r\n userPrescription[key] = value;\r\n this.setState({ userPrescription: { ...userPrescription } });\r\n };\r\n\r\n\r\n public render() {\r\n const { isLoading, userPrescription } = this.state;\r\n\r\n let dialogHeader: string = Translate('Doctors prescription');\r\n\r\n return (\r\n <>\r\n \r\n >\r\n )\r\n }\r\n}\r\n\r\nexport default UserPrescriptionAddEditDialog;","import * as React from 'react';\r\nimport { Button } from \"primereact/button\";\r\nimport { InputText } from 'primereact/inputtext';\r\nimport { Toolbar } from 'primereact/toolbar';\r\nimport { MedicineFilterSettings } from \"../../models/medicineFilterSettings\";\r\nimport AlphabeticalFilter from '../../common/components/alphabeticalFilter/alphabeticalFilter';\r\nimport Translate from '../../common/functions/translate';\r\n\r\ninterface MedicinesFilterProps {\r\n onSearchClick: any,\r\n totalRecordsCount: number\r\n lang: string\r\n onClearClick: any;\r\n}\r\n\r\ninterface MedicinesFilterState {\r\n medicineSettings: MedicineFilterSettings,\r\n selectedType: null,\r\n selectedGroup: null,\r\n filterText: string\r\n}\r\n\r\nexport class MedicineFilter extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n medicineSettings: new MedicineFilterSettings(),\r\n selectedType: null,\r\n selectedGroup: null,\r\n filterText: ''\r\n };\r\n }\r\n\r\n handleAlphaIndexChange = (e, letter: string) => {\r\n e.preventDefault();\r\n let currentSettings: MedicineFilterSettings = this.state.medicineSettings;\r\n currentSettings.name = '';\r\n currentSettings.alphaIndex = letter;\r\n const fiterText = this.generateFilterText(currentSettings);\r\n this.setState({\r\n medicineSettings: currentSettings,\r\n filterText: fiterText\r\n });\r\n this.handleSearchButtonClick();\r\n }\r\n\r\n handleChange = (event) => {\r\n const target = event.target;\r\n const value = target.type === 'checkbox' ? target.checked : target.value\r\n const name = target.name;\r\n\r\n const currentSettings: MedicineFilterSettings = { ...this.state.medicineSettings };\r\n currentSettings.name = value;\r\n currentSettings.alphaIndex = '';\r\n const fiterText = this.generateFilterText(currentSettings);\r\n this.setState({\r\n medicineSettings: { ...currentSettings },\r\n filterText: fiterText\r\n }, this.searchByName);\r\n }\r\n\r\n searchByName = () => {\r\n if (this.state.medicineSettings && this.state.medicineSettings.name && this.state.medicineSettings.name.length >= 3) {\r\n this.handleSearchButtonClick()\r\n }\r\n }\r\n\r\n generateFilterText = (settings) => {\r\n let result = '';\r\n\r\n if (settings.alphaIndex) {\r\n result += Translate(\"Start with\") + \" '\" + settings.alphaIndex + \"', \"\r\n }\r\n if (settings.name) {\r\n result += Translate(\"Name\") + \" '\" + settings.name + \"', \"\r\n }\r\n if (settings.title) {\r\n result += Translate(\"Title\") + \" '\" + settings.title + \"', \"\r\n }\r\n if (settings.number) {\r\n result += Translate(\"Number\") + \" '\" + settings.number + \"', \"\r\n }\r\n\r\n return result.substr(0, result.length - 2);\r\n }\r\n\r\n handleSearchButtonClick = () => {\r\n this.props.onSearchClick(this.state.medicineSettings);\r\n }\r\n\r\n handleClearButtonClick = () => {\r\n let currentSettings: MedicineFilterSettings = this.state.medicineSettings;\r\n currentSettings.name = '';\r\n currentSettings.alphaIndex = '';\r\n this.setState({\r\n medicineSettings: currentSettings,\r\n filterText: ''\r\n });\r\n this.props.onClearClick();\r\n }\r\n\r\n handleKeyPress = (e) => {\r\n if (e.key === 'Enter') {\r\n this.handleSearchButtonClick()\r\n }\r\n }\r\n\r\n render() {\r\n return (\r\n <>\r\n \r\n
\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n
{Translate('BrowseAlphabetically')}:\r\n
\r\n
\r\n \r\n
\r\n {Translate('Result')}: {this.props.totalRecordsCount}\r\n {this.state.filterText ? ', ' : ''}\r\n \r\n
\r\n
\r\n >\r\n )\r\n }\r\n}\r\n\r\nexport default MedicineFilter;\r\n","import * as React from 'react';\r\nimport Button from '@material-ui/core/Button'\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes } from '@fortawesome/free-solid-svg-icons';\r\nimport MedicineService from '../../../services/medicineService';\r\nimport { MedicineFilterSettings, MedicineListModel, MedicineForListModel } from \"../../../models\";\r\nimport Translate from '../../../common/functions/translate';\r\nimport Paginator from '../../../common/components/paginator/paginator';\r\nimport MedicineFilter from '../../interactions/medicineFilter';\r\nimport Radio from '@material-ui/core/Radio';\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\n\r\ninterface IProps {\r\n selectedMedicine: MedicineForListModel,\r\n isVisible: boolean,\r\n cancelClick: any,\r\n addClick: any,\r\n lang: string\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n from: number;\r\n numberOfRows: number;\r\n totalRecordsCount: number;\r\n medicines: Array\r\n currentMedicine: MedicineForListModel;\r\n currentFilterSettings: MedicineFilterSettings;\r\n page: number;\r\n numberOfPages: number;\r\n}\r\n\r\nconst initFrom = 0;\r\nconst numberOfRows = 20;\r\n\r\nclass MedicinesListDialog extends React.Component {\r\n medicineService = new MedicineService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n from: initFrom,\r\n numberOfRows: numberOfRows,\r\n totalRecordsCount: 0,\r\n medicines: new Array(),\r\n currentMedicine: this.props.selectedMedicine,\r\n currentFilterSettings: new MedicineFilterSettings(),\r\n page: 1,\r\n numberOfPages: 1\r\n }\r\n }\r\n\r\n componentDidMount() {\r\n //this.getAllFilteredItems(this.state.page, this.state.numberOfRows, this.state.currentFilterSettings);\r\n }\r\n\r\n getAllFilteredItems(page: number, numberOfRows: number, currentFilterSettings: MedicineFilterSettings) {\r\n let from = (page - 1) * this.state.numberOfRows;\r\n\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n this.medicineService.getAllMedicines(from, numberOfRows, currentFilterSettings, this.props.lang).then(\r\n (data: MedicineListModel) => {\r\n this.setState({\r\n isLoading: false,\r\n from: from,\r\n medicines: data.medicines,\r\n totalRecordsCount: data.totalRecordsCount,\r\n numberOfPages: (data.totalRecordsCount % this.state.numberOfRows > 0 ?\r\n data.totalRecordsCount / this.state.numberOfRows + 1 : data.totalRecordsCount / this.state.numberOfRows)\r\n });\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n handleFilterChange = (event) => {\r\n const target = event.target;\r\n const value = target.type === 'checkbox' ? target.checked : target.value\r\n const name = target.name;\r\n\r\n const currentFilterSettings: MedicineFilterSettings = { ...this.state.currentFilterSettings };\r\n currentFilterSettings[name] = value;\r\n this.setState({\r\n currentFilterSettings: { ...currentFilterSettings }\r\n });\r\n }\r\n\r\n handleCurrentMedicineSelection = (e) => {\r\n this.setState({\r\n currentMedicine: e.data\r\n });\r\n }\r\n\r\n displayHeaderSelection(currentMedicine: MedicineForListModel) {\r\n if (!currentMedicine || (currentMedicine && !currentMedicine.brandName)) {\r\n return {Translate(\"No Selection\")}
;\r\n }\r\n else {\r\n return {Translate('Medicine')}: \r\n {[currentMedicine.medicineNumber, currentMedicine.brandName].filter(Boolean).join(' / ')}
\r\n }\r\n }\r\n\r\n handleCancelButton = () => {\r\n this.props.cancelClick();\r\n }\r\n\r\n handleAddButton = (event) => {\r\n event.preventDefault();\r\n const currentMedicine = this.state.currentMedicine;\r\n this.props.addClick(currentMedicine);\r\n }\r\n\r\n paginataorClick = (page) => {\r\n this.setState({ page: page }, () => this.getAllFilteredItems(page, this.state.numberOfRows, this.state.currentFilterSettings));\r\n }\r\n\r\n handleSearchButtonClick = (settings) => {\r\n this.setState({\r\n isLoading: true, page: 1, currentFilterSettings: settings\r\n }, () => this.getAllFilteredItems(this.state.page, this.state.numberOfRows, settings));\r\n }\r\n\r\n handleClearClick = () => {\r\n this.setState({\r\n page: 1, currentFilterSettings: new MedicineFilterSettings(), medicines: [], totalRecordsCount: 0, numberOfPages: 0\r\n });\r\n }\r\n\r\n onSelectMedicine = (medicine: MedicineForListModel) => {\r\n this.setState({ currentMedicine: { ...medicine } });\r\n }\r\n\r\n render() {\r\n let { medicines, currentMedicine, numberOfPages, page, isLoading, currentFilterSettings } = this.state;\r\n\r\n return (\r\n \r\n )\r\n }\r\n}\r\n\r\nexport default MedicinesListDialog;","import * as React from 'react';\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes, faTimesCircle } from '@fortawesome/free-solid-svg-icons';\r\nimport { UserMedicineHistoryModel } from '../../../models/user/userMedicineHistoryModel';\r\nimport UserService from '../../../services/userService';\r\nimport Translate from '../../../common/functions/translate';\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport { InputText } from 'primereact/inputtext';\r\nimport { MedicineForListModel } from \"../../../models\";\r\nimport MedicinesListDialog from './medicinesListDialog'\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport { UserNotificationModel } from \"../../../models/user/userNotificationModel\";\r\nimport { DatePicker } from '@material-ui/pickers';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport AddIcon from '@material-ui/icons/Add';\r\nimport Fab from '@material-ui/core/Fab';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\n\r\ninterface IProps {\r\n isVisible: boolean,\r\n cancelClick: any,\r\n saveClick: any,\r\n userId: number,\r\n selectedMedicineHistory: UserMedicineHistoryModel;\r\n isMedicineButtonDisabled: boolean,\r\n lang: string\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n validationMessage: string;\r\n from: number;\r\n numberOfRows: number;\r\n totalRecordsCount: number;\r\n currentMedicine: MedicineForListModel;\r\n currentMedicineHistory: UserMedicineHistoryModel;\r\n isVisibleMedicineListDialog: boolean\r\n}\r\n\r\nconst initFrom = 0;\r\nconst numberOfRows = 10;\r\n\r\nclass UserMedicineAddEditDialog extends React.Component {\r\n userService = new UserService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n if (!props.selectedMedicineHistory.userNotifications) {\r\n props.selectedMedicineHistory.userNotifications = new Array(0);\r\n }\r\n\r\n this.state = {\r\n isLoading: false,\r\n validationMessage: '',\r\n from: initFrom,\r\n numberOfRows: numberOfRows,\r\n totalRecordsCount: 0,\r\n currentMedicine: new MedicineForListModel(),\r\n isVisibleMedicineListDialog: false,\r\n currentMedicineHistory: props.selectedMedicineHistory\r\n }\r\n }\r\n\r\n componentDidMount() {\r\n }\r\n\r\n handleMedicineListDialogAddButton = (currentMedicine: MedicineForListModel) => {\r\n this.setState({\r\n currentMedicine: currentMedicine,\r\n isVisibleMedicineListDialog: false\r\n });\r\n }\r\n\r\n handleMedicineListDialogCancelButton = () => {\r\n this.setState({\r\n isVisibleMedicineListDialog: false\r\n });\r\n };\r\n\r\n handleSaveButton = event => {\r\n let currentMedicineHistory: UserMedicineHistoryModel = { ...this.state.currentMedicineHistory };\r\n\r\n if (currentMedicineHistory && currentMedicineHistory.userMedicineHistoryId) {\r\n if (currentMedicineHistory.startDate) {\r\n currentMedicineHistory.startDate = HelperFunctions.fomatDateAsString(new Date(currentMedicineHistory.startDate))\r\n } else {\r\n currentMedicineHistory.startDate = HelperFunctions.fomatDateAsString(new Date())\r\n }\r\n\r\n if (currentMedicineHistory.endDate) {\r\n currentMedicineHistory.endDate = HelperFunctions.fomatDateAsString(new Date(currentMedicineHistory.endDate))\r\n } else {\r\n currentMedicineHistory.endDate = HelperFunctions.fomatDateAsString(new Date())\r\n }\r\n\r\n this.props.saveClick(currentMedicineHistory);\r\n } else {\r\n if (!this.state.currentMedicine || !this.state.currentMedicine.medicineId) {\r\n this.growl.show({ severity: 'warning', summary: Translate(\"Please select medicine\") });\r\n } else {\r\n\r\n currentMedicineHistory.medicineId = this.state.currentMedicine.medicineId;\r\n currentMedicineHistory.userId = this.props.userId;\r\n currentMedicineHistory.medicineName = [this.state.currentMedicine.medicineNumber,\r\n this.state.currentMedicine.brandName].filter(Boolean).join(' / ');\r\n\r\n if (currentMedicineHistory.startDate) {\r\n currentMedicineHistory.startDate = HelperFunctions.fomatDateAsString(new Date(currentMedicineHistory.startDate))\r\n } else {\r\n currentMedicineHistory.startDate = HelperFunctions.fomatDateAsString(new Date())\r\n }\r\n\r\n if (currentMedicineHistory.endDate) {\r\n currentMedicineHistory.endDate = HelperFunctions.fomatDateAsString(new Date(currentMedicineHistory.endDate))\r\n } else {\r\n currentMedicineHistory.endDate = HelperFunctions.fomatDateAsString(new Date())\r\n }\r\n\r\n this.props.saveClick(currentMedicineHistory);\r\n }\r\n }\r\n }\r\n\r\n handleCancelButton = () => {\r\n this.props.cancelClick();\r\n }\r\n\r\n handleChange = (key, value) => {\r\n const currentMedicineHistory: UserMedicineHistoryModel = { ...this.state.currentMedicineHistory };\r\n currentMedicineHistory[key] = value;\r\n this.setState({ currentMedicineHistory: { ...currentMedicineHistory } });\r\n };\r\n\r\n handleMedicineAddEditClick() {\r\n this.setState({\r\n isVisibleMedicineListDialog: true,\r\n validationMessage: ''\r\n });\r\n }\r\n\r\n handleMedicineRemoveClick(event) {\r\n event.preventDefault();\r\n this.setState({\r\n currentMedicine: new MedicineForListModel\r\n });\r\n }\r\n\r\n render() {\r\n const { currentMedicine, currentMedicineHistory } = this.state;\r\n const { isMedicineButtonDisabled } = this.props;\r\n\r\n let medicineValue: string = Translate('Select');\r\n let dialogHeader: string = Translate('Medicine');\r\n\r\n let medicineInputButton;\r\n if (isMedicineButtonDisabled) {\r\n medicineInputButton = null;\r\n medicineValue = currentMedicineHistory.medicineName;\r\n dialogHeader = dialogHeader + ' - ' + medicineValue;\r\n } else {\r\n\r\n if (currentMedicine && currentMedicine.brandName) {\r\n medicineValue = [currentMedicine.medicineNumber, currentMedicine.brandName].filter(Boolean).join(' / ');\r\n dialogHeader = dialogHeader + ' - ' + medicineValue;\r\n }\r\n\r\n let classInput = 'float-left-full-width';\r\n if (!currentMedicine || !currentMedicine.medicineId) {\r\n classInput = 'float-left-calculated-width';\r\n }\r\n\r\n medicineInputButton =\r\n \r\n
\r\n
\r\n
\r\n {currentMedicine && currentMedicine.medicineId ?\r\n <>\r\n
\r\n - \r\n
\r\n
\r\n {currentMedicine.brandName ? currentMedicine.brandName : ''}\r\n
\r\n
\r\n \r\n \r\n
\r\n >\r\n :
{Translate('No medicine selected')}
}\r\n
\r\n {!currentMedicine || !currentMedicine.medicineId ?\r\n
\r\n
this.handleMedicineAddEditClick()}>\r\n \r\n \r\n
: null}\r\n
\r\n
;\r\n }\r\n\r\n return (\r\n <>\r\n \r\n {this.state.isVisibleMedicineListDialog ? (\r\n \r\n ) : null}\r\n\r\n >\r\n )\r\n }\r\n}\r\n\r\nexport default UserMedicineAddEditDialog;\r\n","import * as React from 'react';\r\nimport { UserMedicineHistoryModel } from '../../../models/user/userMedicineHistoryModel';\r\nimport UserService from '../../../services/userService';\r\nimport Translate from '../../../common/functions/translate';\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport { fomatDateAsString } from '../../../common/functions/helperFunctions';\r\nimport { UserPrescriptionModel } from '../../../models/user/userPrescriptionModel';\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport UserMedicineAddEditDialog from './userMedicineAddEditDialog';\r\nimport AuthService from '../../../services/authService';\r\nimport UserNotificationListDialog from '../userNotification/userNotificationListDialog';\r\nimport ConfirmDialog from '../../../common/components/confirmDialog/confirmDialog';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faBell } from '@fortawesome/free-solid-svg-icons';\r\nimport { faChevronDown, faChevronUp, faUserMd } from '@fortawesome/free-solid-svg-icons';\r\nimport Fab from '@material-ui/core/Fab';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport * as Constants from '../../../common/constants';\r\nimport ExpandingList from '../../../common/components/expandingList/expandingList';\r\nimport CSSTransition from 'react-transition-group/CSSTransition';\r\nimport AddIcon from '@material-ui/icons/Add';\r\nimport NotificationsIcon from '@material-ui/icons/Notifications'\r\n\r\ninterface IProps {\r\n closeClick: any,\r\n userPrescriptionId: number,\r\n lang: string\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n validationMessage: string;\r\n from: number;\r\n numberOfRows: number;\r\n totalRecordsCount: number;\r\n currentUserPrescription: UserPrescriptionModel,\r\n isVisibleUserMedcineAddEditDialog: boolean,\r\n isMedicineButtonDisabled: boolean;\r\n currrentUserMedicineHistory: UserMedicineHistoryModel,\r\n userId: number;\r\n isVisibleUserNotificationListDialog: boolean;\r\n isVisibleConfirmDialog: boolean;\r\n expandedMedicine: Array\r\n}\r\n\r\nconst initFrom = 0;\r\nconst numberOfRows = 10;\r\n\r\nclass PrescriptionMedicineListDialog extends React.Component {\r\n userService = new UserService();\r\n authService = new AuthService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n validationMessage: '',\r\n from: initFrom,\r\n numberOfRows: numberOfRows,\r\n totalRecordsCount: 0,\r\n currentUserPrescription: new UserPrescriptionModel(),\r\n isVisibleUserMedcineAddEditDialog: false,\r\n isMedicineButtonDisabled: false,\r\n currrentUserMedicineHistory: new UserMedicineHistoryModel(),\r\n userId: 0,\r\n isVisibleUserNotificationListDialog: false,\r\n isVisibleConfirmDialog: false,\r\n expandedMedicine: new Array()\r\n }\r\n }\r\n\r\n componentDidMount() {\r\n this.getPrescriptionMedicines(this.props.userPrescriptionId);\r\n }\r\n\r\n getPrescriptionMedicines = (userPrescriptionId) => {\r\n if (!userPrescriptionId) {\r\n this.growl.show({ severity: 'error', summary: \"PrescriptionID not valid\" });\r\n } else {\r\n this.setState({\r\n isLoading: true\r\n });\r\n this.userService.getPrescriptionMedicines(userPrescriptionId, this.props.lang)\r\n .then(\r\n (data: UserPrescriptionModel) => {\r\n this.setCurrentUserPrescription(data);\r\n this.setState({\r\n isLoading: false\r\n });\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n }\r\n }\r\n\r\n setCurrentUserPrescription(currentUserPrescription: UserPrescriptionModel) {\r\n this.setState({ currentUserPrescription: { ...currentUserPrescription } });\r\n }\r\n\r\n handleCloseButton = () => {\r\n this.props.closeClick();\r\n }\r\n\r\n //********************** Medicines methods *******************************************************************/\r\n handleUserMedicineAddEditClick = (userMedicineHistoryId) => {\r\n if (!userMedicineHistoryId) {\r\n let currrentUserMedicineHistory = new UserMedicineHistoryModel();\r\n\r\n if (this.state.currentUserPrescription.startDate) {\r\n currrentUserMedicineHistory.startDate = fomatDateAsString(new Date(this.state.currentUserPrescription.startDate));\r\n } else {\r\n currrentUserMedicineHistory.startDate = fomatDateAsString(new Date());\r\n }\r\n\r\n if (this.state.currentUserPrescription.endDate) {\r\n currrentUserMedicineHistory.endDate = fomatDateAsString(new Date(this.state.currentUserPrescription.endDate));\r\n } else {\r\n currrentUserMedicineHistory.endDate = fomatDateAsString(new Date());\r\n }\r\n\r\n this.setState({\r\n currrentUserMedicineHistory: currrentUserMedicineHistory\r\n });\r\n this.showUserMedicineAddEditDialog(true, false);\r\n } else {\r\n let userMedicineHistory = this.state.currentUserPrescription.userMedicines.find(m => m.userMedicineHistoryId === userMedicineHistoryId);\r\n\r\n if (userMedicineHistory) {\r\n this.setState({\r\n currrentUserMedicineHistory: userMedicineHistory\r\n });\r\n }\r\n this.showUserMedicineAddEditDialog(true, true);\r\n }\r\n\r\n if (!this.state.userId || this.state.userId <= 0) {\r\n if (this.authService.isAuthenticated()) {\r\n let profile = this.authService.getProfile();\r\n let id = profile['id'];\r\n this.setState({\r\n userId: id,\r\n });\r\n }\r\n else {\r\n console.log(\"EROR\");\r\n }\r\n }\r\n }\r\n\r\n showUserMedicineAddEditDialog = (show: boolean, isButtonDisabled: boolean) => {\r\n this.setState({\r\n isVisibleUserMedcineAddEditDialog: show,\r\n isMedicineButtonDisabled: isButtonDisabled\r\n });\r\n }\r\n\r\n handleUserMedicineAddEditDialogCancelButton = () => {\r\n this.showUserMedicineAddEditDialog(false, false);\r\n }\r\n\r\n handleUserMedicineSave = (selectedUserMedicine: UserMedicineHistoryModel) => {\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n if (!selectedUserMedicine.userMedicineHistoryId) {\r\n this.userService.addPrescriptionMedicine(this.props.userPrescriptionId, selectedUserMedicine)\r\n .then(\r\n (data) => {\r\n this.growl.show({ severity: 'success', summary: Translate('Data Saved Successfully') });\r\n this.getPrescriptionMedicines(this.props.userPrescriptionId);\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n } else {\r\n this.userService.updatePrescriptionMedicine(this.props.userPrescriptionId, selectedUserMedicine)\r\n .then(\r\n (data) => {\r\n this.growl.show({ severity: 'success', summary: Translate('Data Saved Successfully') });\r\n this.getPrescriptionMedicines(this.props.userPrescriptionId);\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n this.showUserMedicineAddEditDialog(false, false);\r\n }\r\n\r\n handleUserMedicineDeleteClick = (userMedicineHistoryId) => {\r\n let userMedicineHistory = this.state.currentUserPrescription.userMedicines.find(m => m.userMedicineHistoryId === userMedicineHistoryId);\r\n if (userMedicineHistory) {\r\n this.setState({\r\n currrentUserMedicineHistory: userMedicineHistory\r\n });\r\n }\r\n this.setState({\r\n isVisibleConfirmDialog: true\r\n });\r\n }\r\n\r\n deleteUserMedicine = (userMedicineHistoryId) => {\r\n this.setState({\r\n isVisibleConfirmDialog: false,\r\n isLoading: true\r\n });\r\n\r\n if (userMedicineHistoryId && this.state.currentUserPrescription && this.state.currentUserPrescription.userPrescriptionId) {\r\n this.userService.deletePrescriptionMedicine(this.state.currentUserPrescription.userPrescriptionId, userMedicineHistoryId)\r\n .then(\r\n (data) => {\r\n this.growl.show({ severity: 'success', summary: Translate('Deleted Successfully') });\r\n this.getPrescriptionMedicines(this.props.userPrescriptionId);\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n }\r\n else {\r\n this.growl.show({ severity: 'error', summary: \"Delete failed\" });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n }\r\n\r\n //********************** Notifications methods *******************************************************************/\r\n showUserNotificationListDialog = (show: boolean) => {\r\n this.setState({\r\n isVisibleUserNotificationListDialog: show\r\n });\r\n }\r\n\r\n handleUserNotificationButtonClick = (userMedicineHistoryId) => {\r\n if (!userMedicineHistoryId) {\r\n this.growl.show({ severity: 'error', summary: \"UserMedicine ID is not valid\" });\r\n } else {\r\n let userMedicineHistory = this.state.currentUserPrescription.userMedicines.find(m => m.userMedicineHistoryId === userMedicineHistoryId);\r\n\r\n if (userMedicineHistory) {\r\n this.setState({\r\n currrentUserMedicineHistory: userMedicineHistory\r\n });\r\n }\r\n this.showUserNotificationListDialog(true);\r\n }\r\n }\r\n\r\n handleUserNotificationListDialogCloseButton = () => {\r\n this.getPrescriptionMedicines(this.props.userPrescriptionId);\r\n this.showUserNotificationListDialog(false);\r\n }\r\n\r\n expandedData = (rowData: UserMedicineHistoryModel) => {\r\n const classrs = {\r\n backgroundColor: '#17a2b8',\r\n color: 'white',\r\n border: 'none',\r\n borderRadius: '3px',\r\n marginRight: \".5em\",\r\n fontSize: 16,\r\n width: 50\r\n }\r\n\r\n return (\r\n \r\n this.handleUserNotificationButtonClick(rowData.userMedicineHistoryId)}>\r\n \r\n \r\n\r\n this.handleUserMedicineAddEditClick(rowData.userMedicineHistoryId)}\r\n > \r\n this.handleUserMedicineDeleteClick(rowData.userMedicineHistoryId)}\r\n >\r\n
\r\n );\r\n }\r\n\r\n rowExpansionTemplate = (rowData: UserMedicineHistoryModel) => {\r\n return (\r\n r.userMedicineHistoryId == rowData.userMedicineHistoryId)}\r\n timeout={300} classNames=\"list-slide\" mountOnEnter unmountOnExit>\r\n {this.expandedData(rowData)}\r\n \r\n );\r\n }\r\n\r\n expandData = (data: UserMedicineHistoryModel) => {\r\n if (!this.state.expandedMedicine.some(r => r.userMedicineHistoryId == data.userMedicineHistoryId) || this.state.expandedMedicine.length == 0) {\r\n this.setState({ expandedMedicine: [...this.state.expandedMedicine, data] });\r\n } else {\r\n this.setState({ expandedMedicine: this.state.expandedMedicine.filter(r => r.userMedicineHistoryId != data.userMedicineHistoryId) });\r\n }\r\n }\r\n\r\n keyItem = (m: UserMedicineHistoryModel) => {\r\n return m.userMedicineHistoryId + 'umedId';\r\n }\r\n\r\n itemName = (m: UserMedicineHistoryModel) => {\r\n return m.medicineName;\r\n }\r\n\r\n itemDesc = (m: UserMedicineHistoryModel) => {\r\n return (\r\n <>\r\n {m.singleDose ? Translate(\"Single Dose\") + ': ' + m.singleDose : null}
\r\n {m.frequencyOfIntake ? Translate(\"Frequency Of Intake\") + ': ' + m.frequencyOfIntake : null}
\r\n {m.intakeConditions ? Translate(\"Intake Conditions\") + ': ' + m.intakeConditions : null}
\r\n {HelperFunctions.fomatDatesStringWithLang(new Date(m.startDate ? m.startDate : ''), this.props.lang) + \" - \"}\r\n {HelperFunctions.fomatDatesStringWithLang(new Date(m.endDate ? m.endDate : ''), this.props.lang)}\r\n \r\n
\r\n {Translate('Alarms')}\r\n
\r\n {m.notificationsCount ? m.notificationsCount : '0'}\r\n
\r\n
\r\n >\r\n )\r\n }\r\n\r\n itemActions = (m: UserMedicineHistoryModel) => {\r\n return (\r\n <>\r\n {window.innerWidth >= Constants.device.tablet ? this.expandedData(m) :\r\n\r\n this.state.expandedMedicine.some(r => r.userMedicineHistoryId == m.userMedicineHistoryId) ?\r\n \r\n : \r\n }\r\n >\r\n )\r\n }\r\n\r\n render() {\r\n const { isLoading, currentUserPrescription, userId, currrentUserMedicineHistory } = this.state;\r\n\r\n let dialogHeader: string = Translate('Medicines');\r\n let contentHeader = Translate('Medicines') + \" \" + Translate('for') + \" \" + Translate('prescription')\r\n + \" \" + ((currentUserPrescription && currentUserPrescription.prescription) ? currentUserPrescription.prescription : \"\");\r\n\r\n return (\r\n <>\r\n {isLoading ? : null}\r\n {this.state.validationMessage ? {this.state.validationMessage} : null}\r\n this.growl = el} />\r\n {Translate('MedicinesForPrescription')}:
\r\n {HelperFunctions.fomatDatesStringWithLang(new Date(currentUserPrescription.startDate ? currentUserPrescription.startDate : ''), this.props.lang) + \" - \"}\r\n {HelperFunctions.fomatDatesStringWithLang(new Date(currentUserPrescription.endDate ? currentUserPrescription.endDate : ''), this.props.lang)}
\r\n \r\n \r\n
{currentUserPrescription.doctor}
\r\n \r\n \r\n
this.handleUserMedicineAddEditClick(null)} className=\"floating-action-button\">\r\n \r\n \r\n
\r\n {!isLoading && (!currentUserPrescription.userMedicines || currentUserPrescription.userMedicines.length == 0) ? Translate(\"No records found\") : null}\r\n
\r\n\r\n {this.state.isVisibleUserMedcineAddEditDialog ? (\r\n ) : null}\r\n\r\n {this.state.isVisibleUserNotificationListDialog ? (\r\n ) : null}\r\n\r\n { this.deleteUserMedicine(currrentUserMedicineHistory.userMedicineHistoryId) }}\r\n noClick={() => { this.setState({ isVisibleConfirmDialog: false }) }}>\r\n {Translate(\"Confirm Message\") + \" \"}\r\n {(currrentUserMedicineHistory ? ('\"' + currrentUserMedicineHistory.medicineName + '\"')\r\n : \"this record\")}?\r\n \r\n\r\n >\r\n )\r\n }\r\n}\r\n\r\n\r\nexport default PrescriptionMedicineListDialog;\r\n","import * as React from 'react';\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport Button from '@material-ui/core/Button'\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes } from '@fortawesome/free-solid-svg-icons';\r\nimport DiseaseService from '../../../services/diseaseService';\r\nimport { DiseaseGridModel, DiseaseForGridModel, DiseaseFilterSettingsModel } from \"../../../models\";\r\nimport Translate from '../../../common/functions/translate';\r\nimport Paginator from '../../../common/components/paginator/paginator';\r\nimport Radio from '@material-ui/core/Radio';\r\nimport UserDiseaseFilter from '../userDiseases/diseaseFilter';\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\n\r\ninterface IProps {\r\n selectedDisease: DiseaseForGridModel,\r\n isVisible: boolean,\r\n cancelClick: any,\r\n addClick: any,\r\n lang: string,\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n from: number;\r\n numberOfRows: number;\r\n totalRecordsCount: number;\r\n allDiseases: Array;\r\n currentDisease: DiseaseForGridModel;\r\n currentFilterSettings: DiseaseFilterSettingsModel;\r\n page: number;\r\n numberOfPages: number;\r\n}\r\n\r\nconst initFrom = 0;\r\nconst numberOfRows = 20;\r\n\r\nclass DiseasesListDialog extends React.Component {\r\n diseaseService = new DiseaseService(this.props.lang);\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n from: initFrom,\r\n numberOfRows: numberOfRows,\r\n totalRecordsCount: 0,\r\n allDiseases: new Array(0),\r\n currentDisease: this.props.selectedDisease,\r\n currentFilterSettings: new DiseaseFilterSettingsModel(),\r\n page: 1,\r\n numberOfPages: 1\r\n }\r\n }\r\n\r\n componentDidMount() {\r\n //this.getAllFilteredItems(this.state.page, this.state.numberOfRows, this.state.currentFilterSettings);\r\n }\r\n\r\n getAllFilteredItems(page: number, numberOfRows: number, currentFilterSettings: DiseaseFilterSettingsModel) {\r\n let from = (page - 1) * this.state.numberOfRows;\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n this.diseaseService.getAllDiseases(from, numberOfRows, currentFilterSettings, this.props.lang).then(\r\n (data: DiseaseGridModel) => {\r\n this.setState({\r\n isLoading: false,\r\n from: from,\r\n allDiseases: data.diseases,\r\n totalRecordsCount: data.totalRecordsCount,\r\n numberOfPages: (data.totalRecordsCount % this.state.numberOfRows > 0 ?\r\n data.totalRecordsCount / this.state.numberOfRows + 1 : data.totalRecordsCount / this.state.numberOfRows)\r\n });\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n paginataorClick = (page) => {\r\n this.setState({ page: page }, () => this.getAllFilteredItems(page, this.state.numberOfRows, this.state.currentFilterSettings));\r\n }\r\n\r\n handleCurrentDiseaseSelection = (e) => {\r\n this.setState({\r\n currentDisease: e.data\r\n });\r\n }\r\n\r\n displayHeaderSelection(currentDisease: DiseaseForGridModel) {\r\n if (!currentDisease || (currentDisease && !currentDisease.diseaseCode)) {\r\n return {Translate(\"No Selection\")}
;\r\n }\r\n else {\r\n return {Translate(\"Disease\")}: \r\n {[currentDisease.diseaseCode, currentDisease.diseaseName].filter(Boolean).join(' ')}\r\n
\r\n }\r\n }\r\n\r\n handleCancelButton = () => {\r\n this.props.cancelClick();\r\n }\r\n\r\n handleAddButton = event => {\r\n event.preventDefault();\r\n const currentDisease = this.state.currentDisease;\r\n this.props.addClick(currentDisease);\r\n }\r\n\r\n onSelectDisease = (disease: DiseaseForGridModel) => {\r\n this.setState({ currentDisease: { ...disease } });\r\n }\r\n\r\n handleSearchButtonClick = (settings) => {\r\n this.setState({\r\n isLoading: true, page: 1, currentFilterSettings: settings\r\n }, () => this.getAllFilteredItems(this.state.page, this.state.numberOfRows, settings));\r\n }\r\n\r\n handleOnClearClick = () => {\r\n this.setState({ currentFilterSettings: new DiseaseFilterSettingsModel(), page: 1, numberOfPages: 0, allDiseases: [], totalRecordsCount: 0 });\r\n }\r\n\r\n render() {\r\n let { allDiseases, currentDisease, numberOfPages, page, isLoading, currentFilterSettings } = this.state;\r\n\r\n return (\r\n \r\n )\r\n }\r\n}\r\n\r\nexport default DiseasesListDialog;","import * as React from 'react';\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes, faTimesCircle } from '@fortawesome/free-solid-svg-icons';\r\nimport UserService from '../../../services/userService';\r\nimport Translate from '../../../common/functions/translate';\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport DiseasesListDialog from './diseasesListDialog';\r\nimport { DiseaseForGridModel } from \"../../../models\";\r\nimport { UserDiseaseHistoryModel } from \"../../../models/user/userDiseaseHistoryModel\";\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport { DatePicker } from '@material-ui/pickers';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport AddIcon from '@material-ui/icons/Add';\r\nimport Fab from '@material-ui/core/Fab';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\n\r\ninterface IProps {\r\n isVisible: boolean,\r\n cancelClick: any,\r\n saveClick: any,\r\n userId: number,\r\n selectedDiseaseHistory: UserDiseaseHistoryModel,\r\n isDiseaseButtonDisabled: boolean,\r\n lang: string\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n validationMessage: string;\r\n from: number;\r\n numberOfRows: number;\r\n totalRecordsCount: number;\r\n currentDisease: DiseaseForGridModel;\r\n currentDiseaseHistory: UserDiseaseHistoryModel;\r\n isVisibleDiseaseListDialog: boolean;\r\n}\r\n\r\nconst initFrom = 0;\r\nconst numberOfRows = 10;\r\n\r\nclass UserDiseaseAddEditDialog extends React.Component {\r\n userService = new UserService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n validationMessage: '',\r\n from: initFrom,\r\n numberOfRows: numberOfRows,\r\n totalRecordsCount: 0,\r\n currentDisease: new DiseaseForGridModel(),\r\n currentDiseaseHistory: props.selectedDiseaseHistory,\r\n isVisibleDiseaseListDialog: false\r\n }\r\n }\r\n\r\n componentDidMount() {\r\n }\r\n\r\n handleDiseaseListDialogAddButton = (currentDisease: DiseaseForGridModel) => {\r\n this.setState({\r\n currentDisease: currentDisease,\r\n isVisibleDiseaseListDialog: false\r\n });\r\n }\r\n\r\n handleDiseaseListDialogCancelButton = () => {\r\n this.setState({\r\n isVisibleDiseaseListDialog: false\r\n });\r\n };\r\n\r\n handleSaveButton = event => {\r\n let currentDiseaseHistory: UserDiseaseHistoryModel = { ...this.state.currentDiseaseHistory }\r\n\r\n if (currentDiseaseHistory && currentDiseaseHistory.userDiseaseHistoryId) {\r\n if (currentDiseaseHistory.startDate) {\r\n currentDiseaseHistory.startDate = HelperFunctions.fomatDateAsString(new Date(currentDiseaseHistory.startDate))\r\n } else {\r\n currentDiseaseHistory.startDate = HelperFunctions.fomatDateAsString(new Date())\r\n }\r\n\r\n if (currentDiseaseHistory.endDate) {\r\n currentDiseaseHistory.endDate = HelperFunctions.fomatDateAsString(new Date(currentDiseaseHistory.endDate))\r\n } else {\r\n currentDiseaseHistory.endDate = HelperFunctions.fomatDateAsString(new Date())\r\n }\r\n\r\n this.props.saveClick(currentDiseaseHistory);\r\n } else {\r\n if (!this.state.currentDisease || !this.state.currentDisease.diseaseId) {\r\n this.growl.show({ severity: 'warning', summary: Translate(\"Please select disease\") });\r\n } else {\r\n\r\n currentDiseaseHistory.diseaseId = this.state.currentDisease.diseaseId;\r\n currentDiseaseHistory.userId = this.props.userId;\r\n currentDiseaseHistory.diseaseName = [this.state.currentDisease.diseaseCode, this.state.currentDisease.diseaseName].filter(Boolean).join(' ');\r\n\r\n if (currentDiseaseHistory.startDate) {\r\n currentDiseaseHistory.startDate = HelperFunctions.fomatDateAsString(new Date(currentDiseaseHistory.startDate))\r\n } else {\r\n currentDiseaseHistory.startDate = HelperFunctions.fomatDateAsString(new Date())\r\n }\r\n\r\n if (currentDiseaseHistory.endDate) {\r\n currentDiseaseHistory.endDate = HelperFunctions.fomatDateAsString(new Date(currentDiseaseHistory.endDate))\r\n } else {\r\n currentDiseaseHistory.endDate = HelperFunctions.fomatDateAsString(new Date())\r\n }\r\n\r\n this.props.saveClick(currentDiseaseHistory);\r\n }\r\n }\r\n }\r\n\r\n handleCancelButton = () => {\r\n this.props.cancelClick();\r\n }\r\n\r\n handleChange = (key, value) => {\r\n const currentDiseaseHistory: UserDiseaseHistoryModel = { ...this.state.currentDiseaseHistory };\r\n currentDiseaseHistory[key] = value;\r\n this.setState({ currentDiseaseHistory: { ...currentDiseaseHistory } });\r\n };\r\n\r\n handleDiseaseAddEditClick() {\r\n this.setState({\r\n isVisibleDiseaseListDialog: true,\r\n validationMessage: ''\r\n });\r\n }\r\n\r\n handleDiseaseRemoveClick(event) {\r\n event.preventDefault();\r\n this.setState({\r\n currentDisease: new DiseaseForGridModel()\r\n });\r\n }\r\n\r\n render() {\r\n const { currentDisease, currentDiseaseHistory } = this.state;\r\n const { isDiseaseButtonDisabled } = this.props;\r\n\r\n let diseaseValue: string = Translate('Select');\r\n let dialogHeader: string = Translate('Disease');\r\n\r\n let diseaseInputButton;\r\n if (isDiseaseButtonDisabled) {\r\n diseaseInputButton = null;\r\n diseaseValue = currentDiseaseHistory.diseaseName;\r\n dialogHeader = dialogHeader + ' - ' + diseaseValue;\r\n\r\n } else {\r\n if (currentDisease && currentDisease.diseaseCode) {\r\n diseaseValue = [currentDisease.diseaseCode, currentDisease.diseaseName].filter(Boolean).join(' ');\r\n dialogHeader = dialogHeader + ' - ' + diseaseValue;\r\n }\r\n\r\n let classInput = 'float-left-full-width';\r\n if (!currentDisease || !currentDisease.diseaseId) {\r\n classInput = 'float-left-calculated-width';\r\n }\r\n\r\n diseaseInputButton =\r\n \r\n
\r\n
\r\n
\r\n {currentDisease && currentDisease.diseaseId ?\r\n <>\r\n
\r\n - \r\n
\r\n
\r\n {currentDisease.diseaseCode ? currentDisease.diseaseCode : ''}{' '}\r\n {currentDisease.diseaseName ? currentDisease.diseaseName : ''}\r\n
\r\n
\r\n \r\n \r\n
\r\n >\r\n :
{Translate('No disease selected')}
}\r\n
\r\n {!currentDisease || !currentDisease.diseaseId ?\r\n
\r\n
this.handleDiseaseAddEditClick()}>\r\n \r\n \r\n
: null}\r\n
\r\n
\r\n }\r\n return (\r\n <>\r\n \r\n {this.state.isVisibleDiseaseListDialog ? (\r\n \r\n ) : null}\r\n >\r\n )\r\n }\r\n}\r\n\r\nexport default UserDiseaseAddEditDialog;\r\n","import * as React from 'react';\r\nimport UserService from '../../../services/userService';\r\nimport Translate from '../../../common/functions/translate';\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport { fomatDateAsString } from '../../../common/functions/helperFunctions';\r\nimport { UserPrescriptionModel } from '../../../models/user/userPrescriptionModel';\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport AuthService from '../../../services/authService';\r\nimport ConfirmDialog from '../../../common/components/confirmDialog/confirmDialog';\r\nimport { UserDiseaseHistoryModel } from \"../../../models/user/userDiseaseHistoryModel\";\r\nimport UserDiseaseAddEditDialog from './userDiseaseAddEditDialog';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faBell } from '@fortawesome/free-solid-svg-icons';\r\nimport { faChevronDown, faChevronUp, faUserMd } from '@fortawesome/free-solid-svg-icons';\r\nimport CSSTransition from 'react-transition-group/CSSTransition';\r\nimport Fab from '@material-ui/core/Fab';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport AddIcon from '@material-ui/icons/Add';\r\nimport ExpandingList from '../../../common/components/expandingList/expandingList';\r\nimport * as Constants from '../../../common/constants';\r\n\r\ninterface IProps {\r\n isVisible: boolean,\r\n closeClick: any,\r\n userPrescriptionId: number,\r\n lang: string\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n validationMessage: string;\r\n from: number;\r\n numberOfRows: number;\r\n totalRecordsCount: number;\r\n currentUserPrescription: UserPrescriptionModel,\r\n isVisibleUserDisaeseAddEditDialog: boolean,\r\n isDiseaseButtonDisabled: boolean;\r\n currrentUserDiseaseHistory: UserDiseaseHistoryModel,\r\n userId: number;\r\n isVisibleConfirmDialog: boolean;\r\n expandedDiseases: Array\r\n}\r\n\r\nconst initFrom = 0;\r\nconst numberOfRows = 10;\r\n\r\nclass PrescriptionDiseaseListDialog extends React.Component {\r\n userService = new UserService(this.props.lang);\r\n authService = new AuthService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n validationMessage: '',\r\n from: initFrom,\r\n numberOfRows: numberOfRows,\r\n totalRecordsCount: 0,\r\n currentUserPrescription: new UserPrescriptionModel(),\r\n isVisibleUserDisaeseAddEditDialog: false,\r\n isDiseaseButtonDisabled: false,\r\n currrentUserDiseaseHistory: new UserDiseaseHistoryModel(),\r\n userId: 0,\r\n isVisibleConfirmDialog: false,\r\n expandedDiseases: new Array()\r\n }\r\n }\r\n\r\n componentDidMount() {\r\n this.getPrescriptionDiseases(this.props.userPrescriptionId);\r\n }\r\n\r\n getPrescriptionDiseases = (userPrescriptionId) => {\r\n if (!userPrescriptionId) {\r\n this.growl.show({ severity: 'error', summary: \"PrescriptionID not valid\" });\r\n } else {\r\n this.setState({\r\n isLoading: true\r\n });\r\n this.userService.getPrescriptionDiseases(userPrescriptionId, this.props.lang)\r\n .then(\r\n (data: UserPrescriptionModel) => {\r\n this.setCurrentUserPrescription(data);\r\n this.setState({\r\n isLoading: false\r\n });\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n }\r\n }\r\n\r\n setCurrentUserPrescription(currentUserPrescription: UserPrescriptionModel) {\r\n this.setState({ currentUserPrescription: { ...currentUserPrescription } });\r\n }\r\n\r\n handleCloseButton = () => {\r\n this.props.closeClick();\r\n }\r\n\r\n //********************** Disaeses methods *******************************************************************/\r\n handleUserDiseaseAddEditClick = (userDiseaseId) => {\r\n\r\n if (!userDiseaseId) {\r\n let currrentUserDiseaseHistory = new UserDiseaseHistoryModel();\r\n\r\n if (this.state.currentUserPrescription.startDate) {\r\n currrentUserDiseaseHistory.startDate = fomatDateAsString(new Date(this.state.currentUserPrescription.startDate));\r\n } else {\r\n currrentUserDiseaseHistory.startDate = fomatDateAsString(new Date());\r\n }\r\n\r\n if (this.state.currentUserPrescription.endDate) {\r\n currrentUserDiseaseHistory.endDate = fomatDateAsString(new Date(this.state.currentUserPrescription.endDate));\r\n } else {\r\n currrentUserDiseaseHistory.endDate = fomatDateAsString(new Date());\r\n }\r\n\r\n this.setState({\r\n currrentUserDiseaseHistory: currrentUserDiseaseHistory\r\n });\r\n this.showUserDiseaseAddEditDialog(true, false);\r\n } else {\r\n let userDiseaseHistory = this.state.currentUserPrescription.userDiseases.find(m => m.userDiseaseHistoryId === userDiseaseId);\r\n\r\n if (userDiseaseHistory) {\r\n this.setState({\r\n currrentUserDiseaseHistory: userDiseaseHistory\r\n });\r\n }\r\n this.showUserDiseaseAddEditDialog(true, true);\r\n }\r\n\r\n if (!this.state.userId || this.state.userId <= 0) {\r\n if (this.authService.isAuthenticated()) {\r\n let profile = this.authService.getProfile();\r\n let id = profile['id'];\r\n this.setState({\r\n userId: id,\r\n });\r\n }\r\n else {\r\n console.log(\"EROR\");\r\n }\r\n }\r\n }\r\n\r\n showUserDiseaseAddEditDialog = (show: boolean, isButtonDisabled: boolean) => {\r\n this.setState({\r\n isVisibleUserDisaeseAddEditDialog: show,\r\n isDiseaseButtonDisabled: isButtonDisabled\r\n });\r\n }\r\n\r\n handleUserDiseaseAddEditDialogCancelButton = () => {\r\n this.showUserDiseaseAddEditDialog(false, false);\r\n }\r\n\r\n handleUserDiseaseSave = (selectedUserDisease: UserDiseaseHistoryModel) => {\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n if (!selectedUserDisease.userDiseaseHistoryId) { //INSERT \r\n this.userService.addPrescriptionDisease(this.props.userPrescriptionId, selectedUserDisease)\r\n .then(\r\n (data) => {\r\n this.growl.show({ severity: 'success', summary: Translate('Data Saved Successfully') });\r\n this.getPrescriptionDiseases(this.props.userPrescriptionId);\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n } else {//UPDATE\r\n this.userService.updatePrescriptionDisease(this.props.userPrescriptionId, selectedUserDisease)\r\n .then(\r\n (data) => {\r\n this.growl.show({ severity: 'success', summary: Translate('Data Saved Successfully') });\r\n this.getPrescriptionDiseases(this.props.userPrescriptionId);\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n this.showUserDiseaseAddEditDialog(false, false);\r\n }\r\n\r\n handleUserDiseaseDeleteClick = (userDiseaseId) => {\r\n let userDiseaseHistory = this.state.currentUserPrescription.userDiseases.find(m => m.userDiseaseHistoryId === userDiseaseId);\r\n if (userDiseaseHistory) {\r\n this.setState({\r\n currrentUserDiseaseHistory: userDiseaseHistory\r\n });\r\n }\r\n this.setState({\r\n isVisibleConfirmDialog: true\r\n });\r\n }\r\n\r\n deleteUserDisease = (userDiseaseId) => {\r\n this.setState({\r\n isVisibleConfirmDialog: false,\r\n isLoading: true\r\n });\r\n\r\n if (userDiseaseId && this.state.currentUserPrescription && this.state.currentUserPrescription.userPrescriptionId) {\r\n this.userService.deletePrescriptionDisease(this.state.currentUserPrescription.userPrescriptionId, userDiseaseId)\r\n .then(\r\n (data) => {\r\n this.growl.show({ severity: 'success', summary: Translate('Deleted Successfully') });\r\n this.getPrescriptionDiseases(this.props.userPrescriptionId);\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n }\r\n else {\r\n this.growl.show({ severity: 'error', summary: \"Delete failed\" });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n }\r\n\r\n expandedData = (rowData: UserDiseaseHistoryModel) => {\r\n return (\r\n \r\n this.handleUserDiseaseAddEditClick(rowData.userDiseaseHistoryId)}\r\n > \r\n this.handleUserDiseaseDeleteClick(rowData.userDiseaseHistoryId)}\r\n >\r\n
\r\n );\r\n }\r\n\r\n rowExpansionTemplate = (rowData: UserDiseaseHistoryModel) => {\r\n return (\r\n r.userDiseaseHistoryId == rowData.userDiseaseHistoryId)}\r\n timeout={300} classNames=\"list-slide\" mountOnEnter unmountOnExit>\r\n {this.expandedData(rowData)}\r\n \r\n );\r\n }\r\n\r\n expandData = (data: UserDiseaseHistoryModel) => {\r\n if (!this.state.expandedDiseases.some(r => r.userDiseaseHistoryId == data.userDiseaseHistoryId) || this.state.expandedDiseases.length == 0) {\r\n this.setState({ expandedDiseases: [...this.state.expandedDiseases, data] });\r\n } else {\r\n this.setState({ expandedDiseases: this.state.expandedDiseases.filter(r => r.userDiseaseHistoryId != data.userDiseaseHistoryId) });\r\n }\r\n }\r\n\r\n keyItem = (m: UserDiseaseHistoryModel) => {\r\n return m.userDiseaseHistoryId + 'uDisId';\r\n }\r\n\r\n itemName = (m: UserDiseaseHistoryModel) => {\r\n return m.diseaseCode + \" \" + m.diseaseName;\r\n }\r\n\r\n itemDesc = (m: UserDiseaseHistoryModel) => {\r\n return (\r\n <>\r\n {HelperFunctions.fomatDatesStringWithLang(new Date(m.startDate ? m.startDate : ''), this.props.lang) + \" - \"}\r\n {HelperFunctions.fomatDatesStringWithLang(new Date(m.endDate ? m.endDate : ''), this.props.lang)}\r\n >\r\n )\r\n }\r\n\r\n itemActions = (m: UserDiseaseHistoryModel) => {\r\n return (\r\n <>\r\n {window.innerWidth >= Constants.device.tablet ? this.expandedData(m) :\r\n\r\n this.state.expandedDiseases.some(r => r.userDiseaseHistoryId == m.userDiseaseHistoryId) ?\r\n \r\n : \r\n }\r\n >\r\n )\r\n }\r\n\r\n render() {\r\n const { isLoading, currentUserPrescription, userId, currrentUserDiseaseHistory } = this.state;\r\n\r\n let dialogHeader: string = Translate('Diseases');\r\n let contentHeader = Translate('Diseases') + \" \" + Translate('for') + \" \" + Translate('prescription')\r\n + \" \" + ((currentUserPrescription && currentUserPrescription.prescription) ? currentUserPrescription.prescription : \"\");\r\n\r\n return (\r\n <>\r\n {isLoading ? : null}\r\n {this.state.validationMessage ? {this.state.validationMessage} : null}\r\n this.growl = el} />\r\n \r\n
{Translate('DiseasesForPrescription')}:
\r\n
{HelperFunctions.fomatDatesStringWithLang(new Date(currentUserPrescription.startDate ? currentUserPrescription.startDate : ''), this.props.lang) + \" - \"}\r\n {HelperFunctions.fomatDatesStringWithLang(new Date(currentUserPrescription.endDate ? currentUserPrescription.endDate : ''), this.props.lang)}
\r\n
\r\n \r\n
{currentUserPrescription.doctor}
\r\n \r\n
\r\n
this.handleUserDiseaseAddEditClick(null)} className=\"floating-action-button\">\r\n \r\n \r\n
\r\n {!isLoading && (!currentUserPrescription.userDiseases || currentUserPrescription.userDiseases.length == 0) ? Translate(\"No records found\") : null}\r\n\r\n
\r\n
\r\n\r\n {this.state.isVisibleUserDisaeseAddEditDialog ? (\r\n ) : null}\r\n\r\n { this.deleteUserDisease(currrentUserDiseaseHistory.userDiseaseHistoryId) }}\r\n noClick={() => { this.setState({ isVisibleConfirmDialog: false }) }}>\r\n {Translate(\"Confirm Message\") + \" \"}\r\n {(currrentUserDiseaseHistory ? ('\"' + currrentUserDiseaseHistory.diseaseName + '\"')\r\n : \"this record\")}?\r\n \r\n\r\n >\r\n )\r\n }\r\n}\r\n\r\n\r\nexport default PrescriptionDiseaseListDialog;\r\n","import * as React from \"react\";\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport Translate from '../../../common/functions/translate';\r\nimport UserService from '../../../services/userService';\r\nimport AuthService from '../../../services/authService';\r\nimport { UserPrescriptionGridModel } from '../../../models/user/userPrescriptionGridModel';\r\nimport { UserPrescriptionModel } from '../../../models/user/userPrescriptionModel';\r\nimport UserPrescriptionList from './userPrescriptionList';\r\nimport UserPrescriptionAddEditDialog from './userPrescriptionAddEditDialog';\r\nimport ConfirmDialog from '../../../common/components/confirmDialog/confirmDialog';\r\nimport PrescriptionMedicineListDialog from './prescriptionMedicineListDialog';\r\nimport PrescriptionDiseaseListDialog from './prescriptionDiseaseListDialog';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport {\r\n faPills, faUserMd, faNotesMedical, faCheckCircle, faFileAlt, faUtensils, faStethoscope,\r\n faExclamationTriangle, faHospital, faChevronUp, faChevronDown\r\n} from '@fortawesome/free-solid-svg-icons';\r\nimport { connect } from 'react-redux';\r\nimport Fab from '@material-ui/core/Fab';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport AddIcon from '@material-ui/icons/Add';\r\nimport ExpandingList from '../../../common/components/expandingList/expandingList';\r\nimport CSSTransition from 'react-transition-group/CSSTransition';\r\nimport * as HelperFunctions from \"../../../common/functions/helperFunctions\";\r\nimport * as Constants from '../../../common/constants';\r\n\r\ninterface IProps {\r\n history: any\r\n lang: string;\r\n location: any;\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n validationMessage: string;\r\n userId: number;\r\n currentUserPrescription: UserPrescriptionModel;\r\n userPrescriptions: Array\r\n isVisibleUserPrescriptionAddEditDialog: boolean;\r\n isVisibleConfirmDialog: boolean;\r\n currentUserPrescriptionId: number;\r\n isVisiblePrescriptionMedicinesListDialog: boolean;\r\n isVisiblePrescriptionDiseaseListDialog: boolean;\r\n expandedPrescription: Array;\r\n first: number;\r\n rows: number;\r\n totalRecords: number;\r\n activePrescriptionCount: number;\r\n countVisible: boolean;\r\n}\r\n\r\nclass UserPrescriptionComponent extends React.Component {\r\n userService = new UserService();\r\n authService = new AuthService();\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n validationMessage: '',\r\n isLoading: false,\r\n userId: 0,\r\n currentUserPrescription: new UserPrescriptionModel(),\r\n userPrescriptions: new Array(0),\r\n isVisibleUserPrescriptionAddEditDialog: false,\r\n isVisibleConfirmDialog: false,\r\n currentUserPrescriptionId: 0,\r\n isVisiblePrescriptionMedicinesListDialog: false,\r\n isVisiblePrescriptionDiseaseListDialog: false,\r\n expandedPrescription: new Array(0),\r\n first: 0,\r\n rows: 20,\r\n totalRecords: 0,\r\n activePrescriptionCount: 0,\r\n countVisible: true\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n let perscriptionId = HelperFunctions.getURLParameter('perscriptionId');\r\n if (perscriptionId) {\r\n this.setState({\r\n isLoading: true,\r\n countVisible: false\r\n });\r\n\r\n if (this.authService.isAuthenticated()) {\r\n let profile = this.authService.getProfile();\r\n let id = profile ? profile['id'] : 0;\r\n\r\n this.userService.getUserPrescriptionFromLink(+perscriptionId).then(\r\n (data: any) => {\r\n if (data) {\r\n let prescriptions: Array = new Array(0);\r\n prescriptions.push(data);\r\n this.setState({\r\n isLoading: false,\r\n userPrescriptions: [...prescriptions],\r\n totalRecords: 1,\r\n activePrescriptionCount: 0,\r\n userId: id\r\n });\r\n\r\n }\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n }\r\n else {\r\n window.addEventListener('scroll', this.onScroll);\r\n this.getAllUserPrescriptions(true);\r\n }\r\n }\r\n\r\n componentWillUnmount() {\r\n window.removeEventListener('scroll', this.onScroll);\r\n }\r\n onScroll = () => {\r\n let scrollY = window.scrollY ? window.scrollY : window.pageYOffset;\r\n if (window.innerHeight + scrollY >= document.body.offsetHeight - 250 &&\r\n this.state.totalRecords > this.state.userPrescriptions.length && !this.state.isLoading) {\r\n this.paginatorClick({ first: this.state.first + this.state.rows }, false);\r\n }\r\n };\r\n\r\n paginatorClick = (e, isInit: boolean) => {\r\n this.setState({ first: e.first }, () => this.getAllUserPrescriptions(isInit));\r\n }\r\n\r\n componentDidUpdate(prevProps) {\r\n const locationChanged = this.props.location !== prevProps.location;\r\n if (locationChanged) {\r\n let tabName = HelperFunctions.getURLParameter('tabName');\r\n let perscriptionId = HelperFunctions.getURLParameter('perscriptionId');\r\n\r\n if (tabName && tabName == 'Medicines' && this.props.history.action === \"POP\") {\r\n this.handlePrescriptionMedicinesButtonClick(perscriptionId);\r\n }\r\n if (tabName && tabName == 'Diseases' && this.props.history.action === \"POP\") {\r\n this.handlePrescriptionDiseasesButtonClick(perscriptionId);\r\n }\r\n if (!tabName && this.props.history.action === \"POP\") {\r\n this.setState({ isVisiblePrescriptionDiseaseListDialog: false, isVisiblePrescriptionMedicinesListDialog: false, first: 0 }, () => this.getAllUserPrescriptions(true));\r\n }\r\n }\r\n }\r\n\r\n getAllUserPrescriptions(isInit: boolean) {\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n if (this.authService.isAuthenticated()) {\r\n let profile = this.authService.getProfile();\r\n let id = profile ? profile['id'] : 0;\r\n\r\n this.userService.getAllUserPrescriptions(this.state.first, this.state.rows, this.props.lang).then(\r\n (data: any) => {\r\n if (data) {\r\n if (isInit) {\r\n this.setState({\r\n isLoading: false,\r\n userPrescriptions: [...data.userPrescriptions],\r\n totalRecords: data.totalRecords,\r\n activePrescriptionCount: data.activePrescriptionCount,\r\n userId: id\r\n });\r\n }\r\n else {\r\n this.setState({\r\n isLoading: false,\r\n userPrescriptions: [...this.state.userPrescriptions, ...data.userPrescriptions],\r\n totalRecords: data.totalRecords,\r\n userId: id\r\n });\r\n }\r\n }\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n }\r\n\r\n showEditDialog = (show: boolean) => {\r\n this.setState({\r\n isVisibleUserPrescriptionAddEditDialog: show,\r\n validationMessage: ''\r\n });\r\n };\r\n\r\n handleCancelButton = () => {\r\n this.showEditDialog(false);\r\n };\r\n\r\n setCurrentUserPrescription(currentUserPrescription: UserPrescriptionModel) {\r\n this.setState({ currentUserPrescription: { ...currentUserPrescription } });\r\n }\r\n\r\n handleSaveButton = (currentUserPrescription: UserPrescriptionModel, close: boolean) => {\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n if (!currentUserPrescription.userId || currentUserPrescription.userId <= 0) {\r\n currentUserPrescription.userId = this.state.userId;\r\n }\r\n\r\n if (!currentUserPrescription.userPrescriptionId) { // Add\r\n this.userService.addUserPrescription(currentUserPrescription)\r\n .then(\r\n (data) => {\r\n if (close) {\r\n this.showEditDialog(false);\r\n }\r\n this.growl.show({ severity: 'success', summary: Translate('Data Saved Successfully') });\r\n this.setCurrentUserPrescription(new UserPrescriptionModel());\r\n this.setState({ first: 0 }, () => this.getAllUserPrescriptions(true));\r\n },\r\n error => {\r\n this.showEditDialog(false);\r\n this.setCurrentUserPrescription(new UserPrescriptionModel());\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n } else { // Edit\r\n this.userService.updateUserPrescription(currentUserPrescription)\r\n .then(\r\n (data) => {\r\n if (close) {\r\n this.showEditDialog(false);\r\n }\r\n this.growl.show({ severity: 'success', summary: Translate('Data Saved Successfully') });\r\n this.setCurrentUserPrescription(new UserPrescriptionModel());\r\n this.setState({ first: 0 }, () => this.getAllUserPrescriptions(true));\r\n },\r\n error => {\r\n this.showEditDialog(false);\r\n this.setCurrentUserPrescription(new UserPrescriptionModel());\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n };\r\n\r\n getUserPrescription = (userPrescriptionId) => {\r\n this.userService.getUserPrescription(userPrescriptionId, this.props.lang)\r\n .then(\r\n (data: UserPrescriptionModel) => {\r\n this.setCurrentUserPrescription(data);\r\n this.setState({\r\n isLoading: false\r\n });\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n handleUserPrescriptionDeleteClick = (userPrescriptionId: number) => {\r\n this.getUserPrescription(userPrescriptionId);\r\n this.setState({\r\n isVisibleConfirmDialog: true\r\n });\r\n }\r\n\r\n deleteUserPrescription(userPrescriptionId) {\r\n this.setState({\r\n isVisibleConfirmDialog: false,\r\n isLoading: true\r\n });\r\n\r\n this.userService.deleteUserPrescription(userPrescriptionId)\r\n .then(\r\n data => {\r\n this.setState({ first: 0 }, () => this.getAllUserPrescriptions(true));\r\n this.growl.show({ severity: 'success', summary: Translate('Deleted Successfully') });\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n handleUserPrescriptionAddEditClick = (userPrescriptionId) => {\r\n\r\n if (!userPrescriptionId) { // Add\t\t\t\r\n this.setCurrentUserPrescription(new UserPrescriptionModel());\r\n this.showEditDialog(true);\r\n } else { // Edit\r\n this.setState({\r\n isLoading: true\r\n });\r\n this.userService.getUserPrescription(userPrescriptionId, this.props.lang)\r\n .then(\r\n (data: UserPrescriptionModel) => {\r\n this.setCurrentUserPrescription(data);\r\n this.showEditDialog(true);\r\n this.setState({\r\n isLoading: false\r\n });\r\n },\r\n error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n }\r\n );\r\n }\r\n }\r\n\r\n //************************** Prescription medicines methods ******************************************************/\r\n handlePrescriptionMedicinesButtonClick = (userPrescriptionId) => {\r\n if (!userPrescriptionId) {\r\n this.growl.show({ severity: 'error', summary: \"PrescriptionID not valid\" });\r\n } else {\r\n this.setState({\r\n currentUserPrescriptionId: userPrescriptionId\r\n });\r\n this.props.history.push(`/user/prescriptions?tabName=Medicines&perscriptionId=${userPrescriptionId}`);\r\n this.showPrescriptionMedicinesListDialog(true);\r\n }\r\n }\r\n\r\n handlePrescriptionMedicinesCloseButton = () => {\r\n this.showPrescriptionMedicinesListDialog(false);\r\n this.setState({ first: 0 }, () => this.getAllUserPrescriptions(true));\r\n };\r\n\r\n showPrescriptionMedicinesListDialog = (show: boolean) => {\r\n this.setState({\r\n isVisiblePrescriptionMedicinesListDialog: show,\r\n validationMessage: ''\r\n });\r\n };\r\n\r\n //************************** Prescription diseases methods ******************************************************/\r\n handlePrescriptionDiseasesButtonClick = (userPrescriptionId) => {\r\n if (!userPrescriptionId) {\r\n this.growl.show({ severity: 'error', summary: \"PrescriptionID not valid\" });\r\n } else {\r\n this.setState({\r\n currentUserPrescriptionId: userPrescriptionId\r\n });\r\n this.props.history.push(`/user/prescriptions?tabName=Diseases&perscriptionId=${userPrescriptionId}`);\r\n this.showPrescriptionDiseaseListDialog(true);\r\n }\r\n }\r\n\r\n handlePrescriptionDisaeseCloseButton = () => {\r\n this.showPrescriptionDiseaseListDialog(false);\r\n this.setState({ first: 0 }, () => this.getAllUserPrescriptions(true));\r\n };\r\n\r\n showPrescriptionDiseaseListDialog = (show: boolean) => {\r\n this.setState({\r\n isVisiblePrescriptionDiseaseListDialog: show,\r\n validationMessage: ''\r\n });\r\n };\r\n\r\n expanedData = (rowData: UserPrescriptionGridModel) => {\r\n return (\r\n \r\n this.handlePrescriptionMedicinesButtonClick(rowData.userPrescriptionId)}>\r\n \r\n this.handlePrescriptionDiseasesButtonClick(rowData.userPrescriptionId)}>\r\n \r\n this.handleUserPrescriptionAddEditClick(rowData.userPrescriptionId)}\r\n > \r\n this.handleUserPrescriptionDeleteClick(rowData.userPrescriptionId)}\r\n >\r\n
\r\n );\r\n }\r\n\r\n\r\n rowExpansionTemplate = (rowData: UserPrescriptionGridModel) => {\r\n return (\r\n r.userPrescriptionId == rowData.userPrescriptionId)}\r\n timeout={300} classNames=\"list-slide\" mountOnEnter unmountOnExit>\r\n {this.expanedData(rowData)}\r\n \r\n );\r\n }\r\n\r\n expandData = (data: UserPrescriptionGridModel) => {\r\n if (!this.state.expandedPrescription.some(r => r.userPrescriptionId == data.userPrescriptionId) || this.state.expandedPrescription.length == 0) {\r\n this.setState({ expandedPrescription: [...this.state.expandedPrescription, data] });\r\n } else {\r\n this.setState({ expandedPrescription: this.state.expandedPrescription.filter(r => r.userPrescriptionId != data.userPrescriptionId) });\r\n }\r\n }\r\n\r\n keyItem = (m: UserPrescriptionGridModel) => {\r\n return m.userPrescriptionId + 'perscId';\r\n }\r\n\r\n itemName = (m: UserPrescriptionGridModel) => {\r\n return (\r\n <>\r\n {m.isActiveNow ? : null}\r\n {\" \" + Translate('Course of treatment') + \": \"}\r\n \r\n {HelperFunctions.fomatDatesStringWithLang(new Date(m.startDate ? m.startDate : ''), this.props.lang) + \" - \"}\r\n {HelperFunctions.fomatDatesStringWithLang(new Date(m.endDate ? m.endDate : ''), this.props.lang)}\r\n \r\n >)\r\n }\r\n\r\n itemDesc = (m: UserPrescriptionGridModel) => {\r\n return (\r\n <>\r\n \r\n \r\n {m.doctor}\r\n
\r\n {m.hospital ?\r\n \r\n \r\n {m.hospital}\r\n
\r\n : null}\r\n {m.recommendedFoods ?\r\n \r\n \r\n {m.recommendedFoods}\r\n
: null}\r\n {m.notAllowedFoods ?\r\n \r\n \r\n {m.notAllowedFoods}\r\n
: null}\r\n {m.recommendedTreatment ?\r\n \r\n \r\n {m.recommendedTreatment}\r\n
: null}\r\n \r\n
\r\n {Translate('Medicines')}\r\n
\r\n {m.userMedicineCount ? m.userMedicineCount : '0'}\r\n
\r\n
\r\n \r\n
\r\n {Translate('Diseases')}\r\n
\r\n {m.userDiseaseCount ? m.userDiseaseCount : '0'}\r\n
\r\n
\r\n >\r\n )\r\n }\r\n\r\n itemActions = (m: UserPrescriptionGridModel) => {\r\n return (\r\n <>\r\n {window.innerWidth >= Constants.device.tablet ? this.expanedData(m) :\r\n\r\n this.state.expandedPrescription.some(r => r.userPrescriptionId == m.userPrescriptionId) ?\r\n \r\n : \r\n }\r\n >\r\n )\r\n }\r\n\r\n public render() {\r\n const { isLoading, userPrescriptions, totalRecords, activePrescriptionCount, currentUserPrescription,\r\n currentUserPrescriptionId, expandedPrescription, countVisible } = this.state;\r\n\r\n return (\r\n \r\n
this.growl = el} />\r\n\r\n {this.state.isVisiblePrescriptionMedicinesListDialog || this.state.isVisiblePrescriptionDiseaseListDialog ? null :\r\n <>\r\n {Translate('Doctors prescriptions')}
\r\n this.handleUserPrescriptionAddEditClick(null)} className=\"floating-action-button\">\r\n \r\n \r\n\r\n {(!isLoading && userPrescriptions && userPrescriptions.length > 0 && countVisible) ?\r\n \r\n {totalRecords} {Translate('total records.')}
\r\n {activePrescriptionCount} {Translate('current doctors prescriptions.')}\r\n {activePrescriptionCount > 0 ?\r\n \r\n : null}\r\n
: null}\r\n\r\n {/* */}\r\n \r\n {!isLoading && (!userPrescriptions || userPrescriptions.length == 0) ? Translate(\"No records found\") : null}\r\n >\r\n }\r\n {isLoading ? : null}\r\n {this.state.isVisibleUserPrescriptionAddEditDialog ? (\r\n ) : null}\r\n\r\n {this.state.isVisiblePrescriptionMedicinesListDialog ? (\r\n ) : null}\r\n\r\n {this.state.isVisiblePrescriptionDiseaseListDialog ? (\r\n ) : null}\r\n\r\n { this.deleteUserPrescription(currentUserPrescription.userPrescriptionId) }}\r\n noClick={() => { this.setState({ isVisibleConfirmDialog: false }) }}>\r\n {Translate(\"Confirm Message\") + \" \"}\r\n {(currentUserPrescription && currentUserPrescription.prescription) ? '\"' + currentUserPrescription.prescription + '\"'\r\n : Translate(\"This record\")} {Translate('And medicines diseases notifications')}?\r\n \r\n\r\n \r\n )\r\n }\r\n}\r\n\r\nconst mapsStateToProps = state => {\r\n return {\r\n lang: state.common.lang\r\n };\r\n}\r\n\r\nexport default connect(mapsStateToProps)(UserPrescriptionComponent);","import * as React from \"react\";\r\nimport Spinner from '../../common/components/spinner/spinner';\r\nimport Translate from '../../common/functions/translate';\r\nimport { UserChangePasswordModel } from '../../models/user/userChangePasswordModel';\r\nimport { Link } from \"react-router-dom\";\r\nimport * as HelperFunctions from \"../../common/functions/helperFunctions\";\r\nimport Growl from '../../common/components/alertMessage/growl';\r\nimport LoginService from '../../services/loginService';\r\nimport { userInfo } from \"os\";\r\nimport TextField from '@material-ui/core/TextField';\r\nimport Button from '@material-ui/core/Button';\r\nimport GrowlContent from '../../common/components/alertMessage/growlContent';\r\n\r\ninterface IProps {\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n user: UserChangePasswordModel;\r\n mode: string;\r\n emailError: boolean;\r\n passError: boolean;\r\n confPassError: boolean;\r\n}\r\n\r\nclass NewPasswordComponent extends React.Component {\r\n\r\n loginService = new LoginService();\r\n growl: any;\r\n\r\n // min 8 characters, 1 alpha lowercase, 1 alpha uppercase, 1 number and 1 special\r\n passwordStrongRegex = new RegExp(\"^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\\$%\\^&\\*])(?=.{8,})\");\r\n // min 6 characters, 1 alpha and 1 number\r\n passwordMediumRegex = new RegExp(\"^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})\");\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n user: new UserChangePasswordModel(),\r\n mode: '',\r\n emailError: false,\r\n passError: false,\r\n confPassError: false,\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n let confirmCode = HelperFunctions.getURLParameter('confirmCode');\r\n if (confirmCode) {\r\n this.validateConfirmCode(decodeURIComponent(confirmCode + ''));\r\n }\r\n }\r\n\r\n validateConfirmCode(confirmCode) {\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n this.loginService.validateConfirmCode(confirmCode).then(\r\n (data: any) => {\r\n if (data) {\r\n let user = this.state.user;\r\n user.activationCode = confirmCode;\r\n this.setState({\r\n isLoading: false,\r\n mode: 'validConfirmCode',\r\n user: user\r\n })\r\n }\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n handleChange = (key, value) => {\r\n const user: UserChangePasswordModel = { ...this.state.user };\r\n user[key] = value;\r\n this.setState({ user: { ...user } });\r\n\r\n if (key == 'email') {\r\n this.setState({ emailError: !HelperFunctions.validateEmail(user.email) });\r\n }\r\n\r\n if (key == 'newPassword') {\r\n this.setState({ passError: !this.passwordMediumRegex.test(value) });\r\n }\r\n\r\n if (key == 'confirmPassword') {\r\n this.setState({ confPassError: user.newPassword != user.confirmPassword });\r\n }\r\n };\r\n\r\n handleKeyPress = (e) => {\r\n if (e.key === 'Enter') {\r\n this.handleChangeButtonClick(e);\r\n }\r\n }\r\n\r\n isValidAddEditForm() {\r\n let message = '';\r\n\r\n const { user } = this.state;\r\n\r\n if (!user || !user.email || user.email.trim() == '') {\r\n message += Translate('Please enter Email') + '. ';\r\n } else {\r\n if (!HelperFunctions.validateEmail(user.email)) {\r\n message += Translate('Please enter valid Email') + '. ';\r\n }\r\n }\r\n\r\n if (!user.newPassword || user.newPassword.trim() == '') {\r\n message += Translate('Please enter New Password') + \". \";\r\n }\r\n\r\n if (!user.confirmPassword || user.confirmPassword.trim() == '') {\r\n message += Translate('Please enter Confirm Password') + \". \";\r\n }\r\n\r\n if (user.newPassword && user.newPassword.trim() != '' &&\r\n user.confirmPassword && user.confirmPassword.trim() != '' &&\r\n user.newPassword != user.confirmPassword) {\r\n message += Translate('New Password and Confirm Password are different') + \". \";\r\n }\r\n\r\n if (user.newPassword && !this.passwordMediumRegex.test(user.newPassword)) {\r\n message += Translate('Password must be at least 6 characters and contain at least 1 alphabetical and 1 numeric character') + \". \";\r\n }\r\n\r\n if (message != '') {\r\n this.growl.show({ severity: 'error', summary: message });\r\n }\r\n\r\n return message == '';\r\n }\r\n\r\n handleChangeButtonClick = event => {\r\n event.preventDefault();\r\n\r\n if (!this.isValidAddEditForm()) return;\r\n\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n const { user } = this.state;\r\n\r\n this.loginService.newPassword(user).then(\r\n (data: any) => {\r\n if (data) {\r\n let user = this.state.user;\r\n user.email = '';\r\n user.oldPassword = '';\r\n user.newPassword = '';\r\n user.confirmPassword = '';\r\n this.setState({\r\n isLoading: false,\r\n user: user,\r\n mode: 'successPaswordChanged'\r\n });\r\n //this.growl.show({ severity: 'success', detail: Translate('You have successfully changed your Password.') });\r\n }\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n public render() {\r\n const { isLoading, user, mode, emailError, passError, confPassError } = this.state;\r\n\r\n const newPasswordHtml =\r\n <>\r\n {Translate('Enter new Password')}
\r\n \r\n
\r\n this.handleChange('email', e.target['value'])}\r\n helperText={Translate(\"Please enter a valid e-mail address.\")}\r\n />\r\n
\r\n
\r\n this.handleChange('newPassword', e.target['value'])}\r\n value={user && user.newPassword ? user.newPassword : \"\"}\r\n helperText={Translate(\"6 characters or more, at least 1 alphabetical and 1 numeric.\")}\r\n />\r\n
\r\n
\r\n this.handleChange('confirmPassword', e.target['value'])}\r\n value={user && user.confirmPassword ? user.confirmPassword : \"\"}\r\n helperText={Translate(\"Please enter password again.\")}\r\n />\r\n
\r\n
\r\n \r\n \r\n {Translate('Change')}\r\n \r\n
\r\n >\r\n\r\n const successPaswordChangedHtml =\r\n <>\r\n \r\n \r\n
\r\n \r\n {Translate('Now you can go to ')} {Translate('Login')}.\r\n
\r\n >\r\n\r\n let resultHtml;\r\n\r\n switch (mode) {\r\n case 'validConfirmCode':\r\n resultHtml = newPasswordHtml;\r\n break;\r\n case 'successPaswordChanged':\r\n resultHtml = successPaswordChangedHtml;\r\n break;\r\n default:\r\n resultHtml = null;\r\n }\r\n\r\n return (\r\n \r\n\r\n {isLoading ?
: null}\r\n
this.growl = el} />\r\n\r\n \r\n {resultHtml}\r\n
\r\n \r\n )\r\n }\r\n}\r\n\r\nexport default NewPasswordComponent;","import * as React from \"react\";\r\nimport { BrowserRouter, Route, Link, Switch, Redirect, withRouter } from \"react-router-dom\";\r\nimport AuthService from '../../services/authService';\r\nimport { connect } from 'react-redux';\r\nimport * as Constants from '../../common/constants';\r\nimport * as actionTypes from '../../store/actionTypes';\r\n\r\ninterface IProps {\r\n onUserLogout: any,\r\n history: any\r\n}\r\n\r\ninterface IState {\r\n}\r\n\r\nclass NotAuthenticatedComponent extends React.Component {\r\n аuthService = new AuthService();\r\n\r\n componentDidMount() {\r\n if (!this.аuthService.isAuthenticated()) {\r\n this.props.onUserLogout();\r\n this.props.history.push(`/login?returnUrl=${window.location.pathname}`);\r\n }\r\n }\r\n\r\n public render() {\r\n return (\r\n \r\n
You are not Authenticated to view this page.
\r\n \r\n )\r\n }\r\n}\r\n\r\nconst mapDispatchToProps = dispatch => {\r\n return {\r\n onUserLogout: () => dispatch({ type: actionTypes.USER_LOGOUT })\r\n }\r\n}\r\n\r\nexport default withRouter(connect(null, mapDispatchToProps)(NotAuthenticatedComponent));","import * as React from \"react\";\r\nimport Spinner from '../../../common/components/spinner/spinner';\r\nimport Translate from '../../../common/functions/translate';\r\nimport AlertMessage from '../../../common/components/alertMessage/alertMessage';\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../../common/modalDialog';\r\nimport { UserForGridModel } from '../../../models/user/userForGridModel';\r\nimport { DropdownModel } from \"../../../models/dropdownModel\";\r\nimport { enumToDropdownArray } from '../../../common/functions/helperFunctions';\r\nimport { RelationType, UserType } from \"../../../common/enums\";\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes } from '@fortawesome/free-solid-svg-icons';\r\nimport TextField from '@material-ui/core/TextField';\r\nimport Select from '@material-ui/core/Select';\r\nimport InputLabel from '@material-ui/core/InputLabel';\r\nimport MenuItem from '@material-ui/core/MenuItem';\r\nimport Paper from '@material-ui/core/Paper';\r\nimport InputBase from '@material-ui/core/InputBase';\r\nimport IconButton from '@material-ui/core/IconButton';\r\nimport SearchIcon from '@material-ui/icons/Search';\r\nimport FormControl from '@material-ui/core/FormControl';\r\nimport * as Constants from '../../../common/constants';\r\nimport Paginator from '../../../common/components/paginator/paginator';\r\nimport Growl from '../../../common/components/alertMessage/growl';\r\nimport Radio from '@material-ui/core/Radio';\r\nimport UserService from '../../../services/userService';\r\nimport { UserGridModel } from \"../../../models/user\";\r\n\r\ninterface IProps {\r\n saveClick: any,\r\n cancelClick: any,\r\n isVisible: boolean,\r\n selectedUser: UserForGridModel,\r\n dialogHeader: string,\r\n saveCaretakerClick: any\r\n}\r\n\r\ninterface IState {\r\n currentUser: UserForGridModel;\r\n isLoading: boolean;\r\n validationMessage: string;\r\n relationType: Array;\r\n userTypes: Array;\r\n searchText: string;\r\n users: Array;\r\n selectedUser: UserForGridModel;\r\n page: number;\r\n numberOfPages: number;\r\n from: number;\r\n numberOfRows: number;\r\n totalRecordsCount: number;\r\n}\r\n\r\nclass UserFamilyAddEditDialog extends React.Component {\r\n growl: any;\r\n initFrom = 0;\r\n numberOfRows = 10;\r\n userService = new UserService();\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n if (!props.selectedUser) {\r\n props.selectedUser = new UserForGridModel();\r\n }\r\n\r\n this.state = {\r\n currentUser: props.selectedUser,\r\n isLoading: false,\r\n validationMessage: '',\r\n relationType: new Array(0),\r\n userTypes: new Array(0),\r\n searchText: '',\r\n users: new Array(0),\r\n selectedUser: new UserForGridModel(),\r\n page: 1,\r\n from: this.initFrom,\r\n numberOfPages: 1,\r\n numberOfRows: this.numberOfRows,\r\n totalRecordsCount: 0\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n const relationType: Array = [{ label: Translate('Select'), value: 0 }];\r\n const userTypes: Array = enumToDropdownArray(UserType, true);\r\n const user = { ...this.state.currentUser }\r\n user.userTypeId = 1;\r\n this.setState({ relationType: relationType.concat(enumToDropdownArray(RelationType, true)), userTypes: userTypes, currentUser: { ...user } });\r\n }\r\n\r\n handleSaveButton = (event, close) => {\r\n event.preventDefault();\r\n const user = this.state.currentUser;\r\n this.props.saveClick(user, close);\r\n }\r\n\r\n handleCaretakerSaveButton = (event, close) => {\r\n event.preventDefault();\r\n const user = { ...this.state.selectedUser };\r\n user.relationType = this.state.currentUser.relationType;\r\n this.props.saveCaretakerClick(user, close);\r\n }\r\n\r\n handleCancelButton = () => {\r\n this.props.cancelClick();\r\n }\r\n\r\n handleChange = (key, value) => {\r\n const user: UserForGridModel = { ...this.state.currentUser };\r\n user[key] = value;\r\n this.setState({ currentUser: { ...user } });\r\n };\r\n\r\n handleKeyPress = (e) => {\r\n if (e.key === 'Enter') {\r\n this.handleSearchButtonClick();\r\n }\r\n }\r\n\r\n handleSearchButtonClick = () => {\r\n if (!this.state.searchText || this.state.searchText.trim() == '') {\r\n return;\r\n }\r\n this.setState({\r\n isLoading: true,\r\n page: 1\r\n },\r\n () => this.getAllFilteredItems(this.state.page, this.state.numberOfRows)\r\n );\r\n }\r\n\r\n getAllFilteredItems(page: number, numberOfRows: number) {\r\n let from = (page - 1) * this.state.numberOfRows;\r\n\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n this.userService.getFilteredUsers(from, numberOfRows, this.state.searchText.trim()).then(\r\n (data: UserGridModel) => {\r\n this.setState({\r\n isLoading: false,\r\n from: from,\r\n users: data.users,\r\n totalRecordsCount: data.totalRecordsCount,\r\n numberOfPages: (data.totalRecordsCount % this.state.numberOfRows > 0 ?\r\n data.totalRecordsCount / this.state.numberOfRows + 1 : data.totalRecordsCount / this.state.numberOfRows)\r\n });\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n\r\n paginataorClick = (page) => {\r\n this.setState({ page: page }, () => this.getAllFilteredItems(page, this.state.numberOfRows));\r\n }\r\n\r\n handleSelectionChange = (e) => {\r\n this.setState({\r\n selectedUser: e\r\n });\r\n }\r\n\r\n handleSearchChange = (value: string) => {\r\n this.setState({ searchText: value.trim() });\r\n }\r\n\r\n public render() {\r\n\r\n const { isLoading, currentUser, relationType, userTypes, searchText, users, selectedUser, numberOfPages, page } = this.state;\r\n\r\n return (\r\n <>\r\n \r\n >\r\n )\r\n }\r\n}\r\n\r\nexport default UserFamilyAddEditDialog;","import * as React from 'react';\r\nimport { ResponsiveBar } from '@nivo/bar';\r\nimport { UserConditionModel } from \"../../../models/user/userConditionModel\";\r\nimport { ConditionUnitRangeModel } from '../../../models/user/conditionUnitRangeModel';\r\nimport * as HelperFunctions from '../../../common/functions/helperFunctions';\r\nimport { UserConditionType, GenderType } from '../../../common/enums';\r\nimport color from '@material-ui/core/colors/deepOrange';\r\nimport { green } from '@material-ui/core/colors';\r\nimport Translate from '../../../common/functions/translate';\r\n\r\ndeclare module '@nivo/bar'\r\n\r\nclass BarModel {\r\n public conditionDate?: string;\r\n public value: number;\r\n public valueColor: string;\r\n public secondValue?: number;\r\n public secondValueColor?: string;\r\n}\r\n\r\nlet minBorder: any;\r\nlet maxBorder: any;\r\n\r\nconst barData = (userCondition: UserConditionModel, lang: string, typeRanges: ConditionUnitRangeModel) => {\r\n let label = userCondition.isSystemType ? HelperFunctions.getEnumLabel(userCondition.userConditionTypeId, UserConditionType, true) +\r\n ' (' + userCondition.userConditionUnit + ')' + '' : userCondition.personalCondition + '';\r\n\r\n let data: Array = new Array(0);\r\n let sortedItems = userCondition.userConditionTypes.sort((a, b) => new Date(a.conditionDate).getTime() - new Date(b.conditionDate).getTime());\r\n for (let cond of sortedItems) {\r\n let ucond: BarModel = new BarModel();\r\n ucond.conditionDate = HelperFunctions.fomatDateTimeSecondsAsStringWithLang(new Date(cond.conditionDate), lang);\r\n if (userCondition.isSystemType && userCondition.userConditionTypeId == UserConditionType.BloodPressure) {\r\n let bPressure = cond.userConditionValue.split('/');\r\n ucond.value = parseFloat(bPressure[0]);\r\n ucond.secondValue = parseFloat(bPressure[1]);\r\n ucond.valueColor = \"#7bc87b\";\r\n ucond.secondValueColor = \"#7bc87b\";\r\n\r\n if (typeRanges &&\r\n ((typeRanges.minValue && typeRanges.minValue > bPressure[0]) || (typeRanges.maxValue && typeRanges.maxValue < bPressure[0]))) {\r\n ucond.valueColor = \"#ff4d4d\";\r\n }\r\n\r\n if (typeRanges &&\r\n ((typeRanges.secondMinValue && typeRanges.secondMinValue > bPressure[1]) || (typeRanges.secondMaxValue && typeRanges.secondMaxValue < bPressure[1]))) {\r\n ucond.secondValueColor = \"#ff4d4d\";\r\n }\r\n }\r\n else {\r\n ucond.value = parseFloat(cond.userConditionValue)\r\n ucond.valueColor = \"#7bc87b\";\r\n if (typeRanges &&\r\n ((typeRanges.minValue && typeRanges.minValue > cond.userConditionValue) || (typeRanges.maxValue && typeRanges.maxValue < cond.userConditionValue))) {\r\n ucond.valueColor = \"#ff4d4d\";\r\n }\r\n }\r\n data.push(ucond);\r\n }\r\n\r\n return data;\r\n}\r\n\r\nconst getMinAndMax = (userCondition: UserConditionModel, isMin: boolean, minMarker: number, maxMarker: number, isThereMarkers: boolean) => {\r\n let val: number = 0;\r\n if (userCondition.isSystemType && userCondition.userConditionTypeId == UserConditionType.BloodPressure) {\r\n if (isThereMarkers) {\r\n val = isMin ? minMarker : maxMarker\r\n }\r\n else {\r\n let blPressure = userCondition.userConditionTypes[0].userConditionValue.split('/');\r\n val = isMin ? +blPressure[1] : +blPressure[0];\r\n }\r\n for (let uType of userCondition.userConditionTypes) {\r\n let bPressure = uType.userConditionValue.split('/');\r\n if (isMin) {\r\n val = +bPressure[1] < val ? +bPressure[1] : val;\r\n }\r\n else {\r\n val = +bPressure[0] > val ? +bPressure[0] : val;\r\n }\r\n }\r\n }\r\n else {\r\n if (isThereMarkers) {\r\n val = isMin ? minMarker : maxMarker\r\n }\r\n else {\r\n val = +userCondition.userConditionTypes[0].userConditionValue;\r\n }\r\n for (let uType of userCondition.userConditionTypes) {\r\n if (isMin) {\r\n val = +uType.userConditionValue < val ? +uType.userConditionValue : val;\r\n }\r\n else {\r\n val = +uType.userConditionValue > val ? +uType.userConditionValue : val;\r\n }\r\n }\r\n\r\n }\r\n return val;\r\n}\r\n\r\nconst UserConditionBars = (props) => {\r\n let typeRange: ConditionUnitRangeModel = props.typeRanges;\r\n let label = props.userCondition.isSystemType ? HelperFunctions.getEnumLabel(props.userCondition.userConditionTypeId, UserConditionType, true) +\r\n ' (' + props.userCondition.userConditionUnit + ')' + '' : props.userCondition.personalCondition + '';\r\n\r\n let markers = new Array(0);\r\n let minMarker: number = 0;\r\n let maxMarker: number = 0;\r\n\r\n if (typeRange) {\r\n minMarker = +typeRange.minValue;\r\n maxMarker = +typeRange.maxValue;\r\n\r\n if (typeRange.minValue) {\r\n markers.push({\r\n axis: \"y\", value: +typeRange.minValue,\r\n lineStyle: { stroke: '#0aa5ff', strokeDasharray: \"12, 6\" }, legend: \"min: \" + typeRange.minValue, textStyle: { fontSize: 10 }\r\n });\r\n if (+typeRange.minValue < minMarker) {\r\n minMarker = +typeRange.minValue;\r\n }\r\n }\r\n if (typeRange.maxValue) {\r\n markers.push({\r\n axis: \"y\", value: +typeRange.maxValue,\r\n lineStyle: { stroke: '#0aa5ff', strokeDasharray: \"12, 6\" }, legend: \"max: \" + typeRange.maxValue, textStyle: { fontSize: 10 }\r\n });\r\n if (+typeRange.maxValue > maxMarker) {\r\n maxMarker = +typeRange.maxValue;\r\n }\r\n }\r\n\r\n if (typeRange.secondMinValue) {\r\n markers.push({\r\n axis: \"y\", value: +typeRange.secondMinValue,\r\n lineStyle: { stroke: '#34675c', strokeDasharray: \"12, 6\" }, legend: \"min: \" + typeRange.secondMinValue, legendPosition: 'bottom-right', textStyle: { fontSize: 10 }\r\n });\r\n if (+typeRange.secondMinValue < minMarker) {\r\n minMarker = +typeRange.secondMinValue;\r\n }\r\n }\r\n if (typeRange.secondMaxValue) {\r\n markers.push({\r\n axis: \"y\", value: +typeRange.secondMaxValue,\r\n lineStyle: { stroke: '#34675c', strokeDasharray: \"12, 6\" }, legend: \"max: \" + typeRange.secondMaxValue, legendPosition: 'bottom-right', textStyle: { fontSize: 10 }\r\n });\r\n if (+typeRange.secondMaxValue > maxMarker) {\r\n maxMarker = +typeRange.secondMaxValue;\r\n }\r\n }\r\n }\r\n\r\n let minVal: number = getMinAndMax(props.userCondition, true, minMarker, maxMarker, markers && markers.length > 0);\r\n let maxVal: number = getMinAndMax(props.userCondition, false, minMarker, maxMarker, markers && markers.length > 0);\r\n\r\n let delta = maxVal - minVal;\r\n\r\n minBorder = minVal != 0 ? minVal - (delta / 5) : null;\r\n maxBorder = maxVal != 0 ? maxVal + (delta / 2) : null;\r\n\r\n let data = barData(props.userCondition, props.lang, props.typeRanges);\r\n let keys: string[] = [];\r\n if (props.userCondition.isSystemType && props.userCondition.userConditionTypeId == UserConditionType.BloodPressure) {\r\n keys = [\"value\", \"secondValue\"];\r\n }\r\n else {\r\n keys = [\"value\"];\r\n }\r\n\r\n let axisBottom: any = {\r\n \"tickSize\": 5,\r\n \"tickPadding\": 15,\r\n \"tickRotation\": 0,\r\n \"legend\": \"\",\r\n \"legendOffset\": 46,\r\n \"legendPosition\": \"middle\",\r\n renderTick: (data) => {\r\n const { value, opacity, textBaseline, textAnchor, textX, textY, x, y } = data\r\n return (\r\n\r\n \r\n \r\n {getTspanGroups(value, 10, 3)}\r\n \r\n \r\n )\r\n }\r\n }\r\n\r\n return (\r\n data[`${id}Color`]}\r\n // minValue={minVal != 0 ? minVal - (delta / 5) : \"auto\"}\r\n maxValue={maxBorder != null ? maxBorder : \"auto\"}\r\n markers={markers}\r\n axisTop={null}\r\n axisRight={null}\r\n axisBottom={axisBottom}\r\n labelSkipWidth={12}\r\n labelSkipHeight={12}\r\n labelTextColor={\"white\"}\r\n // defs={[\r\n // {\r\n // id: 'lines-green',\r\n // type: 'patternLines',\r\n // background: 'inherit',\r\n // color: '#68a868',\r\n // rotation: -45,\r\n // lineWidth: 4,\r\n // spacing: 10\r\n // },\r\n // {\r\n // id: 'lines-red',\r\n // type: 'patternLines',\r\n // background: 'inherit',\r\n // color: '#b23b3b',\r\n // rotation: -45,\r\n // lineWidth: 4,\r\n // spacing: 10\r\n // }\r\n // ]}\r\n // fill={[\r\n // {\r\n // match: d => {\r\n // console.log(d)\r\n // return d.key.toString().includes(\"secondValue\") && d.color === '#7bc87b'\r\n // }, id: 'lines-green'\r\n // },\r\n // {\r\n // match: d => {\r\n // console.log(d)\r\n // return d.key.toString().includes(\"secondValue\") && d.color === '#ff4d4d'\r\n // }, id: 'lines-red'\r\n // }\r\n // ]}\r\n animate={true}\r\n motionStiffness={90}\r\n motionDamping={15}\r\n tooltip={({ id, value, color }) => {\r\n let tooltip = \r\n {label}: {value}\r\n \r\n if (props.userCondition.isSystemType && props.userCondition.userConditionTypeId == UserConditionType.BloodPressure) {\r\n if (id == \"value\") {\r\n tooltip = \r\n {Translate('TopNumber') + ' (' + props.userCondition.userConditionUnit + ')'}: {value}\r\n \r\n }\r\n else {\r\n tooltip = \r\n {Translate('BottomNumber') + ' (' + props.userCondition.userConditionUnit + ')'}: {value}\r\n \r\n }\r\n }\r\n return tooltip;\r\n }}\r\n />\r\n )\r\n\r\n}\r\n\r\nconst getTspanGroups = (value: string, maxLineLength: number, maxLines: number = 2) => {\r\n const words = value.split(' ')\r\n\r\n type linesAcc = {\r\n lines: string[],\r\n currLine: string\r\n }\r\n\r\n //reduces the words into lines of maxLineLength\r\n const assembleLines: linesAcc = words.reduce((acc: linesAcc, word: string) => {\r\n //if the current line isn't empty and the word + current line is larger than the allowed line size, create a new line and update current line\r\n if ((word + acc.currLine).length > maxLineLength && acc.currLine !== '') {\r\n return {\r\n lines: acc.lines.concat([acc.currLine]),\r\n currLine: word\r\n }\r\n }\r\n //otherwise add the word to the current line\r\n return {\r\n ...acc,\r\n currLine: acc.currLine + ' ' + word\r\n }\r\n\r\n }, { lines: [], currLine: '' })\r\n\r\n //add the ending state of current line (the last line) to lines\r\n const allLines = assembleLines.lines.concat([assembleLines.currLine])\r\n\r\n //for now, only take first 2 lines due to tick spacing and possible overflow\r\n const lines = allLines.slice(0, maxLines)\r\n let children: JSX.Element[] = []\r\n let dy = 0\r\n\r\n lines.forEach((lineText, i) => {\r\n children.push(\r\n \r\n {\r\n // if on the second line, and that line's length is within 3 of the max length, add ellipsis\r\n (1 === i && allLines.length > 2) ? lineText.slice(0, maxLineLength - 3) + '...' : lineText\r\n }\r\n \r\n )\r\n //increment dy to render next line text below\r\n dy += 15\r\n });\r\n\r\n return children\r\n}\r\n\r\nexport default UserConditionBars;","import * as React from 'react';\r\nimport { Link } from \"react-router-dom\";\r\nimport { MedicineForListModel } from \"../../models\";\r\nimport Translate from '../../common/functions/translate';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faTimesCircle } from '@fortawesome/free-solid-svg-icons';\r\n\r\nconst medicinesList = (props) => {\r\n\tconst listItems = props.medicines.map((m: MedicineForListModel) =>\r\n\t\t\r\n\t\t\t\r\n\t\t\t\t
\r\n\t\t\t\t\t{m.brandName ? m.brandName : ''}\r\n\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t\t{m.additionalTitle ? m.additionalTitle : ''}\r\n\t\t\t\t
\r\n\t\t\t
\r\n\t\t\t\r\n\t\t\r\n\t);\r\n\r\n\treturn (\r\n\t\t\r\n\t\t\t{listItems}\r\n\t\t
\r\n\t)\r\n}\r\n\r\nexport default medicinesList;\r\n","import * as React from 'react';\r\nimport { DiseaseForGridModel } from \"../../models\";\r\n\r\nconst diseasesList = (props) => {\r\n\tconst listItems = props.diseases.map((d: DiseaseForGridModel) =>\r\n\t\t\r\n\t\t\t\r\n\t\t\t\t
\r\n\t\t\t\t\t{d.diseaseCode ? d.diseaseCode + ' ' : ''}\r\n\t\t\t\t\t{d.diseaseName ? d.diseaseName : ''}\r\n\t\t\t\t
\r\n\t\t\t
\r\n\t\t\r\n\t);\r\n\r\n\treturn (\r\n\t\t\r\n\t\t\t{listItems}\r\n\t\t
\r\n\t)\r\n}\r\n\r\nexport default diseasesList;\r\n","import { MedicineForListModel } from '../medicineForListModel';\r\nimport { DiseaseForGridModel } from '../diseaseForGridModel';\r\n\r\nexport class InteractionsModel {\r\n public userId: number;\r\n public medicines: Array;\r\n public userMedicines: Array;\r\n public userDiseases: Array;\r\n public drivingAndMachine: boolean;\r\n public pregnancyAndBreastfeeding: boolean;\r\n}","import * as React from \"react\";\r\nimport Dialog from '@material-ui/core/Dialog';\r\nimport * as Modal from '../../common/modalDialog';\r\nimport Spinner from '../../common/components/spinner/spinner';\r\nimport Translate from '../../common/functions/translate';\r\nimport { MedicineForListModel, MedicineListModel } from \"../../models\";\r\nimport { MedicineFilterSettings } from \"../../models/medicineFilterSettings\";\r\nimport MedicineService from '../../services/medicineService';\r\nimport MedicineFilter from './medicineFilter';\r\nimport Growl from '../../common/components/alertMessage/growl';\r\nimport Button from '@material-ui/core/Button';\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\r\nimport { faCheck, faTimes } from '@fortawesome/free-solid-svg-icons';\r\nimport Radio from '@material-ui/core/Radio';\r\nimport Paginator from '../../common/components/paginator/paginator';\r\n\r\ninterface IProps {\r\n isVisible: boolean\r\n addMedicineClick: any,\r\n cancelClick: any,\r\n dialogError: any,\r\n clearDialogError: any,\r\n lang: string,\r\n}\r\n\r\ninterface IState {\r\n isLoading: boolean;\r\n medicines: Array;\r\n selectedMedicine: MedicineForListModel;\r\n from: number;\r\n numberOfRows: number;\r\n totalRecordsCount: number;\r\n medicineSettings: MedicineFilterSettings;\r\n searchText: string;\r\n page: number;\r\n numberOfPages: number;\r\n}\r\n\r\nclass MedicineSearchDialog extends React.Component {\r\n\r\n medicineService = new MedicineService();\r\n initFrom = 0;\r\n numberOfRows = 20;\r\n growl: any;\r\n\r\n constructor(props: IProps) {\r\n super(props);\r\n\r\n this.state = {\r\n isLoading: false,\r\n medicines: new Array(0),\r\n selectedMedicine: new MedicineForListModel(),\r\n from: this.initFrom,\r\n numberOfRows: this.numberOfRows,\r\n totalRecordsCount: 0,\r\n medicineSettings: new MedicineFilterSettings(),\r\n searchText: '',\r\n page: 1,\r\n numberOfPages: 1\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n //this.getAllFilteredItems(this.state.page, this.state.numberOfRows, this.state.medicineSettings);\r\n }\r\n\r\n componentDidUpdate(prevProps) {\r\n if (prevProps.dialogError != this.props.dialogError) {\r\n this.props.dialogError && this.props.dialogError.message ?\r\n this.growl.show({ severity: 'warning', summary: this.props.dialogError.message }) : null;\r\n }\r\n }\r\n\r\n handleAddButton = (event) => {\r\n event.preventDefault();\r\n\r\n const userMedicine = this.state.selectedMedicine;\r\n\r\n if (userMedicine.medicineId) {\r\n this.props.addMedicineClick(userMedicine);\r\n }\r\n }\r\n\r\n handleCancelButton = () => {\r\n this.props.cancelClick();\r\n }\r\n\r\n handleSelectionChange = (e) => {\r\n this.setState({\r\n selectedMedicine: e\r\n });\r\n }\r\n\r\n handleChange = (key, value) => {\r\n this.setState({ searchText: value });\r\n };\r\n\r\n handleSearchButtonClick = (settings) => {\r\n this.props.clearDialogError();\r\n this.setState({\r\n isLoading: true,\r\n page: 1,\r\n medicineSettings: settings\r\n },\r\n () => this.getAllFilteredItems(this.state.page, this.state.numberOfRows, settings)\r\n );\r\n\r\n this.medicineService.getAllMedicines(0, this.state.numberOfRows, settings, this.props.lang).then(\r\n (data: MedicineListModel) => {\r\n this.setState({\r\n isLoading: false,\r\n from: 0,\r\n medicines: data.medicines,\r\n medicineSettings: settings,\r\n totalRecordsCount: data.totalRecordsCount\r\n });\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n getAllFilteredItems(page: number, numberOfRows: number, currentFilterSettings: MedicineFilterSettings) {\r\n let from = (page - 1) * this.state.numberOfRows;\r\n\r\n this.setState({\r\n isLoading: true\r\n });\r\n\r\n this.medicineService.getAllMedicines(from, numberOfRows, currentFilterSettings, this.props.lang).then(\r\n (data: MedicineListModel) => {\r\n this.setState({\r\n isLoading: false,\r\n from: from,\r\n medicines: data.medicines,\r\n totalRecordsCount: data.totalRecordsCount,\r\n numberOfPages: (data.totalRecordsCount % this.state.numberOfRows > 0 ?\r\n data.totalRecordsCount / this.state.numberOfRows + 1 : data.totalRecordsCount / this.state.numberOfRows)\r\n });\r\n })\r\n .catch(error => {\r\n this.growl.show({ severity: 'error', summary: error.message });\r\n this.setState({\r\n isLoading: false\r\n });\r\n });\r\n }\r\n\r\n paginataorClick = (page) => {\r\n this.setState({ page: page }, () => this.getAllFilteredItems(page, this.state.numberOfRows, this.state.medicineSettings));\r\n }\r\n\r\n handleClearClick = () => {\r\n this.setState({\r\n page: 1, medicineSettings: new MedicineFilterSettings(), medicines: [], totalRecordsCount: 0, numberOfPages: 0\r\n });\r\n }\r\n\r\n public render() {\r\n const { isLoading, medicines, page, totalRecordsCount, numberOfPages, selectedMedicine, medicineSettings } = this.state;\r\n\r\n return (\r\n\r\n