Skip to content

Commit

Permalink
[CNFT1-3577] Repeating block pending state (#2073)
Browse files Browse the repository at this point in the history
* race

* names

* address

* phone / email

* identification
  • Loading branch information
adamloup-enquizit authored Dec 6, 2024
1 parent f9bd48a commit fbe885f
Show file tree
Hide file tree
Showing 39 changed files with 220 additions and 173 deletions.
3 changes: 2 additions & 1 deletion apps/modernization-ui/src/apps/patient/add/basic/entry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { today } from 'date';
import { AdministrativeEntry, IdentificationEntry } from 'apps/patient/data/entry';
import { IdentificationEntry } from 'apps/patient/data';
import { AdministrativeEntry } from 'apps/patient/data/entry';
import { Selectable } from 'options';

type NameInformationEntry = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { asSelectable, findByValue, Selectable } from 'options';
import { PatientNameCodedValues } from 'apps/patient/profile/names/usePatientNameCodedValues';
import { AddressEntry, IdentificationEntry, NameEntry, PhoneEmailEntry } from 'apps/patient/data/entry';
import { RaceEntry } from 'apps/patient/data/race/entry';
import { NewPatientEntry } from 'apps/patient/add/NewPatientEntry';

import { RaceEntry, AddressEntry, NameEntry, PhoneEmailEntry, IdentificationEntry } from 'apps/patient/data';
import { NewPatientEntry } from 'apps/patient/add';
import { ExtendedNewPatientEntry } from './entry';
import { CodedValue } from 'coded';
import { isEmpty, Mapping } from 'utils';
Expand Down
7 changes: 2 additions & 5 deletions apps/modernization-ui/src/apps/patient/add/extended/entry.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { today } from 'date';
import {
AdministrativeEntry,
NameEntry,
AddressEntry,
PhoneEmailEntry,
IdentificationEntry,
SexEntry,
BirthEntry,
MortalityEntry,
GeneralInformationEntry
} from 'apps/patient/data/entry';
import { EthnicityEntry, initial as initialEthnicity } from 'apps/patient/data/ethnicity';
import { RaceEntry } from 'apps/patient/data/race';

import { NameEntry, AddressEntry, PhoneEmailEntry, IdentificationEntry, RaceEntry } from 'apps/patient/data';

type ExtendedNewPatientEntry = {
administrative?: AdministrativeEntry;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
import { AddressEntry } from 'apps/patient/data/entry';
import { today } from 'date';
import { Column } from 'design-system/table';
import { AddressView } from './AddressView';
import { AddressEntryFields } from 'apps/patient/data/address/AddressEntryFields';
import { RepeatingBlock } from 'design-system/entry/multi-value/RepeatingBlock';
import { ReactNode } from 'react';
import { Column } from 'design-system/table';
import { RepeatingBlock } from 'design-system/entry/multi-value';
import { AddressEntry, AddressEntryFields, initial } from 'apps/patient/data/address';
import { asAddressTypeUse } from 'apps/patient/data/address/utils';

const defaultValue: Partial<AddressEntry> = {
asOf: today(),
type: null,
use: null,
address1: '',
address2: '',
city: '',
state: null,
zipcode: '',
county: null,
country: null,
censusTract: '',
comment: ''
};
import { AddressView } from './AddressView';

const defaultValue: Partial<AddressEntry> = initial();

type Props = {
id: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render } from '@testing-library/react';
import { AddressEntry } from 'apps/patient/data/entry';
import { AddressEntry } from 'apps/patient/data';
import { AddressView } from './AddressView';

const entry: AddressEntry = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AddressEntry } from 'apps/patient/data/entry';
import { AddressEntry } from 'apps/patient/data';
import { ValueView } from 'design-system/data-display/ValueView';

type Props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { IdentificationEntry } from 'apps/patient/data/entry';
import { IdentificationEntryFields } from 'apps/patient/data/identification/IdentificationEntryFields';
import { today } from 'date';
import { RepeatingBlock } from 'design-system/entry/multi-value/RepeatingBlock';
import { ReactNode } from 'react';
import { Column } from 'design-system/table';
import { RepeatingBlock } from 'design-system/entry/multi-value';
import { IdentificationEntryFields, IdentificationEntry, initial } from 'apps/patient/data/identification';
import { IdentificationView } from './IdentificationView';
import { ReactNode } from 'react';

const defaultValue: Partial<IdentificationEntry> = {
asOf: today(),
type: null,
issuer: null,
id: ''
};
const defaultValue: Partial<IdentificationEntry> = initial();

type Props = {
id: string;
values?: IdentificationEntry[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render } from '@testing-library/react';
import { IdentificationEntry } from 'apps/patient/data/entry';
import { IdentificationEntry } from 'apps/patient/data';
import { IdentificationView } from './IdentificationView';

const entry: IdentificationEntry = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IdentificationEntry } from 'apps/patient/data/entry';
import { IdentificationEntry } from 'apps/patient/data';
import { ValueView } from 'design-system/data-display/ValueView';

type Props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render } from '@testing-library/react';
import { NameEntry } from 'apps/patient/data/entry';
import { NameEntry } from 'apps/patient/data/name';
import { NameEntryView } from './NameEntryView';
import { asSelectable } from 'options/selectable';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NameEntry } from 'apps/patient/data/entry';
import { NameEntry } from 'apps/patient/data/name';
import { ValueView } from 'design-system/data-display/ValueView';

type Props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
import { NameEntry } from 'apps/patient/data/entry';
import { NameEntryFields } from 'apps/patient/data/name/NameEntryFields';
import { today } from 'date';
import { RepeatingBlock } from 'design-system/entry/multi-value/RepeatingBlock';
import { ReactNode } from 'react';
import { Column } from 'design-system/table';
import { RepeatingBlock } from 'design-system/entry/multi-value';
import { NameEntry, NameEntryFields, initial } from 'apps/patient/data/name';
import { NameEntryView } from './NameEntryView';
import { ReactNode } from 'react';

const defaultValue: Partial<NameEntry> = {
asOf: today(),
type: null,
prefix: null,
first: '',
middle: '',
secondMiddle: '',
last: '',
secondLast: '',
suffix: null,
degree: null
};
const defaultValue: Partial<NameEntry> = initial();

const columns: Column<NameEntry>[] = [
{ id: 'nameAsOf', name: 'As of', render: (v) => v.asOf },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
import { PhoneEmailEntry } from 'apps/patient/data/entry';
import { PhoneEmailEntryFields } from 'apps/patient/data/phoneEmail/PhoneEmailEntryFields';
import { today } from 'date';
import { RepeatingBlock } from 'design-system/entry/multi-value/RepeatingBlock';
import { ReactNode } from 'react';
import { RepeatingBlock } from 'design-system/entry/multi-value';
import { Column } from 'design-system/table';
import { PhoneEmailEntry, PhoneEmailEntryFields, initial } from 'apps/patient/data/phoneEmail';
import { PhoneEntryView } from './PhoneEntryView';
import { ReactNode } from 'react';

const defaultValue: Partial<PhoneEmailEntry> = {
asOf: today(),
type: null,
use: null,
countryCode: '',
phoneNumber: '',
extension: '',
email: '',
url: '',
comment: ''
};
const defaultValue: Partial<PhoneEmailEntry> = initial();

type Props = {
id: string;
values?: PhoneEmailEntry[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render } from '@testing-library/react';
import { PhoneEmailEntry } from 'apps/patient/data/entry';
import { PhoneEmailEntry } from 'apps/patient/data';
import { PhoneEntryView } from './PhoneEntryView';

const mockPatientPhoneCodedValues = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PhoneEmailEntry } from 'apps/patient/data/entry';
import { PhoneEmailEntry } from 'apps/patient/data';
import { ValueView } from 'design-system/data-display/ValueView';

type Props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { render, waitFor } from '@testing-library/react';
import { act } from 'react-dom/test-utils';
import { FormProvider, useForm } from 'react-hook-form';
import { AddressEntry } from '../entry';
import { AddressEntryFields } from './AddressEntryFields';
import userEvent from '@testing-library/user-event';
import { render, waitFor, act } from '@testing-library/react';
import { AddressEntry } from './entry';
import { AddressEntryFields } from './AddressEntryFields';

const mockPatientAddressCodedValues = {
types: [{ name: 'House', value: 'H' }],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Controller, useFormContext, useWatch } from 'react-hook-form';
import { EntryFieldsProps } from 'design-system/entry';
import { DatePickerInput, validDateRule } from 'design-system/date';
import { SingleSelect } from 'design-system/select';
import { maxLengthRule, validateRequiredRule } from 'validation/entry';
import { EntryFieldsProps } from 'design-system/entry';
import { usePatientAddressCodedValues } from 'apps/patient/profile/addresses/usePatientAddressCodedValues';
import { Input } from 'components/FormInputs/Input';
import { useLocationCodedValues } from 'location';
import { maxLengthRule, validateRequiredRule } from 'validation/entry';
import { Input } from 'components/FormInputs/Input';
import { AddressSuggestion, AddressSuggestionInput } from 'address/suggestion';
import { AddressEntry } from 'apps/patient/data/entry';
import { AddressEntry } from './entry';

const AS_OF_DATE_LABEL = 'Address as of';
const TYPE_LABEL = 'Type';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { asValue } from 'options';
import { Address } from '../api';
import { AddressEntry } from '../entry';
import { AddressEntry } from './entry';
import { exists, orUndefined } from 'utils';

const asAddress = (entry: AddressEntry): Address | undefined => {
Expand Down
36 changes: 36 additions & 0 deletions apps/modernization-ui/src/apps/patient/data/address/entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { today } from 'date';
import { Selectable } from 'options';
import { EffectiveDated, HasComments } from 'utils';

type AddressEntry = EffectiveDated &
HasComments & {
type: Selectable | null;
use: Selectable | null;
address1?: string;
address2?: string;
city?: string;
county?: Selectable | null;
state?: Selectable | null;
zipcode?: string;
country?: Selectable | null;
censusTract?: string;
};

export type { AddressEntry };

const initial = (asOf: string = today()): Partial<AddressEntry> => ({
asOf,
type: undefined,
use: undefined,
address1: '',
address2: '',
city: '',
state: undefined,
zipcode: '',
county: undefined,
country: undefined,
censusTract: '',
comment: ''
});

export { initial };
5 changes: 5 additions & 0 deletions apps/modernization-ui/src/apps/patient/data/address/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export { initial } from './entry';
export type { AddressEntry } from './entry';

export { AddressEntryFields } from './AddressEntryFields';
export { asAddress } from './asAddress';
55 changes: 1 addition & 54 deletions apps/modernization-ui/src/apps/patient/data/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,6 @@ type LocationEntry = {

type AdministrativeEntry = EffectiveDated & HasComments;

type NameEntry = EffectiveDated & {
type: Selectable | null;
prefix?: Maybe<Selectable>;
first?: string;
middle?: string;
secondMiddle?: string;
last?: string;
secondLast?: string;
suffix?: Maybe<Selectable>;
degree?: Maybe<Selectable>;
};

type AddressEntry = EffectiveDated &
HasComments & {
type: Selectable | null;
use: Selectable | null;
address1?: string;
address2?: string;
city?: string;
county?: Maybe<Selectable>;
state?: Maybe<Selectable>;
zipcode?: string;
country?: Maybe<Selectable>;
censusTract?: string;
};

type PhoneEmailEntry = EffectiveDated &
HasComments & {
type: Selectable | null;
use: Selectable | null;
countryCode?: string;
phoneNumber?: string;
extension?: string;
email?: string;
url?: string;
};

type IdentificationEntry = EffectiveDated & {
type: Selectable | null;
id: string | null;
issuer?: Maybe<Selectable>;
};

type SexEntry = EffectiveDated & {
current?: Selectable;
unknownReason?: Selectable;
Expand Down Expand Up @@ -86,14 +43,4 @@ type GeneralInformationEntry = EffectiveDated & {
stateHIVCase?: string;
};

export type {
AdministrativeEntry,
NameEntry,
AddressEntry,
PhoneEmailEntry,
IdentificationEntry,
SexEntry,
BirthEntry,
MortalityEntry,
GeneralInformationEntry
};
export type { AdministrativeEntry, SexEntry, BirthEntry, MortalityEntry, GeneralInformationEntry };
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { render, waitFor } from '@testing-library/react';
import { PatientIdentificationCodedValues } from 'apps/patient/profile/identification/usePatientIdentificationCodedValues';
import { act } from 'react-dom/test-utils';
import { FormProvider, useForm } from 'react-hook-form';
import { IdentificationEntry } from '../entry';
import { IdentificationEntryFields } from './IdentificationEntryFields';
import { render, waitFor, act } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { PatientIdentificationCodedValues } from 'apps/patient/profile/identification/usePatientIdentificationCodedValues';
import { IdentificationEntry } from './entry';
import { IdentificationEntryFields } from './IdentificationEntryFields';

const mockPatientIdentificationCodedValues: PatientIdentificationCodedValues = {
types: [{ name: 'Account number', value: 'AN' }],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Controller, useFormContext } from 'react-hook-form';
import { EntryFieldsProps } from 'design-system/entry';
import { usePatientIdentificationCodedValues } from 'apps/patient/profile/identification/usePatientIdentificationCodedValues';
import { Input } from 'components/FormInputs/Input';
import { DatePickerInput, validDateRule } from 'design-system/date';
import { maxLengthRule, validateRequiredRule } from 'validation/entry';
import { Input } from 'components/FormInputs/Input';
import { EntryFieldsProps } from 'design-system/entry';
import { SingleSelect } from 'design-system/select';
import { IdentificationEntry } from '../entry';
import { usePatientIdentificationCodedValues } from 'apps/patient/profile/identification/usePatientIdentificationCodedValues';
import { IdentificationEntry } from './entry';

const AS_OF_DATE_LABEL = 'Identification as of';
const TYPE_LABEL = 'Type';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { asValue } from 'options';
import { Identification } from '../api';
import { IdentificationEntry } from '../entry';
import { IdentificationEntry } from './entry';
import { exists } from 'utils';

const asIdentification = (entry: IdentificationEntry): Identification | undefined => {
Expand Down
Loading

0 comments on commit fbe885f

Please sign in to comment.