Giter Site home page Giter Site logo

tasddc1226 / doctor-for-you Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 53 KB

환자가 원하는 의사를 쉽게 찾고, 진료 예약까지 한번에 할 수 있도록 도와주는 백엔드 서비스

Python 100.00%
django-rest-framework mysql-database

doctor-for-you's Introduction

로컬 실행 환경 설정

  1. 프로젝트 클론을 받아주세요.

    ❯ git clone https://github.com/tasddc1226/doctor-for-you.git
  2. 클론된 프로젝트로 이동합니다.

    cd doctor-for-you
  3. venv를 이용한 가상환경을 생성 & 활성화 합니다.

    ❯ python3 -m venv venv
    ❯ source 프로젝트경로/doctor-for-you/venv/bin/activate
  4. 아래의 명령어로 pip upgrade 설치 후 가상환경에 의존성 설치를 진행합니다.

    ❯ pip install --upgrade pip
    ❯ pip install -r requirements.txt
  5. Database(sqlite3) migration을 진행합니다.

    ❯ python manage.py makemigrations
    ❯ python manage.py migrate
  6. 데이터를 추가하기 위해 아래의 명령으로 슈퍼유저 생성을 진행합니다.

    ❯ python manage.py createsuperuser
  7. 서버를 동작시키고 localhost:8000/admin 경로로 진입 후 생성한 슈퍼유저로 로그인합니다.

    ❯ python manage.py runserver
  8. 의사, 환자 및 의사의 평일 혹은 주말에 대한 데이터를 임의로 추가합니다.

  • 의사의 진료과 같은 경우 아래와 같이 콤마(,)로 연결하여 데이터를 추가할 수 있습니다.

  • 의사의 비급여진료과목은 없을 수 있습니다.

    Screen Shot 2022-07-22 at 14 46 51
  • 의사의 평일 영업시간에 대한 데이터를 추가합니다.

    Screen Shot 2022-07-22 at 14 53 17
  • 의사의 주말 영업시간에 대한 데이터를 추가합니다.

    • 휴일 유무를 체크시 해당 요일은 휴무일 입니다.

      Screen Shot 2022-07-22 at 14 56 43

DB Diagram

doctor-for-you


API Documentation


조건에 맞는 의사를 검색

  • GET /api/v1/search/?dept=일반의

  • Server Response

    // status: 200
    [
        {
            "name": "손웅래"
        },
        {
            "name": "선재원"
        }
    ]
  • GET /api/v1/search/?hospital=메라키

  • Server Response

    // status: 200
    [
        {
            "name": "손웅래"
        },
        {
            "name": "선재원"
        }
    ]
  • GET /api/v1/search/?hospital=메라키&doctor=손웅래

  • Server Response

    // status: 200
    [
        {
            "name": "손웅래"
        }
    ]
  • GET /api/v1/search/?dept=한의학과&doctor=선재원

  • Server Response

    // status: 200
    [
        {
            "name": "선재원"
        }
    ]
  • GET /api/v1/search/?doctor=손웅래&non_paid=다이어트

  • Server Response

    // status: 200
    []

입력 시각에 영업중인 의사 검색

  • POST /api/v1/search/

  • Request Body

    {
        "year": 2022,
        "month": 7,
        "day": 21,
        "hour": 15,
        "min" : 30
    }
  • Server Response

    // status: 200
    [
        {
            "name": "손웅래"
        },
        {
            "name": "선재원"
        }
    ]
  • Request Body

    {
        "year": 2022,
        "month": 7,
        "day": 23,
        "hour": 9,
        "min" : 30
    }
    
  • Server Response

    // status: 200
    [
        {
            "name": "선재원"
        }
    ]

새로운 진료 예약 생성

  • POST /api/v1/cares/

  • Request Body

    {
        "patient_id" : 1,
        "doctor_id" : 1,
        "year": 2022,
        "month": 7,
        "day": 22,
        "hour": 16,
        "min": 10
    }
  • Server Response

    // status: 201
    {
        "id": 20,
        "doctor_name": "손웅래",
        "patient_name": "김환자",
        "book_time": "2022-07-22T16:10:00",
        "created_at": "2022-07-21T17:27:29.642660",
        "expire_time": "2022-07-21T17:47:29.632890",
        "is_booked": false,
        "patient": 1,
        "doctor": 1
    }

예약 불가한 경우 1

  • 예약 날짜가 현 시점보다 이전일 경우

  • Request Body

    {
        "patient_id" : 1,
        "doctor_id" : 1,
        "year": 2022,
        "month": 7,
        "day": 20,
        "hour": 16,
        "min": 10
    }
  • Server Response

    // status: 400
    {
        "message": "진료 예약이 불가능합니다. 다른 시간을 선택해주세요."
    }

예약 불가한 경우 2

  • 희망 진료 시각에 의사가 진료(영업)를 하지 않는 경우

  • Request Body

    {
        "patient_id" : 1,
        "doctor_id" : 1,
        "year": 2022,
        "month": 7,
        "day": 21,
        "hour": 21,
        "min": 10
    }
  • Server Response

    // status: 400
    {
        "message": "진료 예약이 불가능합니다. 다른 시간을 선택해주세요."
    }

진료 요청 리스트 조회

  • GET /api/v1/cares/?id=1

  • Server Response

    // status: 200
    [
        {
            "id": 16,
            "patient_name": "박환자",
            "book_time": "2022-07-21T13:45:00",
            "expire_time": "2022-07-21T13:25:39.545884"
        },
        {
            "id": 20,
            "patient_name": "김환자",
            "book_time": "2022-07-22T16:10:00",
            "expire_time": "2022-07-21T17:47:29.632890"
        }
    ]

진료 요청 수락

  • PATCH /api/v1/cares/20

  • Server Response

    // status: 200
    {
        "id": 20,
        "doctor_name": "손웅래",
        "patient_name": "김환자",
        "book_time": "2022-07-22T16:10:00",
        "created_at": "2022-07-21T17:27:29.642660",
        "expire_time": "2022-07-21T17:47:29.632890",
        "is_booked": true,
        "patient": 1,
        "doctor": 1
    }

진료 요청 수락이 불가한 경우

  • 존재하지 않는 요청인 경우

  • Server Response

    // status: 404
    {
        "message": "해당 진료 요청이 존재하지 않습니다."
    }
  • 이미 요청이 수락이 된 경우

  • Server Response

    // status: 400
    {
        "message": "이미 수락된 예약입니다."
    }
  • expire_time이 만료된 경우

  • Server Response

    // status: 400
    {
        "message": "예약 요청이 만료되었습니다."
    }

doctor-for-you's People

Contributors

tasddc1226 avatar

Watchers

 avatar  avatar

doctor-for-you's Issues

#1 다음 영업일 찾기 문제

평일 점심시간에 진료 예약 요청이 들어온 경우

# 예약 요청을 날린 시각을 설정한다.
now = datetime(2022, 1, 11, 12, 50) #  평일 점심시간대로 설정
  • Request Data : 진료 요청 Data는 정상적으로 들어온 경우
{
	"patient_id" : 3,
	"doctor_id" : 2,
	"year": 2022,
	"month": 1,
	"day": 11,
	"hour": 14,
	"min": 45
}
  • Response Data
{
	"id": 11,
	"book_time": "2022-01-11T14:45:00",
	"created_at": "2022-07-21T00:48:42.640920", // don't care
	"expire_time": "2022-01-11T13:15:00",
	"is_booked": false,
	"patient": 3,
	"doctor": 2
}
  • id가 2번인 의사의 평일 점심시간은 12시부터 13시까지 이다.
  • 따라서 요청 만료 시간은 점심시간이 끝난 후 15분까지 유효하므로 정상적으로 점심시간 종료 이후 + 15분의 expire_time이 생성되어진다.

주말에 진료 예약 요청이 들어온 경우

# 예약 요청을 날린 시각을 설정한다.
now = datetime(2022, 1, 15, 1, 0) #  주말 새벽 시간대로 설정
  • Request Data : 진료 요청 Data는 정상적으로 들어온 경우
{
	"patient_id" : 3,
	"doctor_id" : 1,
	"year": 2022,
	"month": 1,
	"day": 17,
	"hour": 10,
	"min": 45
}
- 즉, 환자가 15일(토요일)에 17일(월요일)날 오전 10시 45분에 진료를 요청한 경우이다.
  • Response Data
{
	"id": 12,
	"book_time": "2022-01-17T10:45:00",
	"created_at": "2022-07-21T00:52:59.889905", // don't care
	"expire_time": "2022-01-16T09:15:00",
	"is_booked": false,
	"patient": 3,
	"doctor": 1
}
  • 하지만 응답으로는 위처럼 결과가 나오고 있음.
  • id가 1번인 의사는 주말에 진료를 하지 않는다.
  • 하지만 응답 결과의 expire_time로는 15일(토요일) 다음날인 16일(일요일)의 영업 시작일 + 15분으로 나오는 현상이 발생.

이유

  • 우선, 점심시간 제외 금일 영업시간이 종료되어 다음 영업일을 찾는 방법이 아래와 같다.
                    info = {
                        "patient": data["patient_id"],
                        "doctor": data["doctor_id"],
                        "book_time": book_time,
                        "expire_time": datetime(
                            now.year, now.month, now.day + 1
                        )
                        + timedelta(hours=hour_range_list[0], minutes=15),
                    }
  • 영업이 종료로 인한 의사의 부재인 경우 무조건 다음날 영업시작시간 + 15분을 해주고 있기 때문이다.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.