如何获得摘要“咨询”的倍数

how to get a multiple of summary " Consultations "

我尝试提取所有“咨询”和在文本文档 GoogleDocs 中输入的日期 并将它们恢复到日志文件中

我使用正则表达式:CONSULTATION .... \ / .. \ / .... 工作正常

像这样

https://regex101.com/r/oI5eG4/5

我的脚本

function findNotesContactAjoutText() {

  var doc = DocumentApp.getActiveDocument();
  var bodyElement = DocumentApp.getActiveDocument().getBody();
  var search = "An"
  var searchResult = bodyElement.findText(search);


                /////      Recherche du "Nom Prenom" sur l' Ordonnace      ////

  var regexp = /[^0-9]*/g ;// extrait la chaine de caractère avant la chaine numérique
  var doc = DocumentApp.getActiveDocument().getText();
  var result = regexp.exec(doc);
  var regexp = /[^a-z\s-]+[A-Za-z\s-]+/g; // extrait les espaces devant et derriere Nom Prenom  Demande la Présence de XX Ans (caché en blanc dans l'ordo paramédical)

   var NomPrenom = regexp.exec(result);


//------getContactsWithBirthdays();

   var contacts = ContactsApp.getContactsByName(NomPrenom);
  //Logger.log("Before: " + contacts.length);

  for (var i = contacts.length - 1; i >= 0; i--) {
    if (contacts[i].getDates(ContactsApp.Field.BIRTHDAY).length > 0) {
      Logger.log(contacts[i].getDates(ContactsApp.Field.BIRTHDAY)[0].getYear());
       var birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];
       var day = (birthday.getDay());
       var month = (birthday.getMonth());
       var year = (birthday.getYear());
       var Notes = (contacts[0].getNotes());
       var regexp = /CONSULTATION+.{1,12}/g ;// extrait la 1 ERE CONSULTATION du Patient                          WORK FINE ONLY THE FIRST
       var regexp = /CONSULTATION.*?$/gm ;// extrait toutes les CONSULTATIONS du Patient                                   DO NOT WORK
       var Notes = regexp.exec(Notes);

    }


  while (searchResult !== null) {
    var thisElement = searchResult.getElement();
    var thisElementText = thisElement.asText();
    var matchString = thisElementText.getText().substring(searchResult.getStartOffset(), searchResult.getEndOffsetInclusive()+1);

    Logger.log(matchString);
       thisElementText.setText(age+" Ans "+ "\n" + Notes );   //Affiche Notes         //I WANT ALL CONTACT CONSULTATIONS 

// search for next match
    searchResult = bodyElement.findText(search, searchResult);
}

}

  DocumentApp.getUi().showSidebar(
      HtmlService
          .createHtmlOutput (Notes)
          .setTitle('Notes Patient')
          .setWidth(350 /* pixels */));
}

名字 名字 09/12/1970 1840042088011 07/10/2014

ATCD:糖尿病 2011 6 和 7

家庭:FCV0

烟草:00

疫苗:REVAXIS 2014

监控:

预防:测试

治疗:(停滞 3 片/天)+ 二甲双胍 850 3 片 #

咨询中C02/03/2015

头孢泊肟 2 片早晚 5 天 PREDNISOLONE 20 早上 2 片,连续 4 天 RHINOFLUIMUCIL 每天 3 次,持续 7 天 DAFALGAN 1G 1 cp 3次/d 3盒 特比萘芬 1 片/天

TTT

咨询中C01/10/2014

头孢泊肟 2 片早晚 5 天 PREDNISOLONE 20 早上 2 片,连续 4 天 RHINOFLUIMUCIL 每天 3 次,持续 7 天 DAFALGAN 1G 1 cp 3次/d 3盒

TTT

咨询中C21/05/2012

头孢泊肟 2 片早晚 5 天 PREDNISOLONE 20 早上 2 片,连续 4 天 RHINOFLUIMUCIL 每天 3 次,持续 7 天 DAFALGAN 1G 1 cp 3次/d 3盒

TTT

我要获取

咨询中C02/03/2015 咨询中C01/10/2014 正在咨询 C21/05/2012

GAS/JS 解决方案:

var log = '', reg = /(CONSULTATION C[\d\/]*)/g, nn, str = theWholeString;
while( nn = reg.exec(str ) ){ log += nn[0] + ' '; } Logger.log(log);