use of org.hl7.fhir.r4b.model.PositiveIntType in project beneficiary-fhir-data by CMSgov.
the class TransformerUtilsV2 method addCareTeamPractitioner.
/**
* Ensures that the specified {@link ExplanationOfBenefit} has the specified {@link
* CareTeamComponent}, and links the specified {@link ItemComponent} to that {@link
* CareTeamComponent} (via {@link ItemComponent#addCareTeamLinkId(int)}).
*
* @param eob the {@link ExplanationOfBenefit} that the {@link CareTeamComponent} should be part
* of
* @param eobItem the {@link ItemComponent} that should be linked to the {@link CareTeamComponent}
* @param practitionerIdSystem the {@link Identifier#getSystem()} of the practitioner to reference
* in {@link CareTeamComponent#getProvider()}
* @param practitionerIdValue the {@link Identifier#getValue()} of the practitioner to reference
* in {@link CareTeamComponent#getProvider()}
* @param careTeamRole the {@link ClaimCareteamrole} to use for the {@link
* CareTeamComponent#getRole()}
* @return the {@link CareTeamComponent} that was created/linked
*/
private static CareTeamComponent addCareTeamPractitioner(ExplanationOfBenefit eob, ItemComponent eobItem, C4BBPractitionerIdentifierType type, String practitionerIdValue, String roleSystem, String roleCode, String roleDisplay) {
// Try to find a matching pre-existing entry.
CareTeamComponent careTeamEntry = eob.getCareTeam().stream().filter(ctc -> ctc.getProvider().hasIdentifier()).filter(ctc -> type.getSystem().equals(ctc.getProvider().getIdentifier().getSystem()) && practitionerIdValue.equals(ctc.getProvider().getIdentifier().getValue())).filter(ctc -> ctc.hasRole()).filter(ctc -> roleCode.equals(ctc.getRole().getCodingFirstRep().getCode()) && roleSystem.equals(ctc.getRole().getCodingFirstRep().getSystem())).findAny().orElse(null);
// <ID Value> => ExplanationOfBenefit.careTeam.provider
if (careTeamEntry == null) {
careTeamEntry = eob.addCareTeam();
// addItem adds and returns, so we want size() not size() + 1 here
careTeamEntry.setSequence(eob.getCareTeam().size());
careTeamEntry.setProvider(createPractitionerIdentifierReference(type, practitionerIdValue));
CodeableConcept careTeamRoleConcept = createCodeableConcept(roleSystem, roleCode);
careTeamRoleConcept.getCodingFirstRep().setDisplay(roleDisplay);
careTeamEntry.setRole(careTeamRoleConcept);
}
// care team entry is at eob level so no need to create item link id
if (eobItem == null) {
return careTeamEntry;
}
// ExplanationOfBenefit.careTeam.sequence => ExplanationOfBenefit.item.careTeamSequence
if (!eobItem.getCareTeamSequence().contains(new PositiveIntType(careTeamEntry.getSequence()))) {
eobItem.addCareTeamSequence(careTeamEntry.getSequence());
}
return careTeamEntry;
}
use of org.hl7.fhir.r4b.model.PositiveIntType in project beneficiary-fhir-data by CMSgov.
the class McsClaimTransformerV2 method getItems.
private static List<Claim.ItemComponent> getItems(PreAdjMcsClaim claimGroup) {
return ObjectUtils.defaultIfNull(claimGroup.getDetails(), List.<PreAdjMcsDetail>of()).stream().map(detail -> {
Claim.ItemComponent item = new Claim.ItemComponent().setSequence(detail.getPriority() + 1).setProductOrService(new CodeableConcept(new Coding(BBCodingSystems.HCPCS, detail.getIdrProcCode(), null))).setServiced(new Period().setStart(localDateToDate(detail.getIdrDtlFromDate())).setEnd(localDateToDate(detail.getIdrDtlToDate()))).setModifier(getModifiers(detail));
// Set the DiagnosisSequence only if the detail Dx Code is not null and present in the
// Dx table.
Optional.ofNullable(detail.getIdrDtlPrimaryDiagCode()).ifPresent(detailDiagnosisCode -> {
Optional<PreAdjMcsDiagnosisCode> matchingCode = claimGroup.getDiagCodes().stream().filter(diagnosisCode -> codesAreEqual(diagnosisCode.getIdrDiagCode(), detailDiagnosisCode)).findFirst();
matchingCode.ifPresent(diagnosisCode -> item.setDiagnosisSequence(List.of(new PositiveIntType(diagnosisCode.getPriority() + 1))));
});
return item;
}).sorted(Comparator.comparing(Claim.ItemComponent::getSequence)).collect(Collectors.toList());
}
use of org.hl7.fhir.r4b.model.PositiveIntType in project openmrs-module-fhir2 by openmrs.
the class ImmunizationTranslatorImpl method toFhirResource.
@Override
public Immunization toFhirResource(@Nonnull Obs openmrsImmunization) {
if (openmrsImmunization == null) {
return null;
}
Immunization immunization = new Immunization();
immunization.setId(openmrsImmunization.getUuid());
immunization.setStatus(ImmunizationStatus.COMPLETED);
immunization.setPatient(patientReferenceTranslator.toFhirResource(new Patient(openmrsImmunization.getPerson())));
immunization.setEncounter(visitReferenceTranslator.toFhirResource(openmrsImmunization.getEncounter().getVisit()));
immunization.setPerformer(Collections.singletonList(new ImmunizationPerformerComponent(practitionerReferenceTranslator.toFhirResource(helper.getAdministeringProvider(openmrsImmunization)))));
Map<String, Obs> members = helper.getObsMembersMap(openmrsImmunization);
{
Obs obs = members.get(CIEL_984);
if (obs != null) {
immunization.setVaccineCode(conceptTranslator.toFhirResource(obs.getValueCoded()));
}
}
{
Obs obs = members.get(CIEL_1410);
if (obs != null) {
immunization.setOccurrence(observationValueTranslator.toFhirResource(obs));
}
}
{
Obs obs = members.get(CIEL_1418);
if (obs != null && obs.getValueNumeric() != null) {
immunization.addProtocolApplied(new ImmunizationProtocolAppliedComponent(new PositiveIntType((long) obs.getValueNumeric().doubleValue())));
}
}
{
Obs obs = members.get(CIEL_1419);
if (obs != null) {
immunization.setManufacturer(new Reference().setDisplay(obs.getValueText()));
}
}
{
Obs obs = members.get(CIEL_1420);
if (obs != null) {
immunization.setLotNumber(members.get(CIEL_1420).getValueText());
}
}
{
Obs obs = members.get(CIEL_165907);
if (obs != null) {
immunization.setExpirationDate(obs.getValueDate());
}
}
return immunization;
}
use of org.hl7.fhir.r4b.model.PositiveIntType in project ab2d by CMSgov.
the class NewFilterLogicTest method makeSureLinksAreNotFilteredOut.
@Test
void makeSureLinksAreNotFilteredOut() {
ExplanationOfBenefit eob = (ExplanationOfBenefit) EobTestDataUtil.createEOB();
ExplanationOfBenefit.ItemComponent item = eob.getItem().get(0);
item.getProcedureLinkId().add(new PositiveIntType(4));
ExplanationOfBenefit newEob = (ExplanationOfBenefit) ExplanationOfBenefitTrimmerSTU3.getBenefit(eob);
ExplanationOfBenefit.ItemComponent newItem = newEob.getItem().get(0);
assertEquals(2, newItem.getCareTeamLinkId().get(0).getValue());
assertEquals(4, newItem.getProcedureLinkId().get(0).getValue());
assertEquals(5, newItem.getDiagnosisLinkId().get(0).getValue());
}
use of org.hl7.fhir.r4b.model.PositiveIntType in project kindling by HL7.
the class OldSpreadsheetParser method processValue.
private DataType processValue(Sheet sheet, int row, String column, String source, ElementDefn e) throws Exception {
if (Utilities.noString(source))
return null;
if (e.getTypes().size() != 1)
throw new Exception("Unable to process " + column + " unless a single type is specified (types = " + e.typeCode() + ") " + getLocation(row) + ", column = " + column);
String type = e.typeCode();
if (definitions != null) {
if (definitions.getConstraints().containsKey(type))
type = definitions.getConstraints().get(type).getBaseType();
} else {
StructureDefinition sd = context.fetchTypeDefinition(type);
if (// not loaded yet?
sd != null)
type = sd.getType();
if (type.equals("SimpleQuantity"))
type = "Quantity";
}
if (source.startsWith("{")) {
JsonParser json = new JsonParser();
return json.parseType(source, type);
} else if (source.startsWith("<")) {
XmlParser xml = new XmlParser();
return xml.parseType(source, type);
} else {
if (source.startsWith("\"") && source.endsWith("\""))
source = source.substring(1, source.length() - 1);
if (type.equals("string"))
return new StringType(source);
if (type.equals("boolean"))
return new BooleanType(Boolean.valueOf(source));
if (type.equals("integer"))
return new IntegerType(Integer.valueOf(source));
if (type.equals("integer64"))
return new Integer64Type(Long.valueOf(source));
if (type.equals("unsignedInt"))
return new UnsignedIntType(Integer.valueOf(source));
if (type.equals("positiveInt"))
return new PositiveIntType(Integer.valueOf(source));
if (type.equals("decimal"))
return new DecimalType(new BigDecimal(source));
if (type.equals("base64Binary"))
return new Base64BinaryType(Base64.decode(source.toCharArray()));
if (type.equals("instant"))
return new InstantType(source);
if (type.equals("uri"))
return new UriType(source);
if (type.equals("url"))
return new UrlType(source);
if (type.equals("canonical"))
return new CanonicalType(source);
if (type.equals("date"))
return new DateType(source);
if (type.equals("dateTime"))
return new DateTimeType(source);
if (type.equals("time"))
return new TimeType(source);
if (type.equals("code"))
return new CodeType(source);
if (type.equals("oid"))
return new OidType(source);
if (type.equals("uuid"))
return new UuidType(source);
if (type.equals("id"))
return new IdType(source);
if (type.startsWith("Reference(")) {
Reference r = new Reference();
r.setReference(source);
return r;
}
if (type.equals("Period")) {
if (source.contains("->")) {
String[] parts = source.split("\\-\\>");
Period p = new Period();
p.setStartElement(new DateTimeType(parts[0].trim()));
if (parts.length > 1)
p.setEndElement(new DateTimeType(parts[1].trim()));
return p;
} else
throw new Exception("format not understood parsing " + source + " into a period");
}
if (type.equals("CodeableConcept")) {
CodeableConcept cc = new CodeableConcept();
if (source.contains(":")) {
String[] parts = source.split("\\:");
String system = "";
if (parts[0].equalsIgnoreCase("SCT"))
system = "http://snomed.info/sct";
else if (parts[0].equalsIgnoreCase("LOINC"))
system = "http://loinc.org";
else if (parts[0].equalsIgnoreCase("AMTv2"))
system = "http://nehta.gov.au/amtv2";
else
system = "http://hl7.org/fhir/" + parts[0];
String code = parts[1];
String display = parts.length > 2 ? parts[2] : null;
cc.addCoding().setSystem(system).setCode(code).setDisplay(display);
} else
throw new Exception("format not understood parsing " + source + " into a codeable concept");
return cc;
}
if (type.equals("Identifier")) {
Identifier id = new Identifier();
id.setSystem("urn:ietf:rfc:3986");
id.setValue(source);
return id;
}
if (type.equals("Quantity")) {
int s = 0;
if (source.startsWith("<=") || source.startsWith("=>"))
s = 2;
else if (source.startsWith("<") || source.startsWith(">"))
s = 1;
int i = s;
while (i < source.length() && Character.isDigit(source.charAt(i))) i++;
Quantity q = new Quantity();
if (s > 0)
q.setComparator(QuantityComparator.fromCode(source.substring(0, s)));
if (i > s)
q.setValue(new BigDecimal(source.substring(s, i)));
if (i < source.length())
q.setUnit(source.substring(i).trim());
return q;
}
throw new Exception("Unable to process primitive value '" + source + "' provided for " + column + " - unhandled type " + type + " @ " + getLocation(row));
}
}
Aggregations