use of org.hl7.fhir.r5.model.Identifier in project beneficiary-fhir-data by CMSgov.
the class CoverageTransformer method transformPartA.
/**
* @param metricRegistry the {@link MetricRegistry} to use
* @param beneficiary the {@link Beneficiary} to generate a {@link MedicareSegment#PART_A} {@link
* Coverage} resource for
* @return {@link MedicareSegment#PART_A} {@link Coverage} resource for the specified {@link
* Beneficiary}
*/
private static Coverage transformPartA(MetricRegistry metricRegistry, Beneficiary beneficiary) {
Timer.Context timer = metricRegistry.timer(MetricRegistry.name(CoverageTransformer.class.getSimpleName(), "transform", "part_a")).time();
Objects.requireNonNull(beneficiary);
Coverage coverage = new Coverage();
coverage.setId(TransformerUtils.buildCoverageId(MedicareSegment.PART_A, beneficiary));
if (beneficiary.getPartATerminationCode().isPresent() && beneficiary.getPartATerminationCode().get().equals('0'))
coverage.setStatus(CoverageStatus.ACTIVE);
else
coverage.setStatus(CoverageStatus.CANCELLED);
if (beneficiary.getMedicareCoverageStartDate().isPresent()) {
TransformerUtils.setPeriodStart(coverage.getPeriod(), beneficiary.getMedicareCoverageStartDate().get());
}
// deh start
coverage.addContract().setId("ptc-contract1");
Contract newContract = new Contract();
LocalDate localDate = LocalDate.now();
newContract.setIdentifier(new Identifier().setSystem("part C System").setValue("contract 5555"));
newContract.setApplies((new Period().setStart((TransformerUtils.convertToDate(localDate)), TemporalPrecisionEnum.DAY)));
coverage.addContained(newContract);
coverage.addContract(TransformerUtils.referenceCoverage("contract1 reference", MedicareSegment.PART_A));
coverage.getGrouping().setSubGroup(TransformerConstants.COVERAGE_PLAN).setSubPlan(TransformerConstants.COVERAGE_PLAN_PART_A);
coverage.setType(TransformerUtils.createCodeableConcept(TransformerConstants.COVERAGE_PLAN, TransformerConstants.COVERAGE_PLAN_PART_A));
coverage.setBeneficiary(TransformerUtils.referencePatient(beneficiary));
if (beneficiary.getMedicareEnrollmentStatusCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.MS_CD, beneficiary.getMedicareEnrollmentStatusCode()));
}
if (beneficiary.getEntitlementCodeOriginal().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.OREC, beneficiary.getEntitlementCodeOriginal()));
}
if (beneficiary.getEntitlementCodeCurrent().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.CREC, beneficiary.getEntitlementCodeCurrent()));
}
if (beneficiary.getEndStageRenalDiseaseCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.ESRD_IND, beneficiary.getEndStageRenalDiseaseCode()));
}
if (beneficiary.getPartATerminationCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.A_TRM_CD, beneficiary.getPartATerminationCode()));
}
// The reference year of the enrollment data
if (beneficiary.getBeneEnrollmentReferenceYear().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionDate(CcwCodebookVariable.RFRNC_YR, beneficiary.getBeneEnrollmentReferenceYear()));
}
// Monthly Medicare-Medicaid dual eligibility codes
if (beneficiary.getMedicaidDualEligibilityJanCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_01, beneficiary.getMedicaidDualEligibilityJanCode()));
}
if (beneficiary.getMedicaidDualEligibilityFebCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_02, beneficiary.getMedicaidDualEligibilityFebCode()));
}
if (beneficiary.getMedicaidDualEligibilityMarCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_03, beneficiary.getMedicaidDualEligibilityMarCode()));
}
if (beneficiary.getMedicaidDualEligibilityAprCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_04, beneficiary.getMedicaidDualEligibilityAprCode()));
}
if (beneficiary.getMedicaidDualEligibilityMayCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_05, beneficiary.getMedicaidDualEligibilityMayCode()));
}
if (beneficiary.getMedicaidDualEligibilityJunCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_06, beneficiary.getMedicaidDualEligibilityJunCode()));
}
if (beneficiary.getMedicaidDualEligibilityJulCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_07, beneficiary.getMedicaidDualEligibilityJulCode()));
}
if (beneficiary.getMedicaidDualEligibilityAugCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_08, beneficiary.getMedicaidDualEligibilityAugCode()));
}
if (beneficiary.getMedicaidDualEligibilitySeptCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_09, beneficiary.getMedicaidDualEligibilitySeptCode()));
}
if (beneficiary.getMedicaidDualEligibilityOctCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_10, beneficiary.getMedicaidDualEligibilityOctCode()));
}
if (beneficiary.getMedicaidDualEligibilityNovCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_11, beneficiary.getMedicaidDualEligibilityNovCode()));
}
if (beneficiary.getMedicaidDualEligibilityDecCode().isPresent()) {
coverage.addExtension(TransformerUtils.createExtensionCoding(coverage, CcwCodebookVariable.DUAL_12, beneficiary.getMedicaidDualEligibilityDecCode()));
}
transformEntitlementBuyInIndicators(coverage, beneficiary);
TransformerUtils.setLastUpdated(coverage, beneficiary.getLastUpdated());
timer.stop();
return coverage;
}
use of org.hl7.fhir.r5.model.Identifier in project beneficiary-fhir-data by CMSgov.
the class BeneficiaryTransformer method transform.
/**
* @param beneficiary the CCW {@link Beneficiary} to transform
* @param requestHeader {@link RequestHeaders} the holder that contains all supported resource
* request headers
* @return a FHIR {@link Patient} resource that represents the specified {@link Beneficiary}
*/
private static Patient transform(Beneficiary beneficiary, RequestHeaders requestHeader) {
Objects.requireNonNull(beneficiary);
Patient patient = new Patient();
/*
* Notify end users when they receive Patient records impacted by
* https://jira.cms.gov/browse/BFD-1566. See the documentation on
* LoadAppOptions.isFilteringNonNullAndNon2022Benes() for details.
*/
if (!beneficiary.getSkippedRifRecords().isEmpty()) {
patient.getMeta().addTag(TransformerConstants.CODING_SYSTEM_BFD_TAGS, TransformerConstants.CODING_BFD_TAGS_DELAYED_BACKDATED_ENROLLMENT, TransformerConstants.CODING_BFD_TAGS_DELAYED_BACKDATED_ENROLLMENT_DISPLAY);
}
patient.setId(beneficiary.getBeneficiaryId());
patient.addIdentifier(TransformerUtils.createIdentifier(CcwCodebookVariable.BENE_ID, beneficiary.getBeneficiaryId()));
// Add hicn-hash identifier ONLY if raw hicn is requested.
if (requestHeader.isHICNinIncludeIdentifiers()) {
patient.addIdentifier().setSystem(TransformerConstants.CODING_BBAPI_BENE_HICN_HASH).setValue(beneficiary.getHicn());
}
if (beneficiary.getMbiHash().isPresent()) {
Period mbiPeriod = new Period();
if (beneficiary.getMbiEffectiveDate().isPresent()) {
TransformerUtils.setPeriodStart(mbiPeriod, beneficiary.getMbiEffectiveDate().get());
}
if (beneficiary.getMbiObsoleteDate().isPresent()) {
TransformerUtils.setPeriodEnd(mbiPeriod, beneficiary.getMbiObsoleteDate().get());
}
if (mbiPeriod.hasStart() || mbiPeriod.hasEnd()) {
patient.addIdentifier().setSystem(TransformerConstants.CODING_BBAPI_BENE_MBI_HASH).setValue(beneficiary.getMbiHash().get()).setPeriod(mbiPeriod);
} else {
patient.addIdentifier().setSystem(TransformerConstants.CODING_BBAPI_BENE_MBI_HASH).setValue(beneficiary.getMbiHash().get());
}
}
Extension currentIdentifier = TransformerUtils.createIdentifierCurrencyExtension(CurrencyIdentifier.CURRENT);
Extension historicalIdentifier = TransformerUtils.createIdentifierCurrencyExtension(CurrencyIdentifier.HISTORIC);
// Add lastUpdated
TransformerUtils.setLastUpdated(patient, beneficiary.getLastUpdated());
if (requestHeader.isHICNinIncludeIdentifiers()) {
Optional<String> hicnUnhashedCurrent = beneficiary.getHicnUnhashed();
if (hicnUnhashedCurrent.isPresent())
addUnhashedIdentifier(patient, hicnUnhashedCurrent.get(), TransformerConstants.CODING_BBAPI_BENE_HICN_UNHASHED, currentIdentifier);
List<String> unhashedHicns = new ArrayList<String>();
for (BeneficiaryHistory beneHistory : beneficiary.getBeneficiaryHistories()) {
Optional<String> hicnUnhashedHistoric = beneHistory.getHicnUnhashed();
if (hicnUnhashedHistoric.isPresent())
unhashedHicns.add(hicnUnhashedHistoric.get());
TransformerUtils.updateMaxLastUpdated(patient, beneHistory.getLastUpdated());
}
List<String> unhashedHicnsNoDupes = unhashedHicns.stream().distinct().collect(Collectors.toList());
for (String hicn : unhashedHicnsNoDupes) {
addUnhashedIdentifier(patient, hicn, TransformerConstants.CODING_BBAPI_BENE_HICN_UNHASHED, historicalIdentifier);
}
}
if (requestHeader.isMBIinIncludeIdentifiers()) {
Optional<String> mbiUnhashedCurrent = beneficiary.getMedicareBeneficiaryId();
if (mbiUnhashedCurrent.isPresent())
addUnhashedIdentifier(patient, mbiUnhashedCurrent.get(), TransformerConstants.CODING_BBAPI_MEDICARE_BENEFICIARY_ID_UNHASHED, currentIdentifier);
List<String> unhashedMbis = new ArrayList<String>();
for (MedicareBeneficiaryIdHistory mbiHistory : beneficiary.getMedicareBeneficiaryIdHistories()) {
Optional<String> mbiUnhashedHistoric = mbiHistory.getMedicareBeneficiaryId();
if (mbiUnhashedHistoric.isPresent())
unhashedMbis.add(mbiUnhashedHistoric.get());
TransformerUtils.updateMaxLastUpdated(patient, mbiHistory.getLastUpdated());
}
List<String> unhashedMbisNoDupes = unhashedMbis.stream().distinct().collect(Collectors.toList());
for (String mbi : unhashedMbisNoDupes) {
addUnhashedIdentifier(patient, mbi, TransformerConstants.CODING_BBAPI_MEDICARE_BENEFICIARY_ID_UNHASHED, historicalIdentifier);
}
}
// support header includeAddressFields from downstream components e.g. BB2
// per requirement of BFD-379, BB2 always send header includeAddressFields = False
Boolean addrHdrVal = requestHeader.getValue(PatientResourceProvider.HEADER_NAME_INCLUDE_ADDRESS_FIELDS);
if (addrHdrVal != null && addrHdrVal) {
patient.addAddress().setState(beneficiary.getStateCode()).setPostalCode(beneficiary.getPostalCode()).setCity(beneficiary.getDerivedCityName().orElse(null)).addLine(beneficiary.getDerivedMailingAddress1().orElse(null)).addLine(beneficiary.getDerivedMailingAddress2().orElse(null)).addLine(beneficiary.getDerivedMailingAddress3().orElse(null)).addLine(beneficiary.getDerivedMailingAddress4().orElse(null)).addLine(beneficiary.getDerivedMailingAddress5().orElse(null)).addLine(beneficiary.getDerivedMailingAddress6().orElse(null));
} else {
patient.addAddress().setState(beneficiary.getStateCode()).setPostalCode(beneficiary.getPostalCode());
}
if (beneficiary.getBirthDate() != null) {
patient.setBirthDate(TransformerUtils.convertToDate(beneficiary.getBirthDate()));
}
// Death Date
if (beneficiary.getBeneficiaryDateOfDeath().isPresent()) {
patient.setDeceased(new DateTimeType(TransformerUtils.convertToDate(beneficiary.getBeneficiaryDateOfDeath().get()), TemporalPrecisionEnum.DAY));
}
char sex = beneficiary.getSex();
if (sex == Sex.MALE.getCode())
patient.setGender((AdministrativeGender.MALE));
else if (sex == Sex.FEMALE.getCode())
patient.setGender((AdministrativeGender.FEMALE));
else
patient.setGender((AdministrativeGender.UNKNOWN));
if (beneficiary.getRace().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionCoding(patient, CcwCodebookVariable.RACE, beneficiary.getRace().get()));
}
HumanName name = patient.addName().addGiven(beneficiary.getNameGiven()).setFamily(beneficiary.getNameSurname()).setUse(HumanName.NameUse.USUAL);
if (beneficiary.getNameMiddleInitial().isPresent())
name.addGiven(String.valueOf(beneficiary.getNameMiddleInitial().get()));
// The reference year of the enrollment data
if (beneficiary.getBeneEnrollmentReferenceYear().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionDate(CcwCodebookVariable.RFRNC_YR, beneficiary.getBeneEnrollmentReferenceYear()));
}
// Monthly Medicare-Medicaid dual eligibility codes
if (beneficiary.getMedicaidDualEligibilityJanCode().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionCoding(patient, CcwCodebookVariable.DUAL_01, beneficiary.getMedicaidDualEligibilityJanCode()));
}
if (beneficiary.getMedicaidDualEligibilityFebCode().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionCoding(patient, CcwCodebookVariable.DUAL_02, beneficiary.getMedicaidDualEligibilityFebCode()));
}
if (beneficiary.getMedicaidDualEligibilityMarCode().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionCoding(patient, CcwCodebookVariable.DUAL_03, beneficiary.getMedicaidDualEligibilityMarCode()));
}
if (beneficiary.getMedicaidDualEligibilityAprCode().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionCoding(patient, CcwCodebookVariable.DUAL_04, beneficiary.getMedicaidDualEligibilityAprCode()));
}
if (beneficiary.getMedicaidDualEligibilityMayCode().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionCoding(patient, CcwCodebookVariable.DUAL_05, beneficiary.getMedicaidDualEligibilityMayCode()));
}
if (beneficiary.getMedicaidDualEligibilityJunCode().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionCoding(patient, CcwCodebookVariable.DUAL_06, beneficiary.getMedicaidDualEligibilityJunCode()));
}
if (beneficiary.getMedicaidDualEligibilityJulCode().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionCoding(patient, CcwCodebookVariable.DUAL_07, beneficiary.getMedicaidDualEligibilityJulCode()));
}
if (beneficiary.getMedicaidDualEligibilityAugCode().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionCoding(patient, CcwCodebookVariable.DUAL_08, beneficiary.getMedicaidDualEligibilityAugCode()));
}
if (beneficiary.getMedicaidDualEligibilitySeptCode().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionCoding(patient, CcwCodebookVariable.DUAL_09, beneficiary.getMedicaidDualEligibilitySeptCode()));
}
if (beneficiary.getMedicaidDualEligibilityOctCode().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionCoding(patient, CcwCodebookVariable.DUAL_10, beneficiary.getMedicaidDualEligibilityOctCode()));
}
if (beneficiary.getMedicaidDualEligibilityNovCode().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionCoding(patient, CcwCodebookVariable.DUAL_11, beneficiary.getMedicaidDualEligibilityNovCode()));
}
if (beneficiary.getMedicaidDualEligibilityDecCode().isPresent()) {
patient.addExtension(TransformerUtils.createExtensionCoding(patient, CcwCodebookVariable.DUAL_12, beneficiary.getMedicaidDualEligibilityDecCode()));
}
return patient;
}
use of org.hl7.fhir.r5.model.Identifier in project beneficiary-fhir-data by CMSgov.
the class FissClaimResponseTransformerV2 method transformClaim.
/**
* @param claimGroup the {@link PreAdjFissClaim} to transform
* @return a FHIR {@link ClaimResponse} resource that represents the specified {@link
* PreAdjFissClaim}
*/
private static ClaimResponse transformClaim(PreAdjFissClaim claimGroup) {
ClaimResponse claim = new ClaimResponse();
claim.setId("f-" + claimGroup.getDcn());
claim.setContained(List.of(getContainedPatient(claimGroup)));
claim.setExtension(getExtension(claimGroup));
claim.setIdentifier(getIdentifier(claimGroup));
claim.setStatus(ClaimResponse.ClaimResponseStatus.ACTIVE);
claim.setOutcome(STATUS_TO_OUTCOME.get(Character.toLowerCase(claimGroup.getCurrStatus())));
claim.setType(getType());
claim.setUse(ClaimResponse.Use.CLAIM);
claim.setInsurer(new Reference().setIdentifier(new Identifier().setValue("CMS")));
claim.setPatient(new Reference("#patient"));
claim.setRequest(new Reference(String.format("Claim/f-%s", claimGroup.getDcn())));
claim.setMeta(new Meta().setLastUpdated(Date.from(claimGroup.getLastUpdated())));
claim.setCreated(new Date());
return claim;
}
use of org.hl7.fhir.r5.model.Identifier in project beneficiary-fhir-data by CMSgov.
the class FissClaimTransformerV2 method getContainedProvider.
private static Resource getContainedProvider(PreAdjFissClaim claimGroup) {
Organization organization = new Organization();
if (claimGroup.getMedaProv_6() != null) {
organization.getIdentifier().add(new Identifier().setType(new CodeableConcept(new Coding(C4BBOrganizationIdentifierType.PRN.getSystem(), C4BBOrganizationIdentifierType.PRN.toCode(), C4BBOrganizationIdentifierType.PRN.getDisplay()))).setSystem(BBCodingSystems.PROVIDER_NUM).setValue(claimGroup.getMedaProv_6()));
}
if (claimGroup.getFedTaxNumber() != null) {
organization.getIdentifier().add(new Identifier().setType(new CodeableConcept(new Coding(C4BBOrganizationIdentifierType.TAX.getSystem(), C4BBOrganizationIdentifierType.TAX.toCode(), C4BBOrganizationIdentifierType.TAX.getDisplay()))).setSystem(BBCodingSystems.FISS.TAX_NUM).setValue(claimGroup.getFedTaxNumber()));
}
if (claimGroup.getNpiNumber() != null) {
organization.getIdentifier().add(new Identifier().setType(new CodeableConcept(new Coding(C4BBIdentifierType.NPI.getSystem(), C4BBIdentifierType.NPI.toCode(), C4BBIdentifierType.NPI.getDisplay()))).setSystem(TransformerConstants.CODING_NPI_US).setValue(claimGroup.getNpiNumber()));
}
organization.setId("provider-org");
return organization;
}
use of org.hl7.fhir.r5.model.Identifier in project beneficiary-fhir-data by CMSgov.
the class McsClaimTransformerV2 method getContainedProvider.
private static Resource getContainedProvider(PreAdjMcsClaim claimGroup) {
Organization organization = new Organization();
if (claimGroup.getIdrBillProvType() != null) {
organization.getExtension().add(new Extension(BBCodingSystems.MCS.BILL_PROV_TYPE).setValue(new Coding(BBCodingSystems.MCS.BILL_PROV_TYPE, claimGroup.getIdrBillProvType(), null)));
}
if (claimGroup.getIdrBillProvSpec() != null) {
organization.getExtension().add(new Extension(BBCodingSystems.MCS.BILL_PROV_SPEC).setValue(new Coding(BBCodingSystems.MCS.BILL_PROV_SPEC, claimGroup.getIdrBillProvSpec(), null)));
}
if (claimGroup.getIdrBillProvEin() != null) {
organization.getIdentifier().add(new Identifier().setType(new CodeableConcept(new Coding(C4BBOrganizationIdentifierType.TAX.getSystem(), C4BBOrganizationIdentifierType.TAX.toCode(), C4BBOrganizationIdentifierType.TAX.getDisplay()))).setSystem(BBCodingSystems.MCS.BILL_PROV_EIN).setValue(claimGroup.getIdrBillProvEin()));
}
if (claimGroup.getIdrBillProvNum() != null) {
organization.getIdentifier().add(new Identifier().setType(new CodeableConcept(new Coding(C4BBIdentifierType.NPI.getSystem(), C4BBIdentifierType.NPI.toCode(), C4BBIdentifierType.NPI.getDisplay()))).setSystem(TransformerConstants.CODING_NPI_US).setValue(claimGroup.getIdrBillProvNpi()));
}
organization.setId("provider-org");
return organization;
}
Aggregations