Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.96 KB | None | 0 0
  1.  
  2. function postReqMedReview()
  3. {
  4. global $current_user;
  5.  
  6. // Define variables for every $_POST variable to avoid undefined indexes
  7.  
  8. if (!empty($_POST['DateOfBirth'])) {
  9. $DateOfBirth = $_POST['DateOfBirth'];
  10. $jsonData['BirthYear'] = $DateOfBirth;
  11. }
  12.  
  13. if (!empty($_POST['FirstDayOfLastMenses'])) {
  14. $FirstDayOfLastMenses = $_POST['FirstDayOfLastMenses'];
  15. $jsonData['FirstDayOfLastMenses'] = $FirstDayOfLastMenses;
  16. }
  17.  
  18. if (!empty($_POST['DateGaveBirth'])) {
  19. $DateGaveBirth = $_POST['DateGaveBirth'];
  20. $jsonData['DateGaveBirth'] = $DateGaveBirth;
  21. }
  22.  
  23. if ( isset($_POST['IfCigarettesExceed15Daily']) ) {
  24. $jsonData['IfCigarettesExceed15Daily'] = $_POST['IfCigarettesExceed15Daily'];
  25. }
  26.  
  27. if (isset($_POST['IfUsed_Which'])) {
  28. switch ($_POST['IfUsed_Which']) {
  29. case "Pills":
  30. $IfUsed_Pills = true;
  31. $IfUsed_Patch = false;
  32. $IfUsed_Ring = false;
  33. $IfUsed_Injection = false;
  34. $IfUsed_IUD = false;
  35. $IfUsed_Implant = false;
  36. break;
  37. case "Patch":
  38. $IfUsed_Pills = false;
  39. $IfUsed_Patch = true;
  40. $IfUsed_Ring = false;
  41. $IfUsed_Injection = false;
  42. $IfUsed_IUD = false;
  43. $IfUsed_Implant = false;
  44. break;
  45. case "Ring":
  46. $IfUsed_Pills = false;
  47. $IfUsed_Patch = false;
  48. $IfUsed_Ring = true;
  49. $IfUsed_Injection = false;
  50. $IfUsed_IUD = false;
  51. $IfUsed_Implant = false;
  52. break;
  53. case "Injection":
  54. $IfUsed_Pills = false;
  55. $IfUsed_Patch = false;
  56. $IfUsed_Ring = false;
  57. $IfUsed_Injection = true;
  58. $IfUsed_IUD = false;
  59. $IfUsed_Implant = false;
  60. break;
  61. case "IUD":
  62. $IfUsed_Pills = false;
  63. $IfUsed_Patch = false;
  64. $IfUsed_Ring = false;
  65. $IfUsed_Injection = false;
  66. $IfUsed_IUD = true;
  67. $IfUsed_Implant = false;
  68. break;
  69. case "Implant":
  70. $IfUsed_Pills = false;
  71. $IfUsed_Patch = false;
  72. $IfUsed_Ring = false;
  73. $IfUsed_Injection = false;
  74. $IfUsed_IUD = false;
  75. $IfUsed_Implant = true;
  76. break;
  77. case "Other":
  78. $IfUsed_Pills = false;
  79. $IfUsed_Patch = false;
  80. $IfUsed_Ring = false;
  81. $IfUsed_Injection = false;
  82. $IfUsed_IUD = false;
  83. $IfUsed_Implant = false;
  84. if (isset($_POST['IfUsed_OtherText'])) {
  85. $IfUsed_OtherText = $_POST['IfUsed_OtherText'];
  86. $jsonData['IfUsed_OtherText'] = $IfUsed_OtherText;
  87. }
  88. }
  89.  
  90. $jsonData['IfUsed_Pills'] = $IfUsed_Pills;
  91. $jsonData['IfUsed_Patch'] = $IfUsed_Patch;
  92. $jsonData['IfUsed_Ring'] = $IfUsed_Ring;
  93. $jsonData['IfUsed_Injection'] = $IfUsed_Injection;
  94. $jsonData['IfUsed_IUD'] = $IfUsed_IUD;
  95. $jsonData['IfUsed_Implant'] = $IfUsed_Implant;
  96. }
  97.  
  98. if (isset($_POST['IfCurrent_Which'])) {
  99. switch ($_POST['IfCurrent_Which']) {
  100. case "Pills":
  101. $IfCurrent_Pills = true;
  102. $IfCurrent_Patch = false;
  103. $IfCurrent_Ring = false;
  104. $IfCurrent_Injection = false;
  105. $IfCurrent_IUD = false;
  106. $IfCurrent_Implant = false;
  107. break;
  108. case "Patch":
  109. $IfCurrent_Pills = false;
  110. $IfCurrent_Patch = true;
  111. $IfCurrent_Ring = false;
  112. $IfCurrent_Injection = false;
  113. $IfCurrent_IUD = false;
  114. $IfCurrent_Implant = false;
  115. break;
  116. case "Ring":
  117. $IfCurrent_Pills = false;
  118. $IfCurrent_Patch = false;
  119. $IfCurrent_Ring = true;
  120. $IfCurrent_Injection = false;
  121. $IfCurrent_IUD = false;
  122. $IfCurrent_Implant = false;
  123. break;
  124. case "Injection":
  125. $IfCurrent_Pills = false;
  126. $IfCurrent_Patch = false;
  127. $IfCurrent_Ring = false;
  128. $IfCurrent_Injection = true;
  129. $IfCurrent_IUD = false;
  130. $IfCurrent_Implant = false;
  131. break;
  132. case "IUD":
  133. $IfCurrent_Pills = false;
  134. $IfCurrent_Patch = false;
  135. $IfCurrent_Ring = false;
  136. $IfCurrent_Injection = false;
  137. $IfCurrent_IUD = true;
  138. $IfCurrent_Implant = false;
  139. break;
  140. case "Implant":
  141. $IfCurrent_Pills = false;
  142. $IfCurrent_Patch = false;
  143. $IfCurrent_Ring = false;
  144. $IfCurrent_Injection = false;
  145. $IfCurrent_IUD = false;
  146. $IfCurrent_Implant = true;
  147. break;
  148. case "Other":
  149. $IfCurrent_Pills = false;
  150. $IfCurrent_Patch = false;
  151. $IfCurrent_Ring = false;
  152. $IfCurrent_Injection = false;
  153. $IfCurrent_IUD = false;
  154. $IfCurrent_Implant = false;
  155. if (isset($_POST['IfCurrent_OtherText'])) {
  156. $IfCurrent_OtherText = $_POST['IfCurrent_OtherText'];
  157. $jsonData['IfCurrent_OtherText'] = $IfCurrent_OtherText;
  158. }
  159. }
  160. $jsonData['IfCurrent_Pills'] = $IfCurrent_Pills;
  161. $jsonData['IfCurrent_Patch'] = $IfCurrent_Patch;
  162. $jsonData['IfCurrent_Ring'] = $IfCurrent_Ring;
  163. $jsonData['IfCurrent_Injection'] = $IfCurrent_Injection;
  164. $jsonData['IfCurrent_IUD'] = $IfCurrent_IUD;
  165. $jsonData['IfCurrent_Implant'] = $IfCurrent_Implant;
  166. }
  167.  
  168. if (isset($_POST['IfDiabetesWhich'])) {
  169. switch ($_POST['IfDiabetesWhich']) {
  170. case "nephropathy":
  171. $IfDiabetes_Nephropathy = true;
  172. $IfDiabetes_Retinopathy = false;
  173. $IfDiabetes_Neuropathy = false;
  174. $IfDiabetes_Over20Years = false;
  175. $IfDiabetes_OtherVascularDisease = false;
  176. break;
  177. case "retinopathy":
  178. $IfDiabetes_Nephropathy = false;
  179. $IfDiabetes_Retinopathy = true;
  180. $IfDiabetes_Neuropathy = false;
  181. $IfDiabetes_Over20Years = false;
  182. $IfDiabetes_OtherVascularDisease = false;
  183. break;
  184. case "neuropathy":
  185. $IfDiabetes_Nephropathy = false;
  186. $IfDiabetes_Retinopathy = false;
  187. $IfDiabetes_Neuropathy = true;
  188. $IfDiabetes_Over20Years = false;
  189. $IfDiabetes_OtherVascularDisease = false;
  190. break;
  191. case "longerthan20years":
  192. $IfDiabetes_Nephropathy = false;
  193. $IfDiabetes_Retinopathy = false;
  194. $IfDiabetes_Neuropathy = false;
  195. $IfDiabetes_Over20Years = true;
  196. $IfDiabetes_OtherVascularDisease = false;
  197. break;
  198. case "vasculardisease":
  199. $IfDiabetes_Nephropathy = false;
  200. $IfDiabetes_Retinopathy = false;
  201. $IfDiabetes_Neuropathy = false;
  202. $IfDiabetes_Over20Years = false;
  203. $IfDiabetes_OtherVascularDisease = true;
  204. break;
  205. case "none":
  206. $IfDiabetes_Nephropathy = false;
  207. $IfDiabetes_Retinopathy = false;
  208. $IfDiabetes_Neuropathy = false;
  209. $IfDiabetes_Over20Years = false;
  210. $IfDiabetes_OtherVascularDisease = false;
  211. break;
  212. }
  213. $jsonData['IfDiabetes_Nephropathy'] = $IfDiabetes_Nephropathy;
  214. $jsonData['IfDiabetes_Retinopathy'] = $IfDiabetes_Retinopathy;
  215. $jsonData['IfDiabetes_Neuropathy'] = $IfDiabetes_Neuropathy;
  216. $jsonData['IfDiabetes_Over20Years'] = $IfDiabetes_Over20Years;
  217. $jsonData['IfDiabetes_OtherVascularDisease'] = $IfDiabetes_OtherVascularDisease;
  218. }
  219.  
  220. if (isset($_POST['IfAnyMed'])) {
  221. switch ($_POST['IfAnyMed']) {
  222. case "Fosamprenavir":
  223. $IfAnyMed_Fosamprenavir = true;
  224. $IfAnyMed_Lamotrigine = false;
  225. $IfAnyMed_RifampinOrRifabutin = false;
  226. $IfAnyMed_CertainAnticonvulsants = false;
  227. break;
  228. case "Lamotrigine":
  229. $IfAnyMed_Fosamprenavir = false;
  230. $IfAnyMed_Lamotrigine = true;
  231. $IfAnyMed_RifampinOrRifabutin = false;
  232. $IfAnyMed_CertainAnticonvulsants = false;
  233. break;
  234. case "RifampinRifabutin":
  235. $IfAnyMed_Fosamprenavir = false;
  236. $IfAnyMed_Lamotrigine = false;
  237. $IfAnyMed_RifampinOrRifabutin = true;
  238. $IfAnyMed_CertainAnticonvulsants = false;
  239. break;
  240. case "CertainAnticonvulsants":
  241. $IfAnyMed_Fosamprenavir = false;
  242. $IfAnyMed_Lamotrigine = false;
  243. $IfAnyMed_RifampinOrRifabutin = false;
  244. $IfAnyMed_CertainAnticonvulsants = true;
  245. break;
  246. }
  247. $jsonData['IfAnyMed_Fosamprenavir'] = $IfAnyMed_Fosamprenavir;
  248. $jsonData['IfAnyMed_Lamotrigine'] = $IfAnyMed_Lamotrigine;
  249. $jsonData['IfAnyMed_RifampinOrRifabutin'] = $IfAnyMed_RifampinOrRifabutin;
  250. $jsonData['IfAnyMed_CertainAnticonvulsants'] = $IfAnyMed_CertainAnticonvulsants;
  251. }
  252.  
  253. if (!empty($_POST['Height_Ft'])) {
  254. $Height_Ft = $_POST['Height_Ft'];
  255. $jsonData['Height_Ft'] = $Height_Ft;
  256. }
  257.  
  258. if (!empty($_POST['Height_In'])) {
  259. $Height_In = $_POST['Height_In'];
  260. $jsonData['Height_In'] = $Height_In;
  261. }
  262.  
  263. if (!empty($_POST['Weight_Lb'])) {
  264. $Weight_Lb = $_POST['Weight_Lb'];
  265. $jsonData['Weight_Lb'] = $Weight_Lb;
  266. }
  267.  
  268. if (isset($_POST['IfAllergiesToMedicines'])) {
  269. $IfAllergiesToMedicines = $_POST['IfAllergiesToMedicines'];
  270. $jsonData['IfAllergiesToMedicines'] = $IfAllergiesToMedicines;
  271. }
  272.  
  273. if (!empty($_POST['AllergicToMedicinesList'])) {
  274. $AllergicToMedicinesList = $_POST['AllergicToMedicinesList'];
  275. $jsonData['AllergicToMedicinesList'] = $AllergicToMedicinesList;
  276. }
  277.  
  278. if (!empty($_POST['AgeFirstMenses'])) {
  279. $AgeFirstMenses = $_POST['AgeFirstMenses'];
  280. $jsonData['AgeFirstMenses'] = $AgeFirstMenses;
  281. }
  282.  
  283. if (isset($_POST['IfRegularMenses'])) {
  284. $IfRegularMenses = $_POST['IfRegularMenses'];
  285. $jsonData['IfRegularMenses'] = $IfRegularMenses;
  286. }
  287.  
  288. if (isset($_POST['FK_MensesDuration'])) {
  289. $FK_MensesDuration = $_POST['FK_MensesDuration'];
  290. $jsonData['FK_MensesDuration'] = $FK_MensesDuration;
  291. }
  292.  
  293. if (isset($_POST['IfCigarettes'])) {
  294. $IfCigarettes = $_POST['IfCigarettes'];
  295. $jsonData['IfCigarettes'] = $IfCigarettes;
  296. }
  297.  
  298. if (isset($_POST['IfHighBloodPressure'])) {
  299. $IfHighBloodPressure = $_POST['IfHighBloodPressure'];
  300. $jsonData['IfHighBloodPressure'] = $IfHighBloodPressure;
  301. }
  302.  
  303. if (!empty($_POST['SystolicBloodPressure'])) {
  304. $SystolicBloodPressure = $_POST['SystolicBloodPressure'];
  305. $jsonData['SystolicBloodPressure'] = $SystolicBloodPressure;
  306. }
  307.  
  308. if (!empty($_POST['DiastolicBloodPressure'])) {
  309. $DiastolicBloodPressure = $_POST['DiastolicBloodPressure'];
  310. $jsonData['DiastolicBloodPressure'] = $DiastolicBloodPressure;
  311. }
  312.  
  313. if (isset($_POST['IfPastWeek_ExtremeThirst'])) {
  314. $IfPastWeek_ExtremeThirst = $_POST['IfPastWeek_ExtremeThirst'];
  315. $jsonData['IfPastWeek_ExtremeThirst'] = $IfPastWeek_ExtremeThirst;
  316. }
  317.  
  318. if (isset($_POST['IfPastWeek_ExcessiveUrination'])) {
  319. $IfPastWeek_ExcessiveUrination = $_POST['IfPastWeek_ExcessiveUrination'];
  320. $jsonData['IfPastWeek_ExcessiveUrination'] = $IfPastWeek_ExcessiveUrination;
  321. }
  322.  
  323. if (isset($_POST['IfPastWeek_AlarmingChestPain'])) {
  324. $IfPastWeek_AlarmingChestPain = $_POST['IfPastWeek_AlarmingChestPain'];
  325. $jsonData['IfPastWeek_AlarmingChestPain'] = $IfPastWeek_AlarmingChestPain;
  326. }
  327.  
  328. if (isset($_POST['IfPastWeek_YellowingOfSkinOrEyes'])) {
  329. $IfPastWeek_YellowingOfSkinOrEyes = $_POST['IfPastWeek_YellowingOfSkinOrEyes'];
  330. $jsonData['IfPastWeek_YellowingOfSkinOrEyes'] = $IfPastWeek_YellowingOfSkinOrEyes;
  331. }
  332.  
  333. if (isset($_POST['IfPastWeek_RapidVisualChanges'])) {
  334. $IfPastWeek_RapidVisualChanges = $_POST['IfPastWeek_RapidVisualChanges'];
  335. $jsonData['IfPastWeek_RapidVisualChanges'] = $IfPastWeek_RapidVisualChanges;
  336. }
  337.  
  338. if (isset($_POST['IfPastWeek_ShortnessOfBreath'])) {
  339. $IfPastWeek_ShortnessOfBreath = $_POST['IfPastWeek_ShortnessOfBreath'];
  340. $jsonData['IfPastWeek_ShortnessOfBreath'] = $IfPastWeek_ShortnessOfBreath;
  341. }
  342.  
  343. if (isset($_POST['IfPastWeek_UnexpectedSwellingOfLeg'])) {
  344. $IfPastWeek_UnexpectedSwellingOfLeg = $_POST['IfPastWeek_ExcessiveUrination'];
  345. $jsonData['IfPastWeek_ExcessiveUrination'] = $IfPastWeek_ExcessiveUrination;
  346. }
  347.  
  348. if (isset($_POST['IfPastWeek_LostConsciousness'])) {
  349. $IfPastWeek_LostConsciousness = $_POST['IfPastWeek_LostConsciousness'];
  350. $jsonData['IfPastWeek_LostConsciousness'] = $IfPastWeek_LostConsciousness;
  351. }
  352.  
  353. if (isset($_POST['IfPastWeek_ConsistentVomitingOrDiarrhea'])) {
  354. $IfPastWeek_ConsistentVomitingOrDiarrhea = $_POST['IfPastWeek_ConsistentVomitingOrDiarrhea'];
  355. $jsonData['IfPastWeek_ConsistentVomitingOrDiarrhea'] = $IfPastWeek_ConsistentVomitingOrDiarrhea;
  356. }
  357.  
  358. if (isset($_POST['IfPastWeek_SevereAbdominalSwelling'])) {
  359. $IfPastWeek_SevereAbdominalSwelling = $_POST['IfPastWeek_SevereAbdominalSwelling'];
  360. $jsonData['IfPastWeek_SevereAbdominalSwelling'] = $IfPastWeek_SevereAbdominalSwelling;
  361. }
  362.  
  363. if (isset($_POST['IfPastWeek_ThoughtsOfSuicide'])) {
  364. $IfPastWeek_ThoughtsOfSuicide = $_POST['IfPastWeek_ThoughtsOfSuicide'];
  365. $jsonData['IfPastWeek_ThoughtsOfSuicide'] = $IfPastWeek_ThoughtsOfSuicide;
  366. }
  367.  
  368. if (isset($_POST['IfPastWeekIfPastWeek_OtherText_ExtremeThirst'])) {
  369. $IfPastWeekIfPastWeek_OtherText_ExtremeThirst = $_POST['IfPastWeekIfPastWeek_OtherText_ExtremeThirst'];
  370. $jsonData['IfPastWeekIfPastWeek_OtherText_ExtremeThirst'] = $IfPastWeekIfPastWeek_OtherText_ExtremeThirst;
  371. }
  372.  
  373. if (isset($_POST['PossiblyPregnant'])) {
  374. $PossiblyPregnant = $_POST['PossiblyPregnant'];
  375. $jsonData['PossiblyPregnant'] = $PossiblyPregnant;
  376. }
  377.  
  378. if (isset($_POST['IfGaveBirthPast42Days'])) {
  379. $IfGaveBirthPast42Days = $_POST['IfGaveBirthPast42Days'];
  380. $jsonData['IfGaveBirthPast42Days'] = $IfGaveBirthPast42Days;
  381. }
  382.  
  383. if (isset($_POST['IfBreastfeeding'])) {
  384. $IfBreastfeeding = $_POST['IfBreastfeeding'];
  385. $jsonData['IfBreastfeeding'] = $IfBreastfeeding;
  386. }
  387.  
  388. if (isset($_POST['IfMigraines'])) {
  389. $IfMigraines = $_POST['IfMigraines'];
  390. $jsonData['IfMigraines'] = $IfMigraines;
  391. }
  392.  
  393. if (isset($_POST['IfMigraines_Aura'])) {
  394. $IfMigraines_Aura = $_POST['IfMigraines_Aura'];
  395. $jsonData['IfMigraines_Aura'] = $IfMigraines_Aura;
  396. }
  397.  
  398. if (isset($_POST['IfDiabetes'])) {
  399. $IfDiabetes = $_POST['IfDiabetes'];
  400. $jsonData['IfDiabetes'] = $IfDiabetes;
  401. }
  402.  
  403. if (isset($_POST['IfTraumaSurgeryOrImmobilePastThreeMonths'])) {
  404. $IfTraumaSurgeryOrImmobilePastThreeMonths = $_POST['IfTraumaSurgeryOrImmobilePastThreeMonths'];
  405. $jsonData['IfTraumaSurgeryOrImmobilePastThreeMonths'] = $IfTraumaSurgeryOrImmobilePastThreeMonths;
  406. }
  407.  
  408. if (isset($_POST['IfPeripartumCardiomyopathy'])) {
  409. $IfPeripartumCardiomyopathy = $_POST['IfPeripartumCardiomyopathy'];
  410. $jsonData['IfPeripartumCardiomyopathy'] = $IfPeripartumCardiomyopathy;
  411. }
  412.  
  413. if (isset($_POST['IfIschemicHeartDisease'])) {
  414. $IfIschemicHeartDisease = $_POST['IfIschemicHeartDisease'];
  415. $jsonData['IfIschemicHeartDisease'] = $_POST['IfIschemicHeartDisease'];
  416. }
  417.  
  418. if (isset($_POST['IfHighCholesterol'])) {
  419. $IfHighCholesterol = $_POST['IfHighCholesterol'];
  420. $jsonData['IfHighCholesterol'] = $IfHighCholesterol;
  421. }
  422.  
  423. if (isset($_POST['IfHighDensityLipoprotein'])) {
  424. $IfHighDensityLipoprotein = $_POST['IfHighDensityLipoprotein'];
  425. $jsonData['IfHighDensityLipoprotein'] = $IfHighDensityLipoprotein;
  426. }
  427.  
  428. if (isset($_POST['IfValvularHeartDisease'])) {
  429. $IfValvularHeartDisease = $_POST['IfValvularHeartDisease'];
  430. $jsonData['IfValvularHeartDisease'] = $IfValvularHeartDisease;
  431. }
  432.  
  433. if (isset($_POST['IfPulmonaryHypertension'])) {
  434. $IfPulmonaryHypertension = $_POST['IfPulmonaryHypertension'];
  435. $jsonData['IfPulmonaryHypertension'] = $IfPulmonaryHypertension;
  436. }
  437.  
  438. if (isset($_POST['IfAtrialFibrillation'])) {
  439. $IfAtrialFibrillation = $_POST['IfAtrialFibrillation'];
  440. $jsonData['IfAtrialFibrillation'] = $IfAtrialFibrillation;
  441. }
  442.  
  443. if (isset($_POST['IfSubacuteBacterialEndocarditis'])) {
  444. $IfSubacuteBacterialEndocarditis = $_POST['IfSubacuteBacterialEndocarditis'];
  445. $jsonData['IfSubacuteBacterialEndocarditis'] = $IfSubacuteBacterialEndocarditis;
  446. }
  447.  
  448. if (isset($_POST['IfActiveCancerExcludingNonMelanomaSkinCancer'])) {
  449. $IfActiveCancerExcludingNonMelanomaSkinCancer = $_POST['IfActiveCancerExcludingNonMelanomaSkinCancer'];
  450. $jsonData['IfActiveCancerExcludingNonMelanomaSkinCancer'] = $IfActiveCancerExcludingNonMelanomaSkinCancer;
  451. }
  452.  
  453. if (isset($_POST['IfStroke'])) {
  454. $IfStroke = $_POST['IfStroke'];
  455. $jsonData['IfStroke'] = $IfStroke;
  456. }
  457.  
  458. if (isset($_POST['IfBloodClottingDisease'])) {
  459. $IfBloodClottingDisease = $_POST['IfBloodClottingDisease'];
  460. $jsonData['IfBloodClottingDisease'] = $IfBloodClottingDisease;
  461. }
  462.  
  463. if (isset($_POST['IfSuperficialVenousThrombosis'])) {
  464. $IfSuperficialVenousThrombosis = $_POST['IfSuperficialVenousThrombosis'];
  465. $jsonData['IfSuperficialVenousThrombosis'] = $IfSuperficialVenousThrombosis;
  466. }
  467.  
  468. if (isset($_POST['IfDeepVenousThrombosis'])) {
  469. $IfDeepVenousThrombosis = $_POST['IfDeepVenousThrombosis'];
  470. $jsonData['IfDeepVenousThrombosis'] = $IfDeepVenousThrombosis;
  471. }
  472.  
  473. if (isset($_POST['IfReceivedSolidOrganTransplant'])) {
  474. $IfReceivedSolidOrganTransplant = $_POST['IfReceivedSolidOrganTransplant'];
  475. $jsonData['IfReceivedSolidOrganTransplant'] = $IfReceivedSolidOrganTransplant;
  476. }
  477.  
  478. if (isset($_POST['IfBariatricOrStomachReductionSurgery'])) {
  479. $IfBariatricOrStomachReductionSurgery = $_POST['IfBariatricOrStomachReductionSurgery'];
  480. $jsonData['IfBariatricOrStomachReductionSurgery'] = $IfBariatricOrStomachReductionSurgery;
  481. }
  482.  
  483. if (isset($_POST['IfLiverDiseaseOrTumor_BenignAdenoma'])) {
  484. $IfLiverDiseaseOrTumor_BenignAdenoma = $_POST['IfLiverDiseaseOrTumor_BenignAdenoma'];
  485. $jsonData['IfLiverDiseaseOrTumor_BenignAdenoma'] = $IfLiverDiseaseOrTumor_BenignAdenoma;
  486. }
  487.  
  488. if (isset($_POST['IfLiverDiseaseOrTumor_Malignant'])) {
  489. $IfLiverDiseaseOrTumor_Malignant = $_POST['IfLiverDiseaseOrTumor_Malignant'];
  490. $jsonData['IfLiverDiseaseOrTumor_Malignant'] = $IfLiverDiseaseOrTumor_Malignant;
  491. }
  492.  
  493. if (isset($_POST['IfLiverDiseaseOrTumor_CirrhosisSevere'])) {
  494. $IfLiverDiseaseOrTumor_CirrhosisSevere = $_POST['IfLiverDiseaseOrTumor_CirrhosisSevere'];
  495. $jsonData['IfLiverDiseaseOrTumor_CirrhosisSevere'] = $IfLiverDiseaseOrTumor_CirrhosisSevere;
  496. }
  497.  
  498. if (isset($_POST['IfViralHepatitis_CarrierOrChronic'])) {
  499. $IfViralHepatitis_CarrierOrChronic = $_POST['IfViralHepatitis_CarrierOrChronic'];
  500. $jsonData['IfViralHepatitis_CarrierOrChronic'] = $IfViralHepatitis_CarrierOrChronic;
  501. }
  502.  
  503. if (isset($_POST['IfViralHepatitis_AcuteOrFlare'])) {
  504. $IfViralHepatitis_AcuteOrFlare = $_POST['IfViralHepatitis_AcuteOrFlare'];
  505. $jsonData['IfViralHepatitis_AcuteOrFlare'] = $IfViralHepatitis_AcuteOrFlare;
  506. }
  507.  
  508. if (isset($_POST['IfCholestasis_PregnancyRelated'])) {
  509. $IfCholestasis_PregnancyRelated = $_POST['IfCholestasis_PregnancyRelated'];
  510. $jsonData['IfCholestasis_PregnancyRelated'] = $IfCholestasis_PregnancyRelated;
  511. }
  512.  
  513. if (isset($_POST['IfCholestasis_PregnancyRelated'])) {
  514. $IfCholestasis_PregnancyRelated = $_POST['IfCholestasis_PregnancyRelated'];
  515. $jsonData['IfCholestasis_PregnancyRelated'] = $IfCholestasis_PregnancyRelated;
  516. }
  517.  
  518. if (isset($_POST['IfCholestasis_OralContraceptiveRelated'])) {
  519. $IfCholestasis_OralContraceptiveRelated = $_POST['IfCholestasis_OralContraceptiveRelated'];
  520. $jsonData['IfCholestasis_OralContraceptiveRelated'] = $IfCholestasis_OralContraceptiveRelated;
  521. }
  522.  
  523. if (isset($_POST['IfInflammatoryBowelDisease'])) {
  524. $IfInflammatoryBowelDisease = $_POST['IfInflammatoryBowelDisease'];
  525. $jsonData['IfInflammatoryBowelDisease'] = $IfInflammatoryBowelDisease;
  526. }
  527.  
  528. if (isset($_POST['IfLupus'])) {
  529. $IfLupus = $_POST['IfLupus'];
  530. $jsonData['IfLupus'] = $IfLupus;
  531. }
  532.  
  533. if (isset($_POST['IfMultipleScerosis'])) {
  534. $IfMultipleScerosis = $_POST['IfMultipleScerosis'];
  535. $jsonData['IfMultipleScerosis'] = $IfMultipleScerosis;
  536. }
  537.  
  538. if (isset($_POST['IfBreastCancer_PastFiveYears'])) {
  539. $IfBreastCancer_PastFiveYears = $_POST['IfBreastCancer_PastFiveYears'];
  540. $jsonData['IfBreastCancer_PastFiveYears'] = $IfBreastCancer_PastFiveYears;
  541. }
  542.  
  543. if (isset($_POST['IfHysterectomyOrTubalLigation'])) {
  544. $IfHysterectomyOrTubalLigation = $_POST['IfHysterectomyOrTubalLigation'];
  545. $jsonData['IfHysterectomyOrTubalLigation'] = $IfHysterectomyOrTubalLigation;
  546. }
  547.  
  548. if (isset($_POST['IfHIV'])) {
  549. $IfHIV = $_POST['IfHIV'];
  550. $jsonData['IfHIV'] = $IfHIV;
  551. }
  552.  
  553. if (isset($_POST['GallbladderDisease'])) {
  554. if ($_POST['GallbladderDisease'] == 'false') {
  555. $FK_GallbladderDisease = null;
  556. } else {
  557. $FK_GallbladderDisease = true;
  558. }
  559. $jsonData['FK_GallbladderDisease'] = $FK_GallbladderDisease;
  560. }
  561.  
  562. if (isset($_POST['FK_GallbladderDisease'])) {
  563. $FK_GallbladderDisease = $_POST['FK_GallbladderDisease'];
  564. $jsonData['FK_GallbladderDisease'] = $FK_GallbladderDisease;
  565. }
  566.  
  567. if (isset($_POST['IfIncludeFemaleCondom'])) {
  568. $IfIncludeFemaleCondom = $_POST['IfIncludeFemaleCondom'];
  569. $jsonData['IfIncludeFemaleCondom'] = $IfIncludeFemaleCondom;
  570. }
  571.  
  572. if (isset($_POST['IfIncludeEmergencyContraception'])) {
  573. $IfIncludeEmergencyContraception = $_POST['IfIncludeEmergencyContraception'];
  574. $jsonData['IfIncludeEmergencyContraception'] = $IfIncludeEmergencyContraception;
  575. }
  576.  
  577. if (isset($_POST['IfIncludeGenericOptions'])) {
  578. $IfIncludeGenericOptions = $_POST['IfIncludeGenericOptions'];
  579. $jsonData['IfIncludeGenericOptions'] = $IfIncludeGenericOptions;
  580. }
  581.  
  582. if (isset($_POST['IfIncludeRingAndPatchOptions'])) {
  583. $IfIncludeRingAndPatchOptions = $_POST['IfIncludeRingAndPatchOptions'];
  584. $jsonData['IfIncludeRingAndPatchOptions'] = $IfIncludeRingAndPatchOptions;
  585. }
  586.  
  587. if (isset($_POST['FK_SelfDescribedRace'])) {
  588. $FK_SelfDescribedRace = $_POST['FK_SelfDescribedRace'];
  589. $jsonData['FK_SelfDescribedRace'] = $FK_SelfDescribedRace;
  590. }
  591.  
  592. if (isset($_POST['IfDesiredBenefit_Acne'])) {
  593. $IfDesiredBenefit_Acne = $_POST['IfDesiredBenefit_Acne'];
  594. $jsonD['IfDesiredBenefit_Acne'] = $IfDesiredBenefit_Acne;
  595. }
  596.  
  597. if (isset($_POST['IfDesiredBenefit_SkipPeriods'])) {
  598. $IfDesiredBenefit_SkipPeriods = $_POST['IfDesiredBenefit_SkipPeriods'];
  599. $jsonData['IfDesiredBenefit_SkipPeriods'] = $IfDesiredBenefit_SkipPeriods;
  600. }
  601.  
  602. if (isset($_POST['IfDesiredBenefit_RegulateCrampsAndPeriod'])) {
  603. $IfDesiredBenefit_RegulateCrampsAndPeriod = $_POST['IfDesiredBenefit_RegulateCrampsAndPeriod'];
  604. $jsonData['IfDesiredBenefit_RegulateCrampsAndPeriod'] = $IfDesiredBenefit_RegulateCrampsAndPeriod;
  605. }
  606.  
  607. if (isset($_POST['IfDesiredBenefit_RegulatePMS'])) {
  608. $IfDesiredBenefit_RegulatePMS = $_POST['IfDesiredBenefit_RegulatePMS'];
  609. $jsonData['IfDesiredBenefit_RegulatePMS'] = $IfDesiredBenefit_RegulatePMS;
  610. }
  611.  
  612. if (isset($_POST['IfDesiredBenefit_MinimalSideEffects'])) {
  613. $IfDesiredBenefit_MinimalSideEffects = $_POST['IfDesiredBenefit_MinimalSideEffects'];
  614. $jsonData['IfDesiredBenefit_MinimalSideEffects'] = $IfDesiredBenefit_MinimalSideEffects;
  615. }
  616.  
  617. if (isset($_POST['Name'])) {
  618. $Name = $_POST['Name'];
  619. }
  620.  
  621. if (isset($_POST['Phone'])) {
  622. $Phone = $_POST['Phone'];
  623. }
  624.  
  625. if (isset($_POST['Address'])) {
  626. $Address = $_POST['Address'];
  627. }
  628.  
  629. if (isset($_POST['City'])) {
  630. $City = $_POST['City'];
  631. }
  632.  
  633. if (isset($_POST['ZIP'])) {
  634. $ZIP = $_POST['ZIP'];
  635. }
  636.  
  637. if (isset($_POST['Email'])) {
  638. $Email = $_POST['Email'];
  639. }
  640.  
  641. if (isset($_POST['Company'])) {
  642. $Company = $_POST['Company'];
  643. }
  644.  
  645. if (isset($_POST['Address2'])) {
  646. $Address2 = $_POST['Address2'];
  647. }
  648.  
  649. if (isset($_POST['State'])) {
  650. $State = $_POST['State'];
  651. }
  652.  
  653. if (isset($_POST['Country'])) {
  654. $Country = $_POST['Country'];
  655. }
  656.  
  657. if ( isset( $_POST['IfSendPrescriptionInfo'] ) ) {
  658. $jsonData['Physician'] = array(
  659. 'IfSendPrescriptionInfo' => $_POST['IfSendPrescriptionInfo']
  660. );
  661.  
  662. if ( $_POST['IfSendPrescriptionInfo'] == 'true' ) {
  663. $jsonData['Physician'] = array(
  664. 'IfSendPrescriptionInfo' => $_POST['IfSendPrescriptionInfo'],
  665. 'Name' => $Name,
  666. 'Address' => $Address,
  667. 'City' => $City,
  668. 'ZIP' => $ZIP,
  669. 'Email' => $Email,
  670. 'Company' => $Company,
  671. 'Address2' => $Address2,
  672. 'State' => $State,
  673. 'Country' => $Country,
  674. 'Phone' => $Phone
  675. );
  676. }
  677. }
  678.  
  679. // if (!empty($_POST['Name'])) {
  680. // $Name = $_POST['Name'];
  681. // $jsonData['MedicalBackground_PrimaryCarePhysician'] = array(
  682. // 'Name' => $Name,
  683. // 'Address' => $Address,
  684. // 'City' => $City,
  685. // 'ZIP' => $ZIP,
  686. // 'Email' => $Email,
  687. // 'Company' => $Company,
  688. // 'Address2' => $Address2,
  689. // 'State' => $State,
  690. // 'Country' => $Country,
  691. // 'Phone' => $Phone,
  692. // );
  693. // }
  694.  
  695. if (isset($_POST['FK_BirthControlUseDuration'])) {
  696. $jsonData['FK_BirthControlUseDuration'] = $_POST['FK_BirthControlUseDuration'];
  697. }
  698.  
  699.  
  700. if (isset($_POST['IfIncludeFemaleCondom'])) {
  701. $jsonData['IfIncludeFemaleCondom'] = $_POST['IfIncludeFemaleCondom'];
  702. }
  703.  
  704. if (isset($_POST['IfIncludeEmergencyContraception'])) {
  705. $jsonData['IfIncludeEmergencyContraception'] = $_POST['IfIncludeEmergencyContraception'];
  706. }
  707.  
  708. if (isset($_POST['IfIncludeGenericOptions'])) {
  709. $jsonData['IfIncludeGenericOptions'] = $_POST['IfIncludeGenericOptions'];
  710. }
  711.  
  712. if (isset($_POST['IfIncludeRingAndPatchOptions'])) {
  713. $jsonData['IfIncludeRingAndPatchOptions'] = $_POST['IfIncludeRingAndPatchOptions'];
  714. }
  715.  
  716. if (isset($_POST['FK_SelfDescribedRace'])) {
  717. $jsonData['FK_SelfDescribedRace'] = $_POST['FK_SelfDescribedRace'];
  718. }
  719.  
  720. //API Url
  721. if ( is_user_logged_in() ) {
  722. $url = 'https://oitdataservicedev.azurewebsites.net/api/Patient/' . $_SESSION['patientGuid'] . '/MedicalBackground?returnMeds=true';
  723. // $url = 'http://httpbin.org/post';
  724. } else {
  725. $url = 'https://oitdataservicedev.azurewebsites.net/api/Patient?returnMeds=true';
  726. }
  727.  
  728. if ( isset( $_SESSION['MedicalBackground'] -> Id ) ) {
  729. $url = 'https://oitdataservicedev.azurewebsites.net/api/Patient/' . $_SESSION['patientGuid'] . '/MedicalBackground/' . $_SESSION['MedicalBackground'] -> Id . '/?returnMeds=true';
  730.  
  731. // Set MedicalBackground ID in json Body
  732. $jsonData['Id'] = $_SESSION['MedicalBackground'] -> Id;
  733. }
  734.  
  735. // $url = 'http://httpbin.org/post';
  736.  
  737. //Initiate cURL.
  738. $ch = curl_init($url);
  739. curl_setopt($ch, CURLOPT_URL, $url);
  740.  
  741. //Encode the array into JSON.
  742.  
  743. if ( is_user_logged_in() ) {
  744. $jsonDataEncoded = json_encode($jsonData, JSON_NUMERIC_CHECK);
  745. $jsonData['SurveyResponseDate'] = date('Y-m-dTh:iZ');
  746. } else {
  747. $jsonNoPatient['SurveyResponseDate'] = date('Y-m-dTh:iZ');
  748. $jsonNoPatient['Background'] = $jsonData;
  749. $jsonDataEncoded = json_encode($jsonNoPatient, JSON_NUMERIC_CHECK);
  750. }
  751.  
  752. //Tell cURL that we want to send a POST or PUT request.
  753.  
  754.  
  755. if ( isset( $_SESSION['MedicalBackground'] -> Id ) ) {
  756. curl_setopt($ch, CURLOPT_POST, false);
  757. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  758. } else {
  759. curl_setopt($ch, CURLOPT_POST, true);
  760. }
  761.  
  762. //Attach our encoded JSON string to the POST fields.
  763. curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
  764. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  765. // Check if user is logged in and set HTTP HEADERS
  766. if ( is_user_logged_in()) {
  767. $header = 'Secret:'.$_SESSION['accessToken'];
  768. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  769. 'Content-Type: application/json',
  770. $header
  771. ));
  772. } else {
  773. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  774. 'Content-Type: application/json'
  775. ));
  776. }
  777.  
  778.  
  779. // Execute the request
  780. if ( !is_user_logged_in() ) {
  781. $_SESSION['Patient'] = json_decode(curl_exec($ch));
  782. curl_close($ch);
  783. // wp_redirect('/results-and-recommendations');
  784. $_SESSION['patientGuid'] = $_SESSION['Patient'] -> id;
  785. $_SESSION['accessToken'] = $_SESSION['Patient'] -> accessToken;
  786. $_SESSION['accessTokenExpires'] = $_SESSION['Patient'] -> accessTokenExpires;
  787. wp_redirect('/results-and-recommendations');
  788. exit;
  789.  
  790. } else {
  791. $_SESSION['insertMB'] = json_decode(curl_exec($ch));
  792. // $_SESSION['updateresponse']= curl_exec($ch);
  793. curl_close($ch);
  794. wp_redirect('/results-and-recommendations');
  795. exit;
  796. }
  797.  
  798.  
  799.  
  800. // For testing the output
  801. // echo $jsonDataEncoded;
  802. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement