| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import { Get, Post } from "../../lib/request/method";
- const ref = ['province', 'city', 'area'] as const;
- const ref2 = ['womenSpecialPeriod', 'foodAllergy', 'hobbyFlavor', 'job'] as const;
- function to(params: App.Patient.Model) {
- const { address, ..._data } = params;
- const data: Record<string, any> = {}
- if (Array.isArray(address)) {
- address.forEach(({ name, code }, index) => {
- const key = ref[index];
- data[`${key}Name`] = name
- data[`${key}Code`] = code
- })
- }
- for (const key of ref2) {
- if (Array.isArray(_data[key])) _data[key] = _data[key]?.map(item => item?.value || item).join(',') as any;
- }
- return { ..._data, ...data, }
- }
- function from(params: Record<string, any>) {
- const address = [];
- for (const key of ref) {
- const name = params[`${key}Name`];
- const code = params[`${key}Code`];
- if (name && code) {
- address[address.length] = { name, code };
- delete params[`${key}Name`];
- delete params[`${key}Code`];
- } else {
- break;
- }
- }
- for (const key of ref2) {
- if (typeof params[key] === 'string' && params[key]) params[key] = params[key].split(',')
- }
- return { ...params, address } as App.Patient.Model
- }
- export function getUserInfoMethod() {
- return Post(`/patientInfoManage/getPatientInfoDetail`, {}, {
- transform({ data }) {
- return from(<any>data)
- }
- })
- }
- export function createUserInfoMethod(data: App.Patient.Model) {
- return Post(`/patientInfoManage/savePatientInfo`, { ...to(data), mobileAccountId: 0, }, {
- transform({ data }) { return { patientId: data } }
- });
- }
- export async function updateUserInfoMethod(data: App.Patient.Model) {
- const result = await Post(`/patientInfoManage/updatePatientInfo`, to(data));
- }
- export function verifyCardnoMethod(value: string) {
- return Get(`/patientInfoManage/isExistCardno`, { params: { cardno: value }, transform({ data }) { return data } })
- }
|