Java Code Examples for org.hl7.fhir.dstu3.model.Identifier

The following examples show how to use org.hl7.fhir.dstu3.model.Identifier. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: org.hl7.fhir.core   Source File: ArgonautConverter.java    License: Apache License 2.0 6 votes vote down vote up
private void processSocialHistorySection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
	scanSection("Social History", section);
	int i = 0;
	for (Element c : cda.getChildren(section, "entry")) {
		Element o = cda.getChild(c, "observation");
		Observation obs = new Observation();
		obs.setId(context.baseId+"-smoking-"+(i == 0 ? "" : Integer.toString(i)));
		obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-smokingstatus-dafsmokingstatus");
		i++;
		obs.setSubject(context.subjectRef);
		obs.setContext(new Reference().setReference("Encounter/"+context.encounter.getId()));
		obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), new Coding().setSystem("http://loinc.org").setCode("72166-2")));

		boolean found = false;
		for (Element e : cda.getChildren(o, "id")) {
			Identifier id = convert.makeIdentifierFromII(e);
			obs.getIdentifier().add(convert.makeIdentifierFromII(e));
		}
		if (!found) {
			obs.setStatus(ObservationStatus.FINAL);
			obs.setEffective(convert.makeDateTimeFromTS(cda.getChild(o, "effectiveTime")));
			obs.setValue(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "value")), null));
			saveResource(obs, "-sh");
		}
	}
}
 
Example 2
Source Project: org.hl7.fhir.core   Source File: NarrativeGenerator.java    License: Apache License 2.0 6 votes vote down vote up
private String displayIdentifier(Identifier ii) {
  String s = Utilities.noString(ii.getValue()) ? "??" : ii.getValue();

  if (ii.hasType()) {
  	if (ii.getType().hasText())
  		s = ii.getType().getText()+" = "+s;
  	else if (ii.getType().hasCoding() && ii.getType().getCoding().get(0).hasDisplay())
  		s = ii.getType().getCoding().get(0).getDisplay()+" = "+s;
  	else if (ii.getType().hasCoding() && ii.getType().getCoding().get(0).hasCode())
  		s = lookupCode(ii.getType().getCoding().get(0).getSystem(), ii.getType().getCoding().get(0).getCode())+" = "+s;
  }

  if (ii.hasUse())
    s = s + " ("+ii.getUse().toString()+")";
  return s;
}
 
Example 3
Source Project: bunsen   Source File: TestData.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns a FHIR Observation for testing purposes.
 */
public static Observation newObservation() {

  // Observation based on https://www.hl7.org/FHIR/observation-example-bloodpressure.json.html
  Observation observation = new Observation();

  observation.setId("blood-pressure");

  Identifier identifier = observation.addIdentifier();
  identifier.setSystem("urn:ietf:rfc:3986");
  identifier.setValue("urn:uuid:187e0c12-8dd2-67e2-99b2-bf273c878281");

  observation.setStatus(Observation.ObservationStatus.FINAL);

  Quantity quantity = new Quantity();
  quantity.setValue(new java.math.BigDecimal("123.45"));
  quantity.setUnit("mm[Hg]");
  observation.setValue(quantity);

  return observation;
}
 
Example 4
Source Project: bunsen   Source File: SparkRowConverterTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testNestedReference() {

  Identifier practitionerIdentifier =
      testPatient.getGeneralPractitionerFirstRep().getIdentifier();

  Row practitionerIdentifierRow = testPatientDataset
      .select(functions.explode(functions.col("generalpractitioner")))
      .select("col.organizationId", "col.practitionerId", "col.identifier.id",
          "col.identifier.assigner.reference")
      .head();

  Assert.assertEquals(practitionerIdentifier.getId(), practitionerIdentifierRow.get(2));
  Assert.assertEquals(practitionerIdentifier.getAssigner().getReference(),
      practitionerIdentifierRow.get(3));
}
 
Example 5
public static Identifier.IdentifierUse convertIdentifier(org.hl7.fhir.r4.model.Identifier.IdentifierUse use) {
    switch (use) {
        case OLD:
        case SECONDARY:
             return Identifier.IdentifierUse.SECONDARY;

        case NULL:
             return Identifier.IdentifierUse.NULL;

        case OFFICIAL:
             return Identifier.IdentifierUse.OFFICIAL;

        case TEMP:
            return Identifier.IdentifierUse.TEMP;

        case USUAL:
            return Identifier.IdentifierUse.USUAL;

    }
    return null;
}
 
Example 6
public static org.hl7.fhir.r4.model.Identifier.IdentifierUse convertIdentifier(IdentifierUse use) {
    switch (use) {
        case SECONDARY:
            return org.hl7.fhir.r4.model.Identifier.IdentifierUse.SECONDARY;

        case NULL:
            return org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL;

        case OFFICIAL:
            return org.hl7.fhir.r4.model.Identifier.IdentifierUse.OFFICIAL;

        case TEMP:
            return org.hl7.fhir.r4.model.Identifier.IdentifierUse.TEMP;

        case USUAL:
            return org.hl7.fhir.r4.model.Identifier.IdentifierUse.USUAL;

    }
    return null;
}
 
Example 7
public static void main(String[] theArgs) {

      // Create a resource instance
      Patient pat = new Patient();

      // Add a "name" element
      HumanName name = pat.addName();
      name.setFamily("Simpson").addGiven("Homer").addGiven("J");

      // Add an "identifier" element
      Identifier identifier = pat.addIdentifier();
      identifier.setSystem("http://acme.org/MRNs").setValue("7000135");

      // Model is designed to be chained
      pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("12345");

   }
 
Example 8
public static void main(String[] theArgs) {

      // Create a resource instance
      Patient pat = new Patient();

      // Add a "name" element
      HumanName name = pat.addName();
      name.setFamily("Simpson").addGiven("Homer").addGiven("J");

      // Add an "identifier" element
      Identifier identifier = pat.addIdentifier();
      identifier.setSystem("http://acme.org/MRNs").setValue("7000135");

      // Model is designed to be chained
      pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("12345");

   }
 
Example 9
Source Project: elexis-3-core   Source File: EncounterAccessor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public void setConsultationId(DomainResource resource, String consultationId) {
	org.hl7.fhir.dstu3.model.Encounter fhirEncounter = (org.hl7.fhir.dstu3.model.Encounter) resource;
	boolean identifierFound = false;
	List<Identifier> existing = fhirEncounter.getIdentifier();
	for (Identifier existingIdentifier : existing) {
		if (IdentifierSystem.ELEXIS_CONSID.getSystem().equals(existingIdentifier.getSystem())) {
			existingIdentifier.setValue(consultationId);
			identifierFound = true;
			break;
		}
	}
	if (!identifierFound) {
		Identifier identifier = fhirEncounter.addIdentifier();
		identifier.setSystem(IdentifierSystem.ELEXIS_CONSID.getSystem());
		identifier.setValue(consultationId);
	}
}
 
Example 10
Source Project: org.hl7.fhir.core   Source File: ArgonautConverter.java    License: Apache License 2.0 5 votes vote down vote up
private Observation processObservation(CDAUtilities cda, Convert convert, Context context, Element o) throws Exception {
	Observation obs = new Observation();
	obs.setId(context.baseId+"-results-"+Integer.toString(context.obsId));
	context.obsId++;
	obs.setSubject(context.subjectRef);
	obs.setContext(new Reference().setReference("Encounter/"+context.encounter.getId()));
	obs.setStatus(ObservationStatus.FINAL);
	obs.setEffective(convert.makeDateTimeFromTS(cda.getChild(o, "effectiveTime")));
	obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), null));
	obs.setInterpretation(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "interpretationCode")), null));
	Element rr = cda.getChild(o, "referenceRange");
	if (rr != null)
		obs.addReferenceRange().setText(cda.getChild(cda.getChild(rr, "observationRange"), "text").getTextContent());

	Element v = cda.getChild(o, "value");
	String type = v.getAttribute("xsi:type");
	if ("ST".equals(type)) {
		obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-results-dafresultobsother");
		obs.setValue(new StringType(v.getTextContent()));
	} else if ("CD".equals(type)) {
		obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-results-dafresultobscode");
		obs.setValue(inspectCode(convert.makeCodeableConceptFromCD(v), null));
	} else if ("PQ".equals(type)) {
		obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-results-dafresultobsquantity");
		String va = cda.getChild(o, "value").getAttribute("value");
		if (!Utilities.isDecimal(va, true)) {
			obs.setDataAbsentReason(inspectCode(new CodeableConcept().setText(va), null));
		} else
			obs.setValue(convert.makeQuantityFromPQ(cda.getChild(o, "value"), null));
	} else
		throw new Exception("Unknown type '"+type+"'");

	for (Element e : cda.getChildren(o, "id")) {
		Identifier id = convert.makeIdentifierFromII(e);
		obs.getIdentifier().add(id);
	}
	saveResource(obs, "-gen");
	return obs;
}
 
Example 11
Source Project: org.hl7.fhir.core   Source File: Convert.java    License: Apache License 2.0 5 votes vote down vote up
public Identifier makeIdentifierFromII(Element e) throws Exception {
	Identifier id = new Identifier();
	String r = e.getAttribute("root");
	String ex;
	if (e.hasAttribute("extension") && Utilities.noString(e.getAttribute("extension"))) {
		if (generateMissingExtensions) 
			ex = UUID.randomUUID().toString();
		else
			throw new Exception("Broken identifier - extension is blank");
	} else 
		ex = e.getAttribute("extension");
     
	if (Utilities.noString(ex)) {
		id.setSystem("urn:ietf:rfc:3986");
		if (isGuid(r)) 
			id.setValue("urn:uuid:"+r);
		else if (UriForOid(r) != null)
			id.setValue(UriForOid(r));
		else 
			id.setValue(UriForOid(r));
	} else {
		if (isGuid(r)) 
			id.setSystem("urn:uuid:"+r);
		else if (UriForOid(r) != null)
			id.setSystem(UriForOid(r));
		else 
			id.setSystem("urn:oid:"+r);
		id.setValue(ex);
	}
	return id;
}
 
Example 12
Source Project: org.hl7.fhir.core   Source File: CCDAConverter.java    License: Apache License 2.0 5 votes vote down vote up
protected void addToIdList(List<Identifier> list, Identifier id) throws Exception {
	for (Identifier item : list) {
		if (Comparison.matches(item, id, null))
			Comparison.merge(item, id);
	}
	list.add(id);
}
 
Example 13
Source Project: org.hl7.fhir.core   Source File: CodeSystemUtilities.java    License: Apache License 2.0 5 votes vote down vote up
public static void setOID(CodeSystem cs, String oid) {
  if (!oid.startsWith("urn:oid:"))
     oid = "urn:oid:" + oid;
  if (!cs.hasIdentifier())
    cs.setIdentifier(new Identifier().setSystem("urn:ietf:rfc:3986").setValue(oid));
  else if ("urn:ietf:rfc:3986".equals(cs.getIdentifier().getSystem()) && cs.getIdentifier().hasValue() && cs.getIdentifier().getValue().startsWith("urn:oid:"))
    cs.getIdentifier().setValue(oid);
  else
    throw new Error("unable to set OID on code system");
  
}
 
Example 14
Source Project: org.hl7.fhir.core   Source File: ValueSetUtilities.java    License: Apache License 2.0 5 votes vote down vote up
public static String getOID(ValueSet vs) {
  for (Identifier id : vs.getIdentifier()) {
    if ("urn:ietf:rfc:3986".equals(id.getSystem()) && id.hasValue() && id.getValue().startsWith("urn:oid:"))
      return id.getValue().substring(8);
  }
  return null;
}
 
Example 15
Source Project: org.hl7.fhir.core   Source File: ValueSetUtilities.java    License: Apache License 2.0 5 votes vote down vote up
public static void setOID(ValueSet vs, String oid) {
  if (!oid.startsWith("urn:oid:"))
    oid = "urn:oid:" + oid;
  for (Identifier id : vs.getIdentifier()) {
    if ("urn:ietf:rfc:3986".equals(id.getSystem()) && id.hasValue() && id.getValue().startsWith("urn:oid:")) {
      id.setValue(oid);
      return;
    }
  }
  vs.addIdentifier().setSystem("urn:ietf:rfc:3986").setValue(oid);
}
 
Example 16
Source Project: bunsen   Source File: TestData.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new Observation for testing.
 *
 * @return a FHIR Observation for testing.
 */
public static Observation newObservation() {
  Observation observation = new Observation();

  observation.setId("blood-pressure");

  Identifier identifier = observation.addIdentifier();
  identifier.setSystem("urn:ietf:rfc:3986");
  identifier.setValue("urn:uuid:187e0c12-8dd2-67e2-99b2-bf273c878281");

  observation.setStatus(Observation.ObservationStatus.FINAL);

  CodeableConcept obsCode = new CodeableConcept();

  observation.setCode(obsCode);

  Quantity quantity = new Quantity();
  quantity.setValue(new java.math.BigDecimal("123.45"));
  quantity.setUnit("mm[Hg]");
  quantity.setSystem("http://unitsofmeasure.org");
  observation.setValue(quantity);

  ObservationComponentComponent component = observation.addComponent();

  CodeableConcept code = new CodeableConcept()
      .addCoding(new Coding()
          .setCode("abc")
          .setSystem("PLACEHOLDER"));

  component.setCode(code);

  return observation;
}
 
Example 17
public BaseIdentifier setIdentifier(Identifier identifier, BaseIdentifier entityIdentifier) throws OperationOutcomeException {

        if (identifier.hasType()) {
            ConceptEntity code = conceptDao.findAddCode(identifier.getType().getCoding().get(0));
            if (code != null) {
                entityIdentifier.setIdentifierType(code);
            } else {
                log.info("IdentifierType: Missing System/Code = " + identifier.getType().getCoding().get(0).getSystem() + " code = " + identifier.getType().getCoding().get(0).getCode());

                throw new IllegalArgumentException("Missing System/Code = " + identifier.getType().getCoding().get(0).getSystem() + " code = " + identifier.getType().getCoding().get(0).getCode());
            }

        }
        if (identifier.hasValue()) {
            entityIdentifier.setValue(daoutilsR4.removeSpace(identifier.getValue()));
        }

        if (identifier.hasSystem()) {
            entityIdentifier.setSystem(codeSystemSvc.findSystem(identifier.getSystem()));
        } else {
            entityIdentifier.setSystem(null);
        }
        if (identifier.hasUse()) {
            entityIdentifier.setUse(identifier.getUse());
        }

        return entityIdentifier;
    }
 
Example 18
public BaseIdentifier setIdentifier(org.hl7.fhir.r4.model.Identifier identifier, BaseIdentifier entityIdentifier) throws OperationOutcomeException {

        if (identifier.hasType()) {
            ConceptEntity code = conceptDao.findAddCode(identifier.getType().getCoding().get(0));
            if (code != null) {
                entityIdentifier.setIdentifierType(code);
            } else {
                log.info("IdentifierType: Missing System/Code = " + identifier.getType().getCoding().get(0).getSystem() + " code = " + identifier.getType().getCoding().get(0).getCode());

                throw new IllegalArgumentException("Missing System/Code = " + identifier.getType().getCoding().get(0).getSystem() + " code = " + identifier.getType().getCoding().get(0).getCode());
            }

        }
        if (identifier.hasValue()) {
            entityIdentifier.setValue(daoutilsR4.removeSpace(identifier.getValue()));
        }

        if (identifier.hasSystem()) {
            entityIdentifier.setSystem(codeSystemSvc.findSystem(identifier.getSystem()));
        } else {
            entityIdentifier.setSystem(null);
        }
        if (identifier.hasUse()) {
            entityIdentifier.setUse(convertIdentifier(identifier.getUse()));
        }

        return entityIdentifier;
    }
 
Example 19
public static Identifier getIdentifierStrict(BaseIdentifier2 baseIdentifier, Identifier identifier) {
    if (baseIdentifier.getSystem() != null) identifier.setSystem(baseIdentifier.getSystemValue());
    if (baseIdentifier.getValue() != null) identifier.setValue(baseIdentifier.getValue());
    if (baseIdentifier.getUse() != null) {
        identifier.setUse(baseIdentifier.getIdentifierUse());
    }

    return identifier;
}
 
Example 20
public static Identifier getIdentifier(BaseIdentifier baseIdentifier, Identifier identifier) {
    if (baseIdentifier.getSystem() != null) identifier.setSystem(baseIdentifier.getSystem().getUri());
    if (baseIdentifier.getValue() != null) identifier.setValue(baseIdentifier.getValue());
    if (baseIdentifier.getUse() != null) {
        identifier.setUse(baseIdentifier.getIdentifierUse());
    }
    if (baseIdentifier.getIdentifierType() != null) {
        identifier.getType()
                .addCoding()
                    .setCode(baseIdentifier.getIdentifierType().getCode())
                    .setDisplay(baseIdentifier.getIdentifierType().getDisplay())
                    .setSystem(baseIdentifier.getIdentifierType().getSystem());
    }
    return identifier;
}
 
Example 21
Source Project: net.jgp.labs.spark   Source File: ClaimProcessApp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void call(Row r) throws Exception {

  // Build the claim
  // ---------------

  // CLIENT_ID ....... 0
  // CLIENT_SUB_ID ... 1
  // CLAIM_SK ........ 2
  // CLAIM_NBR ....... 3
  // CLAIM_ADJ_CD,ADJ_FROM_CLAIM_SK,ADJ_FROM_CLAIM_NBR,ADJ_FROM_CLAIM_ADJ_NBR,CLAIM_STS_CD_SK,CLAIM_STS_CD,SYS_SUBSC_SK,SYS_SUBSC_ID,SYS_MBR_SK,SYS_MBR_ID,CLIENT_HIERARCHY_LVL1,CLIENT_HIERARCHY_LVL2,CLIENT_HIERARCHY_LVL3,CLIENT_HIERARCHY_LVL4,MBR_PCP_SK,MBR_PCP_NBR,PROV_SK,PROV_ID,PROV_TP_CD_SK,PROV_TP_CD,PAYEE_SK,PAYEE_ID,PAYEE_TIN,APPROVE_DAY_AMT,ACTUAL_DAY_AMT,CLAIM_BEG_SVC_DT,RECEIVE_DT,PAY_DT,DRG_CD_SK,DRG_CD,SUBMIT_DRG_CD_SK,SUBMIT_DRG_CD,BILL_CLASS_CD,FACILITY_TP_CD,HOSP_FREQ_CD,ADMIT_SRC_CD_SK,ADMIT_SRC_CD,ADMIT_TP_CD_SK,ADMIT_TP_CD,HOSP_ADMIT_DT,HOSP_ADMIT_HR,HOSP_DISCHARGE_DT,HOSP_DISCHARGE_HR,HOSP_DISCHARGE_STS_CD_SK,HOSP_DISCHARGE_STS_CD,ATTENDING_PROV_SK,ATTENDING_PROV_ID,PROV_ADDR_CD_SK,PROV_ADDR_CD,OOA_IND,EDI_REF_ID,CURRENT_IND,SENSTV_DRG_IND,CLIENT_SPECIFIC_TXT1,CLIENT_SPECIFIC_TXT2,CLIENT_SPECIFIC_TXT3,CLIENT_SPECIFIC_TXT4,CLIENT_SPECIFIC_TXT5,CLIENT_SPECIFIC_TXT6,CLIENT_SPECIFIC_TXT7,CLIENT_SPECIFIC_TXT8,CLIENT_SPECIFIC_TXT9,CLIENT_SPECIFIC_TXT10,REC_LOAD_DTTM,REC_LAST_UPD_DTTM,REC_DEL_IND,DRG_CODE_TP_CD,SUBMIT_DRG_CODE_TP_CD,QA_CURRENT_IND
  CodeableConcept cc = new CodeableConcept();
  cc.setUserData("value", r.getString(3)); // TODO check that this is how
                                           // this valued is set here

  Identifier i = new Identifier();
  i.setUse(IdentifierUse.OFFICIAL);
  i.setType(cc);
  i.setSystem("Payer Specific	 Claim Number");
  i.setValue(r.getAs("CLAIM_NBR"));
  // TODO i.setAssigner(value);

  List<Identifier> identifiers = new ArrayList<>();
  identifiers.add(i);

  Claim c = new Claim();
  c.setIdentifier(identifiers);

  // Process/send the claim
  // ----------------------

  // TODO
}
 
Example 22
Source Project: cqf-ruler   Source File: HQMFProvider.java    License: Apache License 2.0 5 votes vote down vote up
private String resolveSetId(CqfMeasure m) {
    Identifier id = this.getIdentifierFor(m, "hqmf-set-id");
    if (id != null && id.hasValue() && !id.getValue().isEmpty()) {
        return id.getValue();
    }
    
    return m.getName();
}
 
Example 23
Source Project: cqf-ruler   Source File: HQMFProvider.java    License: Apache License 2.0 5 votes vote down vote up
private Identifier getIdentifierFor(CqfMeasure m, String identifierCode) {
    for (Identifier i : m.getIdentifier())
    {
        if (i.hasType())
        {
            if(i.getType().getCodingFirstRep().getCode().equalsIgnoreCase(identifierCode)) 
            {
                return i;
            }
        }
    }

    return null;
}
 
Example 24
Source Project: org.hl7.fhir.core   Source File: ArgonautConverter.java    License: Apache License 2.0 4 votes vote down vote up
private void checkGenerateIdentifier(List<Identifier> ids, DomainResource resource) {
	if (ids.isEmpty())
		ids.add(new Identifier().setSystem(DEFAULT_ID_SPACE).setValue(resource.getClass().getName().toLowerCase()+"-"+resource.getId()));
}
 
Example 25
Source Project: org.hl7.fhir.core   Source File: ArgonautConverter.java    License: Apache License 2.0 4 votes vote down vote up
private String keyFor(Identifier identifier) {
	return identifier.getSystem()+"||"+identifier.getValue();
}
 
Example 26
Source Project: org.hl7.fhir.core   Source File: ArgonautConverter.java    License: Apache License 2.0 4 votes vote down vote up
private void processAllergiesSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
	scanSection("Allergies", section);
	ListResource list = new ListResource();
	list.setId(context.baseId+"-list-allergies");
	list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafallergylist");
	list.setSubject(context.subjectRef);
	list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
	list.setTitle(cda.getChild(section, "title").getTextContent());
	list.setStatus(ListStatus.CURRENT);
	list.setDateElement(context.now);
	list.setSource(context.authorRef);
	list.setMode(ListMode.SNAPSHOT);
	buildNarrative(list, cda.getChild(section, "text"));

	int i = 0;
	for (Element c : cda.getChildren(section, "entry")) {
		Element apa = cda.getChild(c, "act"); // allergy problem act
		AllergyIntolerance ai = new AllergyIntolerance();
		ai.setId(context.baseId+"-allergy-"+Integer.toString(i));
		ai.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/allergyintolerance-daf-dafallergyintolerance");
		i++;
		ai.setPatient(context.subjectRef);

		ai.setAssertedDateElement(convert.makeDateTimeFromTS(cda.getChild(cda.getChild(apa, "effectiveTime"), "low")));
		boolean found = false;
		for (Element e : cda.getChildren(apa, "id")) {
			Identifier id = convert.makeIdentifierFromII(e);
			ai.getIdentifier().add(id);
		}
		if (!found) {
			list.addEntry().setItem(new Reference().setReference("AllergyIntolerance/"+ai.getId()));

			Element ao = cda.getChild(cda.getChild(apa, "entryRelationship"), "observation"); // allergy observation
			if (!cda.getChild(ao, "value").getAttribute("code").equals("419511003"))
				throw new Error("unexpected code");
			// nothing....

			// no allergy status observation
			List<Element> reactions = cda.getChildren(ao, "entryRelationship");
			Element pe = cda.getChild(cda.getChild(cda.getChild(ao, "participant"), "participantRole"), "playingEntity");
			Element pec = cda.getChild(pe, "code");
			if (pec == null || !Utilities.noString(pec.getAttribute("nullFlavor"))) {
				String n = cda.getChild(pe, "name").getTextContent();
				//				if (n.contains("No Known Drug Allergies") && reactions.isEmpty())
				//					ai.setSubstance(new CodeableConcept().setText(n)); // todo: what do with this?
				//				else
				ai.setCode(new CodeableConcept().setText(n));
			} else
				ai.setCode(inspectCode(convert.makeCodeableConceptFromCD(pec), null));
			recordAllergyCode(ai.getCode());
			if (!reactions.isEmpty()) {
				AllergyIntoleranceReactionComponent aie = ai.addReaction();
				for (Element er : reactions) {
					Element ro = cda.getChild(er, "observation");
					aie.addManifestation(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(ro, "value")), null));
				}
			}

			saveResource(ai);
		}
	}
	saveResource(list);
}
 
Example 27
Source Project: org.hl7.fhir.core   Source File: ArgonautConverter.java    License: Apache License 2.0 4 votes vote down vote up
private void processVitalSignsSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
	scanSection("Vital Signs", section);
	ListResource list = new ListResource();
	list.setId(context.baseId+"-list-vitalsigns");
	//. list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafproblemlist"); no list
	list.setSubject(context.subjectRef);
	list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
	list.setTitle(cda.getChild(section, "title").getTextContent());
	list.setStatus(ListStatus.CURRENT);
	list.setMode(ListMode.SNAPSHOT);
	list.setDateElement(context.now);
	list.setSource(context.authorRef);
	buildNarrative(list, cda.getChild(section, "text"));

	int i = 0;
	for (Element c : cda.getChildren(section, "entry")) {
		Element org = cda.getChild(c, "organizer"); // problem concern act
		for (Element oc : cda.getChildren(org, "component")) {
			Element o = cda.getChild(oc, "observation"); // problem concern act
			Observation obs = new Observation();
			obs.setId(context.baseId+"-vitals-"+Integer.toString(i));
			obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-vitalsigns-dafvitalsigns");
			i++;
			obs.setSubject(context.subjectRef);
			obs.setContext(new Reference().setReference("Encounter/"+context.encounter.getId()));
			obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), null));

			boolean found = false;
			for (Element e : cda.getChildren(o, "id")) {
				Identifier id = convert.makeIdentifierFromII(e);
				obs.getIdentifier().add(id);
			}

			if (!found) {
				list.addEntry().setItem(new Reference().setReference("Observation/"+obs.getId()));
				obs.setStatus(ObservationStatus.FINAL);
				obs.setEffective(convert.makeDateTimeFromTS(cda.getChild(o, "effectiveTime")));
				String v = cda.getChild(o, "value").getAttribute("value");
				if (!Utilities.isDecimal(v, true)) {
					obs.setDataAbsentReason(inspectCode(new CodeableConcept().setText(v), null));
				} else
					obs.setValue(convert.makeQuantityFromPQ(cda.getChild(o, "value")));
				saveResource(obs, "-vs");
			}
		}
	}
	saveResource(list, "-vs");
}
 
Example 28
Source Project: org.hl7.fhir.core   Source File: ObjectConverter.java    License: Apache License 2.0 4 votes vote down vote up
public static Identifier readAsIdentifier(Element item) {
  Identifier r = new Identifier();
  r.setSystem(item.getNamedChildValue("system"));
  r.setValue(item.getNamedChildValue("value"));
  return r;
}
 
Example 29
Source Project: org.hl7.fhir.core   Source File: LoincToDEConvertor.java    License: Apache License 2.0 4 votes vote down vote up
private void processLoincCodes() {
	Element row = XMLUtil.getFirstChild(xml.getDocumentElement());
	int i = 0;
	while (row != null) {
		i++;
		if (i % 1000 == 0)
			System.out.print(".");
			String code = col(row, "LOINC_NUM");
			String comp = col(row, "COMPONENT");
			DataElement de = new DataElement();
			de.setId("loinc-"+code);
	    de.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));
			bundle.getEntry().add(new BundleEntryComponent().setResource(de));
			Identifier id = new Identifier();
			id.setSystem("http://hl7.org/fhir/commondataelement/loinc");
			id.setValue(code);
			de.addIdentifier(id);
			de.setPublisher("Regenstrief + FHIR Project Team");
			if (!col(row, "STATUS").equals("ACTIVE"))
 				de.setStatus(PublicationStatus.DRAFT); // till we get good at this
			else
				de.setStatus(PublicationStatus.RETIRED);
			de.setDateElement(DateTimeType.now());
			de.setName(comp);
			ElementDefinition dee = de.addElement();

			// PROPERTY	ignore
			// TIME_ASPCT	
			// SYSTEM	
			// SCALE_TYP	
			// METHOD_TYP	
			// dee.getCategory().add(new CodeableConcept().setText(col(row, "CLASS")));
			// SOURCE	
			// DATE_LAST_CHANGED - should be in ?	
			// CHNG_TYPE	
			dee.setComment(col(row , "COMMENTS"));
			if (hasCol(row, "CONSUMER_NAME"))
				dee.addAlias(col(row, "CONSUMER_NAME"));	
			// MOLAR_MASS	
			// CLASSTYPE	
			// FORMULA	
			// SPECIES	
			// EXMPL_ANSWERS	
			// ACSSYM	
			// BASE_NAME - ? this is a relationship	
			// NAACCR_ID	
			// ---------- CODE_TABLE todo	
			// SURVEY_QUEST_TEXT	
			// SURVEY_QUEST_SRC	
			if (hasCol(row, "RELATEDNAMES2")) {
        String n = col(row, "RELATEDNAMES2");
        for (String s : n.split("\\;")) {
					if (!Utilities.noString(s))
						dee.addAlias(s);	
        }
			}
			dee.addAlias(col(row, "SHORTNAME"));	
			// ORDER_OBS	
			// CDISC Code	
			// HL7_FIELD_SUBFIELD_ID	
			//  ------------------ EXTERNAL_COPYRIGHT_NOTICE todo	
			dee.setDefinition(col(row, "LONG_COMMON_NAME"));	
			// HL7_V2_DATATYPE	
			String cc = makeType(col(row, "HL7_V3_DATATYPE"), code);
			if (cc != null)
			  dee.addType().setCode(cc);	
			// todo... CURATED_RANGE_AND_UNITS	
			// todo: DOCUMENT_SECTION	
			// STATUS_REASON	
			// STATUS_TEXT	
			// CHANGE_REASON_PUBLIC	
			// COMMON_TEST_RANK	
			// COMMON_ORDER_RANK	
			// COMMON_SI_TEST_RANK	
			// HL7_ATTACHMENT_STRUCTURE

			// units:
			// UNITSREQUIRED	
			// SUBMITTED_UNITS
			ToolingExtensions.setAllowableUnits(dee, makeUnits(col(row, "EXAMPLE_UNITS"), col(row, "EXAMPLE_UCUM_UNITS")));
			// EXAMPLE_SI_UCUM_UNITS	
		
		row = XMLUtil.getNextSibling(row);
	}
	System.out.println("done");
}
 
Example 30
Source Project: org.hl7.fhir.core   Source File: ToolingExtensions.java    License: Apache License 2.0 4 votes vote down vote up
public static void addIdentifier(Element element, Identifier value) {
  element.getExtension().add(Factory.newExtension(EXT_IDENTIFIER, value, true));       
}