Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD: Display gp floating clinics (gp-f) #341

Merged
merged 10 commits into from
Mar 30, 2023
10 changes: 10 additions & 0 deletions src/assets/icon-gp-floating--blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/components/DoctorCard/Info/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const Info = function Info({ doctor, handleZoom = () => {}, isMarker = false })
type={type}
ageGroup={ageGroup}
isExtra={doctor.isExtra}
isFloating={doctor.isFloating}
viewType={viewType}
/>
</Stack>
Expand All @@ -74,6 +75,7 @@ const Info = function Info({ doctor, handleZoom = () => {}, isMarker = false })
hasOverride={doctor.acceptsOverride || doctor.note ? true : undefined}
/>
<Shared.Availability
isFloating={doctor.isFloating}
availability={doctor.availability}
date={doctor.updatedAt && doctor.formatUpdatedAt(lng)}
hasOverride={doctor.availabilityOverride ? true : undefined}
Expand Down
3 changes: 3 additions & 0 deletions src/components/DoctorCard/PageInfo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const PageInfo = function PageInfo({ doctor }) {
type={type}
ageGroup={ageGroup}
isExtra={doctor.isExtra}
isFloating={doctor.isFloating}
viewType="page"
/>
<Typography component="h2" variant="h2" translate="no">
Expand All @@ -111,8 +112,10 @@ const PageInfo = function PageInfo({ doctor }) {
hasOverride={doctor.acceptsOverride || doctor.note ? true : undefined}
/>
<Shared.Availability
isFloating={doctor.isFloating}
availability={doctor.availability}
date={doctor.updatedAt && doctor.formatUpdatedAt(lng)}
viewType="page"
hasOverride={doctor.availabilityOverride ? true : undefined}
/>
</Stack>
Expand Down
36 changes: 32 additions & 4 deletions src/components/DoctorCard/Shared/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export { default as DoctorLinks } from './DoctorLinks';
export { default as PhoneButton } from './PhoneButton';
export { default as Accepts } from './Accepts';

export const DoubleChip = function DoubleChip({ type, ageGroup, isExtra, viewType }) {
export const DoubleChip = function DoubleChip({ type, ageGroup, isExtra, isFloating, viewType }) {
const drType = t(TypeTranslate[type]);
const drAgeGroup = t(AgeGroupTranslate?.[ageGroup] ?? 'adults');
const typeIcon = TypeIconTranslate[type] ?? 'Family';
Expand All @@ -52,20 +52,39 @@ export const DoubleChip = function DoubleChip({ type, ageGroup, isExtra, viewTyp

let isExtraLabel = '';
let isExtraTooltip = t('clinicForBetterAccessibility');
let isFloatingLabel = '';
let isFloatingTooltip = t('floatingClinic');

if (viewType !== 'page') {
/* empty */
} else {
isExtraLabel = t('clinicForBetterAccessibility');
isExtraTooltip = t('clinicForBetterAccessibilityDesc');
isFloatingLabel = t('floatingClinic');
isFloatingTooltip = t('floatingClinic');
}

const third = isExtra && (
<Tooltip title={isExtraTooltip} leaveTouchDelay={3000} enterTouchDelay={50}>
<Styled.IsExtra direction="row" alignItems="center" spacing={1} viewType={viewType}>
<Styled.IsSpecial direction="row" alignItems="center" spacing={1} viewType={viewType}>
<Icons.Icon name="ClinicViolet" />
{isExtraLabel}
</Styled.IsExtra>
</Styled.IsSpecial>
</Tooltip>
);

const fourth = isFloating && (
<Tooltip title={isFloatingTooltip} leaveTouchDelay={3000} enterTouchDelay={50}>
<Styled.IsSpecial
direction="row"
alignItems="center"
spacing={1}
viewType={viewType}
type="floating"
>
<Icons.Icon name="GpFloatingBlue" />
{isFloatingLabel}
</Styled.IsSpecial>
</Tooltip>
);

Expand All @@ -74,20 +93,23 @@ export const DoubleChip = function DoubleChip({ type, ageGroup, isExtra, viewTyp
{first}
{second}
{third}
{fourth}
</Styled.PageInfo.DCWrapper>
);
};

DoubleChip.defaultProps = {
ageGroup: undefined,
isExtra: false,
isFloating: false,
viewType: 'marker',
};

DoubleChip.propTypes = {
type: PropTypes.string.isRequired,
ageGroup: PropTypes.oneOf([undefined, 'students', 'youth']),
isExtra: PropTypes.bool,
isFloating: PropTypes.bool,
viewType: PropTypes.oneOf(['marker', 'list', 'page']),
};

Expand Down Expand Up @@ -119,7 +141,11 @@ HeadQuotient.propTypes = {
hasOverride: PropTypes.bool,
};

export const Availability = function Availability({ date, availability, hasOverride }) {
export const Availability = function Availability({ date, availability, hasOverride, isFloating }) {
if (isFloating) {
return '';
}

return (
<Tooltip
title={
Expand All @@ -140,10 +166,12 @@ export const Availability = function Availability({ date, availability, hasOverr

Availability.defaultProps = {
hasOverride: false,
isFloating: false,
};

Availability.propTypes = {
date: PropTypes.string.isRequired,
availability: PropTypes.string.isRequired,
hasOverride: PropTypes.bool,
isFloating: PropTypes.bool,
};
17 changes: 13 additions & 4 deletions src/components/DoctorCard/styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export const AcceptsStack = styled(Stack)(({ theme, accepts }) => {
display: 'flex',
alignItems: 'center',
letterSpacing: '0.3px',
margin: '11px 0',

svg: {
width: '14px',
Expand Down Expand Up @@ -252,9 +253,14 @@ export const Link = styled(MuiLink)(({ theme }) => ({
cursor: 'pointer',
}));

export const IsExtra = styled(Stack)(({ theme, viewType }) => {
export const IsSpecial = styled(Stack)(({ theme, type, viewType }) => {
let iconSize = '18px';
let bgColor = theme.customColors.doctor.colors.extraClinicBgColor;
let txtColor = theme.customColors.doctor.colors.extraClinicColor;
if (type === 'floating') {
bgColor = theme.customColors.lightBlue;
txtColor = theme.customColors.darkBlue;
}
let padding = '5px 7px';
let iconMargin = '0';
let iconOpacity = '1';
Expand All @@ -264,9 +270,12 @@ export const IsExtra = styled(Stack)(({ theme, viewType }) => {
iconMargin = '0 5px 0 0';
padding = '5px 8px';
iconOpacity = '0.7';
if (type === 'floating') {
iconOpacity = '1';
}
} else if (viewType === 'list') {
iconSize = '20px';
padding = '2px 6px';
iconSize = '22px';
padding = '1px 6px';
margin = 0;
bgColor = 'transparent';
}
Expand All @@ -275,7 +284,7 @@ export const IsExtra = styled(Stack)(({ theme, viewType }) => {
fontWeight: 400,
fontSize: '12px',
background: bgColor,
color: theme.customColors.doctor.colors.extraClinicColor,
color: txtColor,
borderRadius: '4px',
whiteSpace: 'nowrap',
cursor: 'help',
Expand Down
5 changes: 4 additions & 1 deletion src/components/Doctors/Markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export const Doctor = memo(({ doctor }) => {
const ref = createRef(null);
const theme = useTheme();
const { palette } = theme;
const fillColor = doctor.accepts === 'y' ? palette.success.main : palette.error.main;
let fillColor = doctor.accepts === 'y' ? palette.success.main : palette.error.main;
if (doctor.type === 'gp-f' && doctor.accepts === 'y') {
fillColor = '#3d93b9';
}
return (
<Markers.LeafletCircleMarker
ref={ref}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Shared/Icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { ReactComponent as Booking } from 'assets/icon-booking.svg';
import { ReactComponent as Edit } from 'assets/icon-edit.svg';
import { ReactComponent as Email } from 'assets/icon-email.svg';
import { ReactComponent as ClinicViolet } from 'assets/icon-clinic--violet.svg';
import { ReactComponent as GpFloatingBlue } from 'assets/icon-gp-floating--blue.svg';

export {
Menu as MenuIcon,
Expand Down Expand Up @@ -119,6 +120,7 @@ const icons = {
Edit,
Email,
ClinicViolet,
GpFloatingBlue,
};

export const Icon = function Icon({ name, ...props }) {
Expand Down
2 changes: 1 addition & 1 deletion src/const/doctors.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const PER_PAGE = 20;
export const INSTITUTION_KEY = 'id_inst';
export const TYPES = ['gp', 'gp-x', 'ped', 'ped-x', 'gyn', 'den', 'den-y', 'den-s'];
export const TYPES = ['gp', 'gp-x', 'gp-f', 'ped', 'ped-x', 'gyn', 'den', 'den-y', 'den-s'];
1 change: 1 addition & 0 deletions src/const/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const colors = {
successDark: '#81B130',
dark: '#212529',
darkBlue: '#104856',
lightBlue: '#d7eeff',
lightGrey: '#CDCDCD',
background: '#E8EFF0',
backgroundLight: '#F4F8F8',
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"adults": "adults",
"students": "students",
"youth": "youth",
"floatingClinic": "Infirmary for patients without doctors",
"clinicForBetterAccessibility": "Clinic for better accessibility",
"clinicForBetterAccessibilityDesc": "In clinics for better accessibility, insured persons who do not have a personal doctor (GP or Pediatrician) can choose their personal doctor (in case there is no available doctor or if the chosen personal doctor is permanently absent).",
"doctorCard": {
Expand Down
1 change: 1 addition & 0 deletions src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"pediatrician": "pediatra",
"youth": "giovani",
"floatingClinic": "Ambulatorio per pazienti senza medico",
"clinicForBetterAccessibility": "Clinica per una migliore accessibilità",
"clinicForBetterAccessibilityDesc": "Negli ambulatori per una migliore accessibilità, gli assicurati che non hanno un medico personale (medico di base o pediatra) possono scegliere il proprio medico personale (in caso non ci sia un medico disponibile o se il medico personale prescelto è permanentemente assente).",
"search": "Cerca…",
Expand Down
1 change: 1 addition & 0 deletions src/locales/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"adults": "odrasli",
"students": "študenti",
"youth": "mladina",
"floatingClinic": "Ambulanta za neopredeljene",
"clinicForBetterAccessibility": "Ambulanta za boljšo dostopnost",
"clinicForBetterAccessibilityDesc": "V ambulantah za boljšo dostopnost si izbranega osebnega zdravnika lahko izberejo zavarovane osebe, ki v dejavnosti splošne ambulante in dispanzerju za otroke in šolarje nimajo izbranega osebnega zdravnika (sploh nimajo veljavne izbire, ali je izbrani osebni zdravnik trajno odsoten).",
"doctorCard": {
Expand Down
17 changes: 13 additions & 4 deletions src/services/doctors.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export function createDoctor(doctor, inst) {

const addressObject = getAddressObject(doctor, institution);
const isExtra = doctor.type.match(/-x$/);
const isFloating = doctor.type.match(/-f$/);

const {
accepts: acceptsZZZS,
Expand Down Expand Up @@ -143,12 +144,15 @@ export function createDoctor(doctor, inst) {
get isExtra() {
return isExtra;
},
get isFloating() {
return isFloating;
},
get type() {
return doctor.type;
},
get typeClean() {
if (isExtra) {
return doctor.type.replace(/-x$/, '');
if (isExtra || isFloating) {
return doctor.type.replace(/-x|f$/, '');
}
return doctor.type;
},
Expand Down Expand Up @@ -187,8 +191,13 @@ export default function createDoctors({ doctorsDict, institutionsDict }) {

const filterByTypeAndAccepts = (type, accepts) => {
let tmpByType = byType[type];
if (type === 'gp' && byType['gp-x']) {
tmpByType = tmpByType.concat(byType['gp-x']);
if (type === 'gp') {
if (byType['gp-x']) {
tmpByType = tmpByType.concat(byType['gp-x']);
}
if (byType['gp-f']) {
tmpByType = tmpByType.concat(byType['gp-f']);
}
} else if (type === 'ped' && byType['ped-x']) {
tmpByType = tmpByType.concat(byType['ped-x']);
}
Expand Down