use of org.hl7.fhir.dstu2.model.CodeableConcept in project beneficiary-fhir-data by CMSgov.
the class TransformerUtils 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
*/
static CareTeamComponent addCareTeamPractitioner(ExplanationOfBenefit eob, ItemComponent eobItem, String practitionerIdSystem, String practitionerIdValue, ClaimCareteamrole careTeamRole) {
// Try to find a matching pre-existing entry.
CareTeamComponent careTeamEntry = eob.getCareTeam().stream().filter(ctc -> ctc.getProvider().hasIdentifier()).filter(ctc -> practitionerIdSystem.equals(ctc.getProvider().getIdentifier().getSystem()) && practitionerIdValue.equals(ctc.getProvider().getIdentifier().getValue())).filter(ctc -> ctc.hasRole()).filter(ctc -> careTeamRole.toCode().equals(ctc.getRole().getCodingFirstRep().getCode()) && careTeamRole.getSystem().equals(ctc.getRole().getCodingFirstRep().getSystem())).findAny().orElse(null);
// If no match was found, add one to the EOB.
if (careTeamEntry == null) {
careTeamEntry = eob.addCareTeam();
careTeamEntry.setSequence(eob.getCareTeam().size() + 1);
careTeamEntry.setProvider(createIdentifierReference(practitionerIdSystem, practitionerIdValue));
CodeableConcept careTeamRoleConcept = createCodeableConcept(ClaimCareteamrole.OTHER.getSystem(), careTeamRole.toCode());
careTeamRoleConcept.getCodingFirstRep().setDisplay(careTeamRole.getDisplay());
careTeamEntry.setRole(careTeamRoleConcept);
}
// care team entry is at eob level so no need to create item link id
if (eobItem == null) {
return careTeamEntry;
}
// Link the EOB.item to the care team entry (if it isn't already).
final int careTeamEntrySequence = careTeamEntry.getSequence();
if (eobItem.getCareTeamLinkId().stream().noneMatch(id -> id.getValue() == careTeamEntrySequence)) {
eobItem.addCareTeamLinkId(careTeamEntrySequence);
}
return careTeamEntry;
}
use of org.hl7.fhir.dstu2.model.CodeableConcept in project beneficiary-fhir-data by CMSgov.
the class TransformerUtils method addDiagnosisCode.
/**
* @param eob the {@link ExplanationOfBenefit} to (possibly) modify
* @param diagnosis the {@link Diagnosis} to add, if it's not already present
* @return the {@link DiagnosisComponent#getSequence()} of the existing or newly-added entry
*/
static int addDiagnosisCode(ExplanationOfBenefit eob, Diagnosis diagnosis) {
Optional<DiagnosisComponent> existingDiagnosis = eob.getDiagnosis().stream().filter(d -> d.getDiagnosis() instanceof CodeableConcept).filter(d -> diagnosis.isContainedIn((CodeableConcept) d.getDiagnosis())).findAny();
if (existingDiagnosis.isPresent())
return existingDiagnosis.get().getSequenceElement().getValue();
DiagnosisComponent diagnosisComponent = new DiagnosisComponent().setSequence(eob.getDiagnosis().size() + 1);
diagnosisComponent.setDiagnosis(diagnosis.toCodeableConcept());
for (DiagnosisLabel diagnosisLabel : diagnosis.getLabels()) {
CodeableConcept diagnosisTypeConcept = createCodeableConcept(diagnosisLabel.getSystem(), diagnosisLabel.toCode());
diagnosisTypeConcept.getCodingFirstRep().setDisplay(diagnosisLabel.getDisplay());
diagnosisComponent.addType(diagnosisTypeConcept);
}
if (diagnosis.getPresentOnAdmission().isPresent()) {
diagnosisComponent.addExtension(createExtensionCoding(eob, CcwCodebookVariable.CLM_POA_IND_SW1, diagnosis.getPresentOnAdmission()));
}
eob.getDiagnosis().add(diagnosisComponent);
return diagnosisComponent.getSequenceElement().getValue();
}
use of org.hl7.fhir.dstu2.model.CodeableConcept in project beneficiary-fhir-data by CMSgov.
the class TransformerUtils method createAdjudicationCategory.
/**
* @param ccwVariable the {@link CcwCodebookInterface} being mapped
* @return the {@link AdjudicationComponent#getCategory()} {@link CodeableConcept} to use for the
* specified {@link CcwCodebookInterface}
*/
static CodeableConcept createAdjudicationCategory(CcwCodebookInterface ccwVariable) {
/*
* Adjudication.category is mapped a bit differently than other Codings/CodeableConcepts: they
* all share the same Coding.system and use the CcwCodebookVariable reference URL as their
* Coding.code. This looks weird, but makes it easy for API developers to find more information
* about what the specific adjudication they're looking at means.
*/
String conceptCode = CCWUtils.calculateVariableReferenceUrl(ccwVariable);
CodeableConcept categoryConcept = createCodeableConcept(TransformerConstants.CODING_CCW_ADJUDICATION_CATEGORY, conceptCode);
categoryConcept.getCodingFirstRep().setDisplay(ccwVariable.getVariable().getLabel());
return categoryConcept;
}
use of org.hl7.fhir.dstu2.model.CodeableConcept in project beneficiary-fhir-data by CMSgov.
the class TransformerUtils method createIdentifierReference.
/**
* @param identifierType the {@link gov.cms.bfd.server.war.stu3.providers.IdentifierType}
* @param identifierValue the {@link Identifier#getValue()} to use in {@link
* Reference#getIdentifier()}
* @return a {@link Reference} with the specified {@link Identifier}
*/
static Reference createIdentifierReference(IdentifierType identifierType, String identifierValue) {
Reference reference = new Reference();
Coding coding = new Coding().setSystem(identifierType.getSystem()).setCode(identifierType.getCode()).setDisplay(identifierType.getDisplay());
List<Coding> codingList = new ArrayList<Coding>();
codingList.add(coding);
CodeableConcept codeableConcept = new CodeableConcept().setCoding(codingList);
return reference.setIdentifier(new Identifier().setSystem(identifierType.getSystem()).setValue(identifierValue).setType(codeableConcept)).setDisplay(retrieveNpiCodeDisplay(identifierValue));
}
use of org.hl7.fhir.dstu2.model.CodeableConcept in project beneficiary-fhir-data by CMSgov.
the class TransformerUtils method addProcedureCode.
/**
* @param eob the {@link ExplanationOfBenefit} to (possibly) modify
* @param diagnosis the {@link Diagnosis} to add, if it's not already present
* @return the {@link ProcedureComponent#getSequence()} of the existing or newly-added entry
*/
static int addProcedureCode(ExplanationOfBenefit eob, CCWProcedure procedure) {
Optional<ProcedureComponent> existingProcedure = eob.getProcedure().stream().filter(pc -> pc.getProcedure() instanceof CodeableConcept).filter(pc -> isCodeInConcept((CodeableConcept) pc.getProcedure(), procedure.getFhirSystem(), procedure.getCode())).findAny();
if (existingProcedure.isPresent())
return existingProcedure.get().getSequenceElement().getValue();
ProcedureComponent procedureComponent = new ProcedureComponent().setSequence(eob.getProcedure().size() + 1);
procedureComponent.setProcedure(createCodeableConcept(procedure.getFhirSystem(), null, retrieveProcedureCodeDisplay(procedure.getCode()), procedure.getCode()));
if (procedure.getProcedureDate().isPresent()) {
procedureComponent.setDate(convertToDate(procedure.getProcedureDate().get()));
}
eob.getProcedure().add(procedureComponent);
return procedureComponent.getSequenceElement().getValue();
}
Aggregations