--- Формерование ответа ------------
https://www.youtube.com/watch?v=obKx0Re5qNA
word2vec - перефразирует  готовый шаблон
Fasttext 
spaCy - разбор текста 
-----------------------------------

BLV1 / 123 Регистратор
CHVG / 123 Руководитель
SHNA1 / 123 Эксперт
basorina / bms333

basorina
bms333

BLV1
123

------- ОТЛАДКА sql многострочный текст запроса ---------------
Components/Action/ActionMIS.inc
Найти строку:
  print '"sql":'.json_encode($this->ASQL).', "vars":'.json_encode($bindedVar).',';
Заменить строку: на :
  print '"sqlArr":'.json_encode( explode("\n",$this->ASQL)).',';
  print '"sql":'.json_encode($this->ASQL).', "vars":'.json_encode($bindedVar).',';


Components/DataSet/DataSet.inc
Найти строку:
print ', "sql":'.json_encode($this->EASQL).', "vars":'.json_encode($bindedVar);

Заменить строку: на :

  print ', "sqlArr":'.json_encode( explode("\n",$this->EASQL)).',';
  print ', "sql":'.json_encode($this->EASQL).', "vars":'.json_encode($bindedVar);

---------------------------------------------------------------
Регулярные выражения
https://rubular.com/

[abc] 	A single character of: a, b, or c
[^abc] 	Any single character except: a, b, or c
[a-z] 	Any single character in the range a-z
[a-zA-Z] 	Any single character in the range a-z or A-Z
^ 	Start of line
$ 	End of line
\A 	Start of string
\z 	End of string
. 	Any single character
\s 	Any whitespace character
\S 	Any non-whitespace character
\d 	Any digit
\D 	Any non-digit
\w 	Any word character (letter, number, underscore)
\W 	Any non-word character
\b 	Any word boundary
(...) 	Capture everything enclosed
(a|b) 	a or b
a? 	Zero or one of a
a* 	Zero or more of a
a+ 	One or more of a
a{3} 	Exactly 3 of a
a{3,} 	3 or more of a
a{3,6} 	Between 3 and 6 of a
options: 
	"i" case insensitive 
	"m" make dot match newlines 
	"x" ignore whitespace in regex 
	"o" perform #{...} substitutions only once
---------------------------------------------------------------

Получить BAR code в JS 

    Form.softwareСrutch = function(barCodeElementName,code) {
        // urlSrc =  "getmodule.php?Module="+barCodeElementName+"_module&Form="+getPage().form.name+"&reportid=146958459&nooverflow=true&id="+code+"&hash="+ (new Date()).getTime();
        urlSrc =  "getmodule.php?Module="+barCodeElementName+"_module&Form="+getPage().form.name+"&modal=1&id="+code+"&hash="+ (new Date()).getTime();
        var xmlModuleImage = new XMLHttpRequest();
        xmlModuleImage.open('GET',urlSrc,true);
        xmlModuleImage.responseType = 'arraybuffer';
        xmlModuleImage.onload = function(e) {
            var arr = new Uint8Array(this.response);
            var raw = String.fromCharCode.apply(null,arr);
            var b64=btoa(raw);
            var dataURL="data:image/png;base64,"+b64;
            getControlByName(barCodeElementName).src =  dataURL;
        };
        xmlModuleImage.send();
    }


Добавить коментари 

{{collapse(Скрин изменений)
  !Soft.png!
}}


D_P_EXC('RELATIVE_HH_ID: '||RELATIVE_HH_ID);

 -----------------------------------------------------------------------------------------

git fetch --tags
git checkout latest_KALINA

 -----------------------------------------------------------------------------------------
        Размер в пикселях X (4мм отступ слева и справа) =  1590,990476
        Размер в пикселях Y (4мм отступ сверху и снизу) =  2275,996633
            x = 7,876190476 (1mm)
	    y = 7,875420875 (1mm)
	    ===========================
	    __________
	    |left:8px
	    |top:8px
	    __________
	    x - 1136px
            y - 1620px
        следующий лист начинается 1645px (растояние между листами 25 px)
	    __________
         Х 1136 / (210 - 4 - 4) = 5,623762376237624 (1mm)
         Y 1620 / (297 - 4 - 4) = 5,765124555160142 (1mm)
       Горизонталная ориентация
         X 1620px
         Y 1126px
         следующий лист начинается с 1140 (растояние между листами 14 px)
 -----------------------------------------------------------------------------------------
Размер страницы при печати
	@page {
            size: auto;
            margin-top: 0;
            margin-bottom: 0;
        }
-----------------------------------------------------------------------------------------

openD3Form('System/get_info_repo', 1, {width: 800, height: 200});

openInfoWindow()
getPage().form.userForms.split(';')
getPage().d3Form.userForms.split(';')


-----------------------------------------------------------------------------------------

   MethodDevices.addEvent('onChange', Form.onMethodDevicesChange);
-----------------------------------------------------------------------------------------
// добавить событие на элемент
 base().setComponentEvents('ArmPatientsInDep/pat_in_dep_healing_emp', 'DS_HH_MP_PRESCRIBES_DEPS', 'onchange', "");
 Form.setComponentEvents = function (forname, cmpName, e, e_f) {
     var componentsList = document.querySelector('[formname="' + forname + '"]').querySelectorAll('[cmptype=Edit],[cmptype=ButtonEdit],[cmptype=ComboBox],[cmptype=DateEdit],[cmptype=CheckBox],[cmptype=TextArea]');
     for (var i = 0; i < componentsList.length; i++) {
         var componentName = componentsList[i].getAttribute('name');
         if(componentName) {
             if (componentName == cmpName) {
              	getControlByName(componentName).setAttribute(e, e_f);
             }
         }
     }
};

-----------------------------------------------------------------------------------------
Отследить окончание работы SQL запроса M2
base().updateDataSet('DS_HH_MP_PRESCRIBES_DEPS').then(function(){ console.log('End SQL 222222222');});
Form.updateDataSet ('DS_HH_MP_PRESCRIBES_DEPS').then(function(){ console.log('End SQL 222222222');});
 Form.updateDataSet = function(name){
		return new Promise(function(resolve, reject) {
 			resolve(refreshDataSet(name));
		});
 }

 --- В2 ---
 startActionsGroup(0, true);
    executeAction("LAST_FILL_ACTION");
 endActionsGroup(null, function() {  });

-----------------------------------------------------------------------------------------
Проверять значение из массива строки
:HOSP_RESULT='204;103;203;104;109;202'

     and :HOSP_RESULT  in (select regexp_substr(t.R_CODE, '[^;]+', 1, level)
                                          from dual
                                       connect by instr(t.R_CODE, ';', 1, level - 1) > 0)


-----------------------------------------------------------------------------------------


// ------------------------ Добавить пользователя и права на БД -------------------------------------
// ------- https://4admin.space/all/sozdanie-polzovatelya-postgresql-s-pravami-read-only/  ----------
// --------------------------------------------------------------------------------------------------
CREATE USER Read_Only_User  WITH ENCRYPTED PASSWORD 'STRONG_PASSWORD';
GRANT USAGE ON SCHEMA public to Read_Only_User;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO Read_Only_User;

GRANT CONNECT ON DATABASE DATABASE_TO_READ to Read_Only_User;

\c DATABASE_TO_READ

ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO Read_Only_User;
GRANT USAGE ON SCHEMA public to Read_Only_User; 
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO Read_Only_User;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO Read_Only_User;



----------------------------------------------
HTML to PDF средствами JS
https://www.encodedna.com/javascript/practice-ground/default.htm?pg=convert_html_table_to_pdf_using_javascript
----------------------------------------------

----------------------------------------------
ПР верстка отчета  перед печатью
https://stash-medmis.bars-open.ru/projects/MED/repos/mis/pull-requests/36425/diff#Forms/Reports/showReportHTML.frm
----------------------------------------------


-----------------
Подчеркнутый текст CSS
text-decoration: underline;
-----------------


-----------------
Перенос текста в DIV https://learn.javascript.ru/white-space
    ============================
		<style>
		  div { font-family: monospace; width: 200px; border: 1px solid black; }
		</style>

		<div style="white-space:pre-line">if (hours > 18) {
		      // Пойти поиграть в теннис
		}
		</div>
    ============================
    <style>
        span.mfield {
            font-weight: bold;
            padding-left: 1mm;
            overflow: hidden;
        }
    </style>
    <div style="position:absolute;width: 210mm;">
        13. Диагноз направившего учреждения
        <component  cmptype="Label" style="white-space:pre-line;line-height:1.6" captionfield="OUTER_DIAGNOSIS" class="mfield"/>
    </div>
    ============================
-----------------


          var cloneData = getClone(_dom).clone.data||{};   // получение полей (контролов) данных клона как объект
          var curClone = getClone(_dom, 'rptCON_CARES');   // получение контекста репитера (курсор)
            closureContext(curClone);                        // переключение контекста в JS
          // Создание нового клона с инициализацией всех полей(контролов) 
                var newClone = getRepeater('repDiagnosesData').addClone({
                    'DIAGN_DATE': null,
                    'DIAGN_ID': null,
                    'DIAGN_TYPE_CODE': cloneData['DIAGN_TYPE_CODE'],
                    'DIAGN_TYPE_ID': cloneData['DIAGN_TYPE_ID'],
                    'DIAGN_TYPE_NAME': cloneData['DIAGN_TYPE_NAME'],
                    'HAVE_DATA': '1',
                    'MKB_CODE': null,
                    'MKB_ID': null
                });
            unClosureContext();                             // закрытие курсора
			
            
                var clone = getClone(dom);
                closureContext(clone);
                    setVar('_id', clone.clone.data['DOC']);
                    executeAction('DownloadFileAction', function() {
                        D3Api.downloadFile(getVar('filename'), clone.clone.data['NAME']);
                    });
                unClosureContext();
				
				var data = getClone(dom, 'RptFieldComment').clone.data;

 a_par := string_to_array(trim(both ';' from ps_params::text),';'::text);
 
 
 
    ar := string_to_array(ps_params,';');
    for i in array_lower(ar,1)..array_upper(ar,1)
    loop
        s_sql := replace(s_sql,'<'||ar[i]||'>','null');
    end loop;
	
 
 addEmploeOnOper
       <cmpActionVar name="LPU"                 src="LPU"               srctype="session" />
       <cmpActionVar name="DT_SPEC_ID"          src="DT_SPEC_ID"        srctype="var"     />
       <cmpActionVar name="DT_EMP_ID"           src="DTE_ID"            srctype="var" put=""/>
       <cmpActionVar name="EMP_TXT"             src="EMP_TXT"           srctype="var" />
       <cmpActionVar name="EMP_ID"              src="EMP_ID"            srctype="var" />
       <cmpActionVar name="DTE_EMPGRADE_CODE"   src="DTE_EMPGRADE_CODE" srctype="var" />
	   
	   
	    
        for i in 0..:DAYSCOUNT
					  
DECLARE
  ar_params varchar[];
  s_params  varchar = '';
  s_sql     varchar;
  ref refcursor;
  cr record;
BEGIN
 ar_params := string_to_array(ps_param_name, ','); 
 for i in array_lower(ar_params, 1)..array_upper(ar_params, 1)
 loop
   s_params := s_params||'max(case when param_name = '''||ar_params[i]||''' then param_val else null end)::varchar as '||lower(ar_params[i])||', ';
 end loop;

 
 
 string_to_array(:unitbpcodes, ',')::text[]
  a_par := string_to_array(trim(both ';' from ps_params::text),';'::text);
	
  a_point_name := string_to_array(r_if.point_name,'/');
  s_point_name := a_point_name[array_upper(a_point_name,1)]::varchar;
  
  s_point_name := coalesce(ps_xml_root||'/','')::varchar||s_point_name;
  
  
  
   a_id_del := string_to_array(s_id_del,';');
          for j in array_lower(a_id_del,1)..array_upper(a_id_del,1)
          loop
            s_script_del := replace(replace(s_script_del,'<id>','$1::numeric'),'<lpu>','$2::numeric');
            begin
              execute s_script_del using a_id_del[j],pn_lpu;
            exception when others then
              raise '%','Ошибка при удаление. - '||sqlerrm;
            end;
          end loop;  
		  
-----------------
Разбивка отчета на отдельные страницы 
    <style>
        .page-wrap {
            border-bottom: 1px dashed #777;
        }
    </style>
    <table>
        <tbody class="page">
            <tr>
                <td class="page-wrap">
                    <div style="height: 290mm;">
                        <component cmptype="SubForm" path="Reports/HospPlan/hosphistory_head"/>
                    </div>
                </td>
            </tr>
        </tbody>
        <tbody class="page">
            <tr>
                <td class="page-wrap" >
                    <div style="height: 290mm;">
                         <component cmptype="SubForm" path="Reports/HospPlan/outhost_stat_card_for_blank"/>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
-----------------



-----------------
Разрыв страницы после элемента
      @media print {
            .breackPage {
                page-break-after: always;
            }
            .page-wrap {
                border-bottom: 0!important;
                /* border-bottom: 1px dashed #777; */
            }
        }
-----------------

-----------------
Отчтуп от левого края
      margin-left: 15mm;
-----------------


определить запуск с мобильного приложения
<?
	function ExecModule(&$vars)
	{
        $mobile_agent_array = array('ipad', 'iphone', 'android', 'pocket', 'palm', 'windows ce', 'windowsce', 'cellphone', 'opera mobi', 'ipod', 'small', 'sharp', 'sonyericsson', 'symbian', 'opera mini', 'nokia', 'htc_', 'samsung', 'motorola', 'smartphone', 'blackberry', 'playstation portable', 'tablet browser');
        $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
        foreach ($mobile_agent_array as $value) {
            if (strpos($agent, $value) !== false){
                $vars['RESULT'] = 1;
                return true;
             }
        }
        $vars['RESULT'] = 0;
		return true;
	}
?>


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Определить  CSS для разных браузеров  https://task.bars-open.ru/issues/267228
https://1ps.ru/blog/sites/2019/chto-takoe-krossbrauzernost-sajtov/
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="hackBlock"></div>
 <style>
    /* только для Chrome выгрузки PDF*/
    @media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) {
        .hackBlock {
                width: 100px;
                height: 100px;
                border: 1px solid #fff;
                background: blue;
        }
    }
    /* только для FF*/
    @-moz-document url-prefix() {
        .hackBlock {
            width: 100px;
            height: 100px;
            border: 1px solid #000;
            background: red;
        }
    }

    @-ms-document url-prefix() {
        .hackBlock {
            width: 100px;
            height: 100px;
            border: 1px solid #000;
            background: red
        }
    }

    <svg class="hackBlock pageBreak" style="width:210mm; height:296.1mm; background-color:green;"  xmlns="http://www.w3.org/2000/svg" >
        <line x1="0mm" y1="0mm"   x2="210mm" y2="0mm"   stroke-width="1" stroke="black" />
        <line x1="210mm" y1="0mm" x2="210mm" y2="297mm" stroke-width="1" stroke="black" />
        <line x1="0mm" y1="297mm" x2="210mm" y2="297mm" stroke-width="1" stroke="black" />
        <line x1="0mm" y1="0mm"   x2="0mm"   y2="297mm" stroke-width="1" stroke="black" />
        <text y="30mm"  x="50mm" font-size="30">My SVG dfgsdfgsdfgsdfgdfgsdgsdfgsdfgsdgsdfg</text>
    </svg>
</style>
----------------------------------------------------------------------------------------------------------------------------------------
	Панель с надписью
        <fieldset>
            <legend>Результаты измерений</legend>

        </fieldset>
----------------------------------------------------------------------------------------------------------------------------------------
Вписать текст в  подчеркнутый бланк

   <style>
        .field_border {
            word-wrap:break-word;
            position:relative ;
        }

        .razVer {
           border-spacing: 10mm 0mm;
           border-collapse: separate;
        }
        .m_border {
            display: inline-block;
            white-space: nowrap;
            width: 100%;
            border-bottom: 1px solid black;
            min-height: 20px;
            overflow: hidden;
        }
    </style>


<table class="razVer">
    <tr style="width:100mm"  valign="top">
        <td >Расход медикаментов:</td>
        <td style="width: 100mm; " >
             <span class="m_border">222</span><br/>
             <span class="m_border"></span><br/>
             <span class="m_border"></span><br/>
             <span class="m_border"></span><br/>
             <span class="m_border"></span><br/>
             <span class="m_border"></span><br/>
             <span class="m_border"></span><br/>
             <span class="m_border"></span><br/>
             <cmpLabel caption="1111111111111--------------------------------------------------------------------------------------------------------------------------------------------------------1111111111-------------------------------------------------------------------------------------------------------------------------------------------------------"
                       class="field_border"
                       style="top:-45mm;line-height: 1.5; left:0mm; min-width:37mm;max-width:50mm;"/><br/>
        </td>
        <td style="width: 100mm; ">
             <span class="m_border">111</span><br/>
             <span class="m_border"></span><br/>
             <span class="m_border"></span><br/>
             <span class="m_border"></span><br/>
             <span class="m_border"></span><br/>
             <span class="m_border"></span><br/>
             <span class="m_border"></span><br/>
             <span class="m_border"></span><br/>
             <cmpLabel caption="222222222------------------------------------------------------------------------------------------------------------------------"
                       class="field_border"
                       style="top:-45mm;line-height: 1.5; left:0mm; min-width:37mm;max-width:50mm;"/><br/>
        </td>
    </tr>
</table>
----------------------------------------------------------------------------------------------------------------------------------------
Замена UnitEdit на ButtonEdit
-----------------------------
        Form.openPERSMEDCARD = function(){
            setVar('LOCATE',getValue('PERSMEDCARD'))
            openWindow({name:'UniversalComposition/UniversalComposition',unit:'PERSMEDCARD', composition:'BUTTON_EDIT_DEFAULT',show_buttons:true,
                vars:{'LPU':getVar('LPU')}
            },true)
            .addListener('onafterclose', function(){
                if(getVar('ModalResult') == 1){
                    setValue('PERSMEDCARD',getVar('return_id'))
                    setCaption('PERSMEDCARD',getVar('return'))
                }
                setVar('LOCATE',null)
            });
        }
                        <td>
                            <component cmptype="label" caption="Номер карты пациента:"/>
                        </td>
                        <td>
                            <component cmptype="UnitEdit" name="PERSMEDCARD" unit="PERSMEDCARD" composition="BUTTON_EDIT_DEFAULT" width="100%" emptyMask="true" onchange="base().PatientSelect()">
                                <component cmptype="Button" type="micro" title="Редактировать карту" background="Icons/person_edit" onclick="base().openPersMedCard();"/>
                            </component>
                        
						    <component cmptype="ButtonEdit" name="PERSMEDCARD" unit="PERSMEDCARD" buttononclick="base().openPERSMEDCARD();" width="100%" emptyMask="true" readonly="true">
                              <component cmptype="Button" type="micro" title="Редактировать карту" background="Icons/person_edit" onclick="base().openPersMedCard();"/>
                            </component>
                        </td>
						
----------------------------------------------------------------------------------------------------------------------------------------
Найти элемент на форме через селектор D3
-----------------------------
                  var btnsList2 = getDomBy(getControl('MainGrid'), '.statgrid_parambuttom').previousSibling.previousSibling;
                  console.log(btnsList2)
                  var btnsList3 = getControl('MainGrid').querySelector('[cont=statgridcaptioncontent]');
                  console.log(btnsList3)
                  var btnsList = getDomBy(getControl('MainGrid'), '.statgrid_parambuttom').previousSibling.previousSibling;
                  btnsList.innerHTML ='Всего: '+getDataSet('DsMain').data.length+' записей.';

-----------------------------
@if(:ctrlDateOfDiagnosis && strlen(:ctrlDateOfDiagnosis)){

@}
-----------------------------

  var cmp_array = getControl('CIRCUMSTANCES').querySelectorAll('.edit-textarea')[0];
  var cmp_array = getControlByName('CIRCUMSTANCES').querySelectorAll('[cmptype="ComboBox"],[cmptype="RadioGroup"],[cmptype="CheckBox"],[cmptype="Edit"],[cmptype="ButtonEdit"],[cmptype="DateEdit"]');



        Form.onShowIntroResPart = function() {
            document.querySelectorAll('.wrapper .p-rel #vall').forEach(function(elem) {
                elem.blur();
            });
            var cmp_array = getControl('CIRCUMSTANCES').querySelectorAll('.edit-textarea')[0];
            console.log( cmp_array );
            getControl('CIRCUMSTANCES').querySelectorAll('.edit-textarea')[0].style.height="100%";
            // console.log( document.querySelectorAll('.edit-textarea') );
        };
		
		
	            getControl('CIRCUMSTANCES').querySelectorAll('.edit-textarea')[0].style.height="100%";
	
		tab2
		
		 onclick="Form.PageControlCtrl_showTab(this);" >
		 
		 
		 
		 
	   <div cmptype="tmp" name="tab2" style="display:none">
            <cmpFillingTextArea name="NORMATIVE" fillingdataset="dsNormativeDocs" showfield="STR_VALUE" size="20"  calc_height="parent"  returnfield="STR_VALUE" width="100%" enabled="false"/>
            <!--div cmptype="Base" name="NORMATIVE_BLOCK_OVERFLOW" class="overflow"/-->
       </div>
       <div cmptype="tmp" name="tab3" style="display:none">
            <!--div cmptype="Base" name="RESEARCH_PART_BLOCK_OVERFLOW"  class="overflow"/-->
            <cmpFillingTextArea name="RESEARCH_PART" fillingdataset="dsFmeResearch" showfield="STR_VALUE" size="20" returnfield="STR_VALUE" width="100%"  enabled="false"/>
       </div>


		 http://172.31.36.190:9090/MEDDEV-15733/d3/getform.php?cache_enabled=0&session_cache=1&Form=
		 
		 
		 
		             ['NORMATIVE_BLOCK_OVERFLOW', 'RESEARCH_PART_BLOCK_OVERFLOW'].forEach(function(elem) {
                if (getVar('IS_EDIT')) {
                    getControl(elem).classList.add('d-none');
                } else {
                    getControl(elem).classList.remove('d-none');
                }
            });
			
			
		 FME\ExpertCase\expert_performer
		 &cache=c4a7faea8a26e37a8268175ed017be66e
		if (strtolower($this->enabled) == 'false') {
            $this->class = 'input-ctrl disable';
            $this->readonly = 'true';
        }
		
		 setEnabled(getControl(popup), getDataSet('DsExpJournalReg').data.length !== 0);
		 calc_height="parent" 
		 
		<cmpPageControl name="PageCtrl" style="height:90%;width:100%" >
            <cmpTabSheet caption="Обстоятельства дела:" >
                 <cmpTextArea name="CIRCUMSTANCES" rows="13" enabled="false"/>
            </cmpTabSheet>
            <cmpTabSheet caption="Вопросы, поставленные на разрешение эксперта:" >
                 <cmpTextArea name="QUESTIONS" rows="13" enabled="false"/>
            </cmpTabSheet>
            <cmpTabSheet caption="Литературы:" >
                <cmpFillingTextArea name="NORMATIVE" fillingdataset="dsNormativeDocs" showfield="STR_VALUE" size="8"   returnfield="STR_VALUE" width="100%"/>
                <div cmptype="Base" name="NORMATIVE_BLOCK_OVERFLOW" class="overflow"/>
            </cmpTabSheet>
            <cmpTabSheet caption="Исследовательская часть:" >
                <cmpEdit name="CHEMICAL_RESEARCH_TEXT" width="100%" placeholder="ручной ввод" enabled="false"/>
            </cmpTabSheet>        
        </cmpPageControl>
		
		
		https://jira-medmis.bars.group/browse/MEDDEV-15737
		https://jira-medmis.bars.group/browse/MEDDEV-15733
