Advertisement
Guest User

pastename

a guest
Jan 28th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 216.57 KB | None | 0 0
  1. //Common Ui Scripts---->Start
  2. //variables holding values for the current session
  3. var isQADirty = false;
  4. var RequestTypeLegacyCardiologyNewRequest = 1;
  5. var SpecialtyNameCardiology = "Cardiology";
  6. var SpecialtyCardiologyId = "5688EC08-EFA6-E211-B214-00155D1E5005";
  7. var SpecialtyNameOncology = "Oncology";
  8. var SpecialtyNameRadiationOncology = "Radiation Oncology";
  9. var SpecialtyNameImaging = "Imaging";
  10. var DisplayTypeStandardWithText = "StandaredWithText";
  11. var RequestTypeUmIntake = "UmIntake";
  12.  
  13. var currentRuleTriggerId;
  14. var currentRegimenConversations;
  15. var currentCrmUserId;
  16. var currentCrmServiceId;
  17. var currentCrmIsDssSupplemental;
  18. var currentDeterminationSupportId;
  19. var currentCrmPassedIcdId;
  20. var currentClassificationId;
  21. var currentTreatmentMedicationTypeId;
  22.  
  23. var selectableRegimenData;
  24. var isTestWindow;
  25.  
  26. var REQUEST_TYPE = "";
  27. var selectedRegimenId = "";
  28. var dssSelectedDiagnosisName = "";
  29. var oldSelectedDiagnosisName = "";
  30.  
  31. function GetClinicalInformationJsContextRegimenAssemblyQualifiedName() {
  32.  
  33. if (typeof (Cp) === "undefined" ||
  34. typeof (Cp.NewRequest) === "undefined" ||
  35. typeof (Cp.NewRequest.CommonProcessor) === "undefined" ||
  36. typeof (Cp.NewRequest.CommonProcessor.Instance) === "undefined") {
  37. return medicationOncologyRegimenAssemblyQualifiedName;
  38. }
  39.  
  40. return Cp.NewRequest.CommonProcessor.Instance.IsRadiationOncology()
  41. ? radiationOncologyRegimenAssemblyQualifiedName
  42. : (Cp.NewRequest.CommonProcessor.Instance.IsCardiology()
  43. ? cardiologyRegimenAssemblyQualifiedName
  44. : (Cp.NewRequest.CommonProcessor.Instance.IsImaging()
  45. ? imagingRegimenAssemblyQualifiedName
  46. : medicationOncologyRegimenAssemblyQualifiedName));
  47. }
  48.  
  49. //validate the question answer section
  50. var validateQuestionAnswers = function (suppressErrorHighlight, qaParentDomElement, checkVisibility, allowPartial, isNoQnA) {
  51. var canPartial = allowPartial != undefined && allowPartial;
  52. var qaParent = "";
  53. if (qaParentDomElement != undefined && qaParentDomElement.length > 0) {
  54. qaParent = qaParentDomElement;
  55. } else {
  56. qaParent = $("#commonUiClinicalInformationSection").find(".panel-section:visible");
  57. if (qaParent.length <= 0) {
  58. qaParent = $("#clinicalQuestionAnswerDiv").find(".panel-section:visible");
  59. }
  60. }
  61. var noError = true;
  62. var errorCssClass = "input-validation-error";
  63. var isNoQnACheckBox = $(document).find("#NoQnACheck");
  64. if (isNoQnACheckBox.length > 0 && $(isNoQnACheckBox).val() == "true") {
  65. return noError;
  66. }
  67. qaParent.each(function () {
  68. var inputElement = $(this).find("input:hidden");
  69. var currentQuestion = $(this);
  70. if (inputElement != undefined && inputElement.length > 0) {
  71. inputElement.each(function () {
  72. if (this.value != undefined && this.value.trim().length == 0) {
  73. var checkBoxDisplayItems = inputElement.siblings("label[data-val-visualid='" + $(this).attr("data-val-visualid") + "']").filter(".answerButtonBox");
  74.  
  75. if (checkBoxDisplayItems != undefined && checkBoxDisplayItems.length > 0 && checkBoxDisplayItems.is(":visible") && !(checkBoxDisplayItems.hasClass("active")) && !canPartial) {
  76. if (!suppressErrorHighlight) {
  77. checkBoxDisplayItems.addClass(errorCssClass);
  78. }
  79. noError = false;
  80. }
  81. if (checkVisibility != undefined && checkVisibility == false) {
  82. if (currentQuestion.attr('override-validation') != "true" && checkBoxDisplayItems != undefined && checkBoxDisplayItems.length > 0 && !(checkBoxDisplayItems.hasClass("active"))) {
  83. if (!suppressErrorHighlight) {
  84. checkBoxDisplayItems.addClass(errorCssClass);
  85. }
  86. noError = false;
  87. }
  88. }
  89. }
  90. });
  91. } else {
  92. var textBoxDisplayItems = $(this).find("label.labLabelStyle").find("input:text");
  93. textBoxDisplayItems.each(function () {
  94. if ($(this) != undefined && textBoxDisplayItems.is(":visible")) {
  95. if (($(this).hasClass('labDatePicker') && !isDate(this.value)) && !canPartial) {
  96. $(this).attr('title', "Please enter a valid lab date.");
  97. if (!suppressErrorHighlight) {
  98. $(this).addClass(errorCssClass);
  99. }
  100. noError = false;
  101. } else if ((this.value.trim().length == 0) && !canPartial) {
  102. if (!suppressErrorHighlight) {
  103. $(this).addClass(errorCssClass);
  104. }
  105. noError = false;
  106. }
  107. }
  108. });
  109. }
  110.  
  111. var dssDropdowns = $(this).find(".dssReasonDropdown:visible");
  112. if (dssDropdowns != undefined && dssDropdowns.length > 0) {
  113. dssDropdowns.each(function () {
  114. if (($(this).val() == "0")) {
  115. if (!suppressErrorHighlight) {
  116. $(this).addClass(errorCssClass);
  117. }
  118. noError = false;
  119. }
  120. });
  121. }
  122.  
  123. var inputElementsWithAnswerTextVisible = $(this).find('input[type="text"].answerText');
  124. if (inputElementsWithAnswerTextVisible != undefined && inputElementsWithAnswerTextVisible.length > 0) {
  125. inputElementsWithAnswerTextVisible.each(function () {
  126. if (this.value != undefined && this.value.trim().length == 0 && !canPartial) {
  127. if (!suppressErrorHighlight) {
  128. $(this).addClass(errorCssClass);
  129. }
  130. noError = false;
  131. }
  132. });
  133. }
  134. });
  135.  
  136. return noError;
  137. };
  138. //get all the selected question with answers - returns collection
  139. var getSelectedQuestionAnswers = function (p_qaParent) {
  140. answeredQuestionInfoList = [];
  141. var qaParent = "";
  142. if (p_qaParent != undefined && p_qaParent.length > 0) {
  143. qaParent = p_qaParent;
  144. } else {
  145. qaParent = $("#commonUiClinicalInformationSection").find(".panel-section:visible");
  146. if (qaParent.length <= 0) {
  147. qaParent = $("#clinicalQuestionAnswerDiv").find(".panel-section:visible");
  148. }
  149. }
  150. var isNoQnACheckBox = $(document).find("#NoQnACheck");
  151. if (isNoQnACheckBox.length > 0 && $(isNoQnACheckBox).val() == false) {
  152. return answeredQuestionInfoList;
  153. }
  154. qaParent.each(function () {
  155. var questionText = $(this).find("h3.section-heading").attr('questionText');
  156. var currentQnId = $(this).find("h3.section-heading").attr('question');
  157. var questionOrder = $(this).find("h3.section-heading").attr('sortOrder');
  158. var currentElement = $(this);
  159. answers = [];
  160. if (currentQnId == undefined) {
  161. $(this).find("h3.section-sub-heading").each(function () {
  162. questionText = questionText + ":" + $(this).attr('questionText');
  163. currentQnId = $(this).attr('question');
  164. answers = [];
  165. var activeLabel = currentElement.find("label.active[question='" + currentQnId + "']");
  166. if (activeLabel != undefined && activeLabel.length > 0) {
  167. activeLabel.each(function () {
  168. answerValue = [];
  169. var value = $(this).text();
  170. var displayType = $(this).parent().siblings("table").find("h3.section-heading").attr('displaytype');
  171. var lastAnswer = $(this).parent().find('.answerButtonBox:last')[0];
  172. if (displayType != undefined && displayType == DisplayTypeStandardWithText) {
  173. if ($(this).attr('id') == lastAnswer.id) {
  174. value = ($(this).parent().find("input.answerText")[0].value) == "" ? value : $(this).parent().find("input.answerText")[0].value;
  175. } else {
  176. value = $(this).text();
  177. }
  178. }
  179. var answer = {
  180. Value: value,
  181. RegimenConversationDetailType: "InputValue",
  182. RuleAnswerValueType: "725060001"
  183. }
  184. answerValue.push(answer);
  185. var BaseAnswerInfo = {
  186. Id: this.id,
  187. AnswerValues: answerValue,
  188. TriagePoint: $(this).attr('triage-point')
  189. }
  190. answers.push(BaseAnswerInfo);
  191. });
  192. var reason = $(this).parent().siblings().find(".dssReasonDropdown:visible").val();
  193. var answeredQuestionInfo = {
  194. QuestionId: activeLabel.attr("question"),
  195. Question: questionText,
  196. QuestionOrder: questionOrder,
  197. DssReasonType: reason,
  198. Answers: answers
  199. }
  200. answeredQuestionInfoList.push(answeredQuestionInfo);
  201. questionText = currentElement.find("h3.section-heading").attr('questionText');
  202. }
  203. else {
  204. var answeredQuestionInfo = {
  205. QuestionId: currentQnId,
  206. Question: questionText,
  207. QuestionOrder: questionOrder,
  208. DssReasonType: undefined,
  209. Answers: answers
  210. }
  211. answeredQuestionInfoList.push(answeredQuestionInfo);
  212. }
  213.  
  214. });
  215. } else {
  216.  
  217. var activeLabel = $(this).find("label.active[question='" + currentQnId + "']");
  218.  
  219. //if (currentElement.children != undefined && currentElement.children.length > 0 && currentElement.children(0).attr("id") == "PerformQuestion") {
  220. // activeLabel = $('[data-master=performance-status-ecog]').find("label.active").add($('[data-master=performance-status-karnofsky]').find("label.active"));
  221. //}
  222.  
  223. if (activeLabel != undefined && activeLabel.length > 0) {
  224.  
  225. activeLabel.each(function () {
  226. answerValue = [];
  227. if ($(this).attr("name") == "performance_status_ecog") {
  228. questionText = questionText + ":ECOG";
  229. } else if ($(this).attr("name") == "performance_status_karnofsky") {
  230. questionText = questionText + ":Karnofsky";
  231. }
  232.  
  233. var value = $(this).text();
  234. var displayType = $(this).parent().siblings("table").find("h3.section-heading").attr('displaytype');
  235. var lastAnswer = $(this).parent().find('.answerButtonBox:last')[0];
  236. if (displayType != undefined && displayType == DisplayTypeStandardWithText) {
  237. if ($(this).attr('id') == lastAnswer.id) {
  238. value = ($(this).parent().find("input.answerText")[0].value) == "" ? value : $(this).parent().find("input.answerText")[0].value;
  239. } else {
  240. value = $(this).text();
  241. }
  242. }
  243.  
  244. var answer = {
  245. Value: value,
  246. RegimenConversationDetailType: "InputValue",
  247. RuleAnswerValueType: "725060001"
  248. }
  249. answerValue.push(answer);
  250.  
  251. var BaseAnswerInfo = {
  252. Id: this.id,
  253. AnswerValues: answerValue,
  254. TriagePoint: $(this).attr('triage-point')
  255. }
  256. answers.push(BaseAnswerInfo);
  257. });
  258. var reason = activeLabel.closest(".panel-section").find(".dssReasonDropdown:visible").val();
  259. var answeredQuestionInfo = {
  260. QuestionId: activeLabel.attr("question"),
  261. Question: questionText,
  262. QuestionOrder: questionOrder,
  263. DssReasonType: reason,
  264. Answers: answers
  265. }
  266. answeredQuestionInfoList.push(answeredQuestionInfo);
  267.  
  268. } else {
  269. var textBoxDisplayItems = $(this).find("label.labLabelStyle").find("input:text");
  270.  
  271. answers = [];
  272. textBoxDisplayItems.each(function () {
  273. answerValue = [];
  274. if (this.id == "labValue") {
  275. answer = {
  276. Value: this.value,
  277. RegimenConversationDetailType: "InputValue",
  278. RuleAnswerValueType: "725060002"
  279. }
  280. answerValue.push(answer);
  281. } else if ($(this).hasClass('labDatePicker')) {
  282. answer = {
  283. Value: days_between(new Date(), this.value),
  284. RegimenConversationDetailType: "CalculatedValue",
  285. RuleAnswerValueType: "725060000"
  286. }
  287. answerValue.push(answer);
  288. answer = {
  289. Value: this.value,
  290. RegimenConversationDetailType: "LabDate",
  291. RuleAnswerValueType: "725060003"
  292. }
  293. answerValue.push(answer);
  294. }
  295.  
  296.  
  297. var BaseAnswerInfo = {
  298. Id: $(this).attr("answer"),
  299. AnswerValues: answerValue
  300. }
  301. answers.push(BaseAnswerInfo);
  302.  
  303. });
  304. var reason = textBoxDisplayItems.parent().parent().siblings().find(".dssReasonDropdown:visible").val();
  305. var answeredQuestionInfo = {
  306. QuestionId: currentQnId,
  307. Question: questionText,
  308. QuestionOrder: questionOrder,
  309. DssReasonType: reason,
  310. Answers: answers
  311. }
  312. answeredQuestionInfoList.push(answeredQuestionInfo);
  313. }
  314. }
  315. });
  316. return answeredQuestionInfoList;
  317.  
  318. };
  319. //get Regimens collection
  320. var getRegimens = function (answeredQuestionInfoList, requestType, bypassCallback, onSuccessCallback) {
  321.  
  322. var isSimulation = (requestType == "SimulateRequest");
  323. //loading the selected Information
  324. if (requestType == "NewRequest")
  325. refreshSelectedInfoForDosing(true);
  326.  
  327. var regimenRuleId = $("input:hidden[name='CurrentRegimenRuleSearchingResponse.RegimenRuleId']").attr("value");
  328. var urlPost;
  329.  
  330. if (requestType == "SimulateRequest" ||
  331. requestType == "NewRequest" ||
  332. requestType == RequestTypeLegacyCardiologyNewRequest) {
  333. urlPost = "/Authorization/RegimenSelection/Regimen";
  334. } else if (requestType == "CrmRequest") {
  335. if (currentDeterminationSupportId == undefined || currentDeterminationSupportId == '')
  336. currentDeterminationSupportId = getQueryString('determinationSupportId');
  337. if (currentCrmServiceId == undefined || currentCrmServiceId == '')
  338. currentCrmServiceId = getQueryString('serviceRequestId');
  339. if (currentCrmUserId == undefined || currentCrmUserId == '')
  340. currentCrmUserId = getQueryString('userId');
  341. urlPost = "/QandARegimen/RegimenSelection/Regimen";
  342. currentRuleTriggerId = regimenRuleId;
  343. } else if (requestType == "TestRequest") {
  344. urlPost = "/RegimenRuleAdmin/RegimenSelection/Regimen";
  345. regimenRuleId = currentRuleTriggerId;
  346. } else if (requestType == "PortalDssRequest") {
  347. if (currentDeterminationSupportId == undefined || currentDeterminationSupportId == '')
  348. currentDeterminationSupportId = getQueryString('determinationSupportId');
  349. if (currentCrmServiceId == undefined || currentCrmServiceId == '')
  350. currentCrmServiceId = getQueryString('serviceRequestId');
  351. if (currentCrmUserId == undefined || currentCrmUserId == '')
  352. currentCrmUserId = getQueryString('userId');
  353. urlPost = "/Determination/DssRegimenSelection/Regimen";
  354. currentRuleTriggerId = regimenRuleId;
  355. } else if (requestType === RequestTypeUmIntake) {
  356. urlPost = "/Authorization/RegimenSelection/DisplayRegimen";
  357. }
  358.  
  359. // if (answeredQuestionInfoList != undefined && answeredQuestionInfoList != null && answeredQuestionInfoList.length > 0) {
  360. currentRegimenConversations = answeredQuestionInfoList;
  361.  
  362. if (currentCrmIsDssSupplemental == undefined || currentCrmIsDssSupplemental == '')
  363. currentCrmIsDssSupplemental = getQueryString('isDssSupplemental');
  364.  
  365. if (currentCrmPassedIcdId == undefined || currentCrmPassedIcdId == '') {
  366. currentCrmPassedIcdId = getQueryString('icdId');
  367. }
  368. if (currentClassificationId == undefined || currentClassificationId == '') {
  369. currentClassificationId = getQueryString('classificationId');
  370. }
  371. if (currentTreatmentMedicationTypeId == undefined || currentTreatmentMedicationTypeId == '') {
  372. currentTreatmentMedicationTypeId = getQueryString('treatmentMedicationTypeId');
  373. }
  374.  
  375. if (currentCrmIsDssSupplemental != 'true') {
  376.  
  377. var SelectedQuestionAnswerRequest =
  378. requestType !== RequestTypeUmIntake
  379. ? {
  380. RegimenRuleId: regimenRuleId,
  381. AnsweredQuestions: answeredQuestionInfoList,
  382. DeterminationSupportId: currentDeterminationSupportId,
  383. ServiceRequestId: currentCrmServiceId,
  384. UserId: currentCrmUserId,
  385. IsSimulation: isSimulation,
  386. IcdId: currentCrmPassedIcdId,
  387. ClassificationId: currentClassificationId,
  388. TreatmentMedicationTypeId: currentTreatmentMedicationTypeId,
  389. EligibilityType: 0 // Placeholder for EligibilityType
  390. }
  391. : Cp.IntakeHome.AuthRequest.Instance.GetSelectableRegimenRequest(regimenRuleId, answeredQuestionInfoList);
  392.  
  393. if(requestType !== RequestTypeUmIntake) {
  394. window.scrollTo(10, 10);
  395. }
  396.  
  397. var hasCpOncologyNewRequestRegimenMatcher =
  398. typeof (Cp) != "undefined" &&
  399. typeof (Cp.OncologyNewRequest) != "undefined" &&
  400. typeof (Cp.OncologyNewRequest.RegimenMatcher) != "undefined" &&
  401. typeof (Cp.OncologyNewRequest.RegimenMatcher.Instance) != "undefined" &&
  402. Cp.NewRequest &&
  403. Cp.NewRequest.CommonProcessor &&
  404. Cp.NewRequest.CommonProcessor.Instance &&
  405. Cp.NewRequest.CommonProcessor.Instance.IsOncology();
  406. if (typeof (contextHasRegimenMatcher) == "undefined" ||
  407. !hasCpOncologyNewRequestRegimenMatcher) {
  408. contextIsRegimenMatchingInProgress = false;
  409. } else {
  410. contextIsRegimenMatchingInProgress =
  411. contextHasRegimenMatcher &&
  412. Cp.OncologyNewRequest.RegimenMatcher.Instance.IsRegimenMatchingInProgress() &&
  413. bypassCallback == undefined;
  414. }
  415.  
  416. if (!contextIsRegimenMatchingInProgress) {
  417. $("#loadingSpinner").dialog({
  418. closeOnEscape: false,
  419. dialogClass: 'no-close',
  420. resizable: false,
  421. title: "Loading...",
  422. position: {
  423. my: "center center",
  424. at: "center center",
  425. of: window
  426. },
  427. modal: true
  428. });
  429. }
  430.  
  431. $.ajax({
  432.  
  433. type: "POST",
  434. url: urlPost,
  435. data: JSON.stringify(SelectedQuestionAnswerRequest),
  436. contentType: 'application/json; charset=utf-8',
  437. dataType: 'html',
  438. success: function (html) {
  439. try {
  440. $("#commonUiregimenSelectionSection").html('');
  441. $("#commonUiregimenSelectionSection").html(html);
  442. if(requestType === RequestTypeUmIntake) {
  443. $("#commonUiregimenSelectionSection").show();
  444. Cp.Utilities.Instance.ScrollToElement(".regimen-selection-table");
  445. }
  446. if (requestType == "CrmRequest") {
  447. regimenSelectCallbackPortal30(null, requestType);
  448. }
  449. if (contextIsRegimenMatchingInProgress) {
  450. Cp.OncologyNewRequest.RegimenMatcher.Instance.HandleNewQandANextClickedForRegimenInDifferentRuleCallback();
  451. } else { // handle an existing unhanlded case where new Q&A results in the selected regimen is not available in the new list of selectable regimens
  452. if (isByPassingRegimenSelection()) {
  453. Cp.NewRequest.CommonProcessor.Instance.FullyLockApplicableNewRequestFields();
  454. }
  455. else if (hasCpOncologyNewRequestRegimenMatcher) {
  456. Cp.OncologyNewRequest.RegimenMatcher.Instance.HandleNewQandANextClicked();
  457. }
  458. }
  459.  
  460. if (typeof(onSuccessCallback) === "function") {
  461. onSuccessCallback.apply();
  462. }
  463. } finally {
  464. html = null;
  465. if (requestType != "CrmRequest") {
  466. $("#loadingSpinner").dialog("close");
  467. }
  468. }
  469. },
  470. error: function (xhr, ajaxOptions, thrownError) {
  471. alert(xhr.status);
  472. alert(thrownError);
  473. $("#loadingSpinner").dialog("close");
  474. }
  475. });
  476. }
  477. else {
  478. if (requestType == "CrmRequest") {
  479. regimenSelectCallbackPortal30(null, requestType);
  480. }
  481. }
  482.  
  483. return true;
  484. };
  485.  
  486. function savePortalDssCoversation(answeredQuestionInfoList) {
  487. var regimenRuleId = $("input:hidden[name='CurrentRegimenRuleSearchingResponse.RegimenRuleId']").attr("value");
  488.  
  489. if (currentDeterminationSupportId == undefined || currentDeterminationSupportId == '')
  490. currentDeterminationSupportId = getQueryString('determinationSupportId');
  491. if (currentCrmServiceId == undefined || currentCrmServiceId == '')
  492. currentCrmServiceId = getQueryString('serviceRequestId');
  493. if (currentCrmUserId == undefined || currentCrmUserId == '')
  494. currentCrmUserId = getQueryString('userId');
  495. var urlPost = "/Determination/DssRegimenSelection/SaveDssConversation";
  496. currentRuleTriggerId = regimenRuleId;
  497.  
  498. currentRegimenConversations = answeredQuestionInfoList;
  499.  
  500. if (currentCrmIsDssSupplemental == undefined || currentCrmIsDssSupplemental == '')
  501. currentCrmIsDssSupplemental = getQueryString('isDssSupplemental');
  502.  
  503. if (currentCrmPassedIcdId == undefined || currentCrmPassedIcdId == '') {
  504. currentCrmPassedIcdId = getQueryString('icdId');
  505. }
  506. if (currentClassificationId == undefined || currentClassificationId == '') {
  507. currentClassificationId = getQueryString('classificationId');
  508. }
  509. if (currentTreatmentMedicationTypeId == undefined || currentTreatmentMedicationTypeId == '') {
  510. currentTreatmentMedicationTypeId = getQueryString('treatmentMedicationTypeId');
  511. }
  512.  
  513. var SelectedQuestionAnswerRequest = {
  514. RegimenRuleId: regimenRuleId,
  515. AnsweredQuestions: answeredQuestionInfoList,
  516. DeterminationSupportId: currentDeterminationSupportId,
  517. ServiceRequestId: currentCrmServiceId,
  518. UserId: currentCrmUserId,
  519. IsSimulation: false,
  520. IcdId: currentCrmPassedIcdId,
  521. ClassificationId: currentClassificationId,
  522. TreatmentMedicationTypeId: currentTreatmentMedicationTypeId,
  523. EligibilityType: 0 // Placeholder for EligibilityType
  524. };
  525.  
  526. $("#loadingSpinner").dialog({
  527. closeOnEscape: false,
  528. dialogClass: 'no-close',
  529. resizable: false,
  530. title: "Loading...",
  531. position: {
  532. my: "center center",
  533. at: "center center",
  534. of: window
  535. },
  536. modal: true
  537. });
  538.  
  539. $.ajax({
  540. type: "POST",
  541. url: urlPost,
  542. async:false,
  543. data: JSON.stringify(SelectedQuestionAnswerRequest),
  544. contentType: 'application/json; charset=utf-8',
  545. dataType: 'html',
  546. success: function (response) {
  547. try {
  548. if(response){
  549. if (window.opener) {
  550. window.opener.$("#dssRegimenContainer").show();
  551. window.opener.$("#dssRegimenConversationsContainer").html("");
  552. if(response !== "NoConversationDetail") {
  553. window.opener.$("#dssRegimenConversationsContainer").html(response);
  554. }
  555. if (window.opener.dssSelectedDiagnosisName == "" || window.opener.oldSelectedDiagnosisName == "") {
  556. window.opener.$("#dssSelectedDiagnosisCode").text(window.opener.$("#hdnDssPrimaryDiagnosisName").val());
  557. window.opener.$("#selectedDiagnosis").text(window.opener.$("#hdnDssPrimaryDiagnosisName").val());
  558. } else {
  559. window.opener.$("#dssSelectedDiagnosisCode").text(window.opener.dssSelectedDiagnosisName);
  560. window.opener.$("#selectedDiagnosis").text(window.opener.oldSelectedDiagnosisName);
  561. }
  562. window.opener.$("#diseaseCategory").val(window.opener.$("#hdnOldClassificationIdGuid").val());
  563. window.opener.$("#diseaseCategory").siblings(".nchSelectSpan").text(window.opener.$("#diseaseCategory").children("option:selected").text());
  564. window.opener.$("#treatmentType").val(window.opener.$("#hdnOldTreatmentMedicationTypeIdGuid").val());
  565. window.opener.$("#treatmentType").siblings(".nchSelectSpan").text(window.opener.$("#treatmentType").children("option:selected").text());
  566. window.opener.$("#dssDiseaseClassificationSummary").text(window.opener.$("#hdndssClassificationName").val());
  567. window.opener.$("#dssTreatmentMedicationSummary").text(window.opener.$("#hdndssTreatmentMedicationTypeName").val());
  568. }
  569. if ($("#surgicalInformationSectionDiv").html().trim() == "") {
  570. window.close();
  571. }
  572. }
  573. else{
  574. alert("Some error occurred, please try again.");
  575. }
  576. } finally {
  577. response = null;
  578. $("#loadingSpinner").dialog("close");
  579. }
  580. },
  581. error: function (xhr, ajaxOptions, thrownError) {
  582. alert(xhr.status);
  583. alert(thrownError);
  584. $("#loadingSpinner").dialog("close");
  585. }
  586. });
  587. }
  588.  
  589. function savePortalDssCoversationAndSelectedRegimen(answeredQuestionInfoList, selectedRegimenId) {
  590. var regimenRuleId = $("input:hidden[name='CurrentRegimenRuleSearchingResponse.RegimenRuleId']").attr("value");
  591. var urlPost;
  592.  
  593. if (currentDeterminationSupportId == undefined || currentDeterminationSupportId == '')
  594. currentDeterminationSupportId = getQueryString('determinationSupportId');
  595. if (currentCrmServiceId == undefined || currentCrmServiceId == '')
  596. currentCrmServiceId = getQueryString('serviceRequestId');
  597. if (currentCrmUserId == undefined || currentCrmUserId == '')
  598. currentCrmUserId = getQueryString('userId');
  599. urlPost = "/Determination/DssRegimenSelection/SaveDssRegimenConversationAndSelectedRegimen";
  600. currentRuleTriggerId = regimenRuleId;
  601.  
  602. // if (answeredQuestionInfoList != undefined && answeredQuestionInfoList != null && answeredQuestionInfoList.length > 0) {
  603. currentRegimenConversations = answeredQuestionInfoList;
  604.  
  605. if (currentCrmIsDssSupplemental == undefined || currentCrmIsDssSupplemental == '')
  606. currentCrmIsDssSupplemental = getQueryString('isDssSupplemental');
  607.  
  608. if (currentCrmPassedIcdId == undefined || currentCrmPassedIcdId == '') {
  609. currentCrmPassedIcdId = getQueryString('icdId');
  610. }
  611. if (currentClassificationId == undefined || currentClassificationId == '') {
  612. currentClassificationId = getQueryString('classificationId');
  613. }
  614. if (currentTreatmentMedicationTypeId == undefined || currentTreatmentMedicationTypeId == '') {
  615. currentTreatmentMedicationTypeId = getQueryString('treatmentMedicationTypeId');
  616. }
  617.  
  618.  
  619. if (currentCrmIsDssSupplemental != 'true') {
  620.  
  621. var SelectedQuestionAnswerRequest = {
  622. RegimenRuleId: regimenRuleId,
  623. AnsweredQuestions: answeredQuestionInfoList,
  624. DeterminationSupportId: currentDeterminationSupportId,
  625. ServiceRequestId: currentCrmServiceId,
  626. UserId: currentCrmUserId,
  627. IsSimulation: false,
  628. IcdId: currentCrmPassedIcdId,
  629. ClassificationId: currentClassificationId,
  630. TreatmentMedicationTypeId: currentTreatmentMedicationTypeId,
  631. EligibilityType: 0, // Placeholder for EligibilityType,
  632. SelectedRegimenId: selectedRegimenId
  633. };
  634. }
  635.  
  636. if (selectedRegimenId == null || selectedRegimenId == "" || selectedRegimenId == undefined) {
  637. savePortalDssCoversation(answeredQuestionInfoList);
  638. return;
  639. }
  640.  
  641. $("#loadingSpinner").dialog({
  642. closeOnEscape: false,
  643. dialogClass: 'no-close',
  644. resizable: false,
  645. title: "Loading...",
  646. position: {
  647. my: "center center",
  648. at: "center center",
  649. of: window
  650. },
  651. modal: true
  652. });
  653.  
  654. $.ajax({
  655. type: "POST",
  656. url: urlPost,
  657. async:false,
  658. data: JSON.stringify(SelectedQuestionAnswerRequest),
  659. contentType: 'application/json; charset=utf-8',
  660. dataType: 'html',
  661. success: function (response) {
  662. try {
  663. if (response) {
  664. if (window.opener) {
  665. window.opener.$("#dssRegimenContainer").show();
  666. window.opener.$("#dssRegimenConversationsContainer").html("");
  667. window.opener.$("#dssRegimenConversationsContainer").html(response);
  668. if (window.opener.dssSelectedDiagnosisName == "" || window.opener.oldSelectedDiagnosisName == "") {
  669. window.opener.$("#dssSelectedDiagnosisCode").text(window.opener.$("#hdnDssPrimaryDiagnosisName").val());
  670. window.opener.$("#selectedDiagnosis").text(window.opener.$("#hdnDssPrimaryDiagnosisName").val());
  671. } else
  672. {
  673. window.opener.$("#dssSelectedDiagnosisCode").text(window.opener.dssSelectedDiagnosisName);
  674. window.opener.$("#selectedDiagnosis").text(window.opener.oldSelectedDiagnosisName);
  675. }
  676. window.opener.$("#diseaseCategory").val(window.opener.$("#hdnOldClassificationIdGuid").val());
  677. window.opener.$("#diseaseCategory").siblings(".nchSelectSpan").text(window.opener.$("#diseaseCategory").children("option:selected").text());
  678. window.opener.$("#treatmentType").val(window.opener.$("#hdnOldTreatmentMedicationTypeIdGuid").val());
  679. window.opener.$("#treatmentType").siblings(".nchSelectSpan").text(window.opener.$("#treatmentType").children("option:selected").text());
  680. window.opener.$("#dssDiseaseClassificationSummary").text(window.opener.$("#hdndssClassificationName").val());
  681. window.opener.$("#dssTreatmentMedicationSummary").text(window.opener.$("#hdndssTreatmentMedicationTypeName").val());
  682. //get selected Regimen
  683. getSelectedRegimen();
  684. }
  685. if ($("#surgicalInformationSectionDiv").html().trim() == "") {
  686. window.close();
  687. }
  688. }
  689.  
  690. } finally {
  691. $("#loadingSpinner").dialog("close");
  692. if ($("#surgicalInformationSectionDiv").html().trim() == "") {
  693. window.close();
  694. }
  695. }
  696. },
  697. error: function (xhr, ajaxOptions, thrownError) {
  698. alert(xhr.status);
  699. alert(thrownError);
  700. $("#loadingSpinner").dialog("close");
  701. }
  702. });
  703. }
  704. //get selected regimen from session
  705. function getSelectedRegimen()
  706. {
  707. $.ajax({
  708. async: false,
  709. type: "POST",
  710. url: "/Determination/DssRegimenSelection/GetSelectedRegimen",
  711. data: JSON.stringify({"selectedRegimenId" : selectedRegimenId}),
  712. contentType: 'application/json; charset=utf-8',
  713. success: function (response) {
  714. try {
  715. if (response != null) {
  716. if (window.opener) {
  717. window.opener.$("#displayNoResultRegimen").hide();
  718. window.opener.$("#displayResultRegimen").show();
  719. window.opener.$("#selectedRegimenTextId").text(response.regimenName);
  720. window.opener.$("#riskFactorEmetogenicTextId").text(response.regimenCost);
  721. window.opener.$("#riskFactorNeutropenicTextId").text(response.riskFactorEmetogenic);
  722. window.opener.$("#regimenCostTextId").text(response.riskFactorNeutropenic);
  723. }
  724. }
  725.  
  726. } finally {
  727. response = null;
  728. $("#loadingSpinner").dialog("close");
  729. if ($("#surgicalInformationSectionDiv").html().trim() == "") {
  730. window.close();
  731. }
  732. }
  733. },
  734. error: function (xhr, ajaxOptions, thrownError) {
  735. alert(xhr.status);
  736. alert(thrownError);
  737. $("#loadingSpinner").dialog("close");
  738. }
  739. });
  740. }
  741.  
  742. //get current regimen conversation from session
  743. function getCurrentRegimenConversations(requestType) {
  744.  
  745. var regimenConversationUrl = "/ClinicalInformation/GetCurrentRegimenConversation";
  746. var contentType = 'application/json; charset=utf-8';
  747. var data = null;
  748. if (requestType == "CrmRequest") {
  749.  
  750. if (currentCrmServiceId == undefined || currentCrmServiceId == '')
  751. currentCrmServiceId = getQueryString('serviceRequestId');
  752. data = { ServiceId: currentCrmServiceId };
  753. contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
  754. regimenConversationUrl = "/QandARegimen/ClinicalInformation/GetCurrentRegimenConversationByServiceRequestId";
  755.  
  756. } else if (requestType == "PortalDssRequest") {
  757. if (currentCrmServiceId == undefined || currentCrmServiceId == '')
  758. currentCrmServiceId = getQueryString('serviceRequestId');
  759. data = { ServiceId: currentCrmServiceId };
  760. contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
  761. regimenConversationUrl = "/Determination/DssClinicalInformation/GetCurrentRegimenConversationByServiceRequestId";
  762. }
  763.  
  764. $.ajax({
  765. cache: false,
  766. data: data,
  767. url: regimenConversationUrl,
  768. contentType: contentType,
  769. dataType: 'html',
  770. type: 'POST',
  771. async: false,
  772. success: function (jsonData) {
  773. //regimen conversation data
  774. regimenConversation = jsonData;
  775. },
  776. error: function (xhr, ajaxOptions, thrownError) {
  777. alert('RegimenConversation failed');
  778. }
  779. });
  780.  
  781. return regimenConversation;
  782. }
  783. //get the dateDiff
  784. function days_between(dateTo, dateFrom) {
  785. var ONE_DAY = 1000 * 60 * 60 * 24;
  786. var date1 = new Date(dateTo);
  787. var date2 = new Date(dateFrom);
  788. var date1_ms = date1.getTime();
  789. var date2_ms = date2.getTime();
  790.  
  791. var diff_ms = Math.abs(date1_ms - date2_ms);
  792. return Math.round(diff_ms / ONE_DAY);
  793. }
  794. //check whether it is a future date
  795. function isFutureDate(txtDate) {
  796. var date = new Date(txtDate);
  797. var _now = new Date();
  798. if (date.getTime() > _now.getTime()) {
  799. return true;
  800. }
  801. }
  802. //check whether the input is in date format or not
  803. function isDate(txtDate) {
  804.  
  805. var currVal = txtDate;
  806. if ((currVal == '') || isFutureDate(txtDate))
  807. return false;
  808. //Declare Regex
  809. var rxDatePattern = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
  810. var dtArray = currVal.match(rxDatePattern); // is format OK?
  811.  
  812. if (dtArray == null)
  813. return false;
  814.  
  815. //Checks for mm/dd/yyyy format.
  816.  
  817. dtMonth = dtArray[1];
  818. dtDay = dtArray[3];
  819. dtYear = dtArray[5];
  820.  
  821. if (dtMonth < 1 || dtMonth > 12)
  822. return false;
  823. else if (dtDay < 1 || dtDay > 31)
  824. return false;
  825. else if ((dtMonth == 4 || dtMonth == 6 || dtMonth == 9 || dtMonth == 11) && dtDay == 31)
  826. return false;
  827. else if (dtMonth == 2) {
  828. var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0));
  829. if (dtDay > 29 || (dtDay == 29 && !isleap))
  830. return false;
  831. }
  832.  
  833. return true;
  834. }
  835.  
  836. //load the clinical Information section
  837. function loadClinicalInformationQuestions(requestType, onSuccessCallback) {
  838. if (requestType === RequestTypeUmIntake) {
  839. REQUEST_TYPE = requestType;
  840. }
  841. $("#loadingSpinner").dialog({
  842. closeOnEscape: false,
  843. dialogClass: 'no-close',
  844. resizable: false,
  845. title: "Loading...",
  846. position: {
  847. my: "center center",
  848. at: "center center",
  849. of: window
  850. },
  851. modal: true,
  852. open: function (event, ui) {
  853. $("#loadingSpinner").find(".ui-dialog-titlebar-close").hide();
  854. },
  855. close: function (event, ui) {
  856. $("#loadingSpinner").find(".ui-dialog-titlebar-close").show();
  857. }
  858. });
  859.  
  860. var isSimulation = (requestType == "SimulateRequest");
  861. var networkId = $('#networkSelectWrapper').find(':selected').val();
  862. var clinicalUrl; var serviceRequestId; var isDssSupplemental; var determinationSupportId;
  863. var isRequestTypeLegacyCardiologyNewRequest = requestType == RequestTypeLegacyCardiologyNewRequest;
  864.  
  865. if (requestType == "SimulateRequest" ||
  866. requestType == "NewRequest" ||
  867. isRequestTypeLegacyCardiologyNewRequest) {
  868. clinicalUrl = "/ClinicalInformation/ClinicalInfo";
  869. } else if (requestType == "CrmRequest") {
  870. clinicalUrl = "/QandARegimen/ClinicalInformation/ClinicalInfo";
  871. serviceRequestId = getQueryString('serviceRequestId');
  872. if (currentDeterminationSupportId == undefined || currentDeterminationSupportId == '')
  873. currentDeterminationSupportId = getQueryString('determinationSupportId');
  874. if (currentCrmIsDssSupplemental == undefined || currentCrmIsDssSupplemental == '')
  875. currentCrmIsDssSupplemental = getQueryString('isDssSupplemental');
  876. if (currentCrmPassedIcdId == undefined || currentCrmPassedIcdId == '') {
  877. currentCrmPassedIcdId = getQueryString('icdId');
  878. }
  879. if (currentClassificationId == undefined || currentClassificationId == '') {
  880. currentClassificationId = getQueryString('classificationId');
  881. }
  882. if (currentTreatmentMedicationTypeId == undefined || currentTreatmentMedicationTypeId == '') {
  883. currentTreatmentMedicationTypeId = getQueryString('treatmentMedicationTypeId');
  884. }
  885. } else if (requestType == "PortalDssRequest") {
  886. clinicalUrl = "/Determination/DssClinicalInformation/ClinicalInfo";
  887. serviceRequestId = getQueryString('serviceRequestId');
  888. if (currentDeterminationSupportId == undefined || currentDeterminationSupportId == '')
  889. currentDeterminationSupportId = getQueryString('determinationSupportId');
  890. if (currentCrmIsDssSupplemental == undefined || currentCrmIsDssSupplemental == '')
  891. currentCrmIsDssSupplemental = getQueryString('isDssSupplemental');
  892. if (currentCrmPassedIcdId == undefined || currentCrmPassedIcdId == '') {
  893. currentCrmPassedIcdId = getQueryString('icdId');
  894. }
  895. if (currentClassificationId == undefined || currentClassificationId == '') {
  896. currentClassificationId = getQueryString('classificationId');
  897. }
  898. if (currentTreatmentMedicationTypeId == undefined || currentTreatmentMedicationTypeId == '') {
  899. currentTreatmentMedicationTypeId = getQueryString('treatmentMedicationTypeId');
  900. }
  901. }
  902.  
  903. var treatmentMedicationTypeJQueryObject = $("#ServiceRequest_TreatmentMedicationSummary_Id");
  904. var classificationJQueryObject = $("#ServiceRequest_DiseaseClassificationSummary_Id");
  905.  
  906. if (treatmentMedicationTypeJQueryObject.length != 0) {
  907. currentTreatmentMedicationTypeId = treatmentMedicationTypeJQueryObject.attr('value');
  908. } else if (currentTreatmentMedicationTypeId == undefined) {
  909. currentTreatmentMedicationTypeId = '';
  910. }
  911.  
  912. if (classificationJQueryObject.length != 0) {
  913. currentClassificationId = classificationJQueryObject.attr('value');
  914. } else if (currentClassificationId == undefined) {
  915. currentClassificationId = '';
  916. }
  917.  
  918. var questionAnswerRequest =
  919. isRequestTypeLegacyCardiologyNewRequest
  920. ? cp.cardiology.newRequest.GenerateQuestionAnswerRequest()
  921. : (requestType !== RequestTypeUmIntake
  922. ? {
  923. DiagnosisCode: $('#ServiceRequest_PrimaryDiagnosis_Icd9').attr('value'),
  924. SpecialityId: $('#ServiceRequest_Specialty_Id').attr('value'),
  925. NetworkId: networkId,
  926. IsSimulation: isSimulation,
  927. ServiceId: serviceRequestId,
  928. DeterminationSupportId: currentDeterminationSupportId,
  929. IsDssSupplemental: currentCrmIsDssSupplemental,
  930. IcdId: currentCrmPassedIcdId,
  931. ClassificationId: currentClassificationId,
  932. TreatmentMedicationTypeId: currentTreatmentMedicationTypeId,
  933. PracticeId: $('#practiceSelect').val(),
  934. EligibilityType: 0 // Placeholder for EligibilityType
  935. }
  936. : Cp.IntakeHome.AuthRequest.Instance.GetQuestionAndAnswerRequest());
  937.  
  938. var contentType = 'application/json; charset=utf-8';
  939. var data = JSON.stringify(questionAnswerRequest);
  940. if (requestType == "TestRequest") {
  941. clinicalUrl = "/RegimenRuleAdmin/ClinicalInformation/ClinicalInfo";
  942. data = { ruleId: currentRuleTriggerId };
  943. contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
  944. } else if (requestType === RequestTypeUmIntake) {
  945. clinicalUrl = "/ClinicalInformation/ClinicalQAndA";
  946. }
  947.  
  948. $.ajax({
  949. cache: false,
  950. data: data,
  951. url: clinicalUrl,
  952. contentType: contentType,
  953. dataType: 'html',
  954. type: 'POST',
  955. success: function (html) {
  956. try {
  957. $("#commonUiClinicalInformationSection").html('');
  958. $("#commonUiClinicalInformationSection").html(html);
  959. LoadSurgicalInformationSection(requestType);
  960. if (requestType === RequestTypeUmIntake) {
  961. Cp.Utilities.Instance.ScrollToElement("#clinicalInfoContainer");
  962. }
  963. if (isRequestTypeLegacyCardiologyNewRequest) {
  964. cp.cardiology.newRequest.serviceGroupQuestionnaireViewModel.isVisible(true);
  965. var allQuestionDisplayed =
  966. $("#commonUiClinicalInformationSection").find(".panel-section:visible").length > 0 &&
  967. validateQuestionAnswers(true);
  968. cp.cardiology.newRequest.serviceGroupQuestionnaireViewModel.AllQuestionDisplayed(allQuestionDisplayed);
  969. }
  970. if (typeof(onSuccessCallback) === "function") {
  971. onSuccessCallback.apply();
  972. }
  973. } finally {
  974. html = null;
  975. $("#loadingSpinner").dialog("close");
  976. }
  977. },
  978. error: function (xhr, ajaxOptions, thrownError) {
  979. alert(xhr.status);
  980. alert(thrownError);
  981. $("#loadingSpinner").dialog("close");
  982. }
  983. });
  984. };
  985.  
  986. var medicationOncologyRegimenAssemblyQualifiedName = 'CarePro.Domain.MedicationOncologyRegimen, CarePro.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';
  987. var radiationOncologyRegimenAssemblyQualifiedName = 'CarePro.Domain.RadiationOncologyRegimen, CarePro.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';
  988. var cardiologyRegimenAssemblyQualifiedName = 'CarePro.Domain.CardiologyRegimen, CarePro.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';
  989. var imagingRegimenAssemblyQualifiedName = 'CarePro.Domain.ImagingRegimen, CarePro.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null';
  990.  
  991. //extended jquery method for building the selected regimen, tooltip for the question help text
  992. (function ($) {
  993. // TODO: ML extract all the dynamic html to the respective partial view
  994. //build the regimens div
  995. $.fn.buildRegimens = function (jsonRegimenCollection, callback, pathwayImgUrl, isPathway, isSimulation, requestType, oosItems, isReadOnly, MGFMedications) {
  996. var isRequestTypeUmIntake = REQUEST_TYPE === RequestTypeUmIntake;
  997. var renderTarget = $(this);
  998. var oosFramework = false;
  999. var outOfScopeItems = null;
  1000. var outOfScopeAction = null;
  1001. var requiredOptionalDrugInputNames = new Array();
  1002.  
  1003. var contextRegimenAssemblyQualifiedName = "";
  1004. var regimenDisplayTerm = "";
  1005. var isCardiology = false;
  1006. var isRadiationOncology = false;
  1007. var isMedicalOncology = false;
  1008. var isImaging = false;
  1009. if (jsonRegimenCollection.SpecialtyName() == SpecialtyNameCardiology) {
  1010. contextRegimenAssemblyQualifiedName = cardiologyRegimenAssemblyQualifiedName;
  1011. regimenDisplayTerm = "Service Group Name";
  1012. isCardiology = true;
  1013. }
  1014. else if (jsonRegimenCollection.SpecialtyName() == SpecialtyNameOncology) {
  1015. contextRegimenAssemblyQualifiedName = medicationOncologyRegimenAssemblyQualifiedName;
  1016. regimenDisplayTerm = "Compendium regimens";
  1017. isMedicalOncology = true;
  1018. }
  1019. else if (jsonRegimenCollection.SpecialtyName() == SpecialtyNameImaging) {
  1020. contextRegimenAssemblyQualifiedName = imagingRegimenAssemblyQualifiedName;
  1021. regimenDisplayTerm = "Service Group Name";
  1022. isImaging = true;
  1023. }
  1024. else {
  1025. contextRegimenAssemblyQualifiedName = radiationOncologyRegimenAssemblyQualifiedName;
  1026. regimenDisplayTerm = "Treatment Modality";
  1027. isRadiationOncology = true;
  1028. }
  1029.  
  1030. if (oosItems != null && oosItems != undefined && oosItems != "") {
  1031. outOfScopeItems = oosItems.OutOfSupportedScopeItems != null ? oosItems.OutOfSupportedScopeItems : null;
  1032. outOfScopeAction = oosItems.OutOfSupportedScopeActionInfo != null ? oosItems.OutOfSupportedScopeActionInfo : null;
  1033. }
  1034.  
  1035. if (outOfScopeItems != undefined && outOfScopeItems != null) {
  1036. oosFramework = true;
  1037. }
  1038.  
  1039. var hasProcedures = false;
  1040. if (jsonRegimenCollection.RequiredRegimenProcedures != undefined) {
  1041. hasProcedures = true;
  1042. }
  1043.  
  1044. var oosDisableButton = false;
  1045. var selectedRegimen = {
  1046. Name: null,
  1047. IsPathway: null,
  1048. IsAutoApprovable: null,
  1049. RiskFactor: null,
  1050. Id: null,
  1051. RequiredRegimenMedications: new Array(),
  1052. OptionalRegimenMedications: new Array(),
  1053. RequiredRegimenProcedures: new Array(),
  1054. OptionalRegimenProcedures: new Array(),
  1055. StatusCode: 1,
  1056. MaximumDuration: 0,
  1057. ModelType: contextRegimenAssemblyQualifiedName
  1058. };
  1059.  
  1060. // for test page
  1061. if ((requestType == undefined || requestType == null) && (isSimulation == undefined || isSimulation == null)) {
  1062. isSimulation = 'true';
  1063. }
  1064.  
  1065. var pwayTarget = $("<div></div>")
  1066. .addClass("PwayTarget");
  1067. var nonPwayContainer = $("<div></div>")
  1068. .hide()
  1069. .addClass("NPwaysContainer");
  1070. if (isSimulation) {
  1071. nonPwayContainer.append($("<a href='javascript:void(0)' class='dispPathways'>Click to view " + regimenDisplayTerm + ".</a>").click(function () {
  1072. $(".NPwayTarget").show();
  1073. $(this).hide();
  1074. }));
  1075. }
  1076. var nonPwayTarget = $("<div></div>").addClass("NPwayTarget").hide();
  1077.  
  1078. if (isPathway) {
  1079. renderTarget.append(pwayTarget);
  1080. // .append($("<div id='nonRegimenStatus' style='text-align: center;'>Checking for Compendium regimens<span class='loading_spinner_non_pathway'><img src='../../Content/themes/base/images/spinnerSmall.gif' /></span></div>"));
  1081. } else {
  1082. renderTarget.append(nonPwayContainer);
  1083. nonPwayContainer.append(nonPwayTarget);
  1084.  
  1085. //clear status indicator if no regimens found, othewise just hide spinner
  1086. if (jsonRegimenCollection.length == 0) {
  1087. $("#nonRegimenStatus").html('No ' + regimenDisplayTerm + ' exist.');
  1088. } else {
  1089. $('.nonRegimenMedsButtonGroup').show();
  1090. $("#nonRegimenStatus").hide();
  1091. }
  1092. }
  1093.  
  1094. var hasPathwayImg = pathwayImgUrl != null && pathwayImgUrl != "" && pathwayImgUrl != undefined;
  1095. var compiledTemplate;
  1096.  
  1097. function createRegimenMedication(regData, mgfMedications) {
  1098. var newRegimen = compiledTemplate.clone();
  1099. newRegimen.find(".regRisk").text(getRiskText(GetObjectValue(regData.RiskFactor)));
  1100. newRegimen.find(".regNeuRisk").text(getRiskText(GetObjectValue(regData.RiskFactorNeutropenic)));
  1101. newRegimen.find(".regName").text(GetObjectValue(regData.Name));
  1102. newRegimen.find(".regCost").text(addUSD(regData.RegimenCost));
  1103. newRegimen.data('data-regimen', regData);
  1104.  
  1105. var regDataRequiredRegimenMedications = GetObjectValue(regData.RequiredRegimenMedications);
  1106. var regDataOptionalRegimenMedications = GetObjectValue(regData.OptionalRegimenMedications);
  1107. var requiredMeds = (regDataRequiredRegimenMedications == null || regDataRequiredRegimenMedications === undefined || regDataRequiredRegimenMedications.length == 0) ? null : groupMedsByOrder(regDataRequiredRegimenMedications);
  1108. var optionalMeds = (regDataOptionalRegimenMedications == null || regDataOptionalRegimenMedications === undefined || regDataOptionalRegimenMedications.length == 0) ? null : groupMedsByOrder(regDataOptionalRegimenMedications);
  1109.  
  1110. var requiredMedsListItems = buildListItemMedications(requiredMeds, true);
  1111. var supportMedsListItems = buildListItemMedications(optionalMeds, false);
  1112.  
  1113. var reqMedsList = newRegimen.find("div ul.reqMeds");
  1114. var optMedsList = newRegimen.find("div ul.optMeds");
  1115.  
  1116. $.each(requiredMedsListItems, function (index, currentData) { appendDrugsToList(reqMedsList, currentData); });
  1117. $.each(supportMedsListItems, function (index, currentData) { appendDrugsToList(optMedsList, currentData); });
  1118.  
  1119. var regDataMGfMedications = GetObjectValue(mgfMedications);
  1120. // Check MgfForHighRisk
  1121. if (regData.RiskFactorNeutropenic() == "725060004" && regDataMGfMedications != null && regDataMGfMedications != undefined && regDataMGfMedications.length != null) {
  1122. var mgfMeds = regDataMGfMedications;
  1123. var mgfMedsListItems = buildListItemMGFMedications(mgfMeds, false);
  1124. var mgfMedsList = newRegimen.find("div ul.mgfMeds");
  1125. $.each(mgfMedsListItems, function (index, currentData) { appendDrugsToList(mgfMedsList, currentData); });
  1126. newRegimen.find(".mgfMedsDiv").show();
  1127. } else {
  1128. newRegimen.find(".mgfMedsDiv").hide();
  1129. }
  1130.  
  1131. if (supportMedsListItems && supportMedsListItems.length == 0) {
  1132. newRegimen.find(".clearOptMeds").hide();
  1133. }
  1134.  
  1135. var regDataIsPathway = GetObjectValue(regData.IsPathway);
  1136. if (regDataIsPathway != null) {
  1137. if (regDataIsPathway && hasPathwayImg)
  1138. newRegimen.find(".pathwayImg").append($("<img></img>").attr("src", pathwayImgUrl));
  1139. else
  1140. newRegimen.find(".pathwayImg").remove();
  1141.  
  1142. pwayTarget.append(newRegimen);
  1143. } else if (regDataRequiredRegimenMedications != null && regDataRequiredRegimenMedications != "") {
  1144. newRegimen.find(".pathwayImg").remove();
  1145. nonPwayTarget.append(newRegimen);
  1146. nonPwayContainer.show();
  1147. } else {
  1148. $(".regimenOptionButtonToHideGroup").hide();
  1149. // no regimens. forward to the search box
  1150. if (isSimulation == undefined || !isSimulation) {
  1151. $("#requestedItemsContainer").load("/NewRequest/NonRegimenSelect", {}); // not being used
  1152. }
  1153. }
  1154. newRegimen.find(".chooseRegimen").click(function (button) {
  1155. button.preventDefault();
  1156. processChooseRegimen(packageJsonMedication, newRegimen);
  1157. });
  1158.  
  1159. newRegimen.find(".cancel").click(function (button) {
  1160. $('#page-selection .regimen-selection-table tbody tr').closest('tr').removeClass('selected');
  1161. $(".subpage").removeClass('active');
  1162. $(".subpage").hide();
  1163. $("#regimens").html('');
  1164. $(".btnDivLayout").show();
  1165. });
  1166. //add click event to clear optional meds button
  1167. newRegimen.find(".clearOptMeds").click(function (e) {
  1168. newRegimen.find(".optMeds").find(":input").attr('checked', false);
  1169. e.preventDefault();
  1170. });
  1171. // add click event to clear MGF meds button
  1172. newRegimen.find(".clearMgfMeds").click(function (e) {
  1173. newRegimen.find(".mgfMeds").find(":input").attr('checked', false);
  1174. e.preventDefault();
  1175. });
  1176. newRegimen.show();
  1177. }
  1178.  
  1179. function createRegimenProcedure(regData) {
  1180. var newRegimen = compiledTemplate.clone();
  1181. newRegimen.find(".regName").text(GetObjectValue(regData.Name));
  1182. newRegimen.data('data-regimen', regData);
  1183.  
  1184. var regDataRequiredRegimenProcedures = GetObjectValue(regData.RequiredRegimenProcedures);
  1185. var regDataOptionalRegimenProcedures = GetObjectValue(regData.OptionalRegimenProcedures);
  1186. var requiredProcs = (regDataRequiredRegimenProcedures == null || regDataRequiredRegimenProcedures == undefined || regDataRequiredRegimenProcedures.length == 0) ? null : groupProcsByOrder(regDataRequiredRegimenProcedures);
  1187. var optionalProcs = (regDataOptionalRegimenProcedures == null || regDataOptionalRegimenProcedures == undefined || regDataOptionalRegimenProcedures.length == 0) ? null : groupProcsByOrder(regDataOptionalRegimenProcedures);
  1188.  
  1189. var requiredProcsListItems = buildListItemProcedures(requiredProcs, true);
  1190. var optionalProcsListItems = buildListItemProcedures(optionalProcs, false);
  1191.  
  1192. var reqProcsList = newRegimen.find("div ul.reqProcs");
  1193. var optProcsList = newRegimen.find("div ul.optProcs");
  1194.  
  1195. $.each(requiredProcsListItems, function (index, currentData) { appendDrugsToList(reqProcsList, currentData); });
  1196. $.each(optionalProcsListItems, function (index, currentData) { appendDrugsToList(optProcsList, currentData); });
  1197.  
  1198. if (optionalProcsListItems && optionalProcsListItems.length == 0) {
  1199. newRegimen.find(".clearOptProcs").hide();
  1200. }
  1201.  
  1202. var regDataIsPathway = GetObjectValue(regData.IsPathway);
  1203. if (regDataIsPathway != null) {
  1204. if (regDataIsPathway && hasPathwayImg)
  1205. newRegimen.find(".pathwayImg").append($("<img></img>").attr("src", pathwayImgUrl));
  1206. else
  1207. newRegimen.find(".pathwayImg").remove();
  1208.  
  1209. pwayTarget.append(newRegimen);
  1210. } else if (regDataRequiredRegimenProcedures != null && regDataRequiredRegimenProcedures != "") {
  1211. newRegimen.find(".pathwayImg").remove();
  1212. nonPwayTarget.append(newRegimen);
  1213. nonPwayContainer.show();
  1214. } else {
  1215. $(".regimenOptionButtonToHideGroup").hide();
  1216. // no regimens. forward to the search box
  1217. if (isSimulation == undefined || !isSimulation) {
  1218. $("#requestedItemsContainer").load("/NewRequest/NonRegimenSelect", {}); // not being used
  1219. }
  1220. }
  1221.  
  1222. newRegimen.find(".chooseRegimen").click(function (button) {
  1223. button.preventDefault();
  1224. processChooseRegimen(packageJsonProcedure, newRegimen);
  1225. });
  1226.  
  1227. newRegimen.find(".cancel").click(function (button) {
  1228. $('#page-selection .regimen-selection-table tbody tr').closest('tr').removeClass('selected');
  1229. $(".subpage").removeClass('active');
  1230. $(".subpage").hide();
  1231. $("#regimens").html('');
  1232. $(".btnDivLayout").show();
  1233. });
  1234. //add click event to clear optional procs button
  1235. newRegimen.find(".clearOptProcs").click(function (e) {
  1236. newRegimen.find(".optProcs").find(":input").attr('checked', false);
  1237. e.preventDefault();
  1238. });
  1239. newRegimen.show();
  1240. }
  1241.  
  1242. function CreateCardiologyRegimen(regData) {
  1243. var newRegimen = compiledTemplate.clone();
  1244. newRegimen.find(".regName").text(GetObjectValue(regData.Name));
  1245. newRegimen.data('data-regimen', regData);
  1246.  
  1247. var regDataRequiredRegimenProcedures = GetObjectValue(regData.RequiredRegimenProcedures);
  1248. var regDataRequiredRegimenMedications = GetObjectValue(regData.RequiredRegimenMedications);
  1249. var requiredProcs = (regDataRequiredRegimenProcedures == null || regDataRequiredRegimenProcedures == undefined || regDataRequiredRegimenProcedures.length == 0) ? null : groupProcsByOrder(regDataRequiredRegimenProcedures);
  1250. var requiredMeds = (regDataRequiredRegimenMedications == null || regDataRequiredRegimenMedications == undefined || regDataRequiredRegimenMedications.length == 0) ? null : groupMedsByOrder(regDataRequiredRegimenMedications);
  1251.  
  1252. var requiredProcsListItems = buildListItemProcedures(requiredProcs, true);
  1253. var requiredMedsListItems = buildListItemMedications(requiredMeds, true);
  1254.  
  1255. var reqProcsList = newRegimen.find("div ul.reqProcs");
  1256. var reqMedsList = newRegimen.find("div ul.reqMeds");
  1257.  
  1258. $.each(requiredProcsListItems, function (index, currentData) { appendDrugsToList(reqProcsList, currentData); });
  1259. $.each(requiredMedsListItems, function (index, currentData) {
  1260. appendDrugsToList(reqMedsList, currentData);
  1261. });
  1262.  
  1263. var regDataIsPathway = GetObjectValue(regData.IsPathway);
  1264. if (regDataIsPathway != null) {
  1265. if (regDataIsPathway && hasPathwayImg)
  1266. newRegimen.find(".pathwayImg").append($("<img></img>").attr("src", pathwayImgUrl));
  1267. else
  1268. newRegimen.find(".pathwayImg").remove();
  1269.  
  1270. pwayTarget.append(newRegimen);
  1271. } else if (regDataRequiredRegimenProcedures != null && regDataRequiredRegimenProcedures != "") {
  1272. newRegimen.find(".pathwayImg").remove();
  1273. nonPwayTarget.append(newRegimen);
  1274. nonPwayContainer.show();
  1275. } else {
  1276. $(".regimenOptionButtonToHideGroup").hide();
  1277. // no regimens. forward to the search box
  1278. if (isSimulation == undefined || !isSimulation) {
  1279. $("#requestedItemsContainer").load("/NewRequest/NonRegimenSelect", {}); // not being used
  1280. }
  1281. }
  1282.  
  1283. newRegimen.find(".chooseRegimen").click(function (button) {
  1284. button.preventDefault();
  1285. processChooseRegimen(PackageRegimenJson, newRegimen);
  1286. });
  1287.  
  1288. newRegimen.find(".cancel").click(function (button) {
  1289. $('#page-selection .regimen-selection-table tbody tr').closest('tr').removeClass('selected');
  1290. $(".subpage").removeClass('active');
  1291. $(".subpage").hide();
  1292. $("#regimens").html('');
  1293. $(".btnDivLayout").show();
  1294. });
  1295. //add click event to clear optional procs button
  1296. newRegimen.find(".clearOptProcs").click(function (e) {
  1297. newRegimen.find(".optProcs").find(":input").attr('checked', false);
  1298. e.preventDefault();
  1299. });
  1300. newRegimen.show();
  1301. }
  1302.  
  1303. function CreateRegimen(regData) {
  1304. var newRegimen = compiledTemplate.clone();
  1305. newRegimen.find(".regName").text(GetObjectValue(regData.Name));
  1306. newRegimen.data('data-regimen', regData);
  1307.  
  1308. var requiredProcs = !regData.HasRequiredRegimenProcedures ? null : groupProcsByOrder(GetObjectValue(regData.RequiredRegimenProcedures));
  1309. var requiredMeds = !regData.HasRequiredRegimenMedications ? null : groupMedsByOrder(GetObjectValue(regData.RequiredRegimenMedications));
  1310. var optionalProcs = !regData.HasOptionalRegimenProcedures ? null : groupProcsByOrder(GetObjectValue(regData.OptionalRegimenProcedures));
  1311. var optionalMeds = !regData.HasOptionalRegimenMedications ? null : groupMedsByOrder(GetObjectValue(regData.OptionalRegimenMedications));
  1312.  
  1313. var requiredProcsListItems = buildListItemProcedures(requiredProcs, true);
  1314. var requiredMedsListItems = buildListItemMedications(requiredMeds, true);
  1315.  
  1316. var optionalProcsListItems = buildListItemProcedures(optionalProcs, false);
  1317. var optionalMedsListItems = buildListItemMedications(optionalMeds, false);
  1318.  
  1319. var reqProcsList = newRegimen.find("div ul.reqProcs");
  1320. var reqMedsList = newRegimen.find("div ul.reqMeds");
  1321. var optProcsList = newRegimen.find("div ul.optProcs");
  1322. var optMedsList = newRegimen.find("div ul.optMeds");
  1323.  
  1324. $.each(requiredProcsListItems, function (index, currentData) {
  1325. appendDrugsToList(reqProcsList, currentData);
  1326. });
  1327. $.each(requiredMedsListItems, function (index, currentData) {
  1328. appendDrugsToList(reqMedsList, currentData);
  1329. });
  1330. $.each(optionalProcsListItems, function (index, currentData) {
  1331. appendDrugsToList(optProcsList, currentData);
  1332. });
  1333. $.each(optionalMedsListItems, function (index, currentData) {
  1334. appendDrugsToList(optMedsList, currentData);
  1335. });
  1336.  
  1337. var regDataIsPathway = GetObjectValue(regData.IsPathway);
  1338. if (regDataIsPathway != null) {
  1339. if (regDataIsPathway && hasPathwayImg)
  1340. newRegimen.find(".pathwayImg").append($("<img></img>").attr("src", pathwayImgUrl));
  1341. else
  1342. newRegimen.find(".pathwayImg").remove();
  1343.  
  1344. pwayTarget.append(newRegimen);
  1345. } else if (regData.HasRequiredRegimenProcedures ||
  1346. regData.HasRequiredRegimenMedications) {
  1347. newRegimen.find(".pathwayImg").remove();
  1348. nonPwayTarget.append(newRegimen);
  1349. nonPwayContainer.show();
  1350. } else {
  1351. $(".regimenOptionButtonToHideGroup").hide();
  1352. // no regimens. forward to the search box
  1353. if (isSimulation == undefined || !isSimulation) {
  1354. $("#requestedItemsContainer").load("/NewRequest/NonRegimenSelect", {}); // not being used
  1355. }
  1356. }
  1357.  
  1358. newRegimen.find(".chooseRegimen").click(function (button) {
  1359. button.preventDefault();
  1360. processChooseRegimen(PackageRegimenJson, newRegimen);
  1361. });
  1362.  
  1363. newRegimen.find(".cancel").click(function (button) {
  1364. $('#page-selection .regimen-selection-table tbody tr').closest('tr').removeClass('selected');
  1365. $(".subpage").removeClass('active');
  1366. $(".subpage").hide();
  1367. $("#regimens").html('');
  1368. $(".btnDivLayout").show();
  1369. });
  1370. //add click event to clear optional procs button
  1371. newRegimen.find(".clearOptProcs").click(function (e) {
  1372. newRegimen.find(".optProcs").find(":input").attr('checked', false);
  1373. e.preventDefault();
  1374. });
  1375. //add click event to clear optional meds button
  1376. newRegimen.find(".clearOptMeds").click(function (e) {
  1377. newRegimen.find(".optMeds").find(":input").attr('checked', false);
  1378. e.preventDefault();
  1379. });
  1380. // add click event to clear MGF meds button
  1381. newRegimen.find(".clearMgfMeds").click(function (e) {
  1382. newRegimen.find(".mgfMeds").find(":input").attr('checked', false);
  1383. e.preventDefault();
  1384. });
  1385. newRegimen.show();
  1386. }
  1387.  
  1388. function processChooseRegimen(packageJsonDataCallBack, newRegimen) {
  1389. HideRequiredServiceItemSelectionError();
  1390. $(".chooseRegimen").attr('disabled', true);
  1391. if (packageJsonDataCallBack(newRegimen, requestType)) {
  1392. if (isRequestTypeUmIntake) {
  1393. Cp.IntakeHome.AuthRequest.Instance.ProcessRegimenSelection();
  1394. }
  1395. else if (requestType == undefined || requestType != "CrmRequest") {
  1396. $(".btnDivLayout").show();
  1397. $("#Ntm").hide();
  1398. }
  1399. $('.regimenOptionButtonToHideGroup').hide();
  1400. $(".subpage").removeClass('active');
  1401. $(".subpage").hide();
  1402. $("#regimens").html('');
  1403. } else {
  1404. ShowRequiredServiceItemSelectionError();
  1405. alert("Required data missing");
  1406. $(".chooseRegimen").removeAttr("disabled");
  1407. }
  1408. }
  1409.  
  1410. function HideRequiredServiceItemSelectionError() {
  1411. if ($("#requiredServiceItemContainerTd").length) {
  1412. $('#requiredServiceItemContainerTd').removeClass('input-validation-error');
  1413. $('#requiredServiceItemErrorMessageDiv').hide();
  1414. }
  1415. if ($("#requiredServiceItemMedContainerTd").length) {
  1416. $('#requiredServiceItemMedContainerTd').removeClass('input-validation-error');
  1417. $('#requiredServiceItemMedErrorMessageDiv').hide();
  1418. }
  1419. }
  1420.  
  1421. function ShowRequiredServiceItemSelectionError() {
  1422. if ($("#requiredServiceItemContainerTd").length) {
  1423. $('#requiredServiceItemContainerTd').addClass('input-validation-error');
  1424. $('#requiredServiceItemErrorMessageDiv').show();
  1425. }
  1426.  
  1427. if ($("#requiredServiceItemMedContainerTd").length) {
  1428. $('#requiredServiceItemMedContainerTd').addClass('input-validation-error');
  1429. $('#requiredServiceItemMedErrorMessageDiv').show();
  1430. }
  1431. }
  1432.  
  1433. function getRiskText(riskFactor) {
  1434. switch (riskFactor) {
  1435. case 725060000:
  1436. return "Unspecified";
  1437. break;
  1438. case 725060001:
  1439. return "Minimal";
  1440. break;
  1441. case 725060002:
  1442. return "Low";
  1443. break;
  1444. case 725060003:
  1445. return "Moderate";
  1446. break;
  1447. case 725060004:
  1448. return "High";
  1449. break;
  1450. case 725060005:
  1451. return "Intermediate";
  1452. }
  1453. return "Not Specified";
  1454. }
  1455.  
  1456. function formatCurrency(value) {
  1457. if (value != undefined && value != null)
  1458. return "$" + value();
  1459. }
  1460.  
  1461. function addUSD(regimenCost) {
  1462. if (regimenCost != undefined && regimenCost != null && regimenCost != '') {
  1463.  
  1464. var regimenAverageCost = GetObjectValue(regimenCost.AverageCost);
  1465. if (regimenAverageCost != undefined && regimenAverageCost != null && regimenAverageCost != '')
  1466. return regimenAverageCost;
  1467.  
  1468. }
  1469. }
  1470.  
  1471. function isOutOfScope(id) {
  1472. var returnValue = false;
  1473. if (outOfScopeItems != undefined && outOfScopeItems != null && outOfScopeItems != '') {
  1474. $.each(outOfScopeItems, function (index, outOfScopeItem) {
  1475. if (outOfScopeItem.ScopeItemId == id) {
  1476. returnValue = true;
  1477. }
  1478. });
  1479. }
  1480.  
  1481. return returnValue;
  1482. }
  1483.  
  1484. function buildTemplateMedication(showCost, regimenCost) {
  1485. var template = $("<div></div>").addClass("regTemplate").hide();
  1486. var costTitle = "Estimated Cost Calculation";
  1487. try {
  1488. var clearSupportiveMeds = isReadOnly ? "" : $("<a class='clearOptMeds clear-regimen' title='Clear all supportive medication(s)'>Clear All</a>");
  1489. var clearMgfMeds = isReadOnly ? "" : $("<a class='clearMgfMeds clear-regimen' title='Clear all MGF medication(s)'>Clear</a>");
  1490. template.append($("<table cellpadding='4'></table>").addClass("regimen-panel")
  1491. .append($("<tr></tr>")
  1492. .append($("<td></td>").addClass("selected-regimen-label").text("Regimen Name"))
  1493. .append($("<td></td>").addClass("selected-regimen-label").text(costTitle).attr("style", "visibility:" + showCost)
  1494. .append(" <span class='estimatedCostCalculationToolTip' data-content='The estimated cost calculation is based on anti-cancer medications for three months of therapy using Average Sales Price (ASP) + 6% or Wholesale Acquisition Cost (WAC), if there is no ASP +6%. The calculation is based on an average BSA of 1.8 or weight of 68kg, using the standard dosing and most common frequency for the regimen selected. The cost for anti-emetics and /or growth factors are included in the cost when a regimen with high risk for emesis and/or febrile neutropenia is chosen.' data-title='Estimated Cost Calculation' data-container='body' data-toggle='popover'></span>"))
  1495. .append($("<td></td>").text(""))
  1496. .append($("<td></td>").addClass("selected-regimen-label").text("Emetogenic Risk"))
  1497. .append($("<td></td>").addClass("selected-regimen-label").text("Neutropenic Risk")))
  1498. .append($("<tr></tr>")
  1499. .append($("<td></td>").addClass("selected-regimen-name")
  1500. .append($("<div></div>").addClass("pathwayImg").attr("style", "clear:both"))
  1501. .append($("<span></span>").addClass("regName")))
  1502. .append($("<td></td>").addClass("selected-regimen-name")
  1503. .append($("<span></span>").addClass("regCost")).attr("style", "visibility:" + showCost))
  1504. .append($("<td></td>").text(""))
  1505. .append($("<td></td>").addClass("selected-regimen-name")
  1506. .append($("<span></span>").addClass("regRisk")))
  1507. .append($("<td></td>").addClass("selected-regimen-name")
  1508. .append($("<span></span>").addClass("regNeuRisk"))))
  1509. .append($("<tr></tr>")
  1510. .append($("<td></td>")
  1511. .append($("<h3>Required Medication(s)</h3>").addClass("regimen-panel-section-heading")))
  1512. .append($("<td colspan=4></td>")
  1513. .append($("<h3>Supportive Medication(s)</h3>").addClass("regimen-panel-section-heading").append(clearSupportiveMeds))))
  1514. .append($("<tr></tr>")
  1515. .append($("<td valign='top'></td>")
  1516. .append($("<div></div>").addClass("medListDiv requiredMedsDiv")
  1517. .append($("<ul style='width: 450px; margin-left: 10px;'></ul>").addClass("reqMeds")))
  1518. .append($("<div></div>").addClass("mgfMedsDiv")
  1519. .append($("<h3>MGF Medication(s)</h3>").addClass("regimen-panel-section-heading").append(clearMgfMeds))
  1520. .append($("<ul style='width: 450px; margin-left: 10px;'></ul>").addClass("mgfMeds"))))
  1521. .append($("<td colspan=4 valign='top'></td>")
  1522. .append($("<div></div>").addClass("medListDiv supportMedsDiv")
  1523. .append($("<ul style='width: 450px; margin-left: 10px;'></ul>").addClass("optMeds")))))
  1524. );
  1525.  
  1526. if (!isReadOnly && !isRequestTypeUmIntake) {
  1527. template.append($("<div></div>").addClass("pull-left").append($("<a class='cancel' id='cancel'></a>").append($("<span class='remove-x close' style='margin-right:5px'></span>").text("X"))
  1528. .append($("<a class='cancel'></a>").text("Cancel & Select Another Regimen"))));
  1529. }
  1530.  
  1531. var useRegimenButtonCaption = isRequestTypeUmIntake ? "OK" : "Use This Regimen With Selections";
  1532. if (isSimulation != 'true' && !isReadOnly) {
  1533. template.append($("<div></div>").addClass("selectRegDiv pull-right")
  1534. .append($("<button id='btnUseThisRegimen' class='moveforwardbtnStyle')></button>").addClass("chooseRegimen").text(useRegimenButtonCaption)));
  1535. }
  1536.  
  1537. return template;
  1538. } finally {
  1539. template = null;
  1540. }
  1541. }
  1542.  
  1543. function buildTemplateProcedure() {
  1544. var template = $("<div></div>").addClass("regTemplate").hide();
  1545. try {
  1546. var clearSupportiveProcs = isReadOnly ? "" : $("<a class='clearOptProcs clear-regimen' title='Clear all supportive procedure(s)'>Clear All</a>");
  1547. template.append($("<table cellpadding='4'></table>").addClass("regimen-panel")
  1548. .append($("<tr></tr>")
  1549. .append($("<td></td>").addClass("selected-regimen-label").text("Treatment Modality"))
  1550. .append($("<td></td>").text("")))
  1551. .append($("<tr></tr>")
  1552. .append($("<td></td>").addClass("selected-regimen-name")
  1553. .append($("<div></div>").addClass("pathwayImg").attr("style", "clear:both"))
  1554. .append($("<span></span>").addClass("regName")))
  1555. .append($("<td></td>").text("")))
  1556. .append($("<tr></tr>")
  1557. .append($("<td></td>")
  1558. .append($("<h3>Required Treatment(s)</h3>").addClass("regimen-panel-section-heading")))
  1559. .append($("<td></td>")
  1560. .append($("<h3>Optional Treatment(s)</h3>").addClass("regimen-panel-section-heading").append(clearSupportiveProcs))))
  1561. .append($("<tr></tr>")
  1562. .append($("<td id='requiredServiceItemContainerTd' valign='top'></td>")
  1563. .append($("<div></div>").addClass("medListDiv requiredMedsDiv")
  1564. .append($("<ul style='width: 450px; margin-left: 10px;'></ul>").addClass("reqProcs")))
  1565. .append($("<div id='requiredServiceItemErrorMessageDiv' style='display:none;color:red;'>Selection required</div>")))
  1566. .append($("<td valign='top'></td>")
  1567. .append($("<div></div>").addClass("medListDiv supportMedsDiv")
  1568. .append($("<ul style='width: 450px; margin-left: 10px;'></ul>").addClass("optProcs")))))
  1569. );
  1570.  
  1571. if (!isReadOnly && !isRequestTypeUmIntake) {
  1572. template.append($("<div></div>").addClass("pull-left").append($("<a class='cancel' id='cancel'></a>").append($("<span class='remove-x close' style='margin-right:5px'></span>").text("X"))
  1573. .append($("<a class='cancel'></a>").text("Cancel & Select Another Treatment Modality"))));
  1574. }
  1575.  
  1576. var useRegimenButtonCaption = isRequestTypeUmIntake ? "OK" : "Use This Treatment Plan With Selections";
  1577. if (isSimulation != 'true' && !isReadOnly)
  1578. template.append($("<div></div>").addClass("selectRegDiv pull-right")
  1579. .append($("<button id='btnUseThisRegimen' class='moveforwardbtnStyle')></button>").addClass("chooseRegimen").text(useRegimenButtonCaption)));
  1580.  
  1581. return template;
  1582. } finally {
  1583. template = null;
  1584. }
  1585. }
  1586.  
  1587. function BuildCardiologyTemplate(requiredRegimenMedications) {
  1588. var template = $("<div></div>").addClass("regTemplate").hide();
  1589. try {
  1590. var templateTable =
  1591. $("<table cellpadding='4'></table>").addClass("regimen-panel")
  1592. .append($("<tr></tr>")
  1593. .append($("<td></td>").addClass("selected-regimen-label").text(regimenDisplayTerm))
  1594. .append($("<td></td>").text("")))
  1595. .append($("<tr></tr>")
  1596. .append($("<td></td>").addClass("selected-regimen-name")
  1597. .append($("<div></div>").addClass("pathwayImg").attr("style", "clear:both"))
  1598. .append($("<span></span>").addClass("regName")))
  1599. .append($("<td></td>").text("")))
  1600. .append($("<tr></tr>")
  1601. .append($("<td></td>")
  1602. .append($("<h3>Recommended Procedure(s)</h3>").addClass("regimen-panel-section-heading")))
  1603. .append($("<td></td>")))
  1604. .append($("<tr></tr>")
  1605. .append($("<td id='requiredServiceItemContainerTd' valign='top'></td>")
  1606. .append($("<div></div>").addClass("medListDiv requiredProcsDiv")
  1607. .append($("<ul style='width: 450px; margin-left: 10px;'></ul>").addClass("reqProcs")))
  1608. .append($("<div id='requiredServiceItemErrorMessageDiv' style='display:none;color:red;'>Selection required</div>")))
  1609. .append($("<td></td>")));
  1610. if (requiredRegimenMedications().length != 0) {
  1611. templateTable = templateTable
  1612. .append($("<tr id='requiredMedicationTr'></tr>")
  1613. .append($("<td></td>")
  1614. .append($("<h3>Required Medication(s)</h3>").addClass("regimen-panel-section-heading")))
  1615. .append($("<td></td>")))
  1616. .append($("<tr></tr>")
  1617. .append($("<td id='requiredServiceItemMedContainerTd' valign='top'></td>")
  1618. .append($("<div></div>").addClass("medListDiv requiredMedsDiv")
  1619. .append($("<ul style='width: 450px; margin-left: 10px;'></ul>").addClass("reqMeds")))
  1620. .append($("<div id='requiredServiceItemMedErrorMessageDiv' style='display:none;color:red;'>Selection required</div>")))
  1621. .append($("<td></td>")));
  1622. }
  1623. template.append(templateTable);
  1624.  
  1625. if (!isReadOnly && !isRequestTypeUmIntake) {
  1626. template.append($("<div></div>").addClass("pull-left").append($("<a class='cancel' id='cancel'></a>").append($("<span class='remove-x close' style='margin-right:5px'></span>").text("X"))
  1627. .append($("<a class='cancel'></a>").text("Cancel & Select Another " + regimenDisplayTerm))));
  1628. }
  1629.  
  1630. var useRegimenButtonCaption = isRequestTypeUmIntake ? "OK" : "Use This Treatment Plan With Selections";
  1631. if (isSimulation != 'true' && !isReadOnly)
  1632. template.append($("<div></div>").addClass("selectRegDiv pull-right")
  1633. .append($("<button id='btnUseThisRegimen' class='moveforwardbtnStyle')></button>").addClass("chooseRegimen").text(useRegimenButtonCaption)));
  1634.  
  1635. return template;
  1636. } finally {
  1637. template = null;
  1638. }
  1639. }
  1640.  
  1641. function BuildRegimenTemplate(regimenData) {
  1642. var template = $("<div></div>").addClass("regTemplate").hide();
  1643. try {
  1644. var templateTable =
  1645. $("<table cellpadding='4'></table>").addClass("regimen-panel");
  1646.  
  1647. if (regimenData.HasRequiredRegimenProcedures) {
  1648. templateTable = templateTable
  1649. .append($("<tr></tr>")
  1650. .append($("<td></td>").addClass("selected-regimen-label").text(regimenDisplayTerm))
  1651. .append($("<td></td>").text("")))
  1652. .append($("<tr></tr>")
  1653. .append($("<td></td>").addClass("selected-regimen-name")
  1654. .append($("<div></div>").addClass("pathwayImg").attr("style", "clear:both"))
  1655. .append($("<span></span>").addClass("regName")))
  1656. .append($("<td></td>").text("")))
  1657. .append($("<tr></tr>")
  1658. .append($("<td></td>")
  1659. .append($("<h3>Recommended Procedure(s)</h3>").addClass("regimen-panel-section-heading")))
  1660. .append($("<td></td>")))
  1661. .append($("<tr></tr>")
  1662. .append($("<td id='requiredServiceItemContainerTd' valign='top'></td>")
  1663. .append($("<div></div>").addClass("medListDiv requiredProcsDiv")
  1664. .append($("<ul style='width: 450px; margin-left: 10px;'></ul>").addClass("reqProcs")))
  1665. .append($(
  1666. "<div id='requiredServiceItemErrorMessageDiv' style='display:none;color:red;'>Selection required</div>")))
  1667. .append($("<td></td>")));
  1668. }
  1669. if (regimenData.HasRequiredRegimenMedications) {
  1670. templateTable = templateTable
  1671. .append($("<tr id='requiredMedicationTr'></tr>")
  1672. .append($("<td></td>")
  1673. .append($("<h3>Recommended Medication(s)</h3>").addClass("regimen-panel-section-heading")))
  1674. .append($("<td></td>")))
  1675. .append($("<tr></tr>")
  1676. .append($("<td id='requiredServiceItemMedContainerTd' valign='top'></td>")
  1677. .append($("<div></div>").addClass("medListDiv requiredMedsDiv")
  1678. .append($("<ul style='width: 450px; margin-left: 10px;'></ul>").addClass("reqMeds")))
  1679. .append($("<div id='requiredServiceItemMedErrorMessageDiv' style='display:none;color:red;'>Selection required</div>")))
  1680. .append($("<td></td>")));
  1681. }
  1682. if (regimenData.HasOptionalRegimenProcedures) {
  1683. var clearOptionalProcs = isReadOnly ? "" : $("<a class='clearOptProcs clear-regimen' title='Clear all optional procedure(s)'>Clear All</a>");
  1684. templateTable = templateTable
  1685. .append($("<tr id='optionalProcedureTr'></tr>")
  1686. .append($("<td></td>")
  1687. .append($("<h3>Optional Procedure(s)</h3>").addClass("regimen-panel-section-heading").append(clearOptionalProcs)))
  1688. .append($("<td></td>")))
  1689. .append($("<tr></tr>")
  1690. .append($("<td id='optionalServiceItemProcContainerTd' valign='top'></td>")
  1691. .append($("<div></div>").addClass("medListDiv optionalProcsDiv")
  1692. .append($("<ul style='width: 450px; margin-left: 10px;'></ul>").addClass("optProcs"))))
  1693. .append($("<td></td>")));
  1694. }
  1695. if (regimenData.HasOptionalRegimenMedications) {
  1696. var clearOptionalMeds = isReadOnly ? "" : $("<a class='clearOptMeds clear-regimen' title='Clear all optional medication(s)'>Clear All</a>");
  1697. templateTable = templateTable
  1698. .append($("<tr id='optionalMedicationTr'></tr>")
  1699. .append($("<td></td>")
  1700. .append($("<h3>Optional Medication(s)</h3>").addClass("regimen-panel-section-heading").append(clearOptionalMeds)))
  1701. .append($("<td></td>")))
  1702. .append($("<tr></tr>")
  1703. .append($("<td id='optionalServiceItemMedContainerTd' valign='top'></td>")
  1704. .append($("<div></div>").addClass("medListDiv optionalMedsDiv")
  1705. .append($("<ul style='width: 450px; margin-left: 10px;'></ul>").addClass("optMeds"))))
  1706. .append($("<td></td>")));
  1707. }
  1708. template.append(templateTable);
  1709.  
  1710. if (!isReadOnly && !isRequestTypeUmIntake) {
  1711. template.append($("<div></div>").addClass("pull-left").append($("<a class='cancel' id='cancel'></a>").append($("<span class='remove-x close' style='margin-right:5px'></span>").text("X"))
  1712. .append($("<a class='cancel'></a>").text("Cancel & Select Another " + regimenDisplayTerm))));
  1713. }
  1714.  
  1715. var useRegimenButtonCaption = isRequestTypeUmIntake ? "OK" : "Use This Treatment Plan With Selections";
  1716. if (isSimulation != 'true' && !isReadOnly)
  1717. template.append($("<div></div>").addClass("selectRegDiv pull-right")
  1718. .append($("<button id='btnUseThisRegimen' class='moveforwardbtnStyle')></button>").addClass("chooseRegimen").text(useRegimenButtonCaption)));
  1719.  
  1720. return template;
  1721. } finally {
  1722. template = null;
  1723. }
  1724. }
  1725.  
  1726. function ShowRegimenCost(regimenCost) {
  1727. var showCost = "hidden";
  1728. if (regimenCost != undefined && regimenCost != null && regimenCost != '') {
  1729.  
  1730. var regimenAverageCost = GetObjectValue(regimenCost.AverageCost);
  1731.  
  1732. if (regimenAverageCost != undefined && regimenAverageCost != null && regimenAverageCost != '')
  1733. showCost = "visible";
  1734.  
  1735. }
  1736. return showCost;
  1737. }
  1738.  
  1739. function packageJsonMedication(regimenDiv, contextRequestType) {
  1740. turnOffHighlightRadioDrugs();
  1741.  
  1742. if (!isRequiredOptionalDrugsSelected()) return false;
  1743.  
  1744. var regData = regimenDiv.data("data-regimen");
  1745. selectedRegimen.Id = regData.Id;
  1746. selectedRegimen.IsAutoApprovable = regData.IsAutoApprovable;
  1747. selectedRegimen.IsPathway = regData.IsPathway;
  1748. selectedRegimen.Name = regData.Name;
  1749. selectedRegimen.RiskFactor = regData.RiskFactor;
  1750. selectedRegimen.RiskFactorNeutropenic = regData.RiskFactorNeutropenic;
  1751. selectedRegimen.MaximumDuration = regData.MaximumDuration;
  1752. selectedRegimen.SelectableRegimenId = regData.SelectableRegimenId;
  1753. selectedRegimen["MGFMedications"] = new Array;
  1754. //selectedRegimen.ModelType = medicationOncologyRegimenAssemblyQualifiedName;
  1755.  
  1756. $.each(regimenDiv.find(".requiredMedsDiv input:checked"), function (index, data) { selectedRegimen.RequiredRegimenMedications.push($(data).data("data-drug")); });
  1757. $.each(regimenDiv.find(".supportMedsDiv input:checked"), function (index, data) { selectedRegimen.OptionalRegimenMedications.push($(data).data("data-drug")); });
  1758. $.each(regimenDiv.find(".mgfMedsDiv input:checked"), function (index, data) { selectedRegimen.MGFMedications.push($(data).data("data-drug")); });
  1759. recursivelyRemoveWCFArtifacts(selectedRegimen.RequiredRegimenMedications);
  1760. recursivelyRemoveWCFArtifacts(selectedRegimen.OptionalRegimenMedications);
  1761.  
  1762. if (callback != null) callback(selectedRegimen, contextRequestType);
  1763.  
  1764. return true;
  1765. }
  1766.  
  1767. function packageJsonProcedure(regimenDiv, contextRequestType) {
  1768. turnOffHighlightRadioDrugs();
  1769.  
  1770. if (!isRequiredOptionalDrugsSelected()) return false;
  1771.  
  1772. var regData = regimenDiv.data("data-regimen");
  1773. selectedRegimen.Id = regData.Id;
  1774. selectedRegimen.IsAutoApprovable = regData.IsAutoApprovable;
  1775. selectedRegimen.IsPathway = regData.IsPathway;
  1776. selectedRegimen.Name = regData.Name;
  1777. selectedRegimen.SelectableRegimenId = regData.SelectableRegimenId;
  1778. //selectedRegimen.ModelType = radiationOncologyRegimenAssemblyQualifiedName;
  1779. selectedRegimen.RequiredRegimenProcedures = new Array();
  1780. selectedRegimen.OptionalRegimenProcedures = new Array();
  1781. $.each(regimenDiv.find(".requiredMedsDiv input:checked"), function (index, data) { selectedRegimen.RequiredRegimenProcedures.push($(data).data("data-drug")); });
  1782.  
  1783. if (selectedRegimen.RequiredRegimenProcedures.length == 0)
  1784. return false;
  1785.  
  1786. $.each(regimenDiv.find(".supportMedsDiv input:checked"), function (index, data) { selectedRegimen.OptionalRegimenProcedures.push($(data).data("data-drug")); });
  1787. recursivelyRemoveWCFArtifactsProcedure(selectedRegimen.RequiredRegimenProcedures);
  1788. recursivelyRemoveWCFArtifactsProcedure(selectedRegimen.OptionalRegimenProcedures);
  1789.  
  1790. if (callback != null) callback(selectedRegimen, contextRequestType);
  1791.  
  1792. return true;
  1793. }
  1794.  
  1795. function PackageRegimenJson(regimenDiv, contextRequestType) {
  1796. turnOffHighlightRadioDrugs();
  1797.  
  1798. if (!isRequiredOptionalDrugsSelected()) return false;
  1799.  
  1800. var regData = regimenDiv.data("data-regimen");
  1801. selectedRegimen.Id = regData.Id;
  1802. selectedRegimen.IsAutoApprovable = regData.IsAutoApprovable;
  1803. selectedRegimen.IsPathway = regData.IsPathway;
  1804. selectedRegimen.Name = regData.Name;
  1805. selectedRegimen.SelectableRegimenId = regData.SelectableRegimenId;
  1806. selectedRegimen.AucScore = regData.AucScore;
  1807. //selectedRegimen.ModelType = radiationOncologyRegimenAssemblyQualifiedName;
  1808.  
  1809. if (regData.HasRequiredRegimenProcedures) {
  1810. selectedRegimen.RequiredRegimenProcedures = new Array();
  1811. $.each(regimenDiv.find(".requiredProcsDiv input:checked"), function (index, data) { selectedRegimen.RequiredRegimenProcedures.push($(data).data("data-drug")); });
  1812.  
  1813. if (selectedRegimen.RequiredRegimenProcedures.length == 0) {
  1814. return false;
  1815. }
  1816.  
  1817. recursivelyRemoveWCFArtifactsProcedure(selectedRegimen.RequiredRegimenProcedures);
  1818. }
  1819.  
  1820. if (regData.HasRequiredRegimenMedications) {
  1821. selectedRegimen.RequiredRegimenMedications = new Array();
  1822. $.each(regimenDiv.find(".requiredMedsDiv input:checked"), function (index, data) { selectedRegimen.RequiredRegimenMedications.push($(data).data("data-drug")); });
  1823.  
  1824. if ($("#requiredMedicationTr").length && selectedRegimen.RequiredRegimenMedications.length == 0) {
  1825. return false;
  1826. }
  1827.  
  1828. recursivelyRemoveWCFArtifacts(selectedRegimen.RequiredRegimenMedications);
  1829. }
  1830.  
  1831. if (regData.HasOptionalRegimenProcedures) {
  1832. selectedRegimen.OptionalRegimenProcedures = new Array();
  1833. $.each(regimenDiv.find(".optionalProcsDiv input:checked"), function (index, data) { selectedRegimen.OptionalRegimenProcedures.push($(data).data("data-drug")); });
  1834.  
  1835. recursivelyRemoveWCFArtifactsProcedure(selectedRegimen.OptionalRegimenProcedures);
  1836. }
  1837.  
  1838. if (regData.HasOptionalRegimenMedications) {
  1839. selectedRegimen.OptionalRegimenMedications = new Array();
  1840. $.each(regimenDiv.find(".optionalMedsDiv input:checked"), function (index, data) { selectedRegimen.OptionalRegimenMedications.push($(data).data("data-drug")); });
  1841.  
  1842. recursivelyRemoveWCFArtifacts(selectedRegimen.OptionalRegimenMedications);
  1843. }
  1844.  
  1845. if (callback != null) callback(selectedRegimen, contextRequestType);
  1846.  
  1847. return true;
  1848. }
  1849.  
  1850. function recursivelyRemoveWCFArtifacts(drugCollection) {
  1851. removeAsstacularTypeArtifact(drugCollection);
  1852. for (var i = 0; i < drugCollection.length; i++) {
  1853. var drug = drugCollection[i];
  1854.  
  1855. removeAsstacularTypeArtifact(drug);
  1856. if (drug.Dosing() != null && drug.Dosing().length > 0) {
  1857. for (var n = 0; n < drug.Dosing().length; n++) {
  1858. removeAsstacularTypeArtifact(drug.Dosing()[n]);
  1859. if (drug.Dosing()[n].DirectionForUses() != null && drug.Dosing()[n].DirectionForUses().length > 0) {
  1860. for (var r = 0; r < drug.Dosing()[n].DirectionForUses().length; r++) {
  1861. removeAsstacularTypeArtifact(drug.Dosing()[n].DirectionForUses()[r]);
  1862. }
  1863. }
  1864. }
  1865. }
  1866.  
  1867. if (drug.Medication() != null && drug.Medication().length > 0) {
  1868. for (var n = 0; n < drug.Medication().length; n++) {
  1869. removeAsstacularTypeArtifact(drug.Medication()[n]);
  1870. }
  1871. }
  1872.  
  1873. }
  1874.  
  1875. }
  1876.  
  1877. function recursivelyRemoveWCFArtifactsProcedure(drugCollection) {
  1878. removeAsstacularTypeArtifact(drugCollection);
  1879. for (var i = 0; i < drugCollection.length; i++) {
  1880. var drug = drugCollection[i];
  1881.  
  1882. removeAsstacularTypeArtifact(drug);
  1883.  
  1884. removeAsstacularTypeArtifact(drug.Procedure);
  1885.  
  1886. }
  1887.  
  1888. }
  1889.  
  1890. function removeAsstacularTypeArtifact(currentObj) {
  1891. delete currentObj.__type;
  1892. }
  1893.  
  1894. function appendDrugsToList(list, drug) {
  1895. list.append(drug);
  1896. }
  1897.  
  1898. function groupMedsByOrder(drugCollection) {
  1899. var drugGroups = new Array();
  1900. var currentRank = GetObjectValue(drugCollection[0].Order);
  1901. for (var i = 0; i < drugCollection.length; i++) {
  1902. var med = drugCollection[i];
  1903. var medOrder = GetObjectValue(med.Order);
  1904. if (drugGroups[medOrder - 1] == null) drugGroups[medOrder - 1] = new Array();
  1905. drugGroups[medOrder - 1].push(med);
  1906. }
  1907. return drugGroups;
  1908. }
  1909.  
  1910. function groupProcsByOrder(drugCollection) {
  1911. var drugGroups = new Array();
  1912. for (var i = 0; i < drugCollection.length; i++) {
  1913. var proc = drugCollection[i];
  1914. var procOrder = GetObjectValue(proc.Order);
  1915.  
  1916. if (procOrder < 0) procOrder = 0;
  1917.  
  1918. if (drugGroups[procOrder - 1] == null)
  1919. drugGroups[procOrder - 1] = new Array();
  1920.  
  1921. drugGroups[procOrder - 1].push(proc);
  1922. }
  1923. return drugGroups;
  1924. }
  1925.  
  1926. function buildListItemMGFMedications(drugGroups, isRequired) {
  1927. if (drugGroups == null) return [];
  1928. var list = new Array();
  1929. for (var i = 0; i < drugGroups.length; i++) {
  1930. var drugGroup = drugGroups[i];
  1931. var li = $("<li></li>").addClass('indent');
  1932. if (drugGroup != undefined) {
  1933. var drug = drugGroup;
  1934. var drugMeds = GetObjectValue(drug.Medication);
  1935. var drugId = GetObjectValue(drugMeds[0].Id);
  1936. var drugMedCode = GetObjectValue(drugMeds[0].Code);
  1937. var drugMedGenericName = GetObjectValue(drugMeds[0].GenericName);
  1938. var drugMedBrandName = GetObjectValue(drugMeds[0].BrandName);
  1939. var input = $("<input type='radio' name='mgfMed' id='" + drugId + "' />");
  1940. input.click(function (e) { e.stopPropagation(); });
  1941. input.val(drugId);
  1942. input.data("data-drug", drugGroup);
  1943. var drugText = $("<label for='" + drugId + "'></label>").text(drugMedCode + '-' + drugMedGenericName + ' (' + drugMedBrandName + ')');
  1944. if (oosFramework == true) {
  1945. if (isOutOfScope(drug.Medication()[0].Id())) {
  1946.  
  1947. if ((outOfScopeAction != undefined && outOfScopeAction != null) && outOfScopeAction.OutOfSupportedScopeActionType == "725060002") {
  1948. input.attr("disabled", true);
  1949. }
  1950.  
  1951. //drugText.append(oosText);
  1952. }
  1953. }
  1954. li.append(input);
  1955. li.append(drugText);
  1956. list.push(li);
  1957. }
  1958. }
  1959. return list;
  1960. }
  1961.  
  1962. function buildListItemMedications(drugGroups, isRequired) {
  1963. if (drugGroups == null) return [];
  1964. //var oosText = "<label class='outOfScope'> - Out of scope</label>";
  1965. var list = new Array();
  1966. for (var i = 0; i < drugGroups.length; i++) {
  1967. var group = drugGroups[i];
  1968. var li = $("<li></li>").addClass('indent');
  1969. if (group != undefined && group.length == 1) {
  1970. var drug = group[0];
  1971. var drugId = GetObjectValue(drug.Id);
  1972. var drugMeds = GetObjectValue(drug.Medication);
  1973. var drugMedCode = GetObjectValue(drugMeds[0].Code);
  1974. var drugMedGenericName = GetObjectValue(drugMeds[0].GenericName);
  1975. var drugMedBrandName = GetObjectValue(drugMeds[0].BrandName);
  1976. var input = $("<input type='checkbox' id='" + drugId + "' />");
  1977. input.click(function (e) { e.stopPropagation(); });
  1978. input.val(drugId);
  1979. if (isRequired || isReadOnly) input.attr("checked", true).attr("disabled", true);
  1980. input.data("data-drug", drug);
  1981. var drugText = $("<label for='" + drugId + "'></label>").text(drugMedCode + '-' + drugMedGenericName + ' (' + drugMedBrandName + ')');
  1982. //NoMessageDecompNoMedsSplitForward = 725060000,
  1983. //NoMessageAllowDecompMedsSplitForwardOutOfScope = 725060001,
  1984. //ShowMessageStopDecomp = 725060002,
  1985. if (oosFramework == true) {
  1986. if (isOutOfScope(drug.Medication()[0].Id())) {
  1987. if ((outOfScopeAction != undefined && outOfScopeAction != null) && outOfScopeAction.OutOfSupportedScopeActionType == "725060002") {
  1988. if (isRequired) {
  1989. //Set a flag to disable Regimen selection button if a required medication is OOS and Action type is 'ShowMessageStopDecomp'
  1990. oosDisableButton = true;
  1991. } else {
  1992. input.attr("disabled", true);
  1993. }
  1994. }
  1995.  
  1996. //drugText.append(oosText);
  1997. }
  1998. }
  1999. li.append(input);
  2000. li.append(drugText);
  2001.  
  2002. list.push(li);
  2003. } else if (group != undefined) {
  2004. var orderNum = getFirstGroupOrderNumber(group);
  2005. var groupName = generateGroupName(isRequired, orderNum, false);
  2006. var div = "<div id='" + groupName + "'></div>";
  2007. var indent = $(div).addClass('groupSpacing radioGroup');
  2008. for (var j = 0; j < group.length; j++) {
  2009. var li2 = $("<li></li>");
  2010. var drug = group[j];
  2011. var drugOrder = GetObjectValue(drug.Order);
  2012. var drugId = GetObjectValue(drug.Id);
  2013. var optId = (isRequired ? "reqMed_" : "optMed_") + drugOrder;
  2014. var disableRadio = isReadOnly ? "disabled" : "";
  2015. var input = $("<input type='radio' name=" + optId + " id='" + drugId + "' " + disableRadio + " />");
  2016. input.click(function (e) { e.stopPropagation(); });
  2017. input.val(drugId);
  2018. input.data("data-drug", drug);
  2019.  
  2020. if (isRequired) {
  2021. requiredOptionalDrugInputNames.push(optId);
  2022. }
  2023.  
  2024. var drugMeds = GetObjectValue(drug.Medication);
  2025. var drugMedCode = GetObjectValue(drugMeds[0].Code);
  2026. var drugMedGenericName = GetObjectValue(drugMeds[0].GenericName);
  2027. var drugMedBrandName = GetObjectValue(drugMeds[0].BrandName);
  2028. var drugText = $("<label for='" + drugId + "'></label>").text(drugMedCode + '-' + drugMedGenericName + ' (' + drugMedBrandName + ')');
  2029.  
  2030. if (oosFramework == true) {
  2031. if (isOutOfScope(drug.Medication()[0].Id())) {
  2032.  
  2033. if ((outOfScopeAction != undefined && outOfScopeAction != null) && outOfScopeAction.OutOfSupportedScopeActionType == "725060002") {
  2034. input.attr("disabled", true);
  2035. }
  2036.  
  2037. //drugText.append(oosText);
  2038. }
  2039. }
  2040. li2.append(input);
  2041. li2.append(drugText);
  2042. indent.append(li2);
  2043. }
  2044.  
  2045. li.append(indent);
  2046. list.push(li);
  2047. }
  2048. }
  2049. return list;
  2050. }
  2051.  
  2052. function getFirstGroupOrderNumber(group) {
  2053. if (group.length > 1) {
  2054. return GetObjectValue(group[0].Order);
  2055. }
  2056.  
  2057. return -1;
  2058. }
  2059.  
  2060. function generateGroupName(isRequired, drugOrder, isProc) {
  2061. var suffix = isProc ? "Proc" : "Med";
  2062. var optId = (isRequired ? "req" : "opt") + suffix + "_" + drugOrder;
  2063.  
  2064. return optId;
  2065. }
  2066.  
  2067. function buildListItemProcedures(drugGroups, isRequired) {
  2068. if (drugGroups == null) return [];
  2069. var list = new Array();
  2070. for (var i = 0; i < drugGroups.length; i++) {
  2071. var group = drugGroups[i];
  2072. var li = $("<li></li>").addClass('indent');
  2073. if (group != undefined && group.length == 1) {
  2074. var drug = group[0];
  2075. var drugId = GetObjectValue(drug.Id);
  2076. var drugProc = GetObjectValue(drug.Procedure);
  2077. var drugProcName = GetObjectValue(drugProc.Name);
  2078.  
  2079. var input = $("<input type='checkbox' id='" + drugId + "' />");
  2080. input.click(function (e) {
  2081. e.stopPropagation();
  2082. if (isRequired) {
  2083. HideRequiredServiceItemSelectionError();
  2084. }
  2085. });
  2086. input.val(drugId);
  2087.  
  2088. if (isRequired) input.attr("checked", true);
  2089. if (isRequired || isReadOnly) input.attr("disabled", true);
  2090.  
  2091. input.data("data-drug", drug);
  2092.  
  2093. var drugText = $("<label for='" + drugId + "'></label>").text(drugProcName);
  2094.  
  2095. if (oosFramework == true) {
  2096. if (isOutOfScope(drugProc.Id())) {
  2097. if ((outOfScopeAction != undefined && outOfScopeAction != null) && outOfScopeAction.OutOfSupportedScopeActionType == "725060002") {
  2098. if (isRequired) {
  2099. //Set a flag to disable Regimen selection button if a required procedure is OOS and Action type is 'ShowMessageStopDecomp'
  2100. oosDisableButton = true;
  2101. }
  2102. else {
  2103. input.attr("disabled", true);
  2104. }
  2105. }
  2106. }
  2107. }
  2108. li.append(input);
  2109. li.append(drugText);
  2110.  
  2111. list.push(li);
  2112. } else if (group != undefined) {
  2113. var orderNum = getFirstGroupOrderNumber(group);
  2114. var groupName = generateGroupName(isRequired, orderNum, true);
  2115. var div = "<div id='" + groupName + "'></div>";
  2116. var indent = $(div).addClass('groupSpacing radioGroup');
  2117. for (var j = 0; j < group.length; j++) {
  2118. var li2 = $("<li></li>");
  2119. var drug = group[j];
  2120. var drugId = GetObjectValue(drug.Id);
  2121. var drugProc = GetObjectValue(drug.Procedure);
  2122. var drugProcName = GetObjectValue(drugProc.Name);
  2123. var drugOrder = GetObjectValue(drug.Order);
  2124.  
  2125. var optId = (isRequired ? "reqProc_" : "optProc_") + drugOrder;
  2126. var disableRadio = isReadOnly ? "disabled" : "";
  2127. var input = $("<input type='radio' name=" + optId + " id='" + drugId + "' " + disableRadio + " />");
  2128. input.click(function (e) {
  2129. e.stopPropagation();
  2130. if (isRequired) {
  2131. HideRequiredServiceItemSelectionError();
  2132. }
  2133. });
  2134. input.val(drugId);
  2135. input.data("data-drug", drug);
  2136.  
  2137. if (isRequired) {
  2138. requiredOptionalDrugInputNames.push(optId);
  2139. }
  2140.  
  2141. var drugText = $("<label for='" + drugId + "'></label>").text(drugProcName);
  2142.  
  2143. if (oosFramework == true) {
  2144. if (isOutOfScope(drugProc.Id())) {
  2145. if ((outOfScopeAction != undefined && outOfScopeAction != null) && outOfScopeAction.OutOfSupportedScopeActionType == "725060002") {
  2146. if (isRequired) {
  2147. //Set a flag to disable Regimen selection button if a required procedure is OOS and Action type is 'ShowMessageStopDecomp'
  2148. oosDisableButton = true;
  2149. }
  2150. else {
  2151. input.attr("disabled", true);
  2152. }
  2153. }
  2154. }
  2155. }
  2156.  
  2157. li2.append(input);
  2158. li2.append(drugText);
  2159. indent.append(li2);
  2160. }
  2161.  
  2162. li.append(indent);
  2163. list.push(li);
  2164. }
  2165. }
  2166. return list;
  2167. }
  2168.  
  2169. function isRequiredOptionalDrugsSelected() {
  2170. var isSuccess = true;
  2171. $.each($.unique(requiredOptionalDrugInputNames), function (i, name) {
  2172. var isSelected =
  2173. $('.requiredMedsDiv input[name=' + name + ']:radio:checked').length > 0 ||
  2174. $('.requiredProcsDiv input[name=' + name + ']:radio:checked').length > 0;
  2175.  
  2176. if (!isSelected) {
  2177. isSuccess = false;
  2178. turnOnHighlightRadioDrugs(name);
  2179. }
  2180. });
  2181.  
  2182. return isSuccess;
  2183. }
  2184.  
  2185. function turnOnHighlightRadioDrugs(id) {
  2186. var div = "div[id='" + id + "']";
  2187. $(div).addClass("highlightRadioDrug");
  2188. }
  2189.  
  2190. function turnOffHighlightRadioDrugs() {
  2191. $(".radioGroup").removeClass('highlightRadioDrug');
  2192. }
  2193.  
  2194. var mgfMedications = (typeof (MGFMedications) !== "undefined" && MGFMedications != null)
  2195. ? GetObjectValue(MGFMedications) : null;
  2196. var requiredRegimenProcedures = typeof (jsonRegimenCollection.RequiredRegimenProcedures) !== "undefined"
  2197. ? GetObjectValue(jsonRegimenCollection.RequiredRegimenProcedures)
  2198. : null;
  2199. var requiredRegimenMedications = typeof (jsonRegimenCollection.RequiredRegimenMedications) !== "undefined"
  2200. ? GetObjectValue(jsonRegimenCollection.RequiredRegimenMedications)
  2201. : null;
  2202. var optionalRegimenProcedures = typeof (jsonRegimenCollection.OptionalRegimenProcedures) !== "undefined"
  2203. ? GetObjectValue(jsonRegimenCollection.OptionalRegimenProcedures)
  2204. : null;
  2205. var optionalRegimenMedications = typeof (jsonRegimenCollection.OptionalRegimenMedications) !== "undefined"
  2206. ? GetObjectValue(jsonRegimenCollection.OptionalRegimenMedications)
  2207. : null;
  2208. jsonRegimenCollection.HasRequiredRegimenProcedures = requiredRegimenProcedures &&
  2209. requiredRegimenProcedures.length !== 0;
  2210. jsonRegimenCollection.HasRequiredRegimenMedications = requiredRegimenMedications !== null &&
  2211. requiredRegimenMedications !== undefined &&
  2212. requiredRegimenMedications.length !== 0;
  2213. jsonRegimenCollection.HasOptionalRegimenProcedures = optionalRegimenProcedures !== null &&
  2214. optionalRegimenProcedures !== undefined &&
  2215. optionalRegimenProcedures.length !== 0;
  2216. jsonRegimenCollection.HasOptionalRegimenMedications = optionalRegimenMedications !== null &&
  2217. optionalRegimenMedications !== undefined &&
  2218. optionalRegimenMedications.length !== 0;
  2219.  
  2220. if (isRadiationOncology) {
  2221. compiledTemplate = buildTemplateProcedure();
  2222. createRegimenProcedure(jsonRegimenCollection);
  2223. }
  2224. else if (isCardiology) {
  2225. compiledTemplate = BuildCardiologyTemplate(jsonRegimenCollection.RequiredRegimenMedications);
  2226. CreateCardiologyRegimen(jsonRegimenCollection);
  2227. }
  2228. else if (isImaging) {
  2229. compiledTemplate = BuildRegimenTemplate(jsonRegimenCollection);
  2230. CreateRegimen(jsonRegimenCollection);
  2231. }
  2232. else {
  2233. var visibility = ShowRegimenCost(jsonRegimenCollection.RegimenCost);
  2234. compiledTemplate = buildTemplateMedication(visibility, jsonRegimenCollection.RegimenCost);
  2235. createRegimenMedication(jsonRegimenCollection, MGFMedications);
  2236. }
  2237.  
  2238. compiledTemplate.show();
  2239.  
  2240. //Disabling 'Use this Regimen' button based on flag value
  2241. if (oosDisableButton) {
  2242. $('#btnUseThisRegimen').attr("disabled", true);
  2243.  
  2244. $('#btnUseThisRegimen').css('background-color', '#EF9422');
  2245. $('#btnUseThisRegimen').css('cursor', 'default');
  2246. $('#btnUseThisRegimen').css('color', '#A0A0A0');
  2247. $('#btnUseThisRegimen').css('text-shadow', '1px 1px #FFFFFF');
  2248. }
  2249. $(function () {
  2250. $('.estimatedCostCalculationToolTip').popover({
  2251. trigger: 'hover',
  2252. placement: 'auto top',
  2253. html: true
  2254. });
  2255.  
  2256. });
  2257. };
  2258. //end
  2259. })(jQuery)
  2260. + function (a) { "use strict"; var b = function (a, b) { this.type = this.options = this.enabled = this.timeout = this.hoverState = this.$element = null, this.init("tooltip", a, b) }; b.DEFAULTS = { animation: !0, placement: "top", selector: !1, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>', trigger: "hover focus", title: "", delay: 0, html: !1, container: !1 }, b.prototype.init = function (b, c, d) { this.enabled = !0, this.type = b, this.$element = a(c), this.options = this.getOptions(d); var e = this.options.trigger.split(" "); for (var f = e.length; f--;) { var g = e[f]; if (g == "click") this.$element.on("click." + this.type, this.options.selector, a.proxy(this.toggle, this)); else if (g != "manual") { var h = g == "hover" ? "mouseenter" : "focus", i = g == "hover" ? "mouseleave" : "blur"; this.$element.on(h + "." + this.type, this.options.selector, a.proxy(this.enter, this)), this.$element.on(i + "." + this.type, this.options.selector, a.proxy(this.leave, this)) } } this.options.selector ? this._options = a.extend({}, this.options, { trigger: "manual", selector: "" }) : this.fixTitle() }, b.prototype.getDefaults = function () { return b.DEFAULTS }, b.prototype.getOptions = function (b) { return b = a.extend({}, this.getDefaults(), this.$element.data(), b), b.delay && typeof b.delay == "number" && (b.delay = { show: b.delay, hide: b.delay }), b }, b.prototype.getDelegateOptions = function () { var b = {}, c = this.getDefaults(); return this._options && a.each(this._options, function (a, d) { c[a] != d && (b[a] = d) }), b }, b.prototype.enter = function (b) { var c = b instanceof this.constructor ? b : a(b.currentTarget)[this.type](this.getDelegateOptions()).data("bs." + this.type); clearTimeout(c.timeout), c.hoverState = "in"; if (!c.options.delay || !c.options.delay.show) return c.show(); c.timeout = setTimeout(function () { c.hoverState == "in" && c.show() }, c.options.delay.show) }, b.prototype.leave = function (b) { var c = b instanceof this.constructor ? b : a(b.currentTarget)[this.type](this.getDelegateOptions()).data("bs." + this.type); clearTimeout(c.timeout), c.hoverState = "out"; if (!c.options.delay || !c.options.delay.hide) return c.hide(); c.timeout = setTimeout(function () { c.hoverState == "out" && c.hide() }, c.options.delay.hide) }, b.prototype.show = function () { var b = a.Event("show.bs." + this.type); if (this.hasContent() && this.enabled) { this.$element.trigger(b); if (b.isDefaultPrevented()) return; var c = this.tip(); this.setContent(), this.options.animation && c.addClass("fade"); var d = typeof this.options.placement == "function" ? this.options.placement.call(this, c[0], this.$element[0]) : this.options.placement, e = /\s?auto?\s?/i, f = e.test(d); f && (d = d.replace(e, "") || "top"), c.detach().css({ top: 0, left: 0, display: "block" }).addClass(d), this.options.container ? c.appendTo(this.options.container) : c.insertAfter(this.$element); var g = this.getPosition(), h = c[0].offsetWidth, i = c[0].offsetHeight; if (f) { var j = this.$element.parent(), k = d, l = document.documentElement.scrollTop || document.body.scrollTop, m = this.options.container == "body" ? window.innerWidth : j.outerWidth(), n = this.options.container == "body" ? window.innerHeight : j.outerHeight(), o = this.options.container == "body" ? 0 : j.offset().left; d = d == "bottom" && g.top + g.height + i - l > n ? "top" : d == "top" && g.top - l - i < 0 ? "bottom" : d == "right" && g.right + h > m ? "left" : d == "left" && g.left - h < o ? "right" : d, c.removeClass(k).addClass(d) } var p = this.getCalculatedOffset(d, g, h, i); this.applyPlacement(p, d), this.$element.trigger("shown.bs." + this.type) } }, b.prototype.applyPlacement = function (a, b) { var c, d = this.tip(), e = d[0].offsetWidth, f = d[0].offsetHeight, g = parseInt(d.css("margin-top"), 10), h = parseInt(d.css("margin-left"), 10); isNaN(g) && (g = 0), isNaN(h) && (h = 0), a.top = a.top + g, a.left = a.left + h, d.offset(a).addClass("in"); var i = d[0].offsetWidth, j = d[0].offsetHeight; b == "top" && j != f && (c = !0, a.top = a.top + f - j); if (/bottom|top/.test(b)) { var k = 0; a.left < 0 && (k = a.left * -2, a.left = 0, d.offset(a), i = d[0].offsetWidth, j = d[0].offsetHeight), this.replaceArrow(k - e + i, i, "left") } else this.replaceArrow(j - f, j, "top"); c && d.offset(a) }, b.prototype.replaceArrow = function (a, b, c) { this.arrow().css(c, a ? 50 * (1 - a / b) + "%" : "") }, b.prototype.setContent = function () { var a = this.tip(), b = this.getTitle(); a.find(".tooltip-inner")[this.options.html ? "html" : "text"](b), a.removeClass("fade in top bottom left right") }, b.prototype.hide = function () { function e() { b.hoverState != "in" && c.detach() } var b = this, c = this.tip(), d = a.Event("hide.bs." + this.type); this.$element.trigger(d); if (d.isDefaultPrevented()) return; return c.removeClass("in"), a.support.transition && this.$tip.hasClass("fade") ? c.one(a.support.transition.end, e).emulateTransitionEnd(150) : e(), this.$element.trigger("hidden.bs." + this.type), this }, b.prototype.fixTitle = function () { var a = this.$element; (a.attr("title") || typeof a.attr("data-original-title") != "string") && a.attr("data-original-title", a.attr("title") || "").attr("title", "") }, b.prototype.hasContent = function () { return this.getTitle() }, b.prototype.getPosition = function () { var b = this.$element[0]; return a.extend({}, typeof b.getBoundingClientRect == "function" ? b.getBoundingClientRect() : { width: b.offsetWidth, height: b.offsetHeight }, this.$element.offset()) }, b.prototype.getCalculatedOffset = function (a, b, c, d) { return a == "bottom" ? { top: b.top + b.height, left: b.left + b.width / 2 - c / 2 } : a == "top" ? { top: b.top - d, left: b.left + b.width / 2 - c / 2 } : a == "left" ? { top: b.top + b.height / 2 - d / 2, left: b.left - c } : { top: b.top + b.height / 2 - d / 2, left: b.left + b.width } }, b.prototype.getTitle = function () { var a, b = this.$element, c = this.options; return a = b.attr("data-original-title") || (typeof c.title == "function" ? c.title.call(b[0]) : c.title), a }, b.prototype.tip = function () { return this.$tip = this.$tip || a(this.options.template) }, b.prototype.arrow = function () { return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow") }, b.prototype.validate = function () { this.$element[0].parentNode || (this.hide(), this.$element = null, this.options = null) }, b.prototype.enable = function () { this.enabled = !0 }, b.prototype.disable = function () { this.enabled = !1 }, b.prototype.toggleEnabled = function () { this.enabled = !this.enabled }, b.prototype.toggle = function (b) { var c = b ? a(b.currentTarget)[this.type](this.getDelegateOptions()).data("bs." + this.type) : this; c.tip().hasClass("in") ? c.leave(c) : c.enter(c) }, b.prototype.destroy = function () { this.hide().$element.off("." + this.type).removeData("bs." + this.type) }; var c = a.fn.tooltip; a.fn.tooltip = function (c) { return this.each(function () { var d = a(this), e = d.data("bs.tooltip"), f = typeof c == "object" && c; e || d.data("bs.tooltip", e = new b(this, f)), typeof c == "string" && e[c]() }) }, a.fn.tooltip.Constructor = b, a.fn.tooltip.noConflict = function () { return a.fn.tooltip = c, this } }(jQuery),
  2261. +function (a) { "use strict"; var b = function (a, b) { this.init("popover", a, b) }; if (!a.fn.tooltip) throw new Error("Popover requires tooltip.js"); b.DEFAULTS = a.extend({}, a.fn.tooltip.Constructor.DEFAULTS, { placement: "right", trigger: "click", content: "", template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' }), b.prototype = a.extend({}, a.fn.tooltip.Constructor.prototype), b.prototype.constructor = b, b.prototype.getDefaults = function () { return b.DEFAULTS }, b.prototype.setContent = function () { var a = this.tip(), b = this.getTitle(), c = this.getContent(); a.find(".popover-title")[this.options.html ? "html" : "text"](b), a.find(".popover-content")[this.options.html ? "html" : "text"](c), a.removeClass("fade top bottom left right in"), a.find(".popover-title").html() || a.find(".popover-title").hide() }, b.prototype.hasContent = function () { return this.getTitle() || this.getContent() }, b.prototype.getContent = function () { var a = this.$element, b = this.options; return a.attr("data-content") || (typeof b.content == "function" ? b.content.call(a[0]) : b.content) }, b.prototype.arrow = function () { return this.$arrow = this.$arrow || this.tip().find(".arrow") }, b.prototype.tip = function () { return this.$tip || (this.$tip = a(this.options.template)), this.$tip }; var c = a.fn.popover; a.fn.popover = function (c) { return this.each(function () { var d = a(this), e = d.data("bs.popover"), f = typeof c == "object" && c; e || d.data("bs.popover", e = new b(this, f)), typeof c == "string" && e[c]() }) }, a.fn.popover.Constructor = b, a.fn.popover.noConflict = function () { return a.fn.popover = c, this } }(jQuery)
  2262. //save regimen conversation
  2263. var saveRegimenConversationToSession = function (answeredQuestionInfoList, callback, callbackUrl) {
  2264.  
  2265. var urlPost = "/Authorization/RegimenSelection/SaveQandAToSession";
  2266.  
  2267. if (answeredQuestionInfoList != undefined && answeredQuestionInfoList != null && answeredQuestionInfoList.length > 0) {
  2268. currentRegimenConversations = answeredQuestionInfoList;
  2269. var regimenRuleId = $("input:hidden[name='CurrentRegimenRuleSearchingResponse.RegimenRuleId']").attr("value");
  2270. var SelectedQuestionAnswerRequest = {
  2271. RegimenRuleId: regimenRuleId,
  2272. AnsweredQuestions: answeredQuestionInfoList,
  2273. IsSimulation: false
  2274. }
  2275. window.scrollTo(10, 10);
  2276.  
  2277.  
  2278. $.ajax({
  2279.  
  2280. type: "POST",
  2281. url: urlPost,
  2282. data: JSON.stringify(SelectedQuestionAnswerRequest),
  2283. contentType: 'application/json; charset=utf-8',
  2284. success: function () {
  2285. try {
  2286.  
  2287.  
  2288. } finally {
  2289.  
  2290. callback(true, callbackUrl);
  2291. }
  2292. },
  2293. error: function (xhr, ajaxOptions, thrownError) {
  2294. alert(xhr.status);
  2295. alert(thrownError);
  2296.  
  2297. callback(false, callbackUrl);
  2298. }
  2299. });
  2300. } else
  2301. callback(true, callbackUrl);
  2302. };
  2303. //call after selecting the regimen to save in crm and to populate the dosing and direction for portal
  2304. var regimenSelectCallbackPortal30 = function (json, requestType) {
  2305. if (requestType != undefined && requestType == "CrmRequest") {
  2306.  
  2307. $("#loadingSpinner").dialog({
  2308. closeOnEscape: false,
  2309. dialogClass: 'no-close',
  2310. resizable: false,
  2311. title: "Loading...",
  2312. position: {
  2313. my: "center center",
  2314. at: "center center",
  2315. of: window
  2316. },
  2317. modal: true
  2318. });
  2319.  
  2320. var answeredQuestionInfoList = currentRegimenConversations;
  2321. if (currentCrmServiceId == undefined || currentCrmServiceId == '')
  2322. currentCrmServiceId = getQueryString('serviceRequestId');
  2323. if (currentCrmUserId == undefined || currentCrmUserId == '')
  2324. currentCrmUserId = getQueryString('userId');
  2325. if (currentDeterminationSupportId == undefined || currentDeterminationSupportId == '')
  2326. currentDeterminationSupportId = getQueryString('determinationSupportId');
  2327. if (currentCrmIsDssSupplemental == undefined || currentCrmIsDssSupplemental == '')
  2328. currentCrmIsDssSupplemental = getQueryString('isDssSupplemental');
  2329. if (currentCrmPassedIcdId == undefined || currentCrmPassedIcdId == '') {
  2330. currentCrmPassedIcdId = getQueryString('icdId');
  2331. }
  2332.  
  2333. if (answeredQuestionInfoList != undefined && answeredQuestionInfoList != null) {
  2334. var serviceId = currentCrmServiceId;
  2335. var userId = currentCrmUserId;
  2336. var determinationSupportId = currentDeterminationSupportId;
  2337. var isDssSupplemental = currentCrmIsDssSupplemental;
  2338.  
  2339. var jsonSelectableRegimen = [];
  2340. //jsonSelectableRegimen = populateSelectableRegimenToJson();
  2341. var RegimenServiceIdRequest = {
  2342. //SelectableRegimen: jsonSelectableRegimen,
  2343. SelectedRegimen: json,
  2344. ServiceId: serviceId,
  2345. RuleId: currentRuleTriggerId,
  2346. AnsweredQuestions: answeredQuestionInfoList,
  2347. UserId: userId,
  2348. DeterminationSupportId: determinationSupportId,
  2349. IsDssSupplemental: isDssSupplemental,
  2350. IcdId: currentCrmPassedIcdId
  2351. };
  2352.  
  2353. $.ajax({
  2354. cache: false,
  2355. url: '/QandARegimen/QandARegimen/SaveRegimen',
  2356. type: "POST",
  2357. contentType: 'application/json; charset=utf-8',
  2358. dataType: "text",
  2359. data: ko.toJSON(RegimenServiceIdRequest),
  2360. success: function (returnVal) {
  2361. try {
  2362. if (returnVal != "answered") {
  2363. if (window.opener) {
  2364. window.opener.returnValue = returnVal;
  2365. }
  2366.  
  2367. window.returnValue = returnVal;
  2368. window.close();
  2369. }
  2370. } finally {
  2371. html = null;
  2372. $("#loadingSpinner").dialog("close");
  2373. }
  2374. },
  2375. error: function (xhr, ajaxOptions, thrownError) {
  2376. alert(xhr.status);
  2377. alert(thrownError);
  2378. $("#loadingSpinner").dialog("close");
  2379. window.returnValue = false;
  2380. }
  2381. });
  2382. }
  2383.  
  2384. }
  2385. else {
  2386. if (requestType !== RequestTypeUmIntake) {
  2387. openNextTab();
  2388. sendAuthDetailToGoogleAnalytics("Authorization - New Request - Service Item Detail", "/Authorization/NewRequest/ServiceItemDetail");
  2389. }
  2390. else {
  2391. json.RequestSpecs = Cp.IntakeHome.AuthRequest.Instance.GetRequestSpecs();
  2392. }
  2393.  
  2394. $("#loadingSpinner").dialog({
  2395. closeOnEscape: false,
  2396. dialogClass: 'no-close',
  2397. resizable: false,
  2398. title: "Loading...",
  2399. position: {
  2400. my: "center center",
  2401. at: "center center",
  2402. of: window
  2403. },
  2404. modal: true
  2405. });
  2406.  
  2407. $.ajax({
  2408. cache: false,
  2409. url: '/Authorization/NewRequestHelper/RegimenSelect',
  2410. type: "POST",
  2411. contentType: 'application/json; charset=utf-8',
  2412. dataType: "html",
  2413. data: ko.toJSON(json),// + "&isUmIntake=" + requestType !== RequestTypeUmIntake ,
  2414. success: function(html) {
  2415. RegimenSelectSuccessCallback(html);
  2416. $("#loadingSpinner").dialog("close");
  2417.  
  2418. console.log($("#maxMonthDurationId").val());
  2419. console.log($("#hasRegimenId").val());
  2420. },
  2421. error: function (request, status, error) {
  2422. if ($("#loadingSpinner").hasClass("ui-dialog-content") &&
  2423. $("#loadingSpinner").dialog("isOpen")) {
  2424. $("#loadingSpinner").dialog("close");
  2425. }
  2426. alert(request.responseText);
  2427. }
  2428. });
  2429. }
  2430.  
  2431. };
  2432.  
  2433. function RegimenSelectSuccessCallback(html) {
  2434. try {
  2435. $("#requestedItemsContainer").html('');
  2436. $("#requestedItemsContainer").html(html);
  2437. $.each($('select[id$="__ServiceItem_Quantity"]'), function (i, $obj) {
  2438. setSpanValueForSelect($obj.id);
  2439. });
  2440. } finally {
  2441. html = null;
  2442. $("#loadingSpinnerInDosing").dialog("close");
  2443. if (REQUEST_TYPE !== RequestTypeUmIntake) {
  2444. refreshSelectedInfoForDosing(true);
  2445. Cp.NewRequest.CommonProcessor.Instance.FullyLockApplicableNewRequestFields();
  2446. }
  2447. }
  2448. }
  2449.  
  2450. function saveSelectableRegimenToSession(requestType) {
  2451. var jsonSelectableRegimen = [];
  2452. jsonSelectableRegimen = populateSelectableRegimenToJson();
  2453. var jsonData;
  2454. var requestUrl;
  2455. if (requestType == undefined || requestType == "SimulateRequest" || requestType == "NewRequest") {
  2456. requestUrl = '/Authorization/NewRequest/SaveToSessionSelectableRegimen';
  2457. jsonData = jsonSelectableRegimen;
  2458. }
  2459. if (requestType != undefined && requestType == "CrmRequest") {
  2460. requestUrl = '/QandARegimen/QandARegimen/SaveAllSelectableRegimen';
  2461. if (currentCrmServiceId == undefined || currentCrmServiceId == '')
  2462. currentCrmServiceId = getQueryString('serviceRequestId');
  2463. if (currentCrmUserId == undefined || currentCrmUserId == '')
  2464. currentCrmUserId = getQueryString('userId');
  2465.  
  2466. var RegimenServiceIdRequest = {
  2467. SelectableRegimen: jsonSelectableRegimen,
  2468. ServiceId: currentCrmServiceId,
  2469. UserId: currentCrmUserId
  2470. }
  2471. jsonData = RegimenServiceIdRequest;
  2472.  
  2473. }
  2474. $.ajax({
  2475. cache: false,
  2476. async: false,
  2477. url: requestUrl,
  2478. type: "POST",
  2479. contentType: 'application/json; charset=utf-8',
  2480. dataType: "json",
  2481. data: JSON.stringify(jsonData),
  2482. success: function () { return true; }, error: function (request, status, error) {
  2483. alert(request.responseText);
  2484. }
  2485. });
  2486. }
  2487.  
  2488. function populateSelectableRegimenToJson() {
  2489. var regimens = [];
  2490. if (selectableRegimenData != null) {
  2491. $.each(selectableRegimenData.Regimens, function (index) {
  2492. regimens.push({
  2493. "Id": selectableRegimenData.Regimens[index].Id, "Name": selectableRegimenData.Regimens[index].Name,
  2494. "IsPathway": selectableRegimenData.Regimens[index].IsPathway, "IsAutoApprovable": selectableRegimenData.Regimens[index].IsAutoApprovable,
  2495. "RiskFactor": selectableRegimenData.Regimens[index].RiskFactor, "RequiredRegimenMedications": selectableRegimenData.Regimens[index].RequiredRegimenMedications,
  2496. "OptionalRegimenMedications": selectableRegimenData.Regimens[index].OptionalRegimenMedications, "Diagnoses": selectableRegimenData.Regimens[index].Diagnoses,
  2497. "StateCode": selectableRegimenData.Regimens[index].StateCode, "StatusCode": selectableRegimenData.Regimens[index].StatusCode,
  2498. "RiskFactorNeutropenic": selectableRegimenData.Regimens[index].RiskFactorNeutropenic,
  2499. "SelectableRegimenId": selectableRegimenData.Regimens[index].SelectableRegimenId,
  2500. "MaximumDuration": selectableRegimenData.Regimens[index].MaximumDuration
  2501. });
  2502. });
  2503. }
  2504. return regimens;
  2505. }
  2506.  
  2507. //remove the regimen conversation from session
  2508. function removeRegimenFromSession() {
  2509. //
  2510. var url = "/Authorization/RegimenSelection/DeleteSelectedRegimen";
  2511. $.ajax({
  2512. url: url,
  2513. type: 'POST',
  2514. success: function () {
  2515. try {
  2516. $('#page-selection .regimen-selection-table tbody tr').closest('tr').removeClass('selected');
  2517. $("#DisplayPatientValError").html('');
  2518. } finally {
  2519. result = null;
  2520. }
  2521. },
  2522. error: function (xhr, ajaxOptions, thrownError) {
  2523. alert(xhr.status);
  2524. alert(thrownError);
  2525. }
  2526. });
  2527. }
  2528. //initialize the question and answer section
  2529. function initializeCommonUiQuestionAnswer() {
  2530. $(function () {
  2531. var requestType = $("input:hidden[name='RequestType']").attr("value");
  2532. //Variable decalaration
  2533. var errorCssClass = "input-validation-error";
  2534. answeredQuestionInfoList = [];
  2535. answers = [];
  2536.  
  2537. //Remove error class from input text box for calendar when select the date
  2538. $('.labDatePicker').datepicker({
  2539. onSelect: function (dateText, inst) {
  2540. $(this).removeClass(errorCssClass);
  2541. $(this).attr('title', "");
  2542. $(this).change();
  2543. }
  2544. });
  2545. $('.labDatePicker').change(function (evt) {
  2546. showHideDssDropdown($(this), false);
  2547. });
  2548. $('.dssReasonDropdown').change(function (evt) {
  2549. $(this).removeClass(errorCssClass);
  2550. });
  2551.  
  2552. //Remove error class from input text box for calendar when user enters
  2553. $('.labDatePicker').keyup(function () {
  2554. $(this).removeClass(errorCssClass);
  2555. $(this).attr('title', "");
  2556. });
  2557.  
  2558. $('.qn-help').popover({
  2559. trigger: 'hover',
  2560. placement: 'auto top'
  2561. });
  2562. //Can show the determination support reason dropdown
  2563. var regimenConversations = null;
  2564. function canShowDssReasonDropdown(currentQnId, selectedAnswers, isChoicebox) {
  2565.  
  2566. var canShow = false;
  2567.  
  2568. if (requestType == "CrmRequest" || requestType == "PortalDssRequest") {
  2569. var selectedRegimenConversations = [];
  2570. var regimenConversationsForCurrentQn = [];
  2571. //get answerIds from regimenConversation for the currentQnId
  2572. if (regimenConversations == null) {
  2573. regimenConversations = JSON.parse(getCurrentRegimenConversations(REQUEST_TYPE));
  2574. }
  2575. if (isChoicebox) {
  2576. $.each(regimenConversations, function (index, regimenConversation) {
  2577. if (regimenConversation.QuestionReferenceId == currentQnId) {
  2578. //need this for qns with multiple answers selected
  2579. regimenConversationsForCurrentQn.push(regimenConversation.AnswerReferenceId);
  2580. if (jQuery.inArray(regimenConversation.AnswerReferenceId, selectedAnswers) != -1) {
  2581. selectedRegimenConversations.push(regimenConversation.AnswerReferenceId);
  2582. }
  2583. }
  2584. });
  2585. } else {
  2586.  
  2587. $.each(regimenConversations, function (index, regimenConversation) {
  2588. if (regimenConversation.QuestionReferenceId == currentQnId) {
  2589. if (jQuery.inArray(regimenConversation.ResponseText, selectedAnswers) != -1) {
  2590. selectedRegimenConversations.push(regimenConversation.ResponseText);
  2591. //adding this to keep the below condition intact for lab/lab with calendar
  2592. regimenConversationsForCurrentQn.push(regimenConversation.AnswerReferenceId);
  2593. }
  2594. }
  2595. });
  2596. }
  2597. if ((regimenConversationsForCurrentQn.length != selectedRegimenConversations.length) || (selectedAnswers.length != selectedRegimenConversations.length)) {
  2598. canShow = true;
  2599. }
  2600. }
  2601.  
  2602. return canShow;
  2603. }
  2604. //Show hide determination support reason dropdown
  2605. function showHideDssDropdown(selectedAnswer, isChoicebox) {
  2606. var selectedAnswers = [];
  2607. var selectedAnswerValues = [];
  2608. if (currentCrmIsDssSupplemental == undefined || currentCrmIsDssSupplemental == '')
  2609. currentCrmIsDssSupplemental = getQueryString('isDssSupplemental');
  2610. if (currentDeterminationSupportId == undefined || currentDeterminationSupportId == '')
  2611. currentDeterminationSupportId = getQueryString('determinationSupportId');
  2612. if (currentCrmPassedIcdId == undefined || currentCrmPassedIcdId == '') {
  2613. currentCrmPassedIcdId = getQueryString('icdId');
  2614. }
  2615.  
  2616. if ((requestType == "CrmRequest" || requestType == "PortalDssRequest") && currentCrmIsDssSupplemental != 'true' && currentDeterminationSupportId != undefined && currentDeterminationSupportId != '' &&
  2617. (currentCrmPassedIcdId == undefined || currentCrmPassedIcdId == '' || requestType == "PortalDssRequest")) {
  2618. if (isChoicebox) {
  2619. if (selectedAnswer.hasClass("active")) {
  2620. selectedAnswers.push(selectedAnswer.attr("id"));
  2621. }
  2622. $.each(selectedAnswer.siblings(".active"), function (index, selectedAnswerElement) {
  2623. selectedAnswers.push(selectedAnswerElement.id);
  2624. });
  2625. var currentQnId = selectedAnswer.attr('question');
  2626. if (selectedAnswer.attr("name") == "performance_status_ecog" || selectedAnswer.attr("name") == "performance_status_karnofsky") {
  2627.  
  2628. if (canShowDssReasonDropdown(currentQnId, selectedAnswers, isChoicebox)) {
  2629. selectedAnswer.closest(".panel-section").find(".dssReasonDropdown").each(function () {
  2630. if (currentQnId == $(this).attr("name")) {
  2631. $(this).show();
  2632. }
  2633. });
  2634. } else {
  2635. selectedAnswer.closest(".panel-section").find(".dssReasonDropdown").each(function () {
  2636. if (currentQnId == $(this).attr("name")) {
  2637. $(this).hide();
  2638. $(this).val('0');
  2639. }
  2640. });
  2641. }
  2642. }
  2643. if (canShowDssReasonDropdown(currentQnId, selectedAnswers, isChoicebox)) {
  2644. selectedAnswer.parent().siblings().find(".dssReasonDropdown").each(function () {
  2645. if (currentQnId == $(this).attr("name")) {
  2646. $(this).show();
  2647. }
  2648. });
  2649. } else {
  2650. selectedAnswer.parent().siblings().find(".dssReasonDropdown").each(function () {
  2651. if (currentQnId == $(this).attr("name")) {
  2652. $(this).hide();
  2653. $(this).val('0');
  2654. }
  2655. });
  2656. }
  2657. } else {
  2658. var currentParent = selectedAnswer.parent();
  2659. var textBoxDisplayItems = currentParent.find("input:text");
  2660. textBoxDisplayItems.each(function () {
  2661. if ($(this) != undefined && textBoxDisplayItems.is(":visible")) {
  2662. selectedAnswers.push(this.value);
  2663. }
  2664. });
  2665. var currentQnId = currentParent.attr('question');
  2666. if (canShowDssReasonDropdown(currentQnId, selectedAnswers, isChoicebox)) {
  2667. currentParent.parent().siblings().find(".dssReasonDropdown").each(function () {
  2668. if (currentQnId == $(this).attr("name")) {
  2669. $(this).show();
  2670. }
  2671. });
  2672. } else {
  2673. currentParent.parent().siblings().find(".dssReasonDropdown").each(function () {
  2674. if (currentQnId == $(this).attr("name")) {
  2675. $(this).hide();
  2676. $(this).val('0');
  2677. }
  2678. });
  2679. }
  2680. }
  2681. }
  2682. }
  2683.  
  2684. //Check whether the valus is a number or not
  2685. function isNumber(value, evt) {
  2686. var charCode = (evt.which) ? evt.which : event.keyCode
  2687. if (charCode != 45 && (charCode != 46 || value.indexOf('.') != -1) &&
  2688. (charCode < 48 || charCode > 57) && charCode != 8)
  2689. return false;
  2690. else {
  2691. if (charCode == 8) return true; //backspace.
  2692.  
  2693. var len = value.length;
  2694. var index = value.indexOf('.');
  2695.  
  2696. if (index >= 0) {
  2697. var CharAfterdot = (len + 1) - index;
  2698. if (CharAfterdot > 3) {
  2699. return false;
  2700. }
  2701. } else if (len == 3) {
  2702. if (charCode != 46)
  2703. return false;
  2704. }
  2705.  
  2706. }
  2707.  
  2708. return true;
  2709. }
  2710.  
  2711. //Key press for the lab type
  2712. $('.numbersOnly').keypress(function (evt) {
  2713. if (isNumber(this.value, evt)) {
  2714. if ($(this).hasClass(errorCssClass)) {
  2715. $(this).removeClass(errorCssClass);
  2716. }
  2717. } else
  2718. return false;
  2719. });
  2720.  
  2721. $('.numbersOnly').blur(function (evt) {
  2722. showHideDssDropdown($(this), false);
  2723. });
  2724.  
  2725. //Show/hide Ecog /Karnofsky
  2726. $('[name=performance_status_type]').change(function () {
  2727. if ($('#regimenMappingDialog').is(':visible')) {
  2728. var logicalOperandRadioName = $(this).parents(".panel-section").attr("id");
  2729. $("input[name=" + logicalOperandRadioName + "][value=Or]").prop('checked', true).trigger("click");
  2730. }
  2731. $('[data-master=performance-status-ecog], [data-master=performance-status-karnofsky]').toggleClass('hide');
  2732. });
  2733.  
  2734. //Select Ecog based on Karnofsky value
  2735. var selectEcog = function (karnofskyValue) {
  2736. var ecogValue;
  2737.  
  2738. switch (karnofskyValue) {
  2739. case "0":
  2740. ecogValue = 5;
  2741. break;
  2742. case "1": case "2": case "3":
  2743. ecogValue = 4;
  2744. break;
  2745. case "4": case "5":
  2746. ecogValue = 3;
  2747. break;
  2748. case "6": case "7":
  2749. ecogValue = 2;
  2750. break;
  2751. case "8": case "9":
  2752. ecogValue = 1;
  2753. break;
  2754. case "10":
  2755. ecogValue = 0;
  2756. break;
  2757.  
  2758. }
  2759. var ecogElement = $('[data-master=performance-status-ecog]').find("label:contains('" + ecogValue + " - ')");
  2760. if (ecogElement != undefined) {
  2761. ecogElement.addClass('active');
  2762. ecogElement.siblings(".answerButtonBox").removeClass("active");
  2763. ecogElement.siblings(".answerButtonBox").removeClass(errorCssClass);
  2764. }
  2765.  
  2766.  
  2767. };
  2768.  
  2769. //Get all questions which has pre requisite
  2770. var getAllFocusedQuestionsByPreRequisite = function (selectedAnswer) {
  2771. var questionsWithPreReq = [];
  2772. var commonUiClinicalInformationSection = selectedAnswer.parents('#commonUiClinicalInformationSectionTest');
  2773. if (commonUiClinicalInformationSection.length <= 0) {
  2774. commonUiClinicalInformationSection = selectedAnswer.parents('#commonUiClinicalInformationSection');
  2775. if (commonUiClinicalInformationSection.length <= 0) {
  2776. commonUiClinicalInformationSection = selectedAnswer.parents('.js-question-table');
  2777. }
  2778. }
  2779. commonUiClinicalInformationSection.find(".panel-section").each(function () {
  2780. if (($(this).attr('preReq') == 'true') && ($(this).filter("[preReqQn*='" + selectedAnswer.attr('question') + "']").length > 0)) {
  2781. questionsWithPreReq.push($(this));
  2782. }
  2783. });
  2784. return questionsWithPreReq;
  2785. }
  2786.  
  2787. //check whether current question is pre requisite for any questions. If yes return all those question
  2788. var getAllDependentQuestionsInfo = function (selectedAnswer) {
  2789.  
  2790. var dependentQnInfo = [];
  2791. var currentQnId;
  2792.  
  2793. //Get all hiddent questions for the current answered question
  2794. var currentFocusedHiddenQns = getAllFocusedQuestionsByPreRequisite(selectedAnswer);
  2795.  
  2796.  
  2797. if (currentFocusedHiddenQns != undefined) {
  2798. //get the focused hidden qns
  2799. $.each(currentFocusedHiddenQns, function (index, hiddenQuestion) {
  2800. var hasQuestionsSatisfied = false;
  2801. var hasAnswersSatisfied = false;
  2802. var QnsCount = 0;
  2803. var answerCount = 0;
  2804. var count = 0;
  2805. //Get the pre requisite questions of the hidden qn
  2806. var preReqQns = hiddenQuestion.attr('preReqQn').split(",");
  2807. //get array of all prereq answers and isNot flags in hiddenQuestion
  2808. var preReqAnsWithIsNot = hiddenQuestion.attr('preReqAnswer').split(",");
  2809. var preReqIsNotAns = [];
  2810. var preReqAns = [];
  2811. $.each(preReqAnsWithIsNot, function (index, preReqAnswer) {
  2812. if (preReqAnswer.match("^!")) {
  2813. preReqIsNotAns.push(preReqAnswer.substring(1));
  2814. } else {
  2815. preReqAns.push(preReqAnswer);
  2816. }
  2817. });
  2818. var selectedQns = [];
  2819. var isNotCount = 0;
  2820. var commonUiClinicalInformationSection = selectedAnswer.parents('#commonUiClinicalInformationSectionTest');
  2821. if (commonUiClinicalInformationSection.length <= 0) {
  2822. commonUiClinicalInformationSection = selectedAnswer.parents('#commonUiClinicalInformationSection');
  2823. if (commonUiClinicalInformationSection.length <= 0) {
  2824. commonUiClinicalInformationSection = selectedAnswer.parents('.js-question-table');
  2825. }
  2826. }
  2827. //Get the count of all questions and answer satisified
  2828. commonUiClinicalInformationSection.find("label.active").each(function () {
  2829. //$("#commonUiClinicalInformationSection").find("label.active").each(function () {
  2830.  
  2831. currentQnId = $(this).attr('question');
  2832. //checking for qn count(eliminating duplicates - when multiselect is on)
  2833. if (jQuery.inArray(currentQnId, selectedQns) == -1) {
  2834. selectedQns.push(currentQnId);
  2835. if (jQuery.inArray(currentQnId, preReqQns) >= 0) {
  2836. QnsCount++;
  2837. }
  2838. }
  2839.  
  2840.  
  2841. if (QnsCount > 0) {
  2842. var currentAnswerId = $(this).attr('id');
  2843.  
  2844. if (jQuery.inArray(currentAnswerId, preReqIsNotAns) >= 0) {
  2845. isNotCount++;
  2846. }
  2847. if (jQuery.inArray(currentAnswerId, preReqAns) >= 0) {
  2848. answerCount++;
  2849. }
  2850.  
  2851. }
  2852. });
  2853.  
  2854. //Check whether all the pre req question satisfied
  2855. if (preReqQns.length == QnsCount) {
  2856. hasQuestionsSatisfied = true;
  2857. }
  2858.  
  2859. //check whether answer is satisfied
  2860. if (preReqAns.length == answerCount && isNotCount == 0) {
  2861. //if (answerCount != 0 && isNotCount == 0) {
  2862. hasAnswersSatisfied = true;
  2863. }
  2864.  
  2865.  
  2866.  
  2867. var preReqValue = { hasQuestionsSatisfied: hasQuestionsSatisfied, hasAnswersSatisfied: hasAnswersSatisfied, focusedHiddenQn: hiddenQuestion };
  2868. dependentQnInfo.push(preReqValue);
  2869. });
  2870.  
  2871. }
  2872.  
  2873. return dependentQnInfo;
  2874.  
  2875. };
  2876.  
  2877. //hide the question and clear the error border and the input value
  2878. var hideQuestion = function (currentQn) {
  2879. currentQn.hide();
  2880. currentQn.find(".answerButtonBox").removeClass("active");
  2881. currentQn.find(".answerButtonBox").removeClass(errorCssClass);
  2882. currentQn.find("input").val('');
  2883. currentQn.find(".dssReasonDropdown").val('0');
  2884. currentQn.attr("override-validation", true);
  2885. currentQn.find('input[type="text"].answerText').each(function () { this.type = 'hidden'; this.value = ''; });
  2886. // call again to see whethere there is any dependencies
  2887. var currentAnswerBox = currentQn.find("label.answerButtonBox:first");
  2888. //if undefined, it will be lab
  2889. if (currentAnswerBox == undefined || currentAnswerBox == null)
  2890. currentAnswerBox = currentQn.find("label.labLabelStyle:first");
  2891. hideShowQns(currentAnswerBox);
  2892. var LogicalOprandContainer = currentQn.parent().siblings("td");
  2893. if (LogicalOprandContainer.length > 0) {
  2894. $(LogicalOprandContainer).find(".LogicalOprandDiv").hide();
  2895. }
  2896. }
  2897. //hide show qns based on the answer
  2898. var hideShowQns = function (selectedAnswer) {
  2899. var hideRest = false;
  2900.  
  2901. var dependentQnInfo;
  2902. // check if RegimenMapping as Test harnesss is Active
  2903. var commonUiClinicalInformationSection = selectedAnswer.parents('#commonUiClinicalInformationSectionTest');
  2904. if (commonUiClinicalInformationSection.length <= 0) {
  2905. commonUiClinicalInformationSection = selectedAnswer.parents('#commonUiClinicalInformationSection');
  2906. if (commonUiClinicalInformationSection.length <= 0) {
  2907. commonUiClinicalInformationSection = selectedAnswer.parents('.js-question-table');
  2908. }
  2909. }
  2910. // show or hide the questions if there are any dependent qns
  2911. commonUiClinicalInformationSection.find(".panel-section").each(function () {
  2912. //$("#commonUiClinicalInformationSection").find(".panel-section").each(function () {
  2913.  
  2914. var currentElement = $(this);
  2915.  
  2916. if ($(this).attr('preReq') == 'true') {
  2917.  
  2918. //get the dependent questions details for the selected question. Check it everytime- might be the selection change based on the hide and show
  2919. dependentQnInfo = getAllDependentQuestionsInfo(selectedAnswer);
  2920.  
  2921. $.each(dependentQnInfo, function (index, questionInfo) {
  2922. //if the current element is the focused question
  2923. if (questionInfo != undefined && questionInfo.focusedHiddenQn != undefined && questionInfo.focusedHiddenQn.attr("id") == currentElement.attr("id")) {
  2924. hideRest = false;
  2925. //check qn satisfied for that
  2926. if (questionInfo.hasQuestionsSatisfied) {
  2927. //check for answer satisfied
  2928. if (questionInfo.hasAnswersSatisfied) {
  2929. currentElement.show();
  2930. currentElement.attr("override-validation", false);
  2931. var LogicalOprandContainer = currentElement.parent().siblings("td");
  2932. if (LogicalOprandContainer.length > 0) {
  2933. $(LogicalOprandContainer).find(".LogicalOprandDiv").show();
  2934. }
  2935. return false;
  2936. } else {
  2937. hideQuestion(currentElement);
  2938. return false;
  2939. }
  2940. } else {
  2941. hideQuestion(currentElement);
  2942. return false;
  2943. }
  2944. }
  2945. });
  2946. } else {
  2947. currentElement.show();
  2948. currentElement.attr("override-validation", false);
  2949. var LogicalOprandContainer = currentElement.parent().siblings("td");
  2950. if (LogicalOprandContainer.length > 0) {
  2951. $(LogicalOprandContainer).find(".LogicalOprandDiv").show();
  2952. }
  2953. }
  2954.  
  2955. });
  2956.  
  2957. };
  2958. $("#commonUiClinicalInformationSection").find("label.active").each(function () {
  2959. hideShowQns($(this));
  2960. });
  2961. $("#commonUiClinicalInformationSectionTest").find("label.active").each(function () {
  2962. hideShowQns($(this));
  2963. });
  2964.  
  2965. $("#generalQASelection .js-question-table").find("label.active").each(function () {
  2966. hideShowQns($(this));
  2967. });
  2968.  
  2969. $("#adverseEventsSelection .js-question-table").find("label.active").each(function () {
  2970. hideShowQns($(this));
  2971. });
  2972.  
  2973. $(".LogicalOprand").on("click", function () {
  2974. if ($(this).val() == "And") {
  2975. if ($(this).parents(".LogicalOprandDiv").closest("td").next().find(".section-sub-heading").length > 0) {
  2976. $(this).parents(".LogicalOprandDiv").closest("td").next().find(".section-sub-heading").attr('multiselectable', 'true');
  2977. $(this).parents(".LogicalOprandDiv").closest("td").next().find(".answerButtonBox").each(function () {
  2978. if ($(this).hasClass("active")) {
  2979. $(this).click();
  2980. }
  2981. });
  2982. } else {
  2983. $(this).parents(".LogicalOprandDiv").closest("td").next().find("h3.section-heading").attr('multiselectable', 'true');
  2984. $(this).parents(".LogicalOprandDiv").closest("td").next().find(".answerButtonBox").each(function () {
  2985. if ($(this).hasClass("active")) {
  2986. $(this).click();
  2987. }
  2988. });
  2989. }
  2990.  
  2991. } else if ($(this).val() == "Or") {
  2992. if ($(this).parents(".LogicalOprandDiv").closest("td").next().find(".section-sub-heading").length > 0) {
  2993. $(this).parents(".LogicalOprandDiv").closest("td").next().find(".answerButtonBox").each(function () {
  2994. if ($(this).hasClass("active")) {
  2995. $(this).click();
  2996. }
  2997. });
  2998. } else {
  2999. $(this).parents(".LogicalOprandDiv").closest("td").next().find(".answerButtonBox").each(function () {
  3000. if ($(this).hasClass("active")) {
  3001. $(this).click();
  3002. }
  3003. });
  3004. }
  3005. } else if ($(this).val() == "Any") {
  3006. $(this).parents(".LogicalOprandDiv").closest("td").next().find(".answerButtonBox").removeClass('active');
  3007. if ($(this).parents(".LogicalOprandDiv").closest("td").next().find(".section-sub-heading").length > 0) {
  3008. $(this).parents(".LogicalOprandDiv").closest("td").next().find(".section-sub-heading").attr('multiselectable', 'true');
  3009. } else {
  3010. $(this).parents(".LogicalOprandDiv").closest("td").next().find("h3.section-heading").attr('multiselectable', 'true');
  3011. }
  3012. $(this).prop('checked', false);
  3013. var performanceQuenAnsButtons = $(this).parents(".LogicalOprandDiv").closest("td").next().find(".form-conditional");
  3014. if (performanceQuenAnsButtons.length > 0) {
  3015. $.each(performanceQuenAnsButtons, function () {
  3016. if ($("#" + $(this).data('master')).prop('checked')) {
  3017. $(this).find(".answerButtonBox").click();
  3018. }
  3019. });
  3020. } else {
  3021. $(this).parents(".LogicalOprandDiv").closest("td").next().find(".answerButtonBox").click();
  3022. }
  3023. $(this).prop('checked', true);
  3024. }
  3025. });
  3026.  
  3027. //when select the answer
  3028. $('label.answerButtonBox').unbind('click').click(function (event) {
  3029. var logicalOperandTd = $(this).parents('.panel-section').parent().siblings();
  3030. var isClickable = true;
  3031. var isInteractiveViewActive = false;
  3032. if (logicalOperandTd.length > 0) {
  3033. isInteractiveViewActive = true;
  3034. var questionId = $(this).attr("question");
  3035. if ($("input[name='" + questionId + "']:checked").val() == "Any") {
  3036. isClickable = false;
  3037. }
  3038. }
  3039. if (isClickable) {
  3040. isQADirty = true;
  3041. dirtyTab = "DisplayClinical";
  3042. var ansButton = $(this).parents(".form-conditional").length > 0 ? $(this).parents(".form-conditional") : $(this);
  3043. var multiselect = $(ansButton).parent().siblings("table").find("h3.section-heading").attr('multiselectable');
  3044. var displayType = $(ansButton).parent().siblings("table").find("h3.section-heading").attr('displaytype');
  3045. var chosenValue;
  3046. if (multiselect == undefined)
  3047. multiselect = $(this).parent().siblings("table").find("h3.section-sub-heading[question ='" + $(this).attr('question') + "']").attr('multiselectable');
  3048. //check whether the qn is having mutliselect answer flag
  3049. if ((multiselect != undefined) && (multiselect.toLowerCase() == 'true')) {
  3050. $(this).toggleClass("active");
  3051. } else {
  3052. $(this).addClass('active');
  3053. $(this).siblings(".answerButtonBox").removeClass("active");
  3054. }
  3055.  
  3056. //remove error class when you click
  3057. $(this).siblings(".answerButtonBox").removeClass(errorCssClass);
  3058. $(this).removeClass(errorCssClass);
  3059.  
  3060. //check for hidden input value - answer
  3061. if ($(this).filter(".active").length == 0 && ($(this).siblings(".active").length == 0)) {
  3062. chosenValue = '';
  3063. } else if ($(this).filter(".active").length == 0 && ($(this).siblings(".active").length > 0)) {
  3064.  
  3065. } else {
  3066. chosenValue = $(this).attr('checkBoxItemValue');
  3067. }
  3068.  
  3069. //set the hidden input value
  3070. if (chosenValue != undefined) {
  3071. $(this).siblings("input").not(".answerText").val(chosenValue);
  3072. }
  3073.  
  3074. //check for display type standard with text
  3075. if ((displayType != undefined) && (displayType.toLowerCase() == DisplayTypeStandardWithText.toLowerCase())) {
  3076. var lastAnswer = $(this).parent().find('.answerButtonBox:last')[0];
  3077. if ((multiselect != undefined) && (multiselect.toLowerCase() == 'true')) {
  3078. if ($(this).attr('id') == lastAnswer.id) {
  3079. if ($(this).hasClass('active')) {
  3080. $(this).parent().find('input[type="hidden"].answerText').each(function () { this.type = 'text'; this.value = ''; });
  3081. } else {
  3082. $(this).parent().find('input[type="text"].answerText').each(function () { this.type = 'hidden'; this.value = ''; });
  3083. }
  3084. }
  3085. } else {
  3086. if ($(this).attr('id') == lastAnswer.id) {
  3087. $(this).parent().find('input[type="hidden"].answerText').each(function () { this.type = 'text'; this.value = ''; });
  3088. } else {
  3089. $(this).parent().find('input[type="text"].answerText').each(function () { this.type = 'hidden'; this.value = ''; });
  3090. }
  3091. }
  3092. }
  3093.  
  3094. //clearing karnofsky when change ecog
  3095. if ($(this).attr("name") == "performance_status_ecog") {
  3096. $('[data-master=performance-status-karnofsky]').find("label").removeClass("active");
  3097. $('[data-master=performance-status-karnofsky]').find("label").removeClass(errorCssClass);
  3098. } else if ($(this).attr("name") == "performance_status_karnofsky") {
  3099. selectEcog($(this).attr("checkboxitemvalue"));
  3100. }
  3101.  
  3102. showHideDssDropdown($(this), true);
  3103.  
  3104. hideShowQns($(this));
  3105.  
  3106. if ($('#commonUiTriageClinicalInformationSection').is(':visible')) {
  3107. var allAnswersAnswered = validateQuestionAnswers(true, $(this).parents(".js-question-table").find(".panel-section:visible"));
  3108. if (allAnswersAnswered) {
  3109. openNextAccordionPanel($('#commonUiTriageClinicalInformationSection').find(".js-question-table"));
  3110. $(this).parents(".js-question-table").parent().siblings().find('.all-answered-check').show();
  3111. } else {
  3112. $(this).parents(".js-question-table").parent().siblings().find('.all-answered-check').hide();
  3113. }
  3114.  
  3115. }
  3116.  
  3117. if (REQUEST_TYPE === RequestTypeUmIntake) {
  3118. Cp.IntakeHome.AuthRequest.Instance.CheckAndResetRegimenAndServiceItemSelection();
  3119. if (validateQuestionAnswers(true)) {
  3120. Cp.IntakeHome.AuthRequest.Instance.ShowFindRegimenButton();
  3121. } else {
  3122. Cp.IntakeHome.AuthRequest.Instance.HideFindRegimenButton();
  3123. }
  3124. }
  3125.  
  3126. if (typeof (cp) != "undefined" &&
  3127. typeof (cp.cardiology) != "undefined" &&
  3128. typeof (cp.cardiology.newRequest) != "undefined" &&
  3129. typeof (cp.cardiology.newRequest.serviceGroupQuestionnaireViewModel) != "undefined") {
  3130. cp.cardiology.newRequest.serviceGroupQuestionnaireViewModel.AllQuestionDisplayed(validateQuestionAnswers(true));
  3131. cp.cardiology.newRequest.serviceGroupQuestionnaireViewModel.NotAllRulesManagerQuestionsAnswered(false);
  3132. cp.cardiology.newRequest.serviceGroupQuestionnaireViewModel.HasClinicalInfoSaved(false);
  3133. cp.cardiology.newRequest.serviceGroupItemsViewModel.clear(true);
  3134. }
  3135. if (isInteractiveViewActive)
  3136. showHideTestRegimensQueAns($(this));
  3137. }
  3138. });
  3139.  
  3140. function ShowCurrentQuestion(currentElement) {
  3141. currentElement.show();
  3142. var LogicalOprandContainer = currentElement.parent().siblings("td");
  3143. $("input:radio[name=" + currentElement.attr("id") + "]").each(function () {
  3144. if ($(this).val() == "Or")
  3145. $(this).click();
  3146. });
  3147. $(LogicalOprandContainer).find(".LogicalOprandDiv").show();
  3148. }
  3149.  
  3150. function showHideTestRegimensQueAns(selectedAnswerButton) {
  3151. var commonUiClinicalInformationSection = selectedAnswerButton.parents('#commonUiClinicalInformationSectionTest');
  3152. var dependentQnInfo = getAllDependentQuestionsInfo(selectedAnswerButton);
  3153. var selectedAnswerId = selectedAnswerButton.attr("id");
  3154. var isAllAnswersWithIsNot = true;
  3155. commonUiClinicalInformationSection.find(".panel-section").each(function () {
  3156. var currentElement = $(this);
  3157. if ($(this).attr('preReq') == 'true') {
  3158. //get the dependent questions details for the selected question. Check it everytime- might be the selection change based on the hide and show
  3159. $.each(dependentQnInfo, function (index, questionInfo) {
  3160. //if the current element is the focused question
  3161. if (questionInfo != undefined && questionInfo.focusedHiddenQn != undefined && questionInfo.focusedHiddenQn.attr("id") == currentElement.attr("id")) {
  3162. if (questionInfo.hasQuestionsSatisfied && questionInfo.hasAnswersSatisfied) {
  3163. ShowCurrentQuestion(currentElement);
  3164. } else if (questionInfo.hasQuestionsSatisfied && !questionInfo.hasAnswersSatisfied) {
  3165. var preRequisiteAnswers = currentElement.attr("prereqanswer").split(",");
  3166. var satisfiedAnsCount = 0;
  3167. // If all pre requisite anwsers are with IsNot
  3168. var IsNotAnswerIds = new Array();
  3169. $.each(preRequisiteAnswers, function (index, value) {
  3170. isAllAnswersWithIsNot = true;
  3171. if (value.match("^!") && IsNotAnswerIds.indexOf(value) < 0) {
  3172. value = value.substring(1, value.length);
  3173. answeredPanelSection = $("#" + value).attr("question");
  3174. if ($("#" + answeredPanelSection).attr("class") != "panel-section")
  3175. answeredPanelSection = $("#" + answeredPanelSection).parents(".panel-section");
  3176. $("#" + answeredPanelSection).find(".answerButtonBox").each(function () {
  3177. if ($(this).hasClass("active") && preRequisiteAnswers.indexOf("!" + $(this).attr("id")) < 0) {
  3178. isAllAnswersWithIsNot = false;
  3179. }
  3180. if (preRequisiteAnswers.indexOf("!" + $(this).attr("id")) > -1)
  3181. IsNotAnswerIds.push("!" + $(this).attr("id"));
  3182. });
  3183. if (isAllAnswersWithIsNot)
  3184. satisfiedAnsCount = preRequisiteAnswers.length;
  3185. }
  3186. });
  3187. if (satisfiedAnsCount != preRequisiteAnswers.length) {
  3188. satisfiedAnsCount = 0;
  3189. for (i = 0; i < preRequisiteAnswers.length; i++) {
  3190. if (!preRequisiteAnswers[i].match("^!") && $("#" + preRequisiteAnswers[i]).hasClass("active")) {
  3191. satisfiedAnsCount++;
  3192. } else if (preRequisiteAnswers[i].match("^!")) {
  3193. var preReqNotAnswerId = preRequisiteAnswers[i].substring(1, preRequisiteAnswers[i].length);
  3194. var preReqQn = "";
  3195. var answeredPanelSection = "";
  3196. if ($("#" + preReqNotAnswerId).hasClass("active")) {
  3197. if (selectedAnswerId != preReqNotAnswerId) {
  3198. if ($("#" + selectedAnswerId).hasClass("active"))
  3199. satisfiedAnsCount++;
  3200. else {
  3201. preReqQn = currentElement.attr("prereqqn").split(",");
  3202. if (preReqQn.indexOf($("#" + selectedAnswerId).attr("question")) > -1) {
  3203. answeredPanelSection = $("#" + selectedAnswerId).attr("question");
  3204. if ($("#" + answeredPanelSection).attr("class") != "panel-section")
  3205. answeredPanelSection = $("#" + answeredPanelSection).parents(".panel-section");
  3206. $("#" + answeredPanelSection).find(".answerButtonBox").each(function () {
  3207. if ($(this).hasClass("active") && $(this).attr("id") != selectedAnswerId && $(this).attr("id") != preReqNotAnswerId) {
  3208. satisfiedAnsCount++;
  3209. return false;
  3210. }
  3211. });
  3212. }
  3213. }
  3214. } else if (selectedAnswerId == preReqNotAnswerId) {
  3215. preReqQn = currentElement.attr("prereqqn").split(",");
  3216. if (preReqQn.indexOf($("#" + selectedAnswerId).attr("question")) > -1) {
  3217. answeredPanelSection = $("#" + selectedAnswerId).attr("question");
  3218. if ($("#" + answeredPanelSection).attr("class") != "panel-section")
  3219. answeredPanelSection = $("#" + answeredPanelSection).parents(".panel-section");
  3220. $("#" + answeredPanelSection).find(".answerButtonBox").each(function () {
  3221. if ($(this).hasClass("active") && $(this).attr("id") != selectedAnswerId) {
  3222. satisfiedAnsCount++;
  3223. return false;
  3224. }
  3225. });
  3226. }
  3227. }
  3228. } else {
  3229. satisfiedAnsCount++;
  3230. }
  3231. }
  3232. }
  3233. } else {
  3234. satisfiedAnsCount = 0;
  3235. }
  3236. if (satisfiedAnsCount == preRequisiteAnswers.length) {
  3237. ShowCurrentQuestion(currentElement);
  3238. }
  3239. }
  3240. }
  3241. });
  3242. } else {
  3243. currentElement.show();
  3244. var LogicalOprandContainer = currentElement.parent().siblings("td");
  3245. $(LogicalOprandContainer).find(".LogicalOprandDiv").show();
  3246. }
  3247. });
  3248. }
  3249. });
  3250. }
  3251.  
  3252. function isByPassingRegimenSelection() {
  3253. var success = false;
  3254.  
  3255. try {
  3256. success = Cp.NewRequest.CommonProcessor.Instance.IsDisabledNewRequestField;
  3257. }
  3258. catch (err) {
  3259. return success;
  3260. }
  3261.  
  3262. return success;
  3263. }
  3264.  
  3265. //initialize regimen selection section
  3266. function initializeRegimenSelection(initialData, regimenCheckmarkLocation) {
  3267. $(document).ready(function () {
  3268. var self = this;
  3269. var regimenViewModel = {
  3270. regimenSelectionGrid: ko.mapping.fromJS(initialData),
  3271. selectedRegimen: ko.observable(),
  3272. getRiskText: ko.observable(),
  3273. addUSD: ko.observable(),
  3274. loadRegimen: ko.observable(),
  3275. formatCurrency: ko.observable()
  3276. }
  3277.  
  3278. regimenViewModel.selectRegimen = function(item) {
  3279. regimenViewModel.selectedRegimen(item);
  3280. if (REQUEST_TYPE == "PortalDssRequest") {
  3281. $("#dssSelectedRegimen").show();
  3282. selectedRegimenId = item.Id();
  3283. $(".subpage-selected-regimen").hide();
  3284. $("#page-selection").hide();
  3285. } else {
  3286. $(".subpage-selected-regimen").show();
  3287. var contextRequestTypeUmIntake = REQUEST_TYPE === RequestTypeUmIntake;
  3288. if (contextRequestTypeUmIntake) {
  3289. $("#regimens").html('');
  3290. $("#removeSelectedRegimenButton").hide();
  3291. Cp.IntakeHome.AuthRequest.Instance.ProcessRegimenPeeking();
  3292. }
  3293. loadRegimen(item, regimenViewModel.regimenSelectionGrid.MGFMedications);
  3294. if (contextRequestTypeUmIntake) {
  3295. Cp.Utilities.Instance.ScrollToElement("#regimens");
  3296. }
  3297. }
  3298. }
  3299.  
  3300. function getRiskText(riskFactor) {
  3301. switch (riskFactor) {
  3302. case 725060000:
  3303. return "Unspecified";
  3304. break;
  3305. case 725060001:
  3306. return "Minimal";
  3307. break;
  3308. case 725060002:
  3309. return "Low";
  3310. break;
  3311. case 725060003:
  3312. return "Moderate";
  3313. break;
  3314. case 725060004:
  3315. return "High";
  3316. break;
  3317. case 725060005:
  3318. return "Intermediate";
  3319. }
  3320. return "Not Specified";
  3321. }
  3322.  
  3323. regimenViewModel.getEmetogenicRiskText = function (data) {
  3324. if (data.RiskFactor == undefined)
  3325. return "";
  3326.  
  3327. return getRiskText(data.RiskFactor());
  3328. }
  3329.  
  3330. regimenViewModel.getNeutropenicRiskText = function (data) {
  3331. if (data.RiskFactorNeutropenic == undefined)
  3332. return "";
  3333.  
  3334. return getRiskText(data.RiskFactorNeutropenic());
  3335. }
  3336.  
  3337. function formatCurrency(value) {
  3338. if (value != undefined && value != null)
  3339. return value();
  3340. }
  3341.  
  3342. regimenViewModel.getAverageCostText = function (data) {
  3343. if (data.RegimenCost == undefined)
  3344. return "";
  3345.  
  3346. return formatCurrency(data.RegimenCost.AverageCost);
  3347. }
  3348.  
  3349. regimenViewModel.GetAucScoreText = function (data) {
  3350. if (data.AucScore == undefined)
  3351. return "";
  3352.  
  3353. return data.AucScore();
  3354. }
  3355.  
  3356. regimenViewModel.getMaximumDurationText = function (data) {
  3357. if (data.MaximumDuration == undefined)
  3358. return "";
  3359.  
  3360. return data.MaximumDuration();
  3361. }
  3362.  
  3363. ko.applyBindings(regimenViewModel, document.getElementById('common-ui-regimen-selection'));
  3364. ko.mapping.defaultOptions().ignore = ["__type"];
  3365. var isRequestTypeUmIntake = REQUEST_TYPE === RequestTypeUmIntake;
  3366. var requestType = $("input:hidden[name='RequestType']").attr("value");
  3367. if (isRequestTypeUmIntake) { requestType = RequestTypeUmIntake; }
  3368. var isSimulation = $("input:hidden[name='isSimulation']").attr("value");
  3369. if (isRequestTypeUmIntake) { isSimulation = "false"; }
  3370. selectableRegimenData = initialData;
  3371. // ltrmikeliu the deserialization of the selectable regimens is very slow so move it to upon getting them from the service
  3372. //if (selectableRegimenData.Regimens != null && selectableRegimenData.Regimens.length != 0 && isTestWindow != true ) {
  3373. // saveSelectableRegimenToSession(requestType);
  3374. //}
  3375. //isTestWindow = false;
  3376. var loadRegimen = function (regimenSet, MGFMedications) {
  3377. try {
  3378. //get the OOS Items for given Regimen
  3379. var oosItems = null;
  3380. if (!isTestWindow) {
  3381. oosItems = checkForOOS(regimenSet.Id());
  3382. }
  3383. //hide once we have gotten the regimens
  3384. $(".loading_spinner_regimen").hide();
  3385. // setHasRegimens(jsonPackage.Questions, regimenSet);
  3386.  
  3387. $("#regimens").buildRegimens(regimenSet, regimenSelectCallbackPortal30,
  3388. regimenCheckmarkLocation, true,
  3389. isSimulation, requestType, oosItems, false, MGFMedications);
  3390.  
  3391. //once the call to the pathway regimens completes, get the non-pathway regimens
  3392. // nonPathwayGet();
  3393. } finally {
  3394. resp = null;
  3395. }
  3396. };
  3397. var checkForOOS = function (itemId) {
  3398. if (typeof (contextIsSimulation) !== "undefined" && contextIsSimulation) return true;
  3399. var returnValue = null;
  3400. var currentData = { id: itemId, currentCallOn: "regimen" };
  3401. var url = "/Authorization/NewRequest/CheckOutOfScope";
  3402. if (requestType != undefined && requestType == "CrmRequest") {
  3403. url = "/QandARegimen/QandARegimen/CheckOutOfScope";
  3404. if (currentCrmServiceId == undefined || currentCrmServiceId == '')
  3405. currentCrmServiceId = getQueryString('serviceRequestId');
  3406. //if (currentCrmUserId == undefined || currentCrmUserId == '')
  3407. // currentCrmUserId = getQueryString('userId');
  3408. currentData = { id: itemId, currentCallOn: "regimen", serviceId: currentCrmServiceId };
  3409. }
  3410. var isUmIntake = requestType === RequestTypeUmIntake;
  3411. if (isUmIntake) {
  3412. url = "/IntakeHome/NewRequest/CheckOutOfScope";
  3413. currentData = $.extend({},
  3414. currentData,
  3415. {
  3416. specialtyId: Cp.IntakeHome.Data.Instance.GeneralInfo.GetSpecialtyId(),
  3417. payerId: Cp.IntakeHome.Data.Instance.GeneralInfo.GetPayerId(),
  3418. networkId: Cp.IntakeHome.Data.Instance.FromProviderInfo.GetNetworkId()
  3419. });
  3420. }
  3421. $.ajax(url, {
  3422. type: "GET",
  3423. async: false,
  3424. data: currentData,
  3425. cache: false,
  3426. contentType: 'application/json; charset=utf-8',
  3427. success: function (resp) {
  3428. try {
  3429.  
  3430. returnValue = resp;
  3431.  
  3432. } finally {
  3433. resp = null;
  3434. }
  3435. },
  3436. error: function (jqXHR, textStatus, errorThrown) {
  3437. errorObj = new Object();
  3438. errorObj.xhr = jqXHR;
  3439. errorObj.text = textStatus;
  3440. errorObj.error = errorThrown;
  3441. }
  3442. });
  3443. return returnValue;
  3444. };
  3445. $(".btnDivLayout").show();
  3446.  
  3447. var noRegimenSelection = isByPassingRegimenSelection();
  3448.  
  3449. if (regimenViewModel.regimenSelectionGrid.Regimens() != null && regimenViewModel.regimenSelectionGrid.Regimens().length > 0) {
  3450. var regimenMappingDialog = $(document).find("#regimenMappingDialog");
  3451. var sortTableStr = regimenMappingDialog.length > 0 ? '#questionandRegimenModalWindow table.sortable' : 'table.sortable';
  3452. var oTable = $(sortTableStr).dataTable({
  3453. "bPaginate": false,
  3454. "bLengthChange": false,
  3455. "bFilter": false,
  3456. "bSort": true,
  3457. "bInfo": false,
  3458. "bAutoWidth": false
  3459. });
  3460. // Sort immediately with columns 0 and 1
  3461. oTable.fnSort([[2, 'asc'], [1, 'asc']]);
  3462. oTable.fnSort([[1, 'desc'], [1, 'asc']]);
  3463.  
  3464. $('#page-selection .regimen-selection-table tbody tr').each(function () {
  3465.  
  3466. var firstTd = $(this).find("td:first");
  3467. if (regimenViewModel.regimenSelectionGrid.SelectedRegimen() != null &&
  3468. firstTd.val() == regimenViewModel.regimenSelectionGrid.SelectedRegimen()) {
  3469. $(this).siblings('.selected').removeClass('selected');
  3470. $(this).addClass('selected');
  3471. }
  3472. });
  3473.  
  3474. } else {
  3475. if ((requestType == undefined || requestType == null) && (isSimulation == undefined || isSimulation == null)) {
  3476. isSimulation = 'true';
  3477. }
  3478. if ((requestType != undefined && requestType == "CrmRequest") || (isSimulation == 'true')) {
  3479. var emptyMessageCell = $('#page-selection .regimen-selection-table > tbody > tr > td');
  3480. emptyMessageCell[0].innerHTML = emptyMessageCell[0].innerText.split('.')[0] + ".";
  3481. }
  3482. if ((requestType == undefined || requestType != "CrmRequest") && (isSimulation != 'true')) {
  3483. $("#Ntm").hide();
  3484.  
  3485. if (!noRegimenSelection && REQUEST_TYPE !== RequestTypeUmIntake) //already taken the nextTab
  3486. openNextTab();
  3487. }
  3488.  
  3489. }
  3490.  
  3491. $('#page-selection .regimen-selection-table tbody tr').click(function (event) {
  3492. if (regimenViewModel.regimenSelectionGrid.Regimens() != null && regimenViewModel.regimenSelectionGrid.Regimens().length > 0) {
  3493. var target = $(event.target).closest('tr');
  3494. target.siblings('.selected').removeClass('selected');
  3495. target.siblings('.Peeking').removeClass('Peeking');
  3496. if (REQUEST_TYPE === RequestTypeUmIntake) {
  3497. target.addClass('Peeking');
  3498. } else {
  3499. target.addClass('selected');
  3500. }
  3501. $(".subpage").addClass('active');
  3502. var offset = $('#page-selection').offset();
  3503. var outerHeight = $('#page-selection').outerHeight(true);
  3504. $(".subpage").css({
  3505. minHeight: outerHeight,
  3506. minWidth: $('#page-selection').outerWidth(true),
  3507. backgroundColor: $("body").css("background-color")
  3508. });
  3509. if(REQUEST_TYPE !== RequestTypeUmIntake) {
  3510. $("#dialog.subpage").offset({ top: offset.top, left: offset.left });
  3511. }
  3512. $(".btnDivLayout").hide();
  3513. $("#DisplayPatientValError").html('');
  3514. }
  3515. });
  3516.  
  3517. });
  3518.  
  3519. }
  3520.  
  3521. function DisplaySelectableRegimen(initialData) {
  3522. var displaySelectableRegViewModel = {
  3523. selectableRegimen: ko.mapping.fromJS(initialData)
  3524. };
  3525.  
  3526. displaySelectableRegViewModel.handleSelectRegimenClick = function (item) {
  3527.  
  3528. $("#popRegimenDialog").buildRegimens(item, null, null, true, false, null, null, true, displaySelectableRegViewModel.selectableRegimen.MGFMedications);
  3529.  
  3530. $("#popRegimenDialog").dialog({
  3531. width: 'auto',
  3532. resizable: true,
  3533. modal: true,
  3534. autoOpen: true,
  3535. //width: 1250,
  3536. close: function () {
  3537. $("#popRegimenDialog").empty();
  3538. },
  3539. buttons: {
  3540. "Close": function () {
  3541. $("#popRegimenDialog").dialog("close");
  3542. }
  3543.  
  3544. }
  3545. });
  3546.  
  3547. };
  3548.  
  3549. //KN - need to make reusable
  3550. displaySelectableRegViewModel.getRiskText = function (riskFactor) {
  3551. switch (riskFactor()) {
  3552. case 725060000:
  3553. return "Unspecified";
  3554. break;
  3555. case 725060001:
  3556. return "Minimal";
  3557. break;
  3558. case 725060002:
  3559. return "Low";
  3560. break;
  3561. case 725060003:
  3562. return "Moderate";
  3563. break;
  3564. case 725060004:
  3565. return "High";
  3566. break;
  3567. case 725060005:
  3568. return "Intermediate";
  3569. }
  3570. return "Not Specified";
  3571. };
  3572.  
  3573. displaySelectableRegViewModel.formatCurrencyAverageCost = function (regimenCost) {
  3574. if (regimenCost != null && regimenCost.AverageCost != null)
  3575. return regimenCost.AverageCost;
  3576.  
  3577. return "";
  3578. };
  3579.  
  3580. return displaySelectableRegViewModel;
  3581. }
  3582.  
  3583. function GetObjectValue(objectRecord) {
  3584. if (typeof (objectRecord) == "function") {
  3585. return objectRecord();
  3586. }
  3587.  
  3588. return objectRecord;
  3589. }
  3590.  
  3591. //remove , clear and hide the question answer section
  3592. function removeAndHideQandASection(useAsync) {
  3593.  
  3594. var isSimulatorFlg = $("input:hidden[name='isSimulation']").attr("value");
  3595.  
  3596. var url = "/Authorization/RegimenSelection/DeleteCurrentRegimenConversation";
  3597. $.ajax({
  3598. url: url,
  3599. data: { isSimulator: isSimulatorFlg },
  3600. type: 'POST',
  3601. async: useAsync,
  3602. success: function () {
  3603. try {
  3604.  
  3605. $("#clinicalInformationSection").hide();
  3606. $("#commonUiClinicalInformationSection").html('');
  3607. $("#DisplayPatientValError").html('');
  3608. if ($(document).find("#surgicalInformationSection").length > 0) {
  3609. $("#surgicalInformationSection").hide();
  3610. }
  3611.  
  3612. } finally {
  3613. result = null;
  3614. }
  3615. },
  3616. error: function (xhr, ajaxOptions, thrownError) {
  3617. alert(xhr.status);
  3618. alert(thrownError);
  3619. }
  3620. });
  3621. }
  3622. //Common Ui Scripts---->End
  3623.  
  3624. function initializeTest() {
  3625. reinitializeModal();
  3626. $(document).on("click", "#Next", function () {
  3627. if (validateQuestionAnswers()) {
  3628. $("#DisplayPatientValError").html('');
  3629. getRegimens(getSelectedQuestionAnswers(), "TestRequest");
  3630. $("#commonUiClinicalInformationSection").hide();
  3631. $("#commonUiregimenSelectionSection").show();
  3632. $("#Previous").show();
  3633. $("#Next").hide();
  3634.  
  3635. } else {
  3636. $("#DisplayPatientValError").html('');
  3637. $("#DisplayPatientValError").html("*Please answer all questions before moving to next step.");
  3638. return false;
  3639. }
  3640. });
  3641. $(document).on("click", "#Previous", function () {
  3642. $("#Previous").hide();
  3643. $("#commonUiClinicalInformationSection").show();
  3644. $("#commonUiregimenSelectionSection").hide();
  3645. $("#Next").show();
  3646. });
  3647. }
  3648. function initializeModalWindow(requestType) {
  3649. REQUEST_TYPE = (requestType != undefined && requestType != "") ? requestType : "CrmRequest";
  3650. reinitializeModal();
  3651. $(document).on("click", "#Next", function () {
  3652. if (validateQuestionAnswers() && ValidateSurgicalInformation()) {
  3653. $("#DisplayPatientValError").html('');
  3654. getRegimens(getSelectedQuestionAnswers(), REQUEST_TYPE);
  3655. $("#commonUiClinicalInformationSection").hide();
  3656. $("#commonUiregimenSelectionSection").show();
  3657. $("#Previous").show();
  3658. if (REQUEST_TYPE == "PortalDssRequest") {
  3659. $("#portalDssSave").show();
  3660. $("#surgicalInformationSectionDiv").hide();
  3661. }
  3662. $("#Next").hide();
  3663. $("#portalDssQASave").hide();
  3664.  
  3665. } else {
  3666. $("#DisplayPatientValError").html('');
  3667. $("#DisplayPatientValError").html("*Please answer all questions before moving to next step.");
  3668. return false;
  3669. }
  3670. });
  3671.  
  3672. $(document).on("click", "#portalDssQASave", function () {
  3673. if (validateQuestionAnswers(undefined, undefined, undefined, true)) {
  3674. $("#DisplayPatientValError").html('');
  3675. if ($("#surgicalInformationSectionDiv").html().trim() != '') {
  3676. if (!ValidateSurgicalInformation()) {
  3677. return false;
  3678. } else {
  3679. GetSurgicalInfoModifiedFieldReasonCodes("");
  3680. var dssSelectedQuestionsAndAnswers = getSelectedQuestionAnswers();
  3681. }
  3682. } else {
  3683. var dssSelectedQuestionsAndAnswers = getSelectedQuestionAnswers();
  3684. savePortalDssCoversation(dssSelectedQuestionsAndAnswers);
  3685. }
  3686. } else {
  3687. $("#DisplayPatientValError").html('');
  3688. $("#DisplayPatientValError").html("*Please answer all questions before moving to next step.");
  3689. return false;
  3690. }
  3691. });
  3692.  
  3693.  
  3694. $(document).on("click", "#Previous", function () {
  3695. $("#Previous").hide();
  3696. $("#portalDssSave").hide();
  3697. $("#commonUiClinicalInformationSection").show();
  3698. $("#commonUiregimenSelectionSection").hide();
  3699. $("#Next").show();
  3700. $("#portalDssQASave").show();
  3701. $("#surgicalInformationSectionDiv").show();
  3702. });
  3703. }
  3704.  
  3705. function loadTestWindow(triggerId) {
  3706. reinitializeModal();
  3707. $("#Close").hide();
  3708. $("#displayProcessing").dialog({
  3709. height: 150,
  3710. width: 150,
  3711. resizable: false,
  3712. modal: true,
  3713. autoOpen: true,
  3714. closeOnEscape: false,
  3715. open: function (event, ui) {
  3716. $(".ui-dialog-titlebar-close").hide();
  3717. }
  3718. });
  3719.  
  3720. currentRuleTriggerId = triggerId;
  3721. isTestWindow = true;
  3722. $("#Previous").hide();
  3723. $("#commonUiClinicalInformationSection").show();
  3724. $("#commonUiregimenSelectionSection").hide();
  3725. $("#Next").show();
  3726. loadClinicalInformationQuestions("TestRequest");
  3727. $("#displayProcessing").dialog("destroy");
  3728. $("#questionandRegimenModalWindow").dialog({
  3729. width: 1000,
  3730. height: 800,
  3731. resizable: true,
  3732. modal: true,
  3733. autoOpen: true,
  3734. title: "Test",
  3735. open: function (event, ui) {
  3736. $("#questionandRegimenModalWindow").closest(".ui-dialog").find(".ui-dialog-titlebar-close").show();
  3737. }
  3738. });
  3739. }
  3740.  
  3741. function loadSupplementalTestWindow(triggerId) {
  3742. reinitializeModal();
  3743. $("#Previous").hide();
  3744. $("#Next").hide();
  3745. $("#Close").show();
  3746.  
  3747. $("#questionandRegimenModalWindow").dialog({
  3748. width: 1000,
  3749. height: 800,
  3750. resizable: true,
  3751. modal: true,
  3752. autoOpen: false,
  3753. title: "Test Dss Supplemental",
  3754. open: function (event, ui) {
  3755. $("#questionandRegimenModalWindow").closest(".ui-dialog").find(".ui-dialog-titlebar-close").show();
  3756. }
  3757. });
  3758.  
  3759. $("#questionandRegimenModalWindow").dialog('open');
  3760.  
  3761. $("#Close").click(function () {
  3762. $("#Close").hide();
  3763. $("#questionandRegimenModalWindow").dialog('close');
  3764. });
  3765.  
  3766. currentRuleTriggerId = triggerId;
  3767. isTestWindow = true;
  3768.  
  3769. $("#commonUiClinicalInformationSection").show();
  3770. $("#commonUiregimenSelectionSection").hide();
  3771.  
  3772. loadClinicalInformationQuestions("TestRequest");
  3773. }
  3774.  
  3775. function getQueryStringParams() {
  3776. var queryString = [];
  3777. var hash;
  3778. var currentUrl = decodeURIComponent(document.URL);
  3779. var hashes = currentUrl.slice(currentUrl.indexOf('?') + 1).split('&');
  3780. for (var i = 0; i < hashes.length; i++) {
  3781. hash = hashes[i].split('=');
  3782. queryString.push(hash[0]);
  3783. queryString[hash[0]] = hash[1];
  3784. }
  3785. return queryString;
  3786. }
  3787. function getQueryString(key) {
  3788. var params = getQueryStringParams();
  3789. return params[key];
  3790. }
  3791. function loadClinicalSection(RequestType) {
  3792. REQUEST_TYPE = RequestType;
  3793. reinitializeModal();
  3794. $("#displayProcessing").dialog({
  3795. height: 150,
  3796. width: 150,
  3797. resizable: false,
  3798. modal: true,
  3799. autoOpen: true,
  3800. closeOnEscape: false,
  3801. open: function (event, ui) {
  3802. $(".ui-dialog-titlebar-close").hide();
  3803. }
  3804. });
  3805.  
  3806. $("#Previous").hide();
  3807. $("#commonUiClinicalInformationSection").show();
  3808. $("#commonUiregimenSelectionSection").hide();
  3809.  
  3810. if (RequestType == "CrmRequest") {
  3811. if (currentDeterminationSupportId == undefined || currentDeterminationSupportId == '')
  3812. currentDeterminationSupportId = getQueryString('determinationSupportId');
  3813. if (currentCrmPassedIcdId == undefined || currentCrmPassedIcdId == '') {
  3814. currentCrmPassedIcdId = getQueryString('icdId');
  3815. }
  3816.  
  3817. if (currentDeterminationSupportId != undefined &&
  3818. currentDeterminationSupportId != '') {
  3819. $("#Next").hide();
  3820. $("#dssSave").show();
  3821. $("#dssCancel").show();
  3822. }
  3823. else {
  3824. $("#Next").show();
  3825. $("#dssSave").hide();
  3826. $("#dssCancel").hide();
  3827. }
  3828. } else if (RequestType == "PortalDssRequest") {
  3829. if (currentDeterminationSupportId == undefined || currentDeterminationSupportId == '')
  3830. currentDeterminationSupportId = getQueryString('determinationSupportId');
  3831. if (currentCrmPassedIcdId == undefined || currentCrmPassedIcdId == '') {
  3832. currentCrmPassedIcdId = getQueryString('icdId');
  3833. }
  3834.  
  3835. $("#Next").show();
  3836. $("#portalDssQASave").show();
  3837. $("#dssSave").hide();
  3838. $("#dssCancel").show();
  3839. }
  3840. else {
  3841. $("#Next").show();
  3842. }
  3843.  
  3844. loadClinicalInformationQuestions(RequestType);
  3845.  
  3846. $("#displayProcessing").dialog("destroy");
  3847.  
  3848. if (RequestType == "CrmRequest" && currentDeterminationSupportId != undefined && currentDeterminationSupportId != '') {
  3849.  
  3850. $("#dssSave").click(function () {
  3851.  
  3852. if (currentCrmIsDssSupplemental == undefined || currentCrmIsDssSupplemental == '')
  3853. currentCrmIsDssSupplemental = getQueryString('isDssSupplemental');
  3854.  
  3855. if (currentCrmIsDssSupplemental != 'true') {
  3856. if (validateQuestionAnswers()) {
  3857. $("#DisplayPatientValError").html('');
  3858. getRegimens(getSelectedQuestionAnswers(), "CrmRequest");
  3859. } else {
  3860. $("#DisplayPatientValError").html('');
  3861. $("#DisplayPatientValError").html("*Please answer all questions before saving.");
  3862. return false;
  3863. }
  3864. }
  3865. else {
  3866. getRegimens(getSelectedQuestionAnswers(), "CrmRequest");
  3867. }
  3868. });
  3869.  
  3870. $("#dssCancel").click(function () { window.close(); });
  3871. } else if (RequestType == "PortalDssRequest" && currentDeterminationSupportId != undefined && currentDeterminationSupportId != '') {
  3872. $("#portalDssSave").click(function () {
  3873.  
  3874. if (currentCrmIsDssSupplemental == undefined || currentCrmIsDssSupplemental == '')
  3875. currentCrmIsDssSupplemental = getQueryString('isDssSupplemental');
  3876.  
  3877. if (currentCrmIsDssSupplemental != 'true') {
  3878. if (validateQuestionAnswers()) {
  3879. if ($("#surgicalInformationSectionDiv").html().trim() != '') {
  3880. if (!ValidateSurgicalInformation()) {
  3881. return false;
  3882. } else {
  3883. $("#DisplayPatientValError").html('');
  3884. GetSurgicalInfoModifiedFieldReasonCodes(selectedRegimenId);
  3885. }
  3886. } else {
  3887. $("#DisplayPatientValError").html('');
  3888. savePortalDssCoversationAndSelectedRegimen(getSelectedQuestionAnswers(), selectedRegimenId);
  3889. }
  3890. } else {
  3891. $("#DisplayPatientValError").html('');
  3892. $("#DisplayPatientValError").html("*Please answer all questions before saving.");
  3893. return false;
  3894. }
  3895. }
  3896. // check for supplemental dss
  3897. });
  3898.  
  3899. $("#dssCancel").click(function () { window.close(); });
  3900. }
  3901. }
  3902. function reinitializeModal() {
  3903. $("#DisplayPatientValError").html('');
  3904. $("#commonUiClinicalInformationSection").html('');
  3905. $("#commonUiregimenSelectionSection").html('');
  3906. }
  3907.  
  3908.  
  3909. var requestController;
  3910. //Display clinical javascript
  3911. function ClinicalEventHandler(isEnhancedDiagnosisSelectorFeatureChanged) {
  3912. //var requestController;
  3913. $(document).ready(function () {
  3914. var networkId = $('#networkSelectWrapper').find(':selected').val();
  3915. var diagnosisCode = $('#ServiceRequest_PrimaryDiagnosis_Icd9').attr('value');
  3916. var isSimulation = $("input:hidden[name='isSimulation']").attr("value");
  3917. if (isSimulation == 'true') {
  3918. requestController = "SimulateRequest";
  3919. } else {
  3920. requestController = "NewRequest";
  3921. }
  3922.  
  3923. var isEnhancedDiagnosisSelectorFeatureChangedBool = isEnhancedDiagnosisSelectorFeatureChanged === "True";
  3924. if (isEnhancedDiagnosisSelectorFeatureChangedBool) {
  3925. HandleDiagnosisRemoval(false);
  3926. }
  3927.  
  3928. var hasUseEnhancedDiagnosisSelector = typeof (useEnhancedDiagnosisSelector) != "undefined" && useEnhancedDiagnosisSelector && typeof (enhancedDiagnosisSelectorKoObject) != "undefined" && enhancedDiagnosisSelectorKoObject;
  3929.  
  3930. if (networkId && diagnosisCode && (!hasUseEnhancedDiagnosisSelector || enhancedDiagnosisSelectorKoObject.IsSelectionValidated())) {
  3931. loadClinicalInformationQuestions(requestController);
  3932. $("#clinicalInformationSection").show();
  3933. $("#DisplayPatientValError").html('');
  3934. if ($(document).find("#surgicalInformationSection").length > 0) {
  3935. $("#surgicalInformationSection").show();
  3936. }
  3937. $(".loading_spinner_patient_search").hide();
  3938. }
  3939.  
  3940. if (!hasUseEnhancedDiagnosisSelector) {
  3941. $('#clinicalPageLoadingDiv').hide();
  3942. }
  3943.  
  3944. Cp.NewRequest.CommonProcessor.Instance.PartiallyLockApplicableNewRequestFields();
  3945.  
  3946. });
  3947.  
  3948. //Removing Primary diagnosis
  3949. $(document).ready(function () {
  3950.  
  3951. loadDiagCodeSearchBox();
  3952.  
  3953. // End of validation logic for grey out
  3954.  
  3955. $('#primaryDiagnosisSearchTerm').click(function () {
  3956. if ($("#primaryDiagnosisSearchTerm").val() == "Search by ICD or Diagnosis Code" || $("#primaryDiagnosisSearchTerm").val() == "Secondary Diagnosis") {
  3957. $('#hdnTextVal').val($('#primaryDiagnosisSearchTerm').val());
  3958. $('#primaryDiagnosisSearchTerm').val("");
  3959. }
  3960. $('#primaryDiagnosisSearchTerm').css("color", "#555555");
  3961. });
  3962.  
  3963. $('#primaryDiagnosisSearchTerm').blur(function () {
  3964. if ($('#primaryDiagnosisSearchTerm').val().trim() == "")
  3965. loadDiagCodeSearchBox();
  3966. });
  3967.  
  3968. function loadDiagCodeSearchBox() {
  3969. $('#primaryDiagnosisSearchTerm').val("Search by ICD or Diagnosis Code");
  3970. $('#primaryDiagnosisSearchTerm').css("color", "#999999");
  3971.  
  3972. // Added validation logic for grey out
  3973. if ($("#DiagnosisPrimary").html() != undefined) {
  3974. if ($("#DiagnosisPrimary").is(":visible")) {
  3975. $('#primaryDiagnosisSearchTerm').val("Search by ICD or Diagnosis Code");
  3976. }
  3977. } else {
  3978.  
  3979. if ($("#DiagnosisPrimary").html() != undefined && $("#DiagnosisSecondary").html() != undefined) {
  3980. if ($("#DiagnosisSecondary").is(":visible") && !$("#DiagnosisPrimary").is(":visible")) {
  3981. $('#primaryDiagnosisSearchTerm').val("Search by ICD or Diagnosis Code");
  3982. } else if ($("#DiagnosisPrimary").is(":visible") && $("#DiagnosisSecondary").is(":visible")) {
  3983. $('#primaryDiagnosisSearchTerm').addClass("textBackgroundGrey");
  3984. $('#primaryDiagnosisSearchTerm').attr('readonly', true);
  3985.  
  3986. } else if (!$("#DiagnosisPrimary").is(":visible") && !$("#DiagnosisSecondary").is(":visible")) {
  3987. $('#primaryDiagnosisSearchTerm').val("Search by ICD or Diagnosis Code");
  3988. }
  3989. }
  3990. }
  3991. }
  3992.  
  3993. //Getting Primary diagnosis results
  3994. $('#searchPrimaryDiagnosis_button').click(function () {
  3995. getPrimaryDiagnosisResult();
  3996. }
  3997. );
  3998.  
  3999. $('#searchPrimaryDiagnosis_button').keypress(function (e) {
  4000. $('#hdnTextVal').val("Search by ICD or Diagnosis Code");
  4001. if (e.which == 13) {
  4002. getPrimaryDiagnosisResult();
  4003. }
  4004. });
  4005.  
  4006.  
  4007. function getPrimaryDiagnosisResult() {
  4008. $("#DiagnosisSearch").val($("#primaryDiagnosisSearchTerm").val());
  4009.  
  4010. var searchTerm = $("#primaryDiagnosisSearchTerm").val().trim();
  4011. if ($('#hdnTextVal').val() == "Search by ICD or Diagnosis Code" && searchTerm.length > 0 && (searchTerm != "Search by ICD or Diagnosis Code" && searchTerm != "Secondary Diagnosis")) {
  4012. $(".loading_spinner_primary_diagnosis").show();
  4013. var url = "/Authorization/" + requestController + "/PrimaryDiagnosisSearch";
  4014. $.ajax({
  4015. url: url,
  4016. data: { "searchTerm": searchTerm },
  4017. type: 'POST',
  4018. success: function (result) {
  4019. try {
  4020. $('#primaryDiagnosisSearchResults').html('');
  4021. $('#secondaryDiagnosisSearchResults').html('');
  4022. $('#primaryDiagnosisSearchResults').html(result);
  4023. $(".loading_spinner_primary_diagnosis").hide();
  4024. $('#primaryDiagnosisSearchResults').show();
  4025. } finally {
  4026. result = null;
  4027. }
  4028. },
  4029. error: function (xhr, ajaxOptions, thrownError) {
  4030. alert(xhr.status);
  4031. alert(thrownError);
  4032. }
  4033. });
  4034. }
  4035. //Getting Secondary diagnosis results
  4036. /*
  4037. else {
  4038. if ($('#hdnTextVal').val() == "Secondary Diagnosis" && searchTerm.length > 0 && (searchTerm != "Search by ICD or Diagnosis Code" && searchTerm != "Secondary Diagnosis")) {
  4039. $(".loading_spinner_patient_search").show();
  4040. var url = "/Authorization/" + requestController + "/SecondaryDiagnosisSearch";
  4041. $.ajax({
  4042. url: url,
  4043. data: { "searchTerm": searchTerm },
  4044. type: 'POST',
  4045. success: function (result) {
  4046. try {
  4047. $('#primaryDiagnosisSearchResults').html('');
  4048. $('#secondaryDiagnosisSearchResults').html('');
  4049. $('#secondaryDiagnosisSearchResults').html(result);
  4050. $(".loading_spinner_patient_search").hide();
  4051. $('#secondaryDiagnosisSearchResults').show();
  4052. } finally {
  4053. result = null;
  4054. }
  4055. },
  4056. error: function (xhr, ajaxOptions, thrownError) {
  4057. alert(xhr.status);
  4058. alert(thrownError);
  4059. }
  4060. });
  4061. }
  4062. }
  4063. */
  4064. }
  4065. });
  4066. }
  4067. //End of Display Clinical javascript
  4068.  
  4069. function LoadClinicalQuestions(contextRequestType) {
  4070. loadClinicalInformationQuestions(contextRequestType);
  4071. $("#clinicalInformationSection").show();
  4072. if ($(document).find("#surgicalInformationSection").length > 0) {
  4073. $("#surgicalInformationSection").show();
  4074. }
  4075. HandleDiagnosisSelectionCompletion(contextRequestType);
  4076. }
  4077.  
  4078. function HandleDiagnosisSelectionCompletion(contextRequestType) {
  4079. $("#DisplayPatientValError").html('');
  4080. if (contextRequestType == "NewRequest") {
  4081. $("#saveDraft").show();
  4082. $("#startOverButton").show();
  4083. }
  4084. }
  4085.  
  4086.  
  4087. $(function () {
  4088. $(document).on("click", "#btnSelectPrimary", (function () {
  4089. if ($("#common-ui-regimen-popselection").exists()) {
  4090. $("#common-ui-regimen-popselection").empty();
  4091. }
  4092.  
  4093. if ($('#tblPrimaryResults div.trSelected').attr('id') != undefined) {
  4094. var selectedId = $('#tblPrimaryResults div.trSelected').attr('id');
  4095. if (REQUEST_TYPE != "PortalDssRequest") {
  4096. var searchDiagUrl = "/Authorization/" + requestController + "/PrimaryDiagnosisSelect";
  4097. var isSimulation = $("input:hidden[name='isSimulation']").attr("value");
  4098. if (isSimulation == "true" || checkForOOSDiagnosis(selectedId)) {
  4099. $.ajax({
  4100. cache: false,
  4101. url: searchDiagUrl,
  4102. data: { selectGuid: selectedId },
  4103. success: function (response) {
  4104. try {
  4105. $('#primaryDiagnosisSearchSelection').html('');
  4106. $('#primaryDiagnosisSearchResults').slideUp();
  4107. $("#primaryDiagnosisSearchSelection").html(response);
  4108. $("#NoQnACheck").attr('checked', false);
  4109. $("#ClinicalNoQnASection").hide();
  4110. $("#commonUiClinicalInformationSection").show();
  4111. if($(document).find("#NoQnACheck").length>0 && $(document).find("#NoQnACheck").is(":checked")) {
  4112. $(document).find("#NoQnACheck").click();
  4113. }
  4114. LoadClinicalQuestions(requestController);
  4115. $("#primaryDiagnosisSearchSelection").show();
  4116. if ($("#DiagnosisSecondary").html() != undefined) {
  4117. if ($("#DiagnosisSecondary").is(":visible")) {
  4118. $('#primaryDiagnosisSearchTerm').addClass("textBackgroundGrey");
  4119. $('#primaryDiagnosisSearchTerm').attr('readonly', true);
  4120. }
  4121. }
  4122. } finally {
  4123. response = null;
  4124. }
  4125. },
  4126. error: function (xhr, ajaxOptions, thrownError) {
  4127. alert(xhr.status);
  4128. alert(thrownError);
  4129. }
  4130. });
  4131. }
  4132. } else {
  4133. var selectedDiagnosisName = $('#tblPrimaryResults div.trSelected').text().trim();
  4134. oldSelectedDiagnosisName = $("#selectedDiagnosis").text().trim();
  4135. dssSelectedDiagnosisName = selectedDiagnosisName;
  4136. $("#selectedDiagnosis").text(selectedDiagnosisName);
  4137. $("#hdnICDIdGuid").val(selectedId);
  4138. $('#primaryDiagnosisSearchSelection').html('');
  4139. $('#primaryDiagnosisSearchResults').slideUp();
  4140. $("#primaryDiagnosisSearchSelection").show();
  4141. }
  4142. $('#primaryDiagnosisSearchTerm').css("color", "#999999");
  4143. $('#primaryDiagnosisSearchTerm').val("Search by ICD or Diagnosis Code");
  4144. }
  4145. }));
  4146.  
  4147. //Applied Raka table styles to Primary diagnosis results
  4148. $(document).on("click", ".primarySearchResultTr", (function () {
  4149. $("#tblPrimaryResults div").removeClass("trSelected");
  4150. rakaStyleForTables();
  4151. var selected = $(this).index();
  4152. $(this).removeClass("tblOddRow");
  4153. $(this).removeClass("tblEvenRow");
  4154. $(this).addClass("trSelected");
  4155. }));
  4156.  
  4157. //Applied Raka table styles to Secondary diagnosis results
  4158. $(document).on("click", ".secondarySearchResultTr", (function () {
  4159. $("#tblSecondaryResults div").removeClass("trSelected");
  4160. rakaStyleForTables();
  4161. var selected = $(this).index();
  4162. $(this).removeClass("tblOddRow");
  4163. $(this).removeClass("tblEvenRow");
  4164. $(this).addClass("trSelected");
  4165. }));
  4166.  
  4167. $(document).on("click", "#btnSelectSecondary", (function () {
  4168. if ($('#tblSecondaryResults div.trSelected').attr('id') != undefined) {
  4169. var selectedId = $('#tblSecondaryResults div.trSelected').attr('id');
  4170. var searchDiagUrl = "/Authorization/" + requestController + "/SecondaryDiagnosisSelect";
  4171. $.ajax({
  4172. cache: false,
  4173. url: searchDiagUrl,
  4174. data: { selectGuid: selectedId },
  4175. success: function (response) {
  4176. try {
  4177. $("#secondaryDiagnosisSearchSelection").html('');
  4178. $('#secondaryDiagnosisSearchResults').slideUp();
  4179. $("#secondaryDiagnosisSearchSelection").html(response);
  4180. $("#secondaryDiagnosisSearchSelection").show();
  4181. $('#primaryDiagnosisSearchTerm').addClass("textBackgroundGrey");
  4182. $('#primaryDiagnosisSearchTerm').attr('readonly', true);
  4183.  
  4184. } finally {
  4185. response = null;
  4186. }
  4187. $('#primaryDiagnosisSearchTerm').val("");
  4188. },
  4189. error: function (xhr, ajaxOptions, thrownError) {
  4190. alert(xhr.status);
  4191. alert(thrownError);
  4192. }
  4193. });
  4194. }
  4195. }));
  4196.  
  4197. //Cancelling Primary diagnosis results
  4198. $(document).on("click", "#btnCancelPrimary", (function () {
  4199. $("#primaryDiagnosisSearchResults").hide();
  4200. $('#primaryDiagnosisSearchTerm').css("color", "#999999");
  4201. $('#primaryDiagnosisSearchTerm').val("Search by ICD or Diagnosis Code");
  4202. }));
  4203.  
  4204. //Cancelling Secondary diagnosis results
  4205. $(document).on("click", "#btnCancelSecondary", (function () {
  4206. $("#secondaryDiagnosisSearchResults").hide();
  4207. }));
  4208.  
  4209. $(document).on('click', '.removePrimaryIcd', function () {
  4210. $("#DiagnosisPrimary").html('');
  4211. $('#primaryDiagnosisSearchTerm').val("");
  4212. $('#primaryDiagnosisSearchTerm').val("Search by ICD or Diagnosis Code");
  4213. $("#primaryDiagnosisSearchSelection").hide();
  4214. $('#primaryDiagnosisSearchTerm').removeClass("textBackgroundGrey");
  4215. $('#primaryDiagnosisSearchTerm').attr('readonly', false);
  4216. $('#primaryDiagnosisSearchTerm').css("color", "#999999");
  4217. $("#saveDraft").hide();
  4218. $("#startOverButton").hide();
  4219. $('#secondaryDiagnosisSearchResults').hide();
  4220. HandleDiagnosisRemoval(true);
  4221. });
  4222.  
  4223. //Removing Secondary diagnosis
  4224. $(document).on('click', '.secondaryremove', function () {
  4225. clearSecondaryDiagnosis();
  4226. if ($('#primaryDiagnosisSearchTerm').val() != "Search by ICD or Diagnosis Code") {
  4227. $('#primaryDiagnosisSearchTerm').val("");
  4228. $('#primaryDiagnosisSearchTerm').val("Search by ICD or Diagnosis Code");
  4229. }
  4230. $('#primaryDiagnosisSearchTerm').css("color", "#999999");
  4231. $('#primaryDiagnosisSearchTerm').removeClass("textBackgroundGrey");
  4232. $('#primaryDiagnosisSearchTerm').attr('readonly', false);
  4233. $("#secondaryDiagnosisSearchSelection").hide();
  4234. });
  4235.  
  4236. function clearSecondaryDiagnosis() {
  4237. $("#secondaryDiagnosisSearchSelection").load("/NewRequest/SecondaryDiagnosisRemove");
  4238. }
  4239.  
  4240. function rakaStyleForTables() {
  4241. $("div#tblPrimaryResults div:even").addClass("tblOddRow");
  4242. $("div#tblPrimaryResults div:odd").addClass("tblEvenRow");
  4243. }
  4244. });
  4245.  
  4246. //On-Removal of content inside tab disable successor tabs link
  4247. function disableSuccessorNavLnk() {
  4248. //$("#portalNavigation li.active a").attr('href')
  4249. var activeIndex = $("#portalNavigation li.active").index();
  4250. $('#portalNavigation a').each(function (e) {
  4251. if (e > activeIndex) {
  4252. $(this).data('href', $(this).attr('href'));
  4253. $(this).removeAttr('href');
  4254. }
  4255. });
  4256. }
  4257.  
  4258. //Clear service items
  4259. function clearServiceItems() {
  4260. $('#requestedItemsContainer').html('');
  4261. $('#requestedItemsContainer').load('/Authorization/NewRequestHelper/RegimenSelect',
  4262. {
  4263. ModelType: GetClinicalInformationJsContextRegimenAssemblyQualifiedName()
  4264. });
  4265. }
  4266.  
  4267. function HandleDiagnosisRemoval(useAsync) {
  4268. //Clear Service Items
  4269. if ($("[name$='].ServiceItem.Id']").length > 0) {
  4270. clearServiceItems();
  4271. }
  4272. //To restrict the top navigation
  4273. disableSuccessorNavLnk();
  4274. //remove clinical section and delete the regimen conversation from session
  4275. if ($("#commonUiClinicalInformationSection").html().length != 0) {
  4276. removeAndHideQandASection(useAsync);
  4277. }
  4278. }
  4279.  
  4280. function checkForOOSDiagnosis(itemId) {
  4281. var isRequestTypeUmIntake = REQUEST_TYPE === RequestTypeUmIntake;
  4282. var returnValue = true;
  4283. if (typeof (contextIsSimulation) !== "undefined" && contextIsSimulation) return true;
  4284. var currentData = isRequestTypeUmIntake
  4285. ? {
  4286. id: itemId,
  4287. currentCallOn: "diagnosis",
  4288. specialtyId: Cp.IntakeHome.Data.Instance.GeneralInfo.GetSpecialtyId(),
  4289. payerId: Cp.IntakeHome.Data.Instance.GeneralInfo.GetPayerId(),
  4290. networkId: Cp.IntakeHome.Data.Instance.FromProviderInfo.GetNetworkId()
  4291. }
  4292. : { id: itemId, currentCallOn: "diagnosis" };
  4293. var url = isRequestTypeUmIntake ? "/IntakeHome/NewRequest/CheckOutOfScope" : "/Authorization/NewRequest/CheckOutOfScope";
  4294. $.ajax(url, {
  4295. type: "GET",
  4296. async: false,
  4297. data: currentData,
  4298. cache: false,
  4299. success: function (resp) {
  4300. try {
  4301. var outOfScopeItems = (resp != undefined && resp != null && resp != '') && (resp.OutOfSupportedScopeItems != null) ? resp.OutOfSupportedScopeItems : null;
  4302. var isOos = false;
  4303. var outOfScopeAction = (resp != undefined && resp != null && resp != '' && resp.OutOfSupportedScopeActionInfo != null) ? resp.OutOfSupportedScopeActionInfo : null;
  4304. if (outOfScopeItems != undefined && outOfScopeItems != null) {
  4305. $.each(outOfScopeItems, function (index, outOfScopeItem) {
  4306. if (outOfScopeItem.ScopeItemId == itemId)
  4307. isOos = true;
  4308. });
  4309. }
  4310. //NoMessageDecompNoMedsSplitForward = 725060000,
  4311. //NoMessageAllowDecompMedsSplitForwardOutOfScope = 725060001,
  4312. //ShowMessageStopDecomp = 725060002,
  4313. if ((isOos) && ((outOfScopeAction != undefined && outOfScopeAction != null) && (outOfScopeAction.OutOfSupportedScopeActionType != "725060000") && (outOfScopeAction.OutOfSupportedScopeActionType != "725060001"))) {
  4314.  
  4315. alert(outOfScopeAction.OutOfSupportedScopeMessage);
  4316. }
  4317. if ((outOfScopeAction != undefined && outOfScopeAction != null) && outOfScopeAction.OutOfSupportedScopeActionType == "725060002") {
  4318. returnValue = false;
  4319. }
  4320.  
  4321. } finally {
  4322. resp = null;
  4323. }
  4324. },
  4325. error: function (jqXHR, textStatus, errorThrown) {
  4326. errorObj = new Object();
  4327. errorObj.xhr = jqXHR;
  4328. errorObj.text = textStatus;
  4329. errorObj.error = errorThrown;
  4330. },
  4331. contentType: 'application/json; charset=utf-8'
  4332. });
  4333. return returnValue;
  4334. }
  4335.  
  4336. function getIsDirtyFlag() {
  4337. return isQADirty;
  4338. }
  4339.  
  4340. function setIsDirtyFlag(p_isQADirty) {
  4341. isQADirty = p_isQADirty;
  4342. }
  4343.  
  4344. function LoadSurgicalInformationSection(requestType) {
  4345. var urlPath;
  4346. if (requestType == "NewRequest") {
  4347. urlPath = "/Authorization/NewRequest/LoadSurgicalInformationSection";
  4348. $.ajax({
  4349. type: 'GET',
  4350. cache: false,
  4351. async: false,
  4352. url: urlPath,
  4353. dataType: 'html',
  4354. success: function (surgicalInfoHtml) {
  4355. $("#surgicalInformationSectionDiv").html('');
  4356. $("#surgicalInformationSectionDiv").html(surgicalInfoHtml);
  4357. },
  4358. error: function (xhr, thrownError) {
  4359. alert(xhr.status);
  4360. alert(thrownError);
  4361. }
  4362. });
  4363. } else if (requestType == "PortalDssRequest") {
  4364. urlPath = "/Determination/Request/LoadSurgicalInformationSection";
  4365. $.ajax({
  4366. type: 'POST',
  4367. cache: false,
  4368. async: false,
  4369. url: urlPath,
  4370. contentType: "application/json; charset=utf-8",
  4371. data: JSON.stringify({ "authorizationRequestIdString": window.opener.$("#hdnAuthGuid").val() }),
  4372. dataType: 'html',
  4373. success: function (surgicalInfoHtml) {
  4374. $("#surgicalInformationSectionDiv").html('');
  4375. $("#surgicalInformationSectionDiv").html(surgicalInfoHtml);
  4376. },
  4377. error: function (xhr, thrownError) {
  4378. alert(xhr.status);
  4379. alert(thrownError);
  4380. }
  4381. });
  4382. } else if (requestType == RequestTypeUmIntake) {
  4383. urlPath = "/IntakeHome/AuthRequest/LoadSurgicalInformationSection";
  4384. $.ajax({
  4385. type: 'POST',
  4386. cache: false,
  4387. async: false,
  4388. url: urlPath,
  4389. contentType: "application/json; charset=utf-8",
  4390. dataType: 'html',
  4391. data: JSON.stringify({ "specialtyId": $("#GeneralInfoDataModel_SelectedSpecialtyId").val() }),
  4392. success: function (surgicalInfoHtml) {
  4393. $("#surgicalInfoContainer").empty();
  4394. $("#surgicalInfoContainer").html(surgicalInfoHtml);
  4395. },
  4396. error: function (xhr, thrownError) {
  4397. alert(xhr.status);
  4398. alert(thrownError);
  4399. }
  4400. });
  4401. }
  4402. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement