/
inc-ajax-extractCsForm.php
110 lines (92 loc) · 3.42 KB
/
inc-ajax-extractCsForm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/*
* This file is part of MedShakeEHR.
*
* Copyright (c) 2017
* Bertrand Boutillier <b.boutillier@gmail.com>
* http://www.medshake.net
*
* MedShakeEHR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* MedShakeEHR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MedShakeEHR. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Patient > ajax : obtenir le formulaire de consultation demandé
*
* @author Bertrand Boutillier <b.boutillier@gmail.com>
* @contrib fr33z00 <https://github.com/fr33z00>
*
* SQLPREPOK
*/
$debug = '';
//template
$template = "patientCsForm";
$formIN = $p['page']['formIN'] = $_POST['formIN'];
if (!isset($_POST['csID'])) {
$_POST['csID'] = msSQL::sqlUniqueChamp("SELECT id from data_types where groupe='typecs' and formValues= :formValues limit 1", ['formValues' => $_POST['formIN']]);
}
// formulaire
$formInfos = new msData();
$p['page']['formInfos'] = $formInfos->getDataType($_POST['csID'], array('label'));
// module du formulaire
$formModule = new msForm;
$p['page']['formInfos']['module'] = $formModule->getFormUniqueRawField($formIN, 'module');
// class du module étendant potentiellement msForm
$class = 'msMod' . ucfirst($p['page']['formInfos']['module']) . 'Forms';
$method_pre = 'doPreGetForm_' . $formIN;
$method_post = 'doPostGetForm_' . $formIN;
// instancier la bonne class pour travailler sur le form
if (class_exists($class)) {
$form = new $class;
} else {
$form = new msForm();
}
$form->setFormIDbyName($formIN);
//chargement des values si demandé
if (isset($_POST['prevalues'])) {
if ($_POST['prevalues'] == 'yes') {
$form->setInstance($_POST['objetID']);
$form->setTypesSupForPrevaluesExtraction(['codeTechniqueExamen']);
$form->getPrevaluesForPatient($_POST['patientID']);
}
}
// méthode sépcifique au module et form : pre
if (method_exists($class, $method_pre)) {
$form->$method_pre();
}
$p['page']['form'] = $form->getForm();
if ($_POST['mode'] == 'update' or $_POST['mode'] == 'create') $form->addSubmitToForm($p['page']['form'], 'btn-warning btn-lg btn-block');
// retrait des options d'un champ select qui doit prévenir le duplication
if ($_POST['mode'] == 'create') {
$typePreventDupl = $form->getFormOptions();
if (isset($typePreventDupl['typeToPreventDuplicate'])) {
$objDup = new msObjet;
$objDup->setToID($_POST['patientID']);
$optionsDejaUtilisees = $objDup->getDataTypePatientActiveValues($typePreventDupl['typeToPreventDuplicate']);
$form->removeOptionInSelectForm($p['page']['form'], $typePreventDupl['typeToPreventDuplicate'], $optionsDejaUtilisees);
}
}
//ajout champs cachés au form
$p['page']['form']['addHidden'] = array(
'patientID' => $_POST['patientID'],
'parentID' => $_POST['parentID'],
'csID' => $_POST['csID'],
'mode' => $_POST['mode']
);
if (isset($_POST['objetID'])) {
$p['page']['form']['addHidden']['objetID'] = $_POST['objetID'];
}
$p['page']['formJavascript'] = $form->getFormJavascript();
// méthode spécifique au module et form : post
if (method_exists($class, $method_post)) {
$form->$method_post();
}