Examples of MedicationMention


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

                  }

                  IdentifiedAnnotation neAnnot;
                  final int conceptKey = conceptEntry.getKey();
                  if ( conceptKey == CONST.NE_TYPE_ID_DRUG ) {
                     neAnnot = new MedicationMention( jcas );
                  } else if ( conceptKey == CONST.NE_TYPE_ID_ANATOMICAL_SITE ) {
                      neAnnot = new AnatomicalSiteMention( jcas );
                  } else if ( conceptKey == CONST.NE_TYPE_ID_DISORDER ) {
                      neAnnot = new DiseaseDisorderMention( jcas );
                  } else if ( conceptKey == CONST.NE_TYPE_ID_FINDING ) {
View Full Code Here

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

               final MetaDataHit mdh = lookupHit.getDictMetaDataHit();
               final String code = mdh.getMetaFieldValue( CODE_MF );
               validCodes.add( code );
            }
            final FSArray ocArr = createOntologyConceptArr( jcas, validCodes );
            IdentifiedAnnotation neAnnot = new MedicationMention( jcas ); // medication NEs are EventMention
            neAnnot.setTypeID( CONST.NE_TYPE_ID_DRUG );
            neAnnot.setBegin( neBegin );
            neAnnot.setEnd( neEnd );
            neAnnot.setDiscoveryTechnique( CONST.NE_DISCOVERY_TECH_DICT_LOOKUP );
            neAnnot.setOntologyConceptArr( ocArr );
            neAnnot.addToIndexes();
         } else {
            iv_logger.warn( "Filtered out: " + text );
         }
      }
   }
View Full Code Here

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

      mention.setHistoryOf(original.getHistoryOf());
     

      if (original instanceof MedicationEventMention) {
        MedicationEventMention medEventMention = (MedicationEventMention) original;
        MedicationMention medMention = (MedicationMention) mention;
        JCas jcas = medMention.getCAS().getJCas();
        if (medEventMention.getStartDate()!=null) {
          Date date = medEventMention.getStartDate();
          TimeMention timeMention = new TimeMention(jcas);
          timeMention.setDate(date);
          medMention.setStartDate(timeMention);
        }
        if (medEventMention.getEndDate()!=null) {
          Date date = medEventMention.getEndDate();
          TimeMention timeMention = new TimeMention(jcas);
          timeMention.setDate(date);
          medMention.setEndDate(timeMention);
        }
        if (medEventMention.getMedicationDosage()!=null) {
          MedicationDosage dosage = medEventMention.getMedicationDosage();
          MedicationDosageModifier medDosageModifier = new MedicationDosageModifier(jcas);
          medDosageModifier.setNormalizedForm(dosage);
          medDosageModifier.setCategory(dosage.getValue());
          medMention.setMedicationDosage(medDosageModifier);
         
        }
        if (medEventMention.getMedicationDuration()!=null) {
          MedicationDuration duration = medEventMention.getMedicationDuration();
          MedicationDurationModifier medDurationModifier = new MedicationDurationModifier(jcas);
          medDurationModifier.setNormalizedForm(duration);
          medDurationModifier.setCategory(duration.getValue());
          medMention.setMedicationDuration(medDurationModifier);
        }
        if (medEventMention.getMedicationForm()!=null) {
          MedicationForm form = medEventMention.getMedicationForm();
          MedicationFormModifier medFormModifier = new MedicationFormModifier(jcas);
          medFormModifier.setNormalizedForm(form);
          medFormModifier.setCategory(form.getValue());
          medMention.setMedicationForm(medFormModifier);
        }
        if (medEventMention.getMedicationFrequency()!=null) {
          MedicationFrequency frequency = medEventMention.getMedicationFrequency();
          MedicationFrequencyModifier medFrequencyModifier = new MedicationFrequencyModifier(jcas);
          medFrequencyModifier.setNormalizedForm(frequency);
          medFrequencyModifier.setCategory(frequency.getNumber() + frequency.getUnit());
          medMention.setMedicationFrequency(medFrequencyModifier);
        }
        if (medEventMention.getMedicationRoute()!=null) {
          MedicationRoute route = medEventMention.getMedicationRoute();
          MedicationRouteModifier medRouteModifier = new MedicationRouteModifier(jcas);
          medRouteModifier.setNormalizedForm(route);
          medRouteModifier.setCategory(route.getValue());
          medMention.setMedicationRoute(medRouteModifier);
        }
        if (medEventMention.getMedicationStatusChange()!=null) {
          MedicationStatusChange statusChange = medEventMention.getMedicationStatusChange();
          MedicationStatusChangeModifier medStatusChangeModifier = new MedicationStatusChangeModifier(jcas);
          medStatusChangeModifier.setNormalizedForm(statusChange);
          medStatusChangeModifier.setCategory(statusChange.getValue());
          medMention.setMedicationStatusChange(medStatusChangeModifier);
        }
        if (medEventMention.getMedicationStrength()!=null) {
          MedicationStrength strength = medEventMention.getMedicationStrength();
          MedicationStrengthModifier medStrengthModifier = new MedicationStrengthModifier(jcas);
          medStrengthModifier.setNormalizedForm(strength);
          medStrengthModifier.setCategory(strength.getNumber() + strength.getUnit());
          medMention.setMedicationStrength(medStrengthModifier);
        }
       
        // TODO handle MedicationAllergyModifier here when / if the value is set/disovered some day
       
      }
View Full Code Here

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

          mapToMentions.put(original, original); // with 3.1 don't need to map to proper mention type, already creating as proper type
        } else if (t==CONST.NE_TYPE_ID_DRUG) {
          // Drug NER (ctakes-drug-ner) was creating MedicationEventMention,
          // if found, create MedicationMention with its attributes based on the MedicationEventMention attributes
          if (original instanceof MedicationEventMention) {
            mention = new MedicationMention(jcas);
            mapToMentions.put(original, mention);
            setAttributesFromOriginal(mention, original);
            annotationsToRemoveFromCas.add(original);
          }
View Full Code Here

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

            }
         }
        
         IdentifiedAnnotation neAnnot = new IdentifiedAnnotation(jcas);
         if ( typeId == CONST.NE_TYPE_ID_DRUG ) {
            neAnnot = new MedicationMention( jcas );
         } else if ( typeId == CONST.NE_TYPE_ID_ANATOMICAL_SITE ) {
             neAnnot = new AnatomicalSiteMention( jcas );
         } else if ( typeId == CONST.NE_TYPE_ID_DISORDER ) {
             neAnnot = new DiseaseDisorderMention( jcas );
         } else if ( typeId == CONST.NE_TYPE_ID_FINDING ) {
View Full Code Here

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

            labValue,
            ResultOfTextRelation.class,
            LabValueModifier.class));

      } else if ("Medications/Drugs".equals(annotation.type)) {
        MedicationMention mention = new MedicationMention(jCas, coveringSpan.begin, coveringSpan.end);
        addIdentifiedAnnotationFeatures(
            annotation,
            mention,
            jCas,
            CONST.NE_TYPE_ID_DRUG,
            stringSlots,
            booleanSlots,
            annotationSlots,
            idAnnotationMap,
            delayedFeatures);
        KnowtatorAnnotation allergy = annotationSlots.remove("allergy_indicator");
        delayedFeatures.add(new DelayedFeature(mention, "medicationAllergy", allergy));
        KnowtatorAnnotation changeStatus = annotationSlots.remove("change_status_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationStatusChange", changeStatus));
        KnowtatorAnnotation dosage = annotationSlots.remove("dosage_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationDosage", dosage));
        KnowtatorAnnotation duration = annotationSlots.remove("duration_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationDuration", duration));
        KnowtatorAnnotation form = annotationSlots.remove("form_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationForm", form));
        KnowtatorAnnotation frequency = annotationSlots.remove("frequency_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationFrequency", frequency));
        KnowtatorAnnotation route = annotationSlots.remove("route_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationRoute", route));
        KnowtatorAnnotation startDate = annotationSlots.remove("start_date");
        delayedFeatures.add(new DelayedFeature(mention, "startDate", startDate));
        KnowtatorAnnotation strength = annotationSlots.remove("strength_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationStrength", strength));

      } else if ("Phenomena".equals(annotation.type)) {
        EventMention mention = new EventMention(jCas, coveringSpan.begin, coveringSpan.end);
        addIdentifiedAnnotationFeatures(
            annotation,
            mention,
            jCas,
            CONST.NE_TYPE_ID_PHENOMENA,
            stringSlots,
            booleanSlots,
            annotationSlots,
            idAnnotationMap,
            delayedFeatures);

      } else if ("Procedure".equals(annotation.type)) {
        ProcedureMention mention = new ProcedureMention(jCas, coveringSpan.begin, coveringSpan.end);
        addIdentifiedAnnotationFeatures(
            annotation,
            mention,
            jCas,
            CONST.NE_TYPE_ID_PROCEDURE,
            stringSlots,
            booleanSlots,
            annotationSlots,
            idAnnotationMap,
            delayedFeatures);
        KnowtatorAnnotation bodyLaterality = annotationSlots.remove("body_laterality");
        delayedFeatures.add(new DelayedFeature(mention, "bodyLaterality", bodyLaterality));
        KnowtatorAnnotation bodyLocation = annotationSlots.remove("body_location");
        delayedFeatures.add(DelayedRelationFeature.forArg1(
            mention,
            "bodyLocation",
            bodyLocation,
            LocationOfTextRelation.class,
            AnatomicalSiteMention.class));
        KnowtatorAnnotation bodySide = annotationSlots.remove("body_side");
        delayedFeatures.add(new DelayedFeature(mention, "bodySide", bodySide));
        KnowtatorAnnotation device = annotationSlots.remove("device");
        delayedFeatures.add(new DelayedFeature(mention, "procedureDevice", device));
        KnowtatorAnnotation method = annotationSlots.remove("method");
        delayedFeatures.add(new DelayedFeature(mention, "method", method));

      } else if ("Sign_symptom".equals(annotation.type)) {
        SignSymptomMention mention = new SignSymptomMention(jCas, coveringSpan.begin, coveringSpan.end);
        addIdentifiedAnnotationFeatures(
            annotation,
            mention,
            jCas,
            CONST.NE_TYPE_ID_FINDING,
            stringSlots,
            booleanSlots,
            annotationSlots,
            idAnnotationMap,
            delayedFeatures);
        KnowtatorAnnotation alleviatingFactor = annotationSlots.remove("alleviating_factor");
        delayedFeatures.add(DelayedRelationFeature.forArg2(
            mention,
            "alleviatingFactor",
            alleviatingFactor,
            ManagesTreatsTextRelation.class,
            ProcedureMention.class));
        KnowtatorAnnotation bodyLaterality = annotationSlots.remove("body_laterality");
        delayedFeatures.add(new DelayedFeature(mention, "bodyLaterality", bodyLaterality));
        KnowtatorAnnotation bodyLocation = annotationSlots.remove("body_location");
        delayedFeatures.add(DelayedRelationFeature.forArg1(
            mention,
            "bodyLocation",
            bodyLocation,
            LocationOfTextRelation.class,
            AnatomicalSiteMention.class));
        KnowtatorAnnotation bodySide = annotationSlots.remove("body_side");
        delayedFeatures.add(new DelayedFeature(mention, "bodySide", bodySide));
        KnowtatorAnnotation course = annotationSlots.remove("course");
        delayedFeatures.add(DelayedRelationFeature.forArg1(
            mention,
            "course",
            course,
            DegreeOfTextRelation.class,
            CourseModifier.class));
        KnowtatorAnnotation exacerbatingFactor = annotationSlots.remove("exacerbating_factor");
        delayedFeatures.add(DelayedRelationFeature.forArg2(
            mention,
            "exacerbatingFactor",
            exacerbatingFactor,
            ComplicatesDisruptsTextRelation.class,
            EventMention.class));
        KnowtatorAnnotation severity = annotationSlots.remove("severity");
        delayedFeatures.add(DelayedRelationFeature.forArg1(
            mention,
            "severity",
            severity,
            DegreeOfTextRelation.class,
            SeverityModifier.class));

      } else if ("EVENT".equals(annotation.type)) {

        // collect the event properties (setting defaults as necessary)
        EventProperties eventProperties = new EventProperties(jCas);
        eventProperties.setCategory(stringSlots.remove("type"));
        if (eventProperties.getCategory() == null) {
          eventProperties.setCategory("N/A");
        }
        eventProperties.setContextualModality(stringSlots.remove("contextualmoduality"));
        if (eventProperties.getContextualModality() == null) {
          eventProperties.setContextualModality("ACTUAL");
        }
        eventProperties.setContextualAspect(stringSlots.remove("contextualaspect"));
        if (eventProperties.getContextualAspect() == null) {
          eventProperties.setContextualAspect("N/A");
        }
        eventProperties.setDegree(stringSlots.remove("degree"));
        if (eventProperties.getDegree() == null) {
          eventProperties.setDegree("N/A");
        }
        eventProperties.setDocTimeRel(stringSlots.remove("DocTimeRel"));
        if (eventProperties.getDocTimeRel() == null) {
          LOGGER.warn(String.format(
              "assuming docTimeRel=OVERLAP for annotation with id \"%s\"",
              annotation.id));
          eventProperties.setDocTimeRel("OVERLAP");
        }
        eventProperties.setPermanence(stringSlots.remove("permanence"));
        if (eventProperties.getPermanence() == null) {
          eventProperties.setPermanence("UNDETERMINED");
        }
        String polarityStr = stringSlots.remove("polarity");
        int polarity;
        if (polarityStr == null || polarityStr.equals("POS")) {
          polarity = CONST.NE_POLARITY_NEGATION_ABSENT;
        } else if (polarityStr.equals("NEG")) {
          polarity = CONST.NE_POLARITY_NEGATION_PRESENT;
        } else {
          throw new IllegalArgumentException("Invalid polarity: " + polarityStr);
        }
        eventProperties.setPolarity(polarity);

        // create the event object
        Event event = new Event(jCas);
        event.setConfidence(1.0f);
        event.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);

        // create the event mention
        EventMention eventMention = new EventMention(jCas, coveringSpan.begin, coveringSpan.end);
        eventMention.setConfidence(1.0f);
        eventMention.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);

        // add the links between event, mention and properties
        event.setProperties(eventProperties);
        event.setMentions(new FSArray(jCas, 1));
        event.setMentions(0, eventMention);
        eventMention.setEvent(event);

        // add the annotations to the indexes
        eventProperties.addToIndexes();
        event.addToIndexes();
        eventMention.addToIndexes();
        idAnnotationMap.put(annotation.id, eventMention);

      } else if ("DOCTIME".equals(annotation.type)) {
        TimeMention timeMention = new TimeMention(jCas, coveringSpan.begin, coveringSpan.end);
        timeMention.setTimeClass(annotation.type);
        timeMention.addToIndexes();
        idAnnotationMap.put(annotation.id, timeMention);

      } else if ("SECTIONTIME".equals(annotation.type)) {
        TimeMention timeMention = new TimeMention(jCas, coveringSpan.begin, coveringSpan.end);
        timeMention.setTimeClass(annotation.type);
        timeMention.addToIndexes();
        idAnnotationMap.put(annotation.id, timeMention);

      } else if ("TIMEX3".equals(annotation.type)) {
        String timexClass = stringSlots.remove("class");
        TimeMention timeMention = new TimeMention(jCas, coveringSpan.begin, coveringSpan.end);
        timeMention.setTimeClass(timexClass);
        timeMention.addToIndexes();
        idAnnotationMap.put(annotation.id, timeMention);
       
      } else if ("conditional_class".equals(annotation.type)) {
        Boolean value = booleanSlots.remove("conditional_normalization");
        ConditionalModifier modifier = new ConditionalModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setConditional(value == null ? false : value);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("generic_class".equals(annotation.type)) {
        Boolean value = booleanSlots.remove("generic_normalization");
        GenericModifier modifier = new GenericModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setGeneric(value == null ? false : value);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("negation_indicator_class".equals(annotation.type)) {
        String value = stringSlots.remove("negation_indicator_normalization");
        PolarityModifier modifier = new PolarityModifier(jCas, coveringSpan.begin, coveringSpan.end);
        if (value == null) {
          LOGGER.warn(String.format(
              "assuming NE_POLARITY_NEGATION_PRESENT for %s with id \"%s\"",
              format(modifier),
              annotation.id));
          modifier.setPolarity(CONST.NE_POLARITY_NEGATION_PRESENT);
        } else if (value.equals("negation_absent")) {
          modifier.setPolarity(CONST.NE_POLARITY_NEGATION_ABSENT);
        } else if (value.equals("negation_present")) {
          modifier.setPolarity(CONST.NE_POLARITY_NEGATION_PRESENT);
        } else {
          throw new UnsupportedOperationException("Invalid negation: " + value);
        }
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("uncertainty_indicator_class".equals(annotation.type)) {
        String value = stringSlots.remove("uncertainty_indicator_normalization");
        UncertaintyModifier modifier = new UncertaintyModifier(jCas, coveringSpan.begin, coveringSpan.end);
        if (value == null) {
          LOGGER.warn(String.format(
              "assuming NE_UNCERTAINTY_PRESENT for %s with id \"%s\"",
              format(modifier),
              annotation.id));
          modifier.setUncertainty(CONST.NE_UNCERTAINTY_PRESENT);
        } else if (value.equals("indicator_absent")) {
          modifier.setUncertainty(CONST.NE_UNCERTAINTY_ABSENT);
        } else if (value.equals("indicator_present")) {
          modifier.setUncertainty(CONST.NE_UNCERTAINTY_PRESENT);
        } else {
          throw new UnsupportedOperationException("Invalid uncertainty: " + value);
        }
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Person".equals(annotation.type)) {
        String value = stringSlots.remove("subject_normalization_CU");
        String uimaValue = SUBJECT_KNOWTATOR_TO_UIMA_MAP.get(value);
        String code = stringSlots.remove("associatedCode");
        String uimaCode = SUBJECT_KNOWTATOR_TO_UIMA_MAP.get(code);
        if (value != null && uimaValue == null) {
          LOGGER.error(String.format(
              "unrecognized subject value \"%s\" for annotation with id \"%s\"",
              value,
              annotation.id));
        }
        if (code != null && uimaCode == null) {
          LOGGER.error(String.format(
              "unrecognized subject code \"%s\" for annotation with id \"%s\"",
              code,
              annotation.id));
        }
        if (uimaValue != null && uimaCode != null && !uimaValue.equals(uimaCode)) {
          LOGGER.error(String.format(
              "subject value \"%s\" and code \"%s\" are inconsistent for annotation with id \"%s\"",
              value,
              code,
              annotation.id));
        }
        String subject = uimaValue != null ? uimaValue : uimaCode;
        if (subject == null && this.setDefaults) {
          subject = SHARPKnowtatorXMLDefaults.getSubject();
        }
        SubjectModifier modifier = new SubjectModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setSubject(subject);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("historyOf_indicator_class".equals(annotation.type)) {
        String value = stringSlots.remove("historyOf_normalization");
        HistoryOfModifier modifier = new HistoryOfModifier(jCas, coveringSpan.begin, coveringSpan.end);
        if (null == value) {
          if (this.setDefaults) {
            modifier.setHistoryOf(SHARPKnowtatorXMLDefaults.getHistoryOf());
          }
        } else if ("historyOf_present".equals(value)) {
          modifier.setHistoryOf(CONST.NE_HISTORY_OF_PRESENT);
        } else if ("historyOf_absent".equals(value)) {
          modifier.setHistoryOf(CONST.NE_HISTORY_OF_ABSENT);
        } else {
          LOGGER.error(String.format(
              "unrecognized history-of value \"%s\" on annotation with id \"%s\"",
              value,
              annotation.id));
        }
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("distal_or_proximal".equals(annotation.type)) {
        String value = stringSlots.remove("distal_or_proximal_normalization");
        BodyLateralityModifier modifier = new BodyLateralityModifier(jCas, coveringSpan.begin, coveringSpan.end);
        BodyLaterality attribute = new BodyLaterality(jCas);
        if (value == null) {
          LOGGER.warn(String.format(
              "assuming \"%s\" for %s with id \"%s\"",
              CONST.ATTR_BODYLATERALITY_UNMARKED,
              format(modifier),
              annotation.id));
          value = CONST.ATTR_BODYLATERALITY_UNMARKED;
        } else if (!value.equals(CONST.ATTR_BODYLATERALITY_DISTAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_PROXIMAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_UNMARKED)) {
          throw new UnsupportedOperationException("Invalid BodyLaterality: " + value);
        }
        attribute.setValue(value);
        attribute.addToIndexes();
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("superior_or_inferior".equals(annotation.type)) {
        String value = stringSlots.remove("superior_or_inferior_normalization");
        BodyLateralityModifier modifier = new BodyLateralityModifier(jCas, coveringSpan.begin, coveringSpan.end);
        BodyLaterality attribute = new BodyLaterality(jCas);
        if (value == null) {
          LOGGER.warn(String.format(
              "assuming \"%s\" for %s with id \"%s\"",
              CONST.ATTR_BODYLATERALITY_UNMARKED,
              format(modifier),
              annotation.id));
          value = CONST.ATTR_BODYLATERALITY_UNMARKED;
        } else if (!value.equals(CONST.ATTR_BODYLATERALITY_DISTAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_SUPERIOR) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_INFERIOR)) {
          throw new UnsupportedOperationException("Invalid BodyLaterality: " + value);
        }
        attribute.setValue(value);
        attribute.addToIndexes();
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("medial_or_lateral".equals(annotation.type)) {
        String value = stringSlots.remove("medial_or_lateral_normalization");
       
        BodyLateralityModifier modifier = new BodyLateralityModifier(jCas, coveringSpan.begin, coveringSpan.end);
        BodyLaterality attribute = new BodyLaterality(jCas);
        if (value == null) {
          LOGGER.warn(String.format(
              "assuming \"%s\" for %s with id \"%s\"",
              CONST.ATTR_BODYLATERALITY_UNMARKED,
              format(modifier),
              annotation.id));
          value = CONST.ATTR_BODYLATERALITY_UNMARKED;
        } else if (!value.equals(CONST.ATTR_BODYLATERALITY_DISTAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_MEDIAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_LATERAL)) {
          throw new UnsupportedOperationException("Invalid BodyLaterality: " + value);
        }
        attribute.setValue(value);
        attribute.addToIndexes();
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("dorsal_or_ventral".equals(annotation.type)) {
        String value = stringSlots.remove("dorsal_or_ventral_normalization");
       
        BodyLateralityModifier modifier = new BodyLateralityModifier(jCas, coveringSpan.begin, coveringSpan.end);
        BodyLaterality attribute = new BodyLaterality(jCas);
        if (value == null) {
          LOGGER.warn(String.format(
              "assuming \"%s\" for %s with id \"%s\"",
              CONST.ATTR_BODYLATERALITY_UNMARKED,
              format(modifier),
              annotation.id));
          value = CONST.ATTR_BODYLATERALITY_UNMARKED;
        } else if (!value.equals(CONST.ATTR_BODYLATERALITY_DISTAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_DORSAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_VENTRAL)) {
          throw new UnsupportedOperationException("Invalid BodyLaterality: " + value);
        }
        attribute.setValue(value);
        attribute.addToIndexes();
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("body_side_class".equals(annotation.type)) {
        BodySide attribute = new BodySide(jCas);
        attribute.setValue(stringSlots.remove("body_side_normalization"));
        attribute.addToIndexes();
        BodySideModifier modifier = new BodySideModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("course_class".equals(annotation.type)) {
        Course attribute = new Course(jCas);
        attribute.setValue(stringSlots.remove("course_normalization"));
        attribute.addToIndexes();
        CourseModifier modifier = new CourseModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setTypeID(CONST.MODIFIER_TYPE_ID_COURSE_CLASS);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("estimated_flag_indicator".equals(annotation.type)) {
        boolean value = booleanSlots.remove("estimated_normalization");
        LabEstimatedModifier modifier = new LabEstimatedModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setIndicated(value);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("lab_interpretation_indicator".equals(annotation.type)) {
        String value = stringSlots.remove("lab_interpretation_normalization");
        LabInterpretationModifier modifier = new LabInterpretationModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setTypeID(CONST.MODIFIER_TYPE_ID_LAB_INTERPRETATION_INDICATOR);
        modifier.setValue(value);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("reference_range".equals(annotation.type)) {
        LabReferenceRangeModifier modifier = new LabReferenceRangeModifier(jCas, coveringSpan.begin, coveringSpan.end);
        LabReferenceRange attribute = new LabReferenceRange(jCas);
        attribute.setValue(modifier.getCoveredText());
        attribute.addToIndexes();
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Value".equals(annotation.type)) {
        KnowtatorAnnotation unit = annotationSlots.remove("value_unit");
        KnowtatorAnnotation number = annotationSlots.remove("value_number");
        LabValue attribute = new LabValue(jCas);
        if (unit != null) {
          KnowtatorAnnotation.Span unitSpan = unit.getCoveringSpan();
          String unitString = text.substring(unitSpan.begin, unitSpan.end);
          attribute.setUnit(unitString);
        }
        if (number != null) {
          KnowtatorAnnotation.Span numberSpan = number.getCoveringSpan();
          String numberString = text.substring(numberSpan.begin, numberSpan.end);
          attribute.setNumber(numberString);
        }
        attribute.addToIndexes();
        LabValueModifier modifier = new LabValueModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Value number".equals(annotation.type)) {
        // already handled in "Value" above

      } else if ("Value unit".equals(annotation.type)) {
        // already handled in "Value" above

      } else if ("allergy_indicator_class".equals(annotation.type)) {
        String value = stringSlots.remove("allergy_indicator_normalization");
        MedicationAllergyModifier modifier = new MedicationAllergyModifier(jCas, coveringSpan.begin, coveringSpan.end);
        if (null == value) {
          modifier.setIndicated(false);
        } else if ("indicator_present".equals(value)) {
          modifier.setIndicated(true);
        } else if ("indicator_absent".equals(value)) {
          modifier.setIndicated(false);
        } else {
          LOGGER.error(String.format(
              "unrecognized allergy-indicator value \"%s\" on annotation with id \"%s\"",
              value,
              annotation.id));
        }
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Dosage".equals(annotation.type)) {
        String value = stringSlots.remove("dosage_values");
        MedicationDosage attribute = new MedicationDosage(jCas);
        attribute.setValue(value);
        attribute.addToIndexes();
        MedicationDosageModifier modifier = new MedicationDosageModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Duration".equals(annotation.type)) {
        String value = stringSlots.remove("duration_values");
        MedicationDuration attribute = new MedicationDuration(jCas);
        attribute.setValue(value);
        attribute.addToIndexes();
        MedicationDurationModifier modifier = new MedicationDurationModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Form".equals(annotation.type)) {
        String value = stringSlots.remove("form_values");
        MedicationForm attribute = new MedicationForm(jCas);
        attribute.setValue(value);
        attribute.addToIndexes();
        MedicationFormModifier modifier = new MedicationFormModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);
       
      } else if ("Frequency".equals(annotation.type)) {
        KnowtatorAnnotation unit = annotationSlots.remove("frequency_unit");
        KnowtatorAnnotation number = annotationSlots.remove("frequency_number");
        MedicationFrequency attribute = new MedicationFrequency(jCas);
        if (unit != null) {
          String unitString = unit.stringSlots.get("frequency_unit_values");
          attribute.setUnit(unitString);
        }
        if (number != null) {
          String numberString = number.stringSlots.get("frequency_number_normalization");
          attribute.setNumber(numberString);
        }
        attribute.addToIndexes();
        MedicationFrequencyModifier modifier = new MedicationFrequencyModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Frequency number".equals(annotation.type)) {
        // already handled in "Frequency" above
        stringSlots.remove("frequency_number_normalization");

      } else if ("Frequency unit".equals(annotation.type)) {
        // already handled in "Frequency" above
        stringSlots.remove("frequency_unit_values");

      } else if ("Route".equals(annotation.type)) {
        String value = stringSlots.remove("route_values");
        MedicationRoute attribute = new MedicationRoute(jCas);
        attribute.setValue(value);
        attribute.addToIndexes();
        MedicationRouteModifier modifier = new MedicationRouteModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);
       
      } else if ("Status change".equals(annotation.type)) {
        String value = stringSlots.remove("change_status_value");
        MedicationStatusChange attribute = new MedicationStatusChange(jCas);
        attribute.setValue(value);
        attribute.addToIndexes();
        MedicationStatusChangeModifier modifier = new MedicationStatusChangeModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Strength".equals(annotation.type)) {
        KnowtatorAnnotation unit = annotationSlots.remove("strength_unit");
        KnowtatorAnnotation number = annotationSlots.remove("strength_number");
        MedicationStrength attribute = new MedicationStrength(jCas);
        if (unit != null) {
          KnowtatorAnnotation.Span unitSpan = unit.getCoveringSpan();
          String unitString = text.substring(unitSpan.begin, unitSpan.end);
          attribute.setUnit(unitString);
        }
        if (number != null) {
          KnowtatorAnnotation.Span numberSpan = number.getCoveringSpan();
          String numberString = text.substring(numberSpan.begin, numberSpan.end);
          attribute.setNumber(numberString);
        }
        attribute.addToIndexes();
        MedicationStrengthModifier modifier = new MedicationStrengthModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Strength number".equals(annotation.type)) {
        // already handled in "Strength" above

      } else if ("Strength unit".equals(annotation.type)) {
        // already handled in "Strength" above

      } else if ("device_class".equals(annotation.type)) {
        String code = stringSlots.remove("associatedCode");
        ProcedureDevice attribute = new ProcedureDevice(jCas);
        attribute.setValue(code);
        ProcedureDeviceModifier modifier = new ProcedureDeviceModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("method_class".equals(annotation.type)) {
        String code = stringSlots.remove("associatedCode");
        ProcedureMethod attribute = new ProcedureMethod(jCas);
        attribute.setValue(code);
        ProcedureMethodModifier modifier = new ProcedureMethodModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("severity_class".equals(annotation.type)) {
        Severity attribute = new Severity(jCas);
        attribute.setValue(stringSlots.remove("severity_normalization"));
        attribute.addToIndexes();
        SeverityModifier modifier = new SeverityModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setTypeID(CONST.MODIFIER_TYPE_ID_SEVERITY_CLASS);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Date".equals(annotation.type)) {
        String month = stringSlots.remove("month");
        String day = stringSlots.remove("day");
        Date date = new Date(jCas);
        date.setMonth(month);
        date.setDay(day);
        date.addToIndexes();
        TimeMention mention = new TimeMention(jCas, coveringSpan.begin, coveringSpan.end);
        mention.setDate(date);
        mention.addToIndexes();
        idAnnotationMap.put(annotation.id, mention);

      } else if (eventRelationTypes.contains(annotation.type)) {
        // store the ALINK information for later, once all annotations are in the CAS
        DelayedRelation relation = new DelayedRelation();
View Full Code Here

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

            labValue,
            ResultOfTextRelation.class,
            LabValueModifier.class));

      } else if (getMedicationKnowtatorClasses().contains(annotation.type)) {
        MedicationMention mention = new MedicationMention(jCas, coveringSpan.begin, coveringSpan.end);
        addIdentifiedAnnotationFeatures(
            annotation,
            mention,
            jCas,
            CONST.NE_TYPE_ID_DRUG,
            stringSlots,
            booleanSlots,
            annotationSlots,
            idAnnotationMap,
            delayedFeatures);
        KnowtatorAnnotation allergy = annotationSlots.remove("allergy_indicator");
        delayedFeatures.add(new DelayedFeature(mention, "medicationAllergy", allergy));
        KnowtatorAnnotation changeStatus = annotationSlots.remove("change_status_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationStatusChange", changeStatus));
        KnowtatorAnnotation dosage = annotationSlots.remove("dosage_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationDosage", dosage));
        KnowtatorAnnotation duration = annotationSlots.remove("duration_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationDuration", duration));
        KnowtatorAnnotation form = annotationSlots.remove("form_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationForm", form));
        KnowtatorAnnotation frequency = annotationSlots.remove("frequency_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationFrequency", frequency));
        KnowtatorAnnotation route = annotationSlots.remove("route_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationRoute", route));
        KnowtatorAnnotation startDate = annotationSlots.remove("start_date");
        delayedFeatures.add(new DelayedFeature(mention, "startDate", startDate));
        KnowtatorAnnotation strength = annotationSlots.remove("strength_model");
        delayedFeatures.add(new DelayedFeature(mention, "medicationStrength", strength));

      } else if ("Phenomena".equals(annotation.type)) {
        EventMention mention = new EventMention(jCas, coveringSpan.begin, coveringSpan.end);
        addIdentifiedAnnotationFeatures(
            annotation,
            mention,
            jCas,
            CONST.NE_TYPE_ID_PHENOMENA,
            stringSlots,
            booleanSlots,
            annotationSlots,
            idAnnotationMap,
            delayedFeatures);

      } else if (getProcedureKnowtatorClasses().contains(annotation.type)) {
        ProcedureMention mention = new ProcedureMention(jCas, coveringSpan.begin, coveringSpan.end);
        addIdentifiedAnnotationFeatures(
            annotation,
            mention,
            jCas,
            CONST.NE_TYPE_ID_PROCEDURE,
            stringSlots,
            booleanSlots,
            annotationSlots,
            idAnnotationMap,
            delayedFeatures);
        KnowtatorAnnotation bodyLaterality = annotationSlots.remove("body_laterality");
        delayedFeatures.add(new DelayedFeature(mention, "bodyLaterality", bodyLaterality));
        KnowtatorAnnotation bodyLocation = annotationSlots.remove("body_location");
        delayedFeatures.add(DelayedRelationFeature.forArg1(
            mention,
            "bodyLocation",
            bodyLocation,
            LocationOfTextRelation.class,
            AnatomicalSiteMention.class));
        KnowtatorAnnotation bodySide = annotationSlots.remove("body_side");
        delayedFeatures.add(new DelayedFeature(mention, "bodySide", bodySide));
        KnowtatorAnnotation device = annotationSlots.remove("device");
        delayedFeatures.add(new DelayedFeature(mention, "procedureDevice", device));
        KnowtatorAnnotation method = annotationSlots.remove("method");
        delayedFeatures.add(new DelayedFeature(mention, "method", method));

      } else if (getSignSymptomKnowtatorClasses().contains(annotation.type)) {
        SignSymptomMention mention = new SignSymptomMention(jCas, coveringSpan.begin, coveringSpan.end);
        addIdentifiedAnnotationFeatures(
            annotation,
            mention,
            jCas,
            CONST.NE_TYPE_ID_FINDING,
            stringSlots,
            booleanSlots,
            annotationSlots,
            idAnnotationMap,
            delayedFeatures);
        KnowtatorAnnotation alleviatingFactor = annotationSlots.remove("alleviating_factor");
        delayedFeatures.add(DelayedRelationFeature.forArg2(
            mention,
            "alleviatingFactor",
            alleviatingFactor,
            ManagesTreatsTextRelation.class,
            ProcedureMention.class));
        KnowtatorAnnotation bodyLaterality = annotationSlots.remove("body_laterality");
        delayedFeatures.add(new DelayedFeature(mention, "bodyLaterality", bodyLaterality));
        KnowtatorAnnotation bodyLocation = annotationSlots.remove("body_location");
        delayedFeatures.add(DelayedRelationFeature.forArg1(
            mention,
            "bodyLocation",
            bodyLocation,
            LocationOfTextRelation.class,
            AnatomicalSiteMention.class));
        KnowtatorAnnotation bodySide = annotationSlots.remove("body_side");
        delayedFeatures.add(new DelayedFeature(mention, "bodySide", bodySide));
        KnowtatorAnnotation course = annotationSlots.remove("course");
        delayedFeatures.add(DelayedRelationFeature.forArg1(
            mention,
            "course",
            course,
            DegreeOfTextRelation.class,
            CourseModifier.class));
        KnowtatorAnnotation exacerbatingFactor = annotationSlots.remove("exacerbating_factor");
        delayedFeatures.add(DelayedRelationFeature.forArg2(
            mention,
            "exacerbatingFactor",
            exacerbatingFactor,
            ComplicatesDisruptsTextRelation.class,
            EventMention.class));
        KnowtatorAnnotation severity = annotationSlots.remove("severity");
        delayedFeatures.add(DelayedRelationFeature.forArg1(
            mention,
            "severity",
            severity,
            DegreeOfTextRelation.class,
            SeverityModifier.class));

      } else if ("EVENT".equals(annotation.type)) {

        // collect the event properties (setting defaults as necessary)
        EventProperties eventProperties = new EventProperties(jCas);
        eventProperties.setCategory(stringSlots.remove("type"));
        if (eventProperties.getCategory() == null) {
          eventProperties.setCategory("N/A");
        }
        eventProperties.setContextualModality(stringSlots.remove("contextualmoduality"));
        if (eventProperties.getContextualModality() == null) {
          eventProperties.setContextualModality("ACTUAL");
        }
        eventProperties.setContextualAspect(stringSlots.remove("contextualaspect"));
        if (eventProperties.getContextualAspect() == null) {
          eventProperties.setContextualAspect("N/A");
        }
        eventProperties.setDegree(stringSlots.remove("degree"));
        if (eventProperties.getDegree() == null) {
          eventProperties.setDegree("N/A");
        }
        eventProperties.setDocTimeRel(stringSlots.remove("DocTimeRel"));
        if (eventProperties.getDocTimeRel() == null) {
          LOGGER.warn(String.format(
              "assuming docTimeRel=OVERLAP for annotation with id \"%s\"",
              annotation.id));
          eventProperties.setDocTimeRel("OVERLAP");
        }
        eventProperties.setPermanence(stringSlots.remove("permanence"));
        if (eventProperties.getPermanence() == null) {
          eventProperties.setPermanence("UNDETERMINED");
        }
        String polarityStr = stringSlots.remove("polarity");
        int polarity;
        if (polarityStr == null || polarityStr.equals("POS")) {
          polarity = CONST.NE_POLARITY_NEGATION_ABSENT;
        } else if (polarityStr.equals("NEG")) {
          polarity = CONST.NE_POLARITY_NEGATION_PRESENT;
        } else {
          throw new IllegalArgumentException("Invalid polarity: " + polarityStr);
        }
        eventProperties.setPolarity(polarity);

        // create the event object
        Event event = new Event(jCas);
        event.setConfidence(1.0f);
        event.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);

        // create the event mention
        EventMention eventMention = new EventMention(jCas, coveringSpan.begin, coveringSpan.end);
        eventMention.setConfidence(1.0f);
        eventMention.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);

        // add the links between event, mention and properties
        event.setProperties(eventProperties);
        event.setMentions(new FSArray(jCas, 1));
        event.setMentions(0, eventMention);
        eventMention.setEvent(event);

        // add the annotations to the indexes
        eventProperties.addToIndexes();
        event.addToIndexes();
        eventMention.addToIndexes();
        idAnnotationMap.put(annotation.id, eventMention);

      } else if ("DOCTIME".equals(annotation.type)) {
        TimeMention timeMention = new TimeMention(jCas, coveringSpan.begin, coveringSpan.end);
        timeMention.setTimeClass(annotation.type);
        timeMention.addToIndexes();
        idAnnotationMap.put(annotation.id, timeMention);

      } else if ("SECTIONTIME".equals(annotation.type)) {
        TimeMention timeMention = new TimeMention(jCas, coveringSpan.begin, coveringSpan.end);
        timeMention.setTimeClass(annotation.type);
        timeMention.addToIndexes();
        idAnnotationMap.put(annotation.id, timeMention);

      } else if ("TIMEX3".equals(annotation.type)) {
        String timexClass = stringSlots.remove("class");
        TimeMention timeMention = new TimeMention(jCas, coveringSpan.begin, coveringSpan.end);
        timeMention.setTimeClass(timexClass);
        timeMention.addToIndexes();
        idAnnotationMap.put(annotation.id, timeMention);
       
      } else if ("conditional_class".equals(annotation.type)) {
        Boolean value = booleanSlots.remove("conditional_normalization");
        ConditionalModifier modifier = new ConditionalModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setConditional(value == null ? false : value);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("generic_class".equals(annotation.type)) {
        Boolean value = booleanSlots.remove("generic_normalization");
        GenericModifier modifier = new GenericModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setGeneric(value == null ? false : value);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("negation_indicator_class".equals(annotation.type)) {
        String value = stringSlots.remove("negation_indicator_normalization");
        PolarityModifier modifier = new PolarityModifier(jCas, coveringSpan.begin, coveringSpan.end);
        if (value == null) {
          LOGGER.warn(String.format(
              "assuming NE_POLARITY_NEGATION_PRESENT for %s with id \"%s\"",
              format(modifier),
              annotation.id));
          modifier.setPolarity(CONST.NE_POLARITY_NEGATION_PRESENT);
        } else if (value.equals("negation_absent")) {
          modifier.setPolarity(CONST.NE_POLARITY_NEGATION_ABSENT);
        } else if (value.equals("negation_present")) {
          modifier.setPolarity(CONST.NE_POLARITY_NEGATION_PRESENT);
        } else {
          throw new UnsupportedOperationException("Invalid negation: " + value);
        }
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("uncertainty_indicator_class".equals(annotation.type)) {
        String value = stringSlots.remove("uncertainty_indicator_normalization");
        UncertaintyModifier modifier = new UncertaintyModifier(jCas, coveringSpan.begin, coveringSpan.end);
        if (value == null) {
          LOGGER.warn(String.format(
              "assuming NE_UNCERTAINTY_PRESENT for %s with id \"%s\"",
              format(modifier),
              annotation.id));
          modifier.setUncertainty(CONST.NE_UNCERTAINTY_PRESENT);
        } else if (value.equals("indicator_absent")) {
          modifier.setUncertainty(CONST.NE_UNCERTAINTY_ABSENT);
        } else if (value.equals("indicator_present")) {
          modifier.setUncertainty(CONST.NE_UNCERTAINTY_PRESENT);
        } else {
          throw new UnsupportedOperationException("Invalid uncertainty: " + value);
        }
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Person".equals(annotation.type)) {
        String value = stringSlots.remove("subject_normalization_CU");
        String uimaValue = SUBJECT_KNOWTATOR_TO_UIMA_MAP.get(value);
        String code = stringSlots.remove("associatedCode");
        String uimaCode = SUBJECT_KNOWTATOR_TO_UIMA_MAP.get(code);
        if (value != null && uimaValue == null) {
          LOGGER.error(String.format(
              "unrecognized subject value \"%s\" for annotation with id \"%s\"",
              value,
              annotation.id));
        }
        if (code != null && uimaCode == null) {
          LOGGER.error(String.format(
              "unrecognized subject code \"%s\" for annotation with id \"%s\"",
              code,
              annotation.id));
        }
        if (uimaValue != null && uimaCode != null && !uimaValue.equals(uimaCode)) {
          LOGGER.error(String.format(
              "subject value \"%s\" and code \"%s\" are inconsistent for annotation with id \"%s\"",
              value,
              code,
              annotation.id));
        }
        String subject = uimaValue != null ? uimaValue : uimaCode;
        if (subject == null && this.setDefaults) {
          subject = SHARPKnowtatorXMLDefaults.getSubject();
        }
        SubjectModifier modifier = new SubjectModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setSubject(subject);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("historyOf_indicator_class".equals(annotation.type)) {
        String value = stringSlots.remove("historyOf_normalization");
        HistoryOfModifier modifier = new HistoryOfModifier(jCas, coveringSpan.begin, coveringSpan.end);
        if (null == value) {
          if (this.setDefaults) {
            modifier.setHistoryOf(SHARPKnowtatorXMLDefaults.getHistoryOf());
          }
        } else if ("historyOf_present".equals(value)) {
          modifier.setHistoryOf(CONST.NE_HISTORY_OF_PRESENT);
        } else if ("historyOf_absent".equals(value)) {
          modifier.setHistoryOf(CONST.NE_HISTORY_OF_ABSENT);
        } else {
          LOGGER.error(String.format(
              "unrecognized history-of value \"%s\" on annotation with id \"%s\"",
              value,
              annotation.id));
        }
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("distal_or_proximal".equals(annotation.type)) {
        String value = stringSlots.remove("distal_or_proximal_normalization");
        BodyLateralityModifier modifier = new BodyLateralityModifier(jCas, coveringSpan.begin, coveringSpan.end);
        BodyLaterality attribute = new BodyLaterality(jCas);
        if (value == null) {
          LOGGER.warn(String.format(
              "assuming \"%s\" for %s with id \"%s\"",
              CONST.ATTR_BODYLATERALITY_UNMARKED,
              format(modifier),
              annotation.id));
          value = CONST.ATTR_BODYLATERALITY_UNMARKED;
        } else if (!value.equals(CONST.ATTR_BODYLATERALITY_DISTAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_PROXIMAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_UNMARKED)) {
          throw new UnsupportedOperationException("Invalid BodyLaterality: " + value);
        }
        attribute.setValue(value);
        attribute.addToIndexes();
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("superior_or_inferior".equals(annotation.type)) {
        String value = stringSlots.remove("superior_or_inferior_normalization");
        BodyLateralityModifier modifier = new BodyLateralityModifier(jCas, coveringSpan.begin, coveringSpan.end);
        BodyLaterality attribute = new BodyLaterality(jCas);
        if (value == null) {
          LOGGER.warn(String.format(
              "assuming \"%s\" for %s with id \"%s\"",
              CONST.ATTR_BODYLATERALITY_UNMARKED,
              format(modifier),
              annotation.id));
          value = CONST.ATTR_BODYLATERALITY_UNMARKED;
        } else if (!value.equals(CONST.ATTR_BODYLATERALITY_DISTAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_SUPERIOR) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_INFERIOR)) {
          throw new UnsupportedOperationException("Invalid BodyLaterality: " + value);
        }
        attribute.setValue(value);
        attribute.addToIndexes();
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("medial_or_lateral".equals(annotation.type)) {
        String value = stringSlots.remove("medial_or_lateral_normalization");
       
        BodyLateralityModifier modifier = new BodyLateralityModifier(jCas, coveringSpan.begin, coveringSpan.end);
        BodyLaterality attribute = new BodyLaterality(jCas);
        if (value == null) {
          LOGGER.warn(String.format(
              "assuming \"%s\" for %s with id \"%s\"",
              CONST.ATTR_BODYLATERALITY_UNMARKED,
              format(modifier),
              annotation.id));
          value = CONST.ATTR_BODYLATERALITY_UNMARKED;
        } else if (!value.equals(CONST.ATTR_BODYLATERALITY_DISTAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_MEDIAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_LATERAL)) {
          throw new UnsupportedOperationException("Invalid BodyLaterality: " + value);
        }
        attribute.setValue(value);
        attribute.addToIndexes();
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("dorsal_or_ventral".equals(annotation.type)) {
        String value = stringSlots.remove("dorsal_or_ventral_normalization");
       
        BodyLateralityModifier modifier = new BodyLateralityModifier(jCas, coveringSpan.begin, coveringSpan.end);
        BodyLaterality attribute = new BodyLaterality(jCas);
        if (value == null) {
          LOGGER.warn(String.format(
              "assuming \"%s\" for %s with id \"%s\"",
              CONST.ATTR_BODYLATERALITY_UNMARKED,
              format(modifier),
              annotation.id));
          value = CONST.ATTR_BODYLATERALITY_UNMARKED;
        } else if (!value.equals(CONST.ATTR_BODYLATERALITY_DISTAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_DORSAL) &&
            !value.equals(CONST.ATTR_BODYLATERALITY_VENTRAL)) {
          throw new UnsupportedOperationException("Invalid BodyLaterality: " + value);
        }
        attribute.setValue(value);
        attribute.addToIndexes();
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("body_side_class".equals(annotation.type)) {
        BodySide attribute = new BodySide(jCas);
        attribute.setValue(stringSlots.remove("body_side_normalization"));
        attribute.addToIndexes();
        BodySideModifier modifier = new BodySideModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("course_class".equals(annotation.type)) {
        Course attribute = new Course(jCas);
        attribute.setValue(stringSlots.remove("course_normalization"));
        attribute.addToIndexes();
        CourseModifier modifier = new CourseModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setTypeID(CONST.MODIFIER_TYPE_ID_COURSE_CLASS);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("estimated_flag_indicator".equals(annotation.type)) {
        boolean value = booleanSlots.remove("estimated_normalization");
        LabEstimatedModifier modifier = new LabEstimatedModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setIndicated(value);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("lab_interpretation_indicator".equals(annotation.type)) {
        String value = stringSlots.remove("lab_interpretation_normalization");
        LabInterpretationModifier modifier = new LabInterpretationModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setTypeID(CONST.MODIFIER_TYPE_ID_LAB_INTERPRETATION_INDICATOR);
        modifier.setValue(value);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("reference_range".equals(annotation.type)) {
        LabReferenceRangeModifier modifier = new LabReferenceRangeModifier(jCas, coveringSpan.begin, coveringSpan.end);
        LabReferenceRange attribute = new LabReferenceRange(jCas);
        attribute.setValue(modifier.getCoveredText());
        attribute.addToIndexes();
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Value".equals(annotation.type)) {
        KnowtatorAnnotation unit = annotationSlots.remove("value_unit");
        KnowtatorAnnotation number = annotationSlots.remove("value_number");
        LabValue attribute = new LabValue(jCas);
        if (unit != null) {
          KnowtatorAnnotation.Span unitSpan = unit.getCoveringSpan();
          String unitString = text.substring(unitSpan.begin, unitSpan.end);
          attribute.setUnit(unitString);
        }
        if (number != null) {
          KnowtatorAnnotation.Span numberSpan = number.getCoveringSpan();
          String numberString = text.substring(numberSpan.begin, numberSpan.end);
          attribute.setNumber(numberString);
        }
        attribute.addToIndexes();
        LabValueModifier modifier = new LabValueModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Value number".equals(annotation.type)) {
        // already handled in "Value" above

      } else if ("Value unit".equals(annotation.type)) {
        // already handled in "Value" above

      } else if ("allergy_indicator_class".equals(annotation.type)) {
        String value = stringSlots.remove("allergy_indicator_normalization");
        MedicationAllergyModifier modifier = new MedicationAllergyModifier(jCas, coveringSpan.begin, coveringSpan.end);
        if (null == value) {
          modifier.setIndicated(false);
        } else if ("indicator_present".equals(value)) {
          modifier.setIndicated(true);
        } else if ("indicator_absent".equals(value)) {
          modifier.setIndicated(false);
        } else {
          LOGGER.error(String.format(
              "unrecognized allergy-indicator value \"%s\" on annotation with id \"%s\"",
              value,
              annotation.id));
        }
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Dosage".equals(annotation.type)) {
        String value = stringSlots.remove("dosage_values");
        MedicationDosage attribute = new MedicationDosage(jCas);
        attribute.setValue(value);
        attribute.addToIndexes();
        MedicationDosageModifier modifier = new MedicationDosageModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Duration".equals(annotation.type)) {
        String value = stringSlots.remove("duration_values");
        MedicationDuration attribute = new MedicationDuration(jCas);
        attribute.setValue(value);
        attribute.addToIndexes();
        MedicationDurationModifier modifier = new MedicationDurationModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Form".equals(annotation.type)) {
        String value = stringSlots.remove("form_values");
        MedicationForm attribute = new MedicationForm(jCas);
        attribute.setValue(value);
        attribute.addToIndexes();
        MedicationFormModifier modifier = new MedicationFormModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);
       
      } else if ("Frequency".equals(annotation.type)) {
        KnowtatorAnnotation unit = annotationSlots.remove("frequency_unit");
        KnowtatorAnnotation number = annotationSlots.remove("frequency_number");
        MedicationFrequency attribute = new MedicationFrequency(jCas);
        if (unit != null) {
          String unitString = unit.stringSlots.get("frequency_unit_values");
          attribute.setUnit(unitString);
        }
        if (number != null) {
          String numberString = number.stringSlots.get("frequency_number_normalization");
          attribute.setNumber(numberString);
        }
        attribute.addToIndexes();
        MedicationFrequencyModifier modifier = new MedicationFrequencyModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Frequency number".equals(annotation.type)) {
        // already handled in "Frequency" above
        stringSlots.remove("frequency_number_normalization");

      } else if ("Frequency unit".equals(annotation.type)) {
        // already handled in "Frequency" above
        stringSlots.remove("frequency_unit_values");

      } else if ("Route".equals(annotation.type)) {
        String value = stringSlots.remove("route_values");
        MedicationRoute attribute = new MedicationRoute(jCas);
        attribute.setValue(value);
        attribute.addToIndexes();
        MedicationRouteModifier modifier = new MedicationRouteModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);
       
      } else if ("Status change".equals(annotation.type)) {
        String value = stringSlots.remove("change_status_value");
        MedicationStatusChange attribute = new MedicationStatusChange(jCas);
        attribute.setValue(value);
        attribute.addToIndexes();
        MedicationStatusChangeModifier modifier = new MedicationStatusChangeModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Strength".equals(annotation.type)) {
        KnowtatorAnnotation unit = annotationSlots.remove("strength_unit");
        KnowtatorAnnotation number = annotationSlots.remove("strength_number");
        MedicationStrength attribute = new MedicationStrength(jCas);
        if (unit != null) {
          KnowtatorAnnotation.Span unitSpan = unit.getCoveringSpan();
          String unitString = text.substring(unitSpan.begin, unitSpan.end);
          attribute.setUnit(unitString);
        }
        if (number != null) {
          KnowtatorAnnotation.Span numberSpan = number.getCoveringSpan();
          String numberString = text.substring(numberSpan.begin, numberSpan.end);
          attribute.setNumber(numberString);
        }
        attribute.addToIndexes();
        MedicationStrengthModifier modifier = new MedicationStrengthModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Strength number".equals(annotation.type)) {
        // already handled in "Strength" above

      } else if ("Strength unit".equals(annotation.type)) {
        // already handled in "Strength" above

      } else if ("device_class".equals(annotation.type)) {
        String code = stringSlots.remove("associatedCode");
        ProcedureDevice attribute = new ProcedureDevice(jCas);
        attribute.setValue(code);
        ProcedureDeviceModifier modifier = new ProcedureDeviceModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("method_class".equals(annotation.type)) {
        String code = stringSlots.remove("associatedCode");
        ProcedureMethod attribute = new ProcedureMethod(jCas);
        attribute.setValue(code);
        ProcedureMethodModifier modifier = new ProcedureMethodModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("severity_class".equals(annotation.type)) {
        Severity attribute = new Severity(jCas);
        attribute.setValue(stringSlots.remove("severity_normalization"));
        attribute.addToIndexes();
        SeverityModifier modifier = new SeverityModifier(jCas, coveringSpan.begin, coveringSpan.end);
        modifier.setTypeID(CONST.MODIFIER_TYPE_ID_SEVERITY_CLASS);
        modifier.setNormalizedForm(attribute);
        modifier.addToIndexes();
        idAnnotationMap.put(annotation.id, modifier);

      } else if ("Date".equals(annotation.type)) {
        String month = stringSlots.remove("month");
        String day = stringSlots.remove("day");
        Date date = new Date(jCas);
        date.setMonth(month);
        date.setDay(day);
        date.addToIndexes();
        TimeMention mention = new TimeMention(jCas, coveringSpan.begin, coveringSpan.end);
        mention.setDate(date);
        mention.addToIndexes();
        idAnnotationMap.put(annotation.id, mention);

      } else {
        LOGGER.info(String.format(
            "unrecognized type '%s' for annotation with id \"%s\"",
View Full Code Here

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

  {
    int id = firstId;
    FSIterator itr = jcas.getJFSIndexRepository().getAnnotationIndex(type).iterator();
    while (itr.hasNext())
    {
      MedicationMention idAnnot = (MedicationMention) itr.next();
      idAnnot.setId(id);
      id++;
    }
    return id;
  }
View Full Code Here

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

   */

  private void generateDrugMentions(JCas jcas, Segment seg, boolean narrativeType) throws Exception
  {
    int begin = seg.getBegin(), end = seg.getEnd() + 1;
    MedicationMention nextNER = null;
    int nextNERPosition = 0;
    List uniqueNEs;
    List allNEs;

    int[] validNeTypes = { CONST.NE_TYPE_ID_DRUG, CONST.NE_TYPE_ID_UNKNOWN };
   
    try {
      uniqueNEs = findUniqueMentions( FSUtil.getAnnotationsInSpan(jcas, MedicationMention.type, begin, end, validNeTypes).toArray());
      // FIX ID: 3476114, ID: 3476113, and ID: 3476110
      int globalArraySize = uniqueNEs.size()*3;
      int [][] windowSpans =  new int [globalArraySize][2];
      int globalWindowSize = 0;
      if (narrativeType) {
        for (int neCount = 0; neCount < uniqueNEs.size() ; neCount ++ ) {
          boolean processedSpan = false;
          MedicationMention neNarrative = (MedicationMention) uniqueNEs.get(neCount);
          for (int spanCheck = 0 ; spanCheck < windowSpans.length && !processedSpan && windowSpans[spanCheck][0] != 0; spanCheck ++ ) {
            if (windowSpans[spanCheck][0] ==  neNarrative.getBegin())
              processedSpan = true;
          }
          if (!processedSpan) {
            int [][] narrativeSpans =  getWindowSpan(jcas, "narrative", MedicationMention.type, neNarrative.getBegin(), neNarrative.getEnd(),  false, globalArraySize);
            for (int elementCount = 0; elementCount < narrativeSpans.length; elementCount ++ ) {
              windowSpans[globalWindowSize] = narrativeSpans[elementCount];
              globalWindowSize++;
            }
          }
        }
      } else if (uniqueNEs.size() > 0){ // don't bother finding spans if no ne in list
        windowSpans = getWindowSpan(jcas, "list", MedicationMention.type, begin, end,  false, globalArraySize);
        if (windowSpans.length > 0 && windowSpans[0][0] == -1) {
          windowSpans[0][0] = begin;
          windowSpans[0][1] = end;
        }
      }
      for (int count= 0; count < windowSpans.length; count++) {
        List neTokenUpdatedList = getAnnotationsInSpan(jcas,
            MedicationMention.type, windowSpans[count][0], windowSpans[count][1]);

        if (!neTokenUpdatedList.isEmpty())
        {
          List globalDrugNERList = new ArrayList();
          try
          {
            generateDrugMentionsAndAnnotations(jcas, neTokenUpdatedList,
                windowSpans[count][0], windowSpans[count][1], null, null, 0, globalDrugNERList);
          } catch (NumberFormatException nfe)
          {
            iv_logger.info(nfe.getMessage());
          } catch (Exception e)
          {
            iv_logger.info(e.getMessage());
          }

          globalDrugNERList.clear();
        }
      }
    } catch (ArrayIndexOutOfBoundsException aioobe) {
      allNEs =
        FSUtil.getAnnotationsInSpan(jcas, MedicationMention.type, begin, end, validNeTypes);

      uniqueNEs = findUniqueMentions(allNEs.toArray());

      int lastNL = seg.getEnd();
      boolean lastOne = false;
      Iterator newLineItr =
        FSUtil.getAnnotationsIteratorInSpan(jcas, NewlineToken.type, begin, end);

      for (int i = 0; i < uniqueNEs.size(); i++)
      {
        MedicationMention thisNER = (MedicationMention) uniqueNEs.get(i);
        boolean hasNext = false;
        if (uniqueNEs.size() > i + 1)
        {
          nextNER = (MedicationMention) uniqueNEs.get(i + 1);
          nextNERPosition = nextNER.getBegin();
          if (nextNER != null)
            hasNext = true;
        } else if (!uniqueNEs.isEmpty())
        {
          nextNER = (MedicationMention) uniqueNEs.get(i);
          nextNERPosition = nextNER.getBegin();
          lastOne = true;
        }
        boolean foundLeftParen = false;
        boolean foundRightParen = false;

        foundRightParen = findCoveredTextInSpan(jcas, PunctuationToken.type, thisNER.getEnd(), thisNER.getEnd()+3, (new String[]{")","/"}));


        if (hasNext && !lastOne)
          end = nextNERPosition;
        else
          end = seg.getEnd();

        boolean hasNLEnd = true;
        boolean wrapItUp = false;

        while (hasNLEnd && !wrapItUp && end <= seg.getEnd()
            && ((begin < end) || (!hasNext && begin <= end) || foundLeftParen))
        {

          if (begin == end) {
            foundLeftParen = false;
            end = end+1;
          }
          NewlineToken nl = null;
          if (hasNLEnd && newLineItr.hasNext())
          {
            nl = (NewlineToken) newLineItr.next();
            hasNLEnd = true;
          }
          if ((!hasNext && begin <= end) || (nextNERPosition < end))
            wrapItUp = true;
          boolean findNextNL = false;

          if (lastNL <= thisNER.getBegin())
          {
            begin = thisNER.getBegin();
          }

          if ((nl != null) && (thisNER.getBegin() >= nl.getEnd()))
          {
            findNextNL = true;

          } else if (nl != null)
          {
            lastNL = nl.getEnd();
          }

          if (!hasNext)
          {
            findNextNL = false;
            end = seg.getEnd();
          }
          if (!findNextNL)
          {
            if ((nextNER != null)
                && (((nextNER.getCoveredText().compareToIgnoreCase(
                    thisNER.getCoveredText()) == 0) || ((foundRightParen) || nextNER.getBegin() == thisNER.getEnd() + 2))))
            {
              if (nl == null)
              {
                if (!hasNext)
                  end = seg.getEnd();
View Full Code Here

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

      String [] relatedStatus, int countNER, List<DrugMentionAnnotation> globalDrugNER) throws Exception
      {

    Iterator<MedicationMention> uniqueNER = nerTokenList.iterator();
    DrugMentionAnnotation drugTokenAnt = null;
    MedicationMention tokenAnt = null;

    List<DrugMentionAnnotation> holdDrugNERArr = new ArrayList<DrugMentionAnnotation>();

    while (uniqueNER.hasNext())
    {

      tokenAnt = (MedicationMention) uniqueNER.next();
      boolean isDrugNER = false;
      FSArray ocArr = tokenAnt.getOntologyConceptArr();
      if (ocArr != null)
      {
        for (int i = 0; i < ocArr.size() && !isDrugNER; i++)
        {
          OntologyConcept oc = (OntologyConcept) ocArr.get(i);

          String scheme = oc.getCodingScheme();
          //if (scheme.compareTo("RXNORM") == 0)
          //{
            isDrugNER = true;
          //}

        }
      }
      if (tokenAnt != null && (isDrugNER || relatedStatus != null))
      {
        boolean keepNoChangeStatus = false;

        boolean maxExists = false;
        int maxOffsetEnd = 0;
        int holdRightEnd = end + 1;
        int holdLeftStart = begin;
        drugTokenAnt = new DrugMentionAnnotation(jcas, tokenAnt.getBegin(),
            tokenAnt.getEnd());
        tokenAnt.setTypeID(NERTypeIdentifier);
        holdDrugNERArr.add(drugTokenAnt);

        Iterator statusChangeItr = FSUtil.getAnnotationsIteratorInSpan(jcas, DrugChangeStatusAnnotation.type, holdLeftStart, holdRightEnd);
        List holdStatusChanges = new ArrayList();
        // Separate the subsection from the change status elements
        int[] localSpan = getNarrativeSpansContainingGivenSpanType(jcas, drugTokenAnt.getBegin(), iBoundaryAnnType);
        while (statusChangeItr.hasNext())
        {
          Iterator findSubSection = FSUtil.getAnnotationsIteratorInSpan(jcas, SubSectionAnnotation.type, holdLeftStart, holdRightEnd);
          // if there aren't subsection in the span add to the hold
          // status changes list (unless Maximum special case)
          boolean isolate = false;
          if (!findSubSection.hasNext())
          {

            DrugChangeStatusAnnotation dsa = (DrugChangeStatusAnnotation) statusChangeItr.next();

            // Maximum case means the drug mention elements should
            // be overridden by this value
            if (((dsa.getChangeStatus().compareTo(
                DrugChangeStatusElement.MAXIMUM_STATUS) != 0)
                && dsa.getEnd() < holdRightEnd)
                && (localSpan[0]<dsa.getBegin() && localSpan[1]> dsa.getEnd()))
            {
              holdStatusChanges.add(dsa);
            } else if (dsa.getChangeStatus().compareTo(
                DrugChangeStatusElement.MAXIMUM_STATUS) == 0
                && dsa.getEnd() < holdRightEnd)
            {
              maxExists = true;
              maxOffsetEnd = dsa.getEnd();
            }

          } else
          {
            statusChangeItr.next();// Added this line to make sure the the next DrugChangeStatusAnnotation in the event that there is no subsection to look at
            boolean noWeirdError = true;
            boolean pullOut = false;
            while (!pullOut && !isolate && findSubSection.hasNext()
                && noWeirdError)
            {
              try
              {
                // each status change is checked against all
                // available sub-spans in that range
                SubSectionAnnotation sub = (SubSectionAnnotation) findSubSection.next();
                Iterator findStartLF = FSUtil.getAnnotationsIteratorInSpan(
                    jcas, NewlineToken.type, holdLeftStart, sub.getBegin() + 1);
                Iterator findEndLF = FSUtil.getAnnotationsIteratorInSpan(jcas,
                    NewlineToken.type, sub.getEnd(), holdRightEnd);

                if (findStartLF.hasNext() && findEndLF.hasNext())
                {

                  while (findStartLF.hasNext())
                  {
                    // int countSymbols = 0;
                    NewlineToken nta = (NewlineToken) findStartLF.next();

                    // Iterator findSymbols =
                    // FSUtil.getAnnotationsInSpanIterator(jcas,
                    // SymbolToken.type,
                    // nta.getEnd(), sub.getBegin());
                    //         
                    // while (findSymbols.hasNext())
                    // {
                    // findSymbols.next();
                    // countSymbols++;
                    // }

                    int countSymbols = FSUtil.countAnnotationsInSpan(jcas,
                        SymbolToken.type, nta.getEnd(), sub.getBegin());

                    if ((nta.getEnd() + countSymbols + 1) >= sub.getBegin())
                    {
                      isolate = true;
                      holdRightEnd = sub.getBegin();
                      end = sub.getBegin();
                    }
                  }

                  if (!isolate)
                  {
                    DrugChangeStatusAnnotation dsa = (DrugChangeStatusAnnotation) statusChangeItr.next();
                    holdStatusChanges.add(dsa);
                    pullOut = true;
                    sub.removeFromIndexes();
                  }
                } else if (findEndLF.hasNext())
                {
                  // subsection is on a prior separate line than the rest
                  // of the content
                  holdLeftStart = sub.getEnd();
                  // sub.removeFromIndexes();

                } else if (sub.getBegin() > tokenAnt.getEnd())
                {
                  end = sub.getBegin();
                  holdRightEnd = sub.getBegin();
                  sub.removeFromIndexes();
                } else
                {
                  holdLeftStart = sub.getEnd();
                  holdRightEnd = tokenAnt.getBegin();
                }
              } catch (NoSuchElementException nsee)
              {
                noWeirdError = false;
                iv_logger.info(nsee.getLocalizedMessage());
              }
            }
          }
        }

        // handles cases like "then discontinue" so the two change status mentions are merged and the last
        // value is used for the change status i.e. 'discontinue'

        List modifiedOrderDrugStatusChanges = new ArrayList();
        Iterator sortStatusChanges = sortAnnotations(holdStatusChanges.toArray()).iterator();
        Iterator sortNextStatusChanges = sortAnnotations(holdStatusChanges.toArray()).iterator();
        // increment sortNextStatusChanges
        if (sortNextStatusChanges.hasNext()) sortNextStatusChanges.next();
        boolean skipNext = false;
        int checkSkippedOffsetBegin = 0, checkSkippedOffsetEnd = 0;
        while (sortStatusChanges.hasNext()) {
          DrugChangeStatusAnnotation hos1 = (DrugChangeStatusAnnotation) sortStatusChanges.next();
          if (sortNextStatusChanges.hasNext()) {

            DrugChangeStatusAnnotation hos2 = (DrugChangeStatusAnnotation) sortNextStatusChanges.next();
            if (hos1.getBegin() == hos2.getBegin()) {
              if (hos1.getEnd() >= hos2.getEnd()) {
                skipNext = true;
                checkSkippedOffsetBegin = hos2.getBegin();
                checkSkippedOffsetEnd = hos2.getEnd();
                hos2.removeFromIndexes();
                modifiedOrderDrugStatusChanges.add(hos1);

              } else {
                iv_logger.info("found reverse case . . need to handle");
              }

            } else if (!skipNext) {
              modifiedOrderDrugStatusChanges.add(hos1);
            } else
              skipNext = false;
          }
          else if (checkSkippedOffsetBegin == 0 || (checkSkippedOffsetBegin != hos1.getBegin() && checkSkippedOffsetEnd != hos1.getEnd())){
            modifiedOrderDrugStatusChanges.add(hos1);
          }
        }       

        Iterator orderedStatusChanges = sortAnnotations(holdStatusChanges.toArray()).iterator();
        Iterator orderedDrugStatusChanges = sortAnnotations(holdStatusChanges.toArray()).iterator();

        if (modifiedOrderDrugStatusChanges.size() > 0 ) {
          int [] newSpan = {begin, end};
          newSpan = statusChangePhraseGenerator ( jcas,  begin,  end,  maxExists,  uniqueNER,
              orderedStatusChanges,  modifiedOrderDrugStatusChanges,  relatedStatus,  drugTokenAnt, 
              globalDrugNER,  countNER );
          begin = newSpan[0];
          end = newSpan[1];
          if ((drugTokenAnt.getDrugChangeStatus() != null && drugTokenAnt.getDrugChangeStatus().equals(DrugChangeStatusToken.NOCHANGE)) ||
              (drugTokenAnt.getDrugChangeStatus() != null && drugTokenAnt.getDrugChangeStatus().equals(DrugChangeStatusToken.OTHER)))  {
            keepNoChangeStatus = true;
            if (drugTokenAnt.getDrugChangeStatus().equals(DrugChangeStatusToken.OTHER))
              drugTokenAnt.setDrugChangeStatus(DrugChangeStatusToken.NOCHANGE);
          }           
          // No change is default state since the change state has been handled
        }
        DrugMention dm = new DrugMention(jcas, begin, end)
        boolean overrideStatus = false;
        boolean statusFound = false;
        if (!keepNoChangeStatus) {
          // All entries may not be appropriate, so some
          // filtering
          // may need to be implemented here
          JFSIndexRepository indexes = jcas.getJFSIndexRepository();
          Iterator subSectionItr = indexes.getAnnotationIndex(
              SubSectionAnnotation.type).iterator();

          String statusKey = null;
          while (subSectionItr.hasNext() && !statusFound)
          {

            SubSectionAnnotation ssid = (SubSectionAnnotation) subSectionItr.next();

            if (ssid.getSubSectionBodyBegin() <= tokenAnt.getBegin()
                && ssid.getSubSectionBodyEnd() >= tokenAnt.getEnd())
            {

              // Look for special case where date comes before the
              // drug mention
              // A better means to locate the beginning of the chunk
              // is lacking here mainly due
              // to the fact that the sentence annotator cannot be
              // trusted to find the beginning
              // accurately.
              boolean overrideDate = false;
              Iterator statusSpecialDateItr = FSUtil.getAnnotationsIteratorInSpan(jcas, DateAnnotation.type, ssid.getEnd(), drugTokenAnt.getBegin());
              while (statusSpecialDateItr.hasNext() && !overrideDate)
              {
                DateAnnotation specialDate = (DateAnnotation) statusSpecialDateItr.next();
                Iterator findLF = FSUtil.getAnnotationsIteratorInSpan(jcas,
                    NewlineToken.type, ssid.getEnd(), specialDate.getBegin());
                if (!findLF.hasNext())
                {
                  // if (specialDate.getEnd() <=
                  // drugTokenAnt.getBegin() ){
                  drugTokenAnt.setStartDate(specialDate.getCoveredText());
                  overrideDate = true;
                }
              }

              DrugChangeStatusAnnotation dsa = null;
              if (orderedDrugStatusChanges.hasNext())
              {
                dsa = (DrugChangeStatusAnnotation) orderedDrugStatusChanges.next();
              }
              if (dsa != null
                  && (dsa.getChangeStatus().compareTo(DrugChangeStatusElement.START_STATUS) == 0 ||
                      dsa.getChangeStatus().compareTo(DrugChangeStatusElement.STOP_STATUS) == 0))
              {
                // Should we override here? Let's get only the first
                // one as an override

                drugTokenAnt.setDrugChangeStatus(dsa.getChangeStatus());
              } else
              {
                statusKey = dm.convertToChangeStatus(ssid.getCoveredText());
                if (ssid.getStatus() == 1)
                {

                  // drugTokenAnt.setCertainty(-1);
                  statusKey = DrugChangeStatusToken.STOP;
                }
                if (statusKey.compareTo(DrugChangeStatusToken.NOCHANGE) == 0)
                {
                  Iterator oneDrugChangeStatus = FSUtil.getAnnotationsIteratorInSpan(jcas,
                      DrugChangeStatusAnnotation.type, ssid.getBegin(), ssid.getEnd() + 1);
                  if (oneDrugChangeStatus.hasNext())
                  {
                    dsa = (DrugChangeStatusAnnotation) oneDrugChangeStatus.next();
                    drugTokenAnt.setDrugChangeStatus(dsa.getChangeStatus());
                    statusKey = dsa.getChangeStatus();
                  }
                }
                drugTokenAnt.setStatus(ssid.getStatus());
                dm.setDrugChangeStatusElement(statusKey, begin, end);

                statusFound = true;
              }
            }
          }

          // Look for special case where status comes before the drug
          // mention
          // A better means to locate the beginning of the chunk is
          // lacking here mainly due
          // to the fact that the sentence annotator cannot be trusted to
          // find the beginning
          // accurately.

          Iterator statusSpecialChangeItr = FSUtil.getAnnotationsIteratorInSpan(jcas, DrugChangeStatusAnnotation.type, begin - 20, drugTokenAnt.getBegin() + 1);
          while (statusSpecialChangeItr.hasNext())
          {
            DrugChangeStatusAnnotation specialDsa = (DrugChangeStatusAnnotation) statusSpecialChangeItr.next();
            if (specialDsa.getEnd() + 1 == drugTokenAnt.getBegin()
                && relatedStatus == null)
            {
              drugTokenAnt.setDrugChangeStatus(specialDsa.getChangeStatus());
              drugTokenAnt.setChangeStatusBegin(specialDsa.getBegin());
              drugTokenAnt.setChangeStatusEnd(specialDsa.getEnd());
              overrideStatus = true;
            }
          }
        }
        // If a strength token is discovered before the next
        // distinguished
        // drug mentions then the remaining sentence is scanned for
        // DrugChangeStatus.
        // Iterator strengthAllItr = FSUtil.getAnnotationsIteratorInSpan(
        // jcas, StrengthAnnotation.type, begin, end + 1);
        //
        // List holdStrength = new ArrayList();
        // while (strengthAllItr.hasNext()) {
        // StrengthAnnotation sa = (StrengthAnnotation) strengthAllItr
        // .next();
        // holdStrength.add(sa);
        // }
        String strengthText = null;
        boolean onlyNeedOneStrength = false;
        if (!keepNoChangeStatus || (drugTokenAnt.getStrength() == null)) {
          List holdStrength = getAnnotationsInSpan(jcas, StrengthAnnotation.type,
              begin, end + 1);

          Iterator strengthItr = findUniqueMentions(holdStrength.toArray()).iterator();

          double strengthValue = 0;


          int holdStrengthBeginOffset = 0, holdStrengthEndOffset = 0;


          while (strengthItr.hasNext() && !onlyNeedOneStrength)
          {
            StrengthAnnotation sa = (StrengthAnnotation) strengthItr.next();

            if (holdStrengthBeginOffset != sa.getBegin()
                && holdStrengthEndOffset != sa.getEnd()
                && (relatedStatus != null))
            {

              double curStrengthValue = 0;

              int hyphenLocation = sa.getCoveredText().indexOf("-");
              String holdStrengthValue = sa.getCoveredText();

              if (hyphenLocation > 0)
              {
                holdStrengthValue = holdStrengthValue.substring(0, hyphenLocation);
              }

              int spaceLocation = holdStrengthValue.indexOf(" ");

              if (spaceLocation > 0)
              {
                holdStrengthValue = holdStrengthValue.substring(0, spaceLocation);
              }

              if (holdStrengthValue != null
                  && holdStrengthValue.compareTo("") != 0)
                curStrengthValue = new Double(dm.parseDoubleValue(holdStrengthValue)).doubleValue();
              boolean findLowValue = true;

              if (relatedStatus[0].compareTo(DrugChangeStatusToken.INCREASE) == 0)
              {
                if (curStrengthValue > strengthValue)
                {
                  strengthValue = curStrengthValue;
                  strengthText = dm.getStrengthElement();
                }
              } else if (relatedStatus[0].compareTo(DrugChangeStatusToken.DECREASE) == 0)
              {
                if (findLowValue)
                  strengthValue = curStrengthValue;
                if (curStrengthValue <= strengthValue)
                {
                  strengthValue = curStrengthValue;
                  strengthText = dm.getStrengthElement();
                }
                findLowValue = false;

              } else if (relatedStatus[0].compareTo(DrugChangeStatusToken.SUM) == 0)
              {

                strengthValue = curStrengthValue;
                strengthText = dm.getStrengthElement();
                // get first value found
              }
            } else
            {
              strengthText = dm.getStrengthElement();
              if (!maxExists)
                onlyNeedOneStrength = true;
              else if (maxOffsetEnd + 1 == sa.getBegin())
              {
                onlyNeedOneStrength = true;
                strengthText = sa.getCoveredText();
              }
            }

            holdStrengthBeginOffset = sa.getBegin();
            holdStrengthEndOffset = sa.getEnd();

          }
        }
        String doseText = null;
        if (!keepNoChangeStatus || (drugTokenAnt.getDosage() == null)) {
          Iterator dosageItr = FSUtil.getAnnotationsIteratorInSpan(jcas,
              DosagesAnnotation.type, begin, end + 1);
          List holdDosages = new ArrayList();
          double doseValue = 0;

          int holdDoseBeginOffset = 0, holdDoseEndOffset = 0;
          boolean onlyNeedOneDose = false;

          while (dosageItr.hasNext() && !onlyNeedOneDose)
          {
            DosagesAnnotation da = (DosagesAnnotation) dosageItr.next();
            if (holdDoseBeginOffset != da.getBegin()
                && holdDoseEndOffset != da.getEnd() && relatedStatus != null)
            {
              int removeComma = da.getCoveredText().indexOf(',');
              String doseTextCheck = da.getCoveredText();
              if (removeComma > 0)
              {
                doseTextCheck = doseTextCheck.substring(0, removeComma);
              }
              double curDoseValue = new Double(dm.convertFromTextToNum(doseTextCheck)).doubleValue();
              boolean findLowValue = true;
              if (relatedStatus[0].compareTo(DrugChangeStatusToken.INCREASE) == 0)
              {
                if (curDoseValue > doseValue)
                {
                  doseValue = curDoseValue;
                  doseText = dm.getDosageElement();
                } else if (relatedStatus[0].compareTo(DrugChangeStatusToken.SUM) == 0)
                {

                  doseValue = curDoseValue;
                  doseText = dm.getDosageElement();

                }
              } else if (relatedStatus[0].compareTo(DrugChangeStatusToken.DECREASE) == 0)
              {
                if (findLowValue)
                  doseValue = curDoseValue;
                if (curDoseValue <= doseValue)
                {
                  doseValue = curDoseValue;
                  doseText = dm.getDosageElement();
                }
                findLowValue = false;
              }
              holdDosages.add(da);
              holdDoseBeginOffset = da.getBegin();
              holdDoseEndOffset = da.getEnd();
            } else
            {
              doseText = dm.getDosageElement();

              if (!maxExists)
                onlyNeedOneDose = true;
            }
          }
        }
        String frequencyText = null;
        if (!keepNoChangeStatus || (drugTokenAnt.getFrequency() == null)) {
          Iterator freqItr = FSUtil.getAnnotationsIteratorInSpan(jcas,
              FrequencyAnnotation.type, begin, end + 1);

          List holdFreqItr = new ArrayList();
          while (freqItr.hasNext())
          {
            holdFreqItr.add(freqItr.next());
          }
          Iterator frequencyItr = sortAnnotations(holdFreqItr.toArray()).iterator();

          List holdFrequency = new ArrayList();
          double frequencyValue = 0;

          int holdFrequencyBeginOffset = 0, holdFrequencyEndOffset = 0;
          boolean onlyNeedOneFrequency = false;

          while (frequencyItr.hasNext() && !onlyNeedOneFrequency)
          {
            FrequencyAnnotation fa = (FrequencyAnnotation) frequencyItr.next();

            if (dm.frequency != null
                && dm.frequency.getFrequencyMention() == null)
            {
              double curFrequencyValue = new Double(dm.convertFromTextToNum(fa.getCoveredText())).doubleValue();
              String curFreqValueText = new Double(curFrequencyValue).toString();
              dm.setFrequencyElement(curFreqValueText, fa.getBegin(), fa.getEnd());
              frequencyText = curFreqValueText;
            }
            onlyNeedOneFrequency = true;

            holdFrequency.add(fa);
            holdFrequencyBeginOffset = fa.getBegin();
            holdFrequencyEndOffset = fa.getEnd();
          }
        }
        boolean foundPRN = false;
        String frequencyUnitText = null;
        if (!keepNoChangeStatus || (drugTokenAnt.getFrequencyUnit() == null)) {
          Iterator frequencyUnitItr = FSUtil.getAnnotationsIteratorInSpan(jcas,
              FrequencyUnitAnnotation.type, begin, end + 1);
          List holdFrequencyUnit = new ArrayList();
          double frequencyUnitValue = 0;

          int holdFrequencyUnitBeginOffset = 0, holdFrequencyUnitEndOffset = 0;
          boolean onlyNeedOneFrequencyUnit = false;


          while (frequencyUnitItr.hasNext() && !onlyNeedOneFrequencyUnit)
          {
            FrequencyUnitAnnotation fua = (FrequencyUnitAnnotation) frequencyUnitItr.next();
            if (holdFrequencyUnitBeginOffset != fua.getBegin()
                && holdFrequencyUnitEndOffset != fua.getEnd()
                && relatedStatus != null)
            {
              double curFrequencyUnitValue = new Float(fua.getPeriod()).doubleValue();

              boolean findLowValue = true;
              if (relatedStatus[0].compareTo(DrugChangeStatusToken.INCREASE) == 0)
              {
                if (curFrequencyUnitValue > frequencyUnitValue)
                {
                  frequencyUnitValue = curFrequencyUnitValue;
                  frequencyUnitText = dm.getFrequencyUnitElement();
                }
              } else if (relatedStatus[0] == null
                  || relatedStatus[0].compareTo(DrugChangeStatusToken.DECREASE) == 0)
              {
                if (findLowValue)
                  frequencyUnitValue = curFrequencyUnitValue;
                if (curFrequencyUnitValue <= frequencyUnitValue)
                {
                  frequencyUnitValue = curFrequencyUnitValue;
                  frequencyUnitText = dm.getFrequencyUnitElement();
                }
                findLowValue = false;
              }
            } else
            {
              if (fua.getPeriod() == FrequencyUnitToken.QUANTITY_PRN)
                foundPRN = true;
              else
              {
                frequencyUnitText = dm.getFrequencyUnitElement();

                if (!maxExists)
                {
                  onlyNeedOneStrength = true;
                }

              }
            }

            holdFrequencyUnit.add(fua);
            holdFrequencyUnitBeginOffset = fua.getBegin();
            holdFrequencyUnitEndOffset = fua.getEnd();
          }

        }
        if (recurseNER != null && recurseNER.getDrugChangeStatus() != null
            && relatedStatus[0] != null  && dm.changeStatus == null)
          drugTokenAnt.setDrugChangeStatus(relatedStatus[0]);
        else if (keepNoChangeStatus || (dm.changeStatus != null &&
            (dm.changeStatus.getDrugChangeStatus().equals(DrugChangeStatusToken.INCREASEFROM)
                || dm.changeStatus.getDrugChangeStatus().equals(DrugChangeStatusToken.DECREASEFROM)))) {
          drugTokenAnt.setDrugChangeStatus(DrugChangeStatusToken.NOCHANGE);
        }
        else if (dm.getDrugChangeStatusElement() != null
            && dm.getDrugChangeStatusElement().compareTo("") != 0
            && dm.getDrugChangeStatusElement().compareTo(
                DrugChangeStatusToken.NOCHANGE) != 0
                /*
                 * && drugTokenAnt.getDrugChangeStatus() != null && drugTokenAnt
                 * .getDrugChangeStatus().compareTo(DrugChangeStatusToken .NOCHANGE)
                 * == 0
                 */
                && !overrideStatus)
        {
          // Don't want subsections here

          Iterator negateStatusChanges = FSUtil.getAnnotationsIteratorInSpan(
              jcas, SubSectionAnnotation.type,
              dm.changeStatus.getBeginOffset(),
              dm.changeStatus.getEndOffset() + 2);
          if ((!negateStatusChanges.hasNext() || statusFound) && !keepNoChangeStatus) {
            drugTokenAnt.setDrugChangeStatus(dm.getDrugChangeStatusElement());
            drugTokenAnt.setChangeStatusBegin(dm.getChangeStatusBegin());
            drugTokenAnt.setChangeStatusEnd(dm.getChangeStatusEnd());
          }
          else
            drugTokenAnt.setDrugChangeStatus(DrugChangeStatusToken.NOCHANGE);
        } else if (relatedStatus != null && relatedStatus[0] != null) {
          drugTokenAnt.setDrugChangeStatus(relatedStatus[0]);
          drugTokenAnt.setChangeStatusBegin(new Integer (relatedStatus[1]).intValue());
          drugTokenAnt.setChangeStatusEnd(new Integer (relatedStatus[2]).intValue());
        } else if (drugTokenAnt.getDrugChangeStatus() == null
            || drugTokenAnt.getDrugChangeStatus().compareTo("") == 0)
          drugTokenAnt.setDrugChangeStatus(DrugChangeStatusToken.NOCHANGE);
        if (!keepNoChangeStatus) {
          String relatedStatusString = null;
          if (relatedStatus != null && relatedStatus[0] != null)
            relatedStatusString = relatedStatus[0];
          float confidenceScore = alignDrugMentionAttributes( strengthText,  dm ,  drugTokenAnt,  recurseNER,  relatedStatusString,  statusFound,  overrideStatus,
              maxExists,  doseText,  frequencyText,  frequencyUnitText);
          drugTokenAnt.setConfidence(confidenceScore);
        }

        if (foundPRN)
          drugTokenAnt.setDrugChangeStatus(drugTokenAnt.getDrugChangeStatus());

        ChunkAnnotation ca = new ChunkAnnotation(jcas, begin, end);
        ca.addToIndexes();
        ca.setSentenceID(tokenAnt.getSentenceID());

        drugTokenAnt.addToIndexes();
        globalDrugNER.add(drugTokenAnt);

      }

      if (isDrugNER)
      {
        countNER = globalDrugNER.size();
        boolean gotChangeStatus = false;
        for (int i = 0; i < countNER; i++)
        {
          if (!globalDrugNER.get(i).getDrugChangeStatus().equals("noChange") && !globalDrugNER.get(i).getDrugChangeStatus().equals("stop") && !globalDrugNER.get(i).getDrugChangeStatus().equals("start"))
            gotChangeStatus = true;
          if (i == 0) {
            addMedicationSpecificAttributes(jcas, globalDrugNER.get(i), tokenAnt);
          }
          else if (gotChangeStatus){
            MedicationMention mem = new MedicationMention(jcas, globalDrugNER.get(i).getBegin(), globalDrugNER.get(i).getEnd());
            addMedicationSpecificAttributes(jcas, globalDrugNER.get(i), mem);
            mem.addToIndexes(jcas);
          }
        }
      }
     
    }
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.