Examples of MedicationEventMention


Examples of org.apache.ctakes.typesystem.type.textsem.MedicationEventMention

  }

  return span;
}
  private void findFSMInRange(JCas jcas, int begin, int end) throws Exception {
    MedicationEventMention ne = null;
    WordToken we = null;
    // grab iterator over tokens within this chunk
    Iterator btaItr = FSUtil.getAnnotationsInSpanIterator(jcas,
        BaseToken.type, begin,
        end+1);
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.textsem.MedicationEventMention

        }
      }

    } else if (elementType == MedicationEventMention.type) {
      while (neItr.hasNext()) {
        MedicationEventMention nea = (MedicationEventMention) neItr.next();
        if(nea.getTypeID()==1 || nea.getTypeID()==0) {
          lastLocation[0]= nea.getBegin();
          lastLocation[1] = nea.getEnd();
          if ((counter == 0 || lastLocation[0] != location[counter-1][0]) && (nea.getBegin()>=begin && nea.getEnd() <= end)) {
            location[counter][0]= lastLocation[0];
            location[counter][1]= lastLocation[1];
            counter++;
          }

        }
      }
    } else if (elementType == PunctuationToken.type) {
      while (neItr.hasNext()) {
        boolean foundPair = false;
        PunctuationToken nea = (PunctuationToken) neItr.next();
        if (nea.getCoveredText().compareTo("(")==0)
          lastLocation[0] = nea.getBegin();
        else if (nea.getCoveredText().compareTo(")")==0) {
          lastLocation[1] = nea.getEnd();
          foundPair = true;
        }
        if (nea.getBegin()>=begin && nea.getEnd() <= end && foundPair && (counter == || (counter> 0 && lastLocation[0] !=  location[counter - 1][0]))) {
          location[counter][0]= lastLocation[0];
          location[counter][1]= lastLocation[1];
          counter++;
        }
      }
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.textsem.MedicationEventMention

    Iterator neItr = FSUtil.getAnnotationsIteratorInSpan(jcas, MedicationEventMention.type, begin, end);

    int numDrugs=0;
    int beginOffset=0;
    while (neItr.hasNext()) {
      MedicationEventMention nea = (MedicationEventMention) neItr.next();
     
      if((nea.getTypeID()==|| nea.getTypeID()==0) && beginOffset != nea.getBegin())    
        numDrugs++;
      beginOffset = nea.getBegin();
    }
    if(numDrugs>1) return true;
    else return false;        
  }
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.textsem.MedicationEventMention

    if (drugSpanLength > 1)
      for (int j = 0; j < drugSpanLength; j++) {
        Iterator drugListItr = FSUtil.getAnnotationsIteratorInSpan(jcas, MedicationEventMention.type, drugSpan[j][0], drugSpan[j][1]+1);
        Iterator drugListItrNext = FSUtil.getAnnotationsIteratorInSpan(jcas, MedicationEventMention.type, drugSpan[j+1][0], drugSpan[j+1][1]+1);
        if (drugListItr.hasNext()) {
          MedicationEventMention nea = (MedicationEventMention) drugListItr.next();
          drugSpanArray[j][0] = nea.getBegin();
          boolean patternFound = false;
          boolean hasNext = true;
          boolean isPairedDrug = false;
          boolean usingLeftParenthesisExclusive = false;
          boolean usingLeftParenthesisInclusive = false;
          boolean usingRightParenthesisInclusive = false;
          int endRange = 0;
          int countMultiplePre = 0;
          char highestInRange = ' ';
          char lowestPositiveInRange = ' ';
          char lowestInRange = ' ';
          int highestValueInRange = 0;
          int lowestValueInRange = 0;
          int lowestPositiveValueInRange = endPhrase;
          if (drugListItrNext.hasNext()) {
            MedicationEventMention neaNext = (MedicationEventMention) drugListItrNext.next();
            endPhrase = neaNext.getBegin();
          } else {
            hasNext = false;
            endPhrase = senSpan[1];
          }
          int [] testForMultipleElementsInRange = {0,0};
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.textsem.MedicationEventMention

      }

    } else if (elementType == MedicationEventMention.type) {
      int holdEndElement = 0;
      while (neItr.hasNext()) {
        MedicationEventMention nea = (MedicationEventMention) neItr.next();
        if(nea.getTypeID()==1 || nea.getTypeID()==0) {
          lastLocation[0]= nea.getBegin();
          lastLocation[1] = nea.getEnd();
          if ((counter == 0 || lastLocation[0] != location[counter-1][0]) && (nea.getBegin()>=begin && nea.getEnd() <= end)) {
            location[counter][0]= lastLocation[0];
            holdEndElement = location[counter][1] = lastLocation[1];
            counter++;
          } else if (counter > 0 && holdEndElement > lastLocation[1]) {
            holdEndElement = location[counter-1][1] = lastLocation[1];
          }

        }
      }
    } else if (elementType == PunctuationToken.type) {
      while (neItr.hasNext()) {
        int holdBeginElement = 0;
        boolean foundPair = false;
        PunctuationToken nea = (PunctuationToken) neItr.next();
        if (nea.getCoveredText().compareTo("(")==0 || nea.getCoveredText().compareTo("[")==0)
          lastLocation[0] = nea.getBegin();
        else if (nea.getCoveredText().compareTo(")")==0 || nea.getCoveredText().compareTo("]")==0) {
          lastLocation[1] = nea.getEnd();
          foundPair = true;
        }
        if (holdBeginElement < nea.getBegin() && nea.getBegin()>=begin && nea.getEnd() <= end && foundPair) {
          location[counter][0]= lastLocation[0];
          location[counter][1]= lastLocation[1];
          counter++;
        }
      }
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.textsem.MedicationEventMention

      }
     
            Iterator nerItr = indexes.getAnnotationIndex(MedicationEventMention.type).iterator();
      while (nerItr.hasNext())
      {
        MedicationEventMention neAnnot = (MedicationEventMention) nerItr.next();
//System.err.println("DrugNE :"+neAnnot.getCoveredText());       
        gotDup = false;

        // assign segment ID
        Iterator segItr = segmentSet.iterator();
        while (segItr.hasNext())
        {
          Segment seg = (Segment) segItr.next();
          if ((keepTrackOfDupBegin == neAnnot.getBegin()) && (keepTrackOfDupEnd == neAnnot.getEnd()))
          {
            gotDup = true;
          }

          if ((neAnnot.getBegin() >= seg.getBegin())
              && (neAnnot.getEnd() <= seg.getEnd()) && !gotDup) {

            // found segment for this NE
            String segmentID = seg.getId();
         
            if (iv_medicalSections.contains(segmentID)
                || !iv_useCurrentMedsSectionOnly.booleanValue()) {

              if (!gotDup) {
                keepTrackOfDupBegin = neAnnot.getBegin();
                keepTrackOfDupEnd = neAnnot.getEnd();



                Date localDate = neAnnot.getStartDate();//.getStartDate();
                String chunk = null;

                boolean foundChunk = false;
                Iterator findChunk = indexes
                .getAnnotationIndex(
                    ChunkAnnotation.type)
                    .iterator();

                try {
                  while (findChunk.hasNext() && !foundChunk)
                  {
                      ChunkAnnotation ca = (ChunkAnnotation) findChunk.next();
                    if (neAnnot.getBegin() >= ca.getBegin()
                        && neAnnot.getEnd() <= ca
                        .getEnd()) {
                      chunk = ca.getCoveredText()
                      .replace('\n', ' ')
                      .replace(',', ';');
                      foundChunk = true;
                    }
                  }
                } catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
                String containedInSubSection = segmentID;
                Iterator subSectionItr = indexes.getAnnotationIndex(
                    SubSectionAnnotation.type).iterator();
                while (subSectionItr.hasNext())
                {
                    SubSectionAnnotation ssAnnot = (SubSectionAnnotation) subSectionItr.next();
                    if (ssAnnot.getSubSectionBodyBegin() <= neAnnot.getBegin() && ssAnnot.getSubSectionBodyEnd() >= neAnnot.getEnd())
                    {
                  Iterator textSpanInSs = FSUtil.getAnnotationsIteratorInSpan(jcas, WordToken.type, ssAnnot.getSubSectionHeaderBegin(), ssAnnot.getSubSectionHeaderEnd());
                  String subSectionHeaderName = "";
                   
                  while (textSpanInSs.hasNext())
                  {
                      WordToken wta = (WordToken) textSpanInSs.next();
                      subSectionHeaderName = subSectionHeaderName + " " + wta.getCoveredText();
                  }
                  containedInSubSection = containedInSubSection+"|"+subSectionHeaderName+"|"+ssAnnot.getStatus();
                    }
                }
                gotMeds = true;
                trackMedOccur++;

                Calendar calendar = Calendar.getInstance();

                SimpleDateFormat format = new SimpleDateFormat("MM'/'dd'/'yyyy");

                if(vRevDate != null && vRevDate.length() > 0)
                    calendar.setTimeInMillis(new Long(vRevDate).longValue());
                else if(vNoteDate != null && vNoteDate.length() > 0)
                    calendar.setTimeInMillis(new Long(vNoteDate).longValue());
               
                String globalDate = format.format(calendar.getTime());
//                if (localDate == null
//                    || localDate.length() < 1) {
//                  localDate = globalDate;
//                }
  //              Iterator neItr = FSUtil.getAnnotationsIteratorInSpan(jcas, IdentifiedAnnotation.type, neAnnot.getBegin(), neAnnot.getEnd()+1);
                String neCui = "n/a";
                String status = "n/a";
                String rxNormCui = "n/a";

                FSArray ocArr = neAnnot.getOntologyConceptArr();
                if (ocArr != null)
                {
                  for (int i = 0; i < ocArr.size(); i++)
                  {
                    OntologyConcept oc = (OntologyConcept) ocArr.get(i);
                    neCui = oc.getCode();
                    rxNormCui = oc.getOui();
                  }
                }

                MedicationStrength strengthTerm = neAnnot.getMedicationStrength();//getStrength();
                String strengthTermString = "null";
                if (strengthTerm != null)
                  strengthTermString = strengthTerm.getNumber()+ " " +strengthTerm.getUnit();
                String medicationDosageString = "null";
                if (neAnnot.getMedicationDosage() != null && neAnnot.getMedicationDosage().getValue() != null)
                  medicationDosageString = neAnnot.getMedicationDosage().getValue();
                String medicationFrequencyNumber = "null";
                if (neAnnot.getMedicationFrequency() != null && neAnnot.getMedicationFrequency().getNumber() != null)
                  medicationFrequencyNumber = neAnnot.getMedicationFrequency().getNumber()+" "+neAnnot.getMedicationFrequency().getUnit();
                String duration = "null";
                if (neAnnot.getMedicationDuration() != null && neAnnot.getMedicationDuration().getValue() != null)
                  duration = neAnnot.getMedicationDuration().getValue();

                String route = "null";
                if (neAnnot.getMedicationRoute() != null && neAnnot.getMedicationRoute().getValue() != null)
                  route = neAnnot.getMedicationRoute().getValue();
                String form = "null";
                if (neAnnot.getMedicationForm() != null && neAnnot.getMedicationForm().getValue() != null)
                  form = neAnnot.getMedicationForm().getValue();
                String changeStatus = "null";
                if (neAnnot.getMedicationStatusChange() != null && neAnnot.getMedicationStatusChange().getValue() != null )
                  changeStatus = neAnnot.getMedicationStatusChange().getValue();
                medInfo = clinicNumber + "," +neAnnot.getCoveredText()  + "," + rxNormCui
                + ",\"" + neAnnot.getStartDate() + "\","
                + globalDate + "," + medicationDosageString + "," +strengthTermString + ","
                + medicationFrequencyNumber + "," +  duration + "," + route + ","
                +  form + "," + status + ","
                + changeStatus + "," +neAnnot.getConfidence() + "," +containedInSubSection
                + "," +docLinkId+"_"+docRevision+","+chunk; 
                store(fileForIO, medInfo);
              }
            }
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.