Search in sources :

Example 1 with DateTimeType

use of org.hl7.fhir.dstu3.model.DateTimeType in project bunsen by cerner.

the class TestData method newCondition.

/**
 * Returns a FHIR Condition for testing purposes.
 */
public static Condition newCondition() {
    Condition condition = new Condition();
    // Condition based on example from FHIR:
    // https://www.hl7.org/fhir/condition-example.json.html
    condition.setId("Condition/example");
    condition.setLanguage("en_US");
    // Narrative text
    Narrative narrative = new Narrative();
    narrative.setStatusAsString("generated");
    narrative.setDivAsString("This data was generated for test purposes.");
    XhtmlNode node = new XhtmlNode();
    node.setNodeType(NodeType.Text);
    node.setValue("Severe burn of left ear (Date: 24-May 2012)");
    condition.setText(narrative);
    condition.setSubject(new Reference("Patient/example").setDisplay("Here is a display for you."));
    condition.setVerificationStatus(Condition.ConditionVerificationStatus.CONFIRMED);
    // Condition code
    CodeableConcept code = new CodeableConcept();
    code.addCoding().setSystem("http://snomed.info/sct").setCode("39065001").setDisplay("Severe");
    condition.setSeverity(code);
    // Severity code
    CodeableConcept severity = new CodeableConcept();
    severity.addCoding().setSystem("http://snomed.info/sct").setCode("24484000").setDisplay("Burn of ear").setUserSelected(true);
    condition.setSeverity(severity);
    // Onset date time
    DateTimeType onset = new DateTimeType();
    onset.setValueAsString("2012-05-24");
    condition.setOnset(onset);
    return condition;
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) Narrative(org.hl7.fhir.dstu3.model.Narrative) Reference(org.hl7.fhir.dstu3.model.Reference) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 2 with DateTimeType

use of org.hl7.fhir.dstu3.model.DateTimeType in project gpconnect-demonstrator by nhsconnect.

the class MedicationStatementResourceProvider method getMedicationStatementResource.

public MedicationStatement getMedicationStatementResource(MedicationStatementDetail statementDetail) {
    MedicationStatement medicationStatement = new MedicationStatement();
    medicationStatement.setId(statementDetail.getId().toString());
    List<Identifier> identifiers = new ArrayList<>();
    Identifier identifier = new Identifier().setSystem("https://fhir.nhs.uk/Id/cross-care-setting-identifier").setValue(statementDetail.getGuid());
    identifiers.add(identifier);
    medicationStatement.setIdentifier(identifiers);
    medicationStatement.setMeta(new Meta().addProfile(SystemURL.SD_GPC_MEDICATION_STATEMENT));
    medicationStatement.addExtension(new Extension(SystemURL.SD_CC_EXT_MEDICATION_STATEMENT_LAST_ISSUE, new DateTimeType(statementDetail.getLastIssueDate(), TemporalPrecisionEnum.DAY)));
    if (statementDetail.getMedicationRequestPlanId() != null) {
        medicationStatement.addBasedOn(new Reference(new IdType("MedicationRequest", statementDetail.getMedicationRequestPlanId())));
    }
    try {
        medicationStatement.setStatus(MedicationStatementStatus.fromCode(statementDetail.getStatusCode()));
    } catch (FHIRException e) {
        throw new UnprocessableEntityException(e.getMessage());
    }
    if (statementDetail.getMedicationId() != null) {
        medicationStatement.setMedication(new Reference(new IdType("Medication", statementDetail.getMedicationId())));
    }
    medicationStatement.setEffective(new Period().setStart(statementDetail.getStartDate()).setEnd(statementDetail.getEndDate()));
    medicationStatement.setDateAsserted(statementDetail.getDateAsserted());
    if (statementDetail.getPatientId() != null)
        medicationStatement.setSubject(new Reference(new IdType("Patient", statementDetail.getPatientId())));
    try {
        medicationStatement.setTaken(statementDetail.getTakenCode() != null ? MedicationStatementTaken.fromCode(statementDetail.getTakenCode()) : MedicationStatementTaken.UNK);
    } catch (FHIRException e) {
        throw new UnprocessableEntityException(e.getMessage());
    }
    setReasonCodes(medicationStatement, statementDetail);
    setNotes(medicationStatement, statementDetail);
    String dosageText = statementDetail.getDosageText();
    medicationStatement.addDosage(new Dosage().setText(dosageText == null || dosageText.trim().isEmpty() ? NO_INFORMATION_AVAILABLE : dosageText).setPatientInstruction(statementDetail.getDosagePatientInstruction()));
    String prescribingAgency = statementDetail.getPrescribingAgency();
    if (prescribingAgency != null && !prescribingAgency.trim().isEmpty()) {
        String prescribingAgencyDisplay = "";
        if (prescribingAgency.equalsIgnoreCase("prescribed-at-gp-practice")) {
            prescribingAgencyDisplay = "Prescribed at GP practice";
        } else if (prescribingAgency.equalsIgnoreCase("prescribed-by-another-organisation")) {
            prescribingAgencyDisplay = "Prescribed by another organisation";
        }
        Coding coding = new Coding(SystemURL.CS_CC_PRESCRIBING_AGENCY_STU3, prescribingAgency, prescribingAgencyDisplay);
        CodeableConcept codeableConcept = new CodeableConcept().addCoding(coding);
        medicationStatement.addExtension(new Extension(SystemURL.SD_EXTENSION_CC_PRESCRIBING_AGENCY, codeableConcept));
    }
    // #281 1.2.5 add dosageLastChanged
    Date dosageLastChanged = statementDetail.getDosageLastChanged();
    if (dosageLastChanged != null) {
        medicationStatement.addExtension(new Extension(SystemURL.SD_EXTENSION_CC_DOSAGE_LAST_CHANGED, new DateTimeType(dosageLastChanged)));
    }
    return medicationStatement;
}
Also used : UnprocessableEntityException(ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException) ArrayList(java.util.ArrayList) FHIRException(org.hl7.fhir.exceptions.FHIRException) Date(java.util.Date)

Example 3 with DateTimeType

use of org.hl7.fhir.dstu3.model.DateTimeType in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method registerPatientResourceConverterToPatientDetail.

private PatientDetails registerPatientResourceConverterToPatientDetail(Patient patientResource) {
    PatientDetails patientDetails = new PatientDetails();
    HumanName name = patientResource.getNameFirstRep();
    String givenNames = name.getGiven().stream().map(n -> n.getValue()).collect(Collectors.joining(","));
    patientDetails.setForename(givenNames);
    patientDetails.setSurname(name.getFamily());
    patientDetails.setDateOfBirth(patientResource.getBirthDate());
    if (patientResource.getGender() != null) {
        patientDetails.setGender(patientResource.getGender().toString());
    }
    patientDetails.setNhsNumber(patientResource.getIdentifierFirstRep().getValue());
    DateTimeType deceased = (DateTimeType) patientResource.getDeceased();
    if (deceased != null) {
        try {
            patientDetails.setDeceased((deceased.getValue()));
        } catch (ClassCastException cce) {
            throwUnprocessableEntity422_InvalidResourceException("The multiple deceased property is expected to be a datetime");
        }
    }
    // activate patient as temporary
    patientDetails.setRegistrationStartDateTime(new Date());
    // patientDetails.setRegistrationEndDateTime(getRegistrationEndDate(patientResource));
    patientDetails.setRegistrationStatus(ACTIVE_REGISTRATION_STATUS);
    patientDetails.setRegistrationType(TEMPORARY_RESIDENT_REGISTRATION_TYPE);
    updateAddressAndTelecom(patientResource, patientDetails);
    // set some standard values for defaults, ensure managing org is always returned
    // added at 1.2.2 7 is A20047 the default GP Practice
    patientDetails.setManagingOrganization("7");
    return patientDetails;
}
Also used : ParametersParameterComponent(org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent) AppointmentResourceProvider(uk.gov.hscic.appointments.AppointmentResourceProvider) Autowired(org.springframework.beans.factory.annotation.Autowired) IdentifierUse(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse) NhsCodeValidator(uk.gov.hscic.util.NhsCodeValidator) OperationOutcomeIssueComponent(org.hl7.fhir.dstu3.model.OperationOutcome.OperationOutcomeIssueComponent) FhirRequestGenericIntercepter.throwInvalidRequest400_BadRequestException(uk.gov.hscic.common.filters.FhirRequestGenericIntercepter.throwInvalidRequest400_BadRequestException) ForbiddenOperationException(ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException) IResourceProvider(ca.uhn.fhir.rest.server.IResourceProvider) VS_GPC_ERROR_WARNING_CODE(uk.gov.hscic.SystemURL.VS_GPC_ERROR_WARNING_CODE) ParseException(java.text.ParseException) OrganizationSearch(uk.gov.hscic.organization.OrganizationSearch) IdDt(ca.uhn.fhir.model.primitive.IdDt) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) OrganizationDetails(uk.gov.hscic.model.organization.OrganizationDetails) Count(ca.uhn.fhir.rest.annotation.Count) Collectors(java.util.stream.Collectors) UnclassifiedServerFailureException(ca.uhn.fhir.rest.server.exceptions.UnclassifiedServerFailureException) IssueType(org.hl7.fhir.dstu3.model.OperationOutcome.IssueType) AdministrativeGender(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender) SortSpec(ca.uhn.fhir.rest.api.SortSpec) IdentifierValidator(uk.gov.hscic.common.validators.IdentifierValidator) PostConstruct(javax.annotation.PostConstruct) ContactPointSystem(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem) SystemCode(uk.gov.hscic.SystemCode) PopulateMedicationBundle(uk.gov.hscic.medications.PopulateMedicationBundle) Pattern(java.util.regex.Pattern) NameUse(org.hl7.fhir.dstu3.model.HumanName.NameUse) PatientSearch(uk.gov.hscic.patient.details.PatientSearch) AddressType(org.hl7.fhir.dstu3.model.Address.AddressType) java.util(java.util) FhirRequestGenericIntercepter.throwUnprocessableEntity422_InvalidResourceException(uk.gov.hscic.common.filters.FhirRequestGenericIntercepter.throwUnprocessableEntity422_InvalidResourceException) PatientStore(uk.gov.hscic.patient.details.PatientStore) SimpleDateFormat(java.text.SimpleDateFormat) PractitionerRoleResourceProvider(uk.gov.hscic.practitioner.PractitionerRoleResourceProvider) SD_CC_EXT_NHS_COMMUNICATION(uk.gov.hscic.SystemURL.SD_CC_EXT_NHS_COMMUNICATION) PractitionerResourceProvider(uk.gov.hscic.practitioner.PractitionerResourceProvider) Value(org.springframework.beans.factory.annotation.Value) UnprocessableEntityException(ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException) TelecomDetails(uk.gov.hscic.model.telecom.TelecomDetails) AddressUse(org.hl7.fhir.dstu3.model.Address.AddressUse) WORK(org.hl7.fhir.dstu3.model.Address.AddressUse.WORK) org.hl7.fhir.dstu3.model(org.hl7.fhir.dstu3.model) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) Integer.min(java.lang.Integer.min) ca.uhn.fhir.rest.annotation(ca.uhn.fhir.rest.annotation) PatientDetails(uk.gov.hscic.model.patient.PatientDetails) BundleType(org.hl7.fhir.dstu3.model.Bundle.BundleType) SystemConstants(uk.gov.hscic.SystemConstants) SystemURL(uk.gov.hscic.SystemURL) OLD(org.hl7.fhir.dstu3.model.Address.AddressUse.OLD) TokenParam(ca.uhn.fhir.rest.param.TokenParam) ContactComponent(org.hl7.fhir.dstu3.model.Patient.ContactComponent) OperationOutcomeFactory(uk.gov.hscic.OperationOutcomeFactory) Component(org.springframework.stereotype.Component) StaticElementsHelper(uk.gov.hscic.common.helpers.StaticElementsHelper) DateAndListParam(ca.uhn.fhir.rest.param.DateAndListParam) ContactPointUse(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse) OrganizationResourceProvider(uk.gov.hscic.organization.OrganizationResourceProvider) FHIRException(org.hl7.fhir.exceptions.FHIRException) PatientDetails(uk.gov.hscic.model.patient.PatientDetails)

Example 4 with DateTimeType

use of org.hl7.fhir.dstu3.model.DateTimeType in project gpconnect-demonstrator by nhsconnect.

the class StructuredAllergyIntoleranceBuilder method buildStructuredAllergyIntolerence.

public Bundle buildStructuredAllergyIntolerence(String NHS, Set<String> practitionerIds, Bundle bundle, Boolean includedResolved) {
    List<StructuredAllergyIntoleranceEntity> allergyData = structuredAllergySearch.getAllergyIntollerence(NHS);
    ListResource activeList = initiateListResource(NHS, ACTIVE_ALLERGIES_DISPLAY, allergyData);
    ListResource resolvedList = initiateListResource(NHS, RESOLVED_ALLERGIES_DISPLAY, allergyData);
    // This is patient 5 example 2 only
    if (allergyData.size() == 1 && allergyData.get(0).getClinicalStatus().equals(SystemConstants.NO_KNOWN)) {
        StructuredAllergyIntoleranceEntity noKnownAllergy = allergyData.get(0);
        // #214 had incorrect code and value for no known allergies
        CodeableConcept noKnownAllergies = createCoding(SystemURL.VS_LIST_EMPTY_REASON_CODE, NO_CONTENT_RECORDED, NO_CONTENT_RECORDED_DISPLAY);
        noKnownAllergies.setText("No Known Allergies");
        // activeList.setEmptyReason(noKnownAllergies);
        // see spec example 2 no known allergies positively asserted
        Reference patient = new Reference(SystemConstants.PATIENT_REFERENCE_URL + allergyData.get(0).getPatientRef());
        String noKnownAllergyId = noKnownAllergy.getGuid();
        Reference allergyIntolerance = new Reference("AllergyIntolerance/" + noKnownAllergyId);
        Resource noKnownAllergyResource = createNoKnownAllergy(noKnownAllergy);
        activeList.setSubject(patient);
        // reference to AllergyIntolerance item
        activeList.addEntry().setItem(allergyIntolerance);
        activeList.setOrderedBy(createCoding(SystemURL.CS_LIST_ORDER, "event-date", "Sorted by Event Date"));
        bundle.addEntry().setResource(activeList);
        bundle.addEntry().setResource(noKnownAllergyResource);
        if (includedResolved) {
            resolvedList.setSubject(patient);
            resolvedList.setEmptyReason(noKnownAllergies);
            bundle.addEntry().setResource(resolvedList);
        }
        return bundle;
    }
    for (StructuredAllergyIntoleranceEntity allergyIntoleranceEntity : allergyData) {
        AllergyIntolerance allergyIntolerance = new AllergyIntolerance();
        allergyIntolerance.setOnset(new DateTimeType(allergyIntoleranceEntity.getOnSetDateTime()));
        allergyIntolerance.setMeta(createMeta(SystemURL.SD_CC_ALLERGY_INTOLERANCE));
        allergyIntolerance.setId(allergyIntoleranceEntity.getId().toString());
        List<Identifier> identifiers = new ArrayList<>();
        Identifier identifier1 = new Identifier().setSystem("https://fhir.nhs.uk/Id/cross-care-setting-identifier").setValue(allergyIntoleranceEntity.getGuid());
        identifiers.add(identifier1);
        allergyIntolerance.setIdentifier(identifiers);
        if (allergyIntoleranceEntity.getClinicalStatus().equals(SystemConstants.ACTIVE)) {
            allergyIntolerance.setClinicalStatus(AllergyIntoleranceClinicalStatus.ACTIVE);
        } else {
            allergyIntolerance.setClinicalStatus(AllergyIntoleranceClinicalStatus.RESOLVED);
        }
        if (allergyIntoleranceEntity.getCategory().equals(SystemConstants.MEDICATION)) {
            allergyIntolerance.addCategory(AllergyIntoleranceCategory.MEDICATION);
        } else {
            allergyIntolerance.addCategory(AllergyIntoleranceCategory.ENVIRONMENT);
        }
        allergyIntolerance.setVerificationStatus(AllergyIntoleranceVerificationStatus.UNCONFIRMED);
        // CODE
        codeableConceptBuilder.addConceptCode(SystemConstants.SNOMED_URL, allergyIntoleranceEntity.getConceptCode(), allergyIntoleranceEntity.getConceptDisplay()).addDescription(allergyIntoleranceEntity.getDescCode(), allergyIntoleranceEntity.getDescDisplay()).addTranslation(allergyIntoleranceEntity.getCodeTranslationRef());
        allergyIntolerance.setCode(codeableConceptBuilder.build());
        codeableConceptBuilder.clear();
        allergyIntolerance.setAssertedDate(allergyIntoleranceEntity.getAssertedDate());
        Reference patient = new Reference(SystemConstants.PATIENT_REFERENCE_URL + allergyIntoleranceEntity.getPatientRef());
        allergyIntolerance.setPatient(patient);
        Annotation noteAnnotation = new Annotation(new StringType(allergyIntoleranceEntity.getNote()));
        allergyIntolerance.setNote(Collections.singletonList(noteAnnotation));
        AllergyIntoleranceReactionComponent reaction = new AllergyIntoleranceReactionComponent();
        // MANIFESTATION
        List<CodeableConcept> theManifestation = new ArrayList<>();
        codeableConceptBuilder.addConceptCode(SystemConstants.SNOMED_URL, allergyIntoleranceEntity.getManifestationCoding(), allergyIntoleranceEntity.getManifestationDisplay()).addDescription(allergyIntoleranceEntity.getManifestationDescCoding(), allergyIntoleranceEntity.getManifestationDescDisplay()).addTranslation(allergyIntoleranceEntity.getManTranslationRef());
        theManifestation.add(codeableConceptBuilder.build());
        codeableConceptBuilder.clear();
        reaction.setManifestation(theManifestation);
        reaction.setDescription(allergyIntoleranceEntity.getNote());
        // SEVERITY
        try {
            reaction.setSeverity(AllergyIntoleranceSeverity.fromCode(allergyIntoleranceEntity.getSeverity()));
        } catch (FHIRException e) {
            throw OperationOutcomeFactory.buildOperationOutcomeException(new UnprocessableEntityException("Unknown severity: " + allergyIntoleranceEntity.getSeverity()), SystemCode.INVALID_RESOURCE, IssueType.INVALID);
        }
        // EXPOSURE
        CodeableConcept exposureRoute = new CodeableConcept();
        reaction.setExposureRoute(exposureRoute);
        allergyIntolerance.addReaction(reaction);
        // RECORDER
        final Reference refValue = new Reference();
        final Identifier identifier = new Identifier();
        final String recorder = allergyIntoleranceEntity.getRecorder();
        // This is just an example to demonstrate using Reference element instead of Identifier element
        if (recorder.equals(patient2NhsNo.trim())) {
            Reference rec = new Reference(SystemConstants.PATIENT_REFERENCE_URL + allergyIntoleranceEntity.getPatientRef());
            allergyIntolerance.setRecorder(rec);
        } else if (patientRepository.findByNhsNumber(recorder) != null) {
            identifier.setSystem(SystemURL.ID_NHS_NUMBER);
            identifier.setValue(recorder);
            refValue.setIdentifier(identifier);
            allergyIntolerance.setRecorder(refValue);
        } else if (practitionerSearch.findPractitionerByUserId(recorder) != null) {
            refValue.setReference("Practitioner/" + recorder);
            allergyIntolerance.setRecorder(refValue);
            practitionerIds.add(recorder);
        }
        // CLINICAL STATUS
        List<Extension> extensions = new ArrayList<>();
        if (allergyIntolerance.getClinicalStatus().getDisplay().contains("Active")) {
            listResourceBuilder(activeList, allergyIntolerance, false);
            bundle.addEntry().setResource(allergyIntolerance);
        } else if (allergyIntolerance.getClinicalStatus().getDisplay().equals("Resolved") && includedResolved.equals(true)) {
            listResourceBuilder(resolvedList, allergyIntolerance, true);
            allergyIntolerance.setLastOccurrence(allergyIntoleranceEntity.getEndDate());
            final Extension allergyEndExtension = createAllergyEndExtension(allergyIntoleranceEntity);
            extensions.add(allergyEndExtension);
        }
        if (!extensions.isEmpty()) {
            allergyIntolerance.setExtension(extensions);
        }
        // ASSERTER
        Reference asserter = allergyIntolerance.getAsserter();
        if (asserter != null && asserter.getReference() != null && asserter.getReference().startsWith("Practitioner")) {
            String[] split = asserter.getReference().split("/");
            practitionerIds.add(split[1]);
        }
    }
    if (!activeList.hasEntry()) {
        addEmptyListNote(activeList);
        addEmptyReasonCode(activeList);
    }
    bundle.addEntry().setResource(activeList);
    if (includedResolved && !resolvedList.hasEntry()) {
        addEmptyListNote(resolvedList);
        addEmptyReasonCode(resolvedList);
    }
    if (includedResolved) {
        bundle.addEntry().setResource(resolvedList);
    }
    return bundle;
}
Also used : UnprocessableEntityException(ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException) StructuredAllergyIntoleranceEntity(uk.gov.hscic.patient.structuredAllergyIntolerance.StructuredAllergyIntoleranceEntity) FHIRException(org.hl7.fhir.exceptions.FHIRException) AllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance)

Example 5 with DateTimeType

use of org.hl7.fhir.dstu3.model.DateTimeType in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method patientDetailsToMinimalPatient.

private Patient patientDetailsToMinimalPatient(PatientDetails patientDetails) throws FHIRException {
    Patient patient = new Patient();
    Date lastUpdated = patientDetails.getLastUpdated() == null ? new Date() : patientDetails.getLastUpdated();
    String resourceId = String.valueOf(patientDetails.getId());
    String versionId = String.valueOf(lastUpdated.getTime());
    String resourceType = patient.getResourceType().toString();
    IdType id = new IdType(resourceType, resourceId, versionId);
    patient.setId(id);
    patient.getMeta().setVersionId(versionId);
    patient.getMeta().setLastUpdated(lastUpdated);
    patient.getMeta().addProfile(SystemURL.SD_GPC_PATIENT);
    Identifier patientNhsNumber = new Identifier().setSystem(SystemURL.ID_NHS_NUMBER).setValue(patientDetails.getNhsNumber());
    Extension extension = createCodingExtension("01", "Number present and verified", SystemURL.CS_CC_NHS_NUMBER_VERIF, SystemURL.SD_CC_EXT_NHS_NUMBER_VERIF);
    patientNhsNumber.addExtension(extension);
    patient.addIdentifier(patientNhsNumber);
    patient.setBirthDate(patientDetails.getDateOfBirth());
    String gender = patientDetails.getGender();
    if (gender != null) {
        patient.setGender(AdministrativeGender.fromCode(gender.toLowerCase(Locale.UK)));
    }
    Date registrationEndDateTime = patientDetails.getRegistrationEndDateTime();
    Date registrationStartDateTime = patientDetails.getRegistrationStartDateTime();
    Extension regDetailsExtension = new Extension(SystemURL.SD_EXTENSION_CC_REG_DETAILS);
    Period registrationPeriod = new Period().setStart(registrationStartDateTime).setEnd(registrationEndDateTime);
    Extension regPeriodExt = new Extension(SystemURL.SD_CC_EXT_REGISTRATION_PERIOD, registrationPeriod);
    regDetailsExtension.addExtension(regPeriodExt);
    String registrationStatusValue = patientDetails.getRegistrationStatus();
    patient.setActive(ACTIVE_REGISTRATION_STATUS.equals(registrationStatusValue) || null == registrationStatusValue);
    String registrationTypeValue = patientDetails.getRegistrationType();
    if (registrationTypeValue != null) {
        Coding regTypeCode = new Coding();
        regTypeCode.setCode(registrationTypeValue);
        // Should always be Temporary
        regTypeCode.setDisplay("Temporary");
        regTypeCode.setSystem(SystemURL.CS_REGISTRATION_TYPE);
        CodeableConcept regTypeConcept = new CodeableConcept();
        regTypeConcept.addCoding(regTypeCode);
        Extension regTypeExt = new Extension(SystemURL.SD_CC_EXT_REGISTRATION_TYPE, regTypeConcept);
        regDetailsExtension.addExtension(regTypeExt);
    }
    patient.addExtension(regDetailsExtension);
    String maritalStatus = patientDetails.getMaritalStatus();
    if (maritalStatus != null) {
        CodeableConcept marital = new CodeableConcept();
        Coding maritalCoding = new Coding();
        maritalCoding.setSystem(SystemURL.VS_CC_MARITAL_STATUS);
        maritalCoding.setCode(patientDetails.getMaritalStatus());
        maritalCoding.setDisplay("Married");
        marital.addCoding(maritalCoding);
        patient.setMaritalStatus(marital);
    }
    patient.setMultipleBirth(patientDetails.isMultipleBirth());
    if (patientDetails.isDeceased()) {
        DateTimeType decesed = new DateTimeType(patientDetails.getDeceased());
        patient.setDeceased(decesed);
    }
    return patient;
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) Identifier(org.hl7.fhir.dstu3.model.Identifier) Coding(org.hl7.fhir.dstu3.model.Coding) Patient(org.hl7.fhir.dstu3.model.Patient) Period(org.hl7.fhir.dstu3.model.Period) Date(java.util.Date) IdType(org.hl7.fhir.dstu3.model.IdType) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

UnprocessableEntityException (ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException)3 FHIRException (org.hl7.fhir.exceptions.FHIRException)3 Date (java.util.Date)2 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)2 DateTimeType (org.hl7.fhir.dstu3.model.DateTimeType)2 IdDt (ca.uhn.fhir.model.primitive.IdDt)1 ca.uhn.fhir.rest.annotation (ca.uhn.fhir.rest.annotation)1 Count (ca.uhn.fhir.rest.annotation.Count)1 SortSpec (ca.uhn.fhir.rest.api.SortSpec)1 DateAndListParam (ca.uhn.fhir.rest.param.DateAndListParam)1 TokenParam (ca.uhn.fhir.rest.param.TokenParam)1 IResourceProvider (ca.uhn.fhir.rest.server.IResourceProvider)1 ForbiddenOperationException (ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException)1 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)1 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)1 UnclassifiedServerFailureException (ca.uhn.fhir.rest.server.exceptions.UnclassifiedServerFailureException)1 Integer.min (java.lang.Integer.min)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 java.util (java.util)1